4

This may not be possible in theory, if so please elaborate.

I am trying to fit some data with Python's sklearn SVM class sklearn SVM class

When I use a linear kernel, I can extract the coefs using get_params method where

coef_ : array, shape = [n_features] if n_classes == 2 else [n_classes, n_features] Weights assigned to the features (coefficients in the primal problem). This is only available in the case of linear kernel.

So I can find the equation of best fit that depends on all the independent variables, and am able to use this equation elsewhere.

Is it possible to do the same (get a non-linear equation) from a nonlinear kernel (like the RBF or the polynomial kernel) using sklearn?

Thanks!

Tim

Tim
  • 135
  • 1
  • 11

1 Answers1

3

According to the documentation:

The decision function is:

\operatorname{sgn}(\sum_{i=1}^n y_i \alpha_i K(x_i, x) + \rho)

...

This parameters can be accessed through the members dual_coef_ which holds the product y_i alpha_i, support_vectors_ which holds the support vectors, and intercept_ which holds the independent term \rho ...

("support vectors" means the x_i in the decision function equation).

Each kernel has a different function, which you'll need to understand to compute the K(x_i,x) term.

Andreus
  • 2,437
  • 14
  • 22