@@ 164-169 (lines=6) @@ | ||
161 | return function ($x, $y) { |
|
162 | return Matrix::dot($x, $y)[0]; |
|
163 | }; |
|
164 | case self::KERNEL_RBF: |
|
165 | // k(x,y)=exp(-γ.|x-y|) where |..| is Euclidean distance |
|
166 | $dist = new Euclidean(); |
|
167 | return function ($x, $y) use ($dist) { |
|
168 | return exp(-$this->gamma * $dist->sqDistance($x, $y)); |
|
169 | }; |
|
170 | ||
171 | case self::KERNEL_SIGMOID: |
|
172 | // k(x,y)=tanh(γ.xT.y+c0) where c0=1 |
|
@@ 178-183 (lines=6) @@ | ||
175 | return tanh($this->gamma * $res); |
|
176 | }; |
|
177 | ||
178 | case self::KERNEL_LAPLACIAN: |
|
179 | // k(x,y)=exp(-γ.|x-y|) where |..| is Manhattan distance |
|
180 | $dist = new Manhattan(); |
|
181 | return function ($x, $y) use ($dist) { |
|
182 | return exp(-$this->gamma * $dist->distance($x, $y)); |
|
183 | }; |
|
184 | } |
|
185 | } |
|
186 |