Scikit-Learn



Yüklə 1,92 Mb.
Pdf görüntüsü
səhifə62/124
tarix23.02.2023
ölçüsü1,92 Mb.
#101394
1   ...   58   59   60   61   62   63   64   65   ...   124
sklearn

support_vectors_
: array-like, shape = 
[n_SV, n_features] 
It returns the support vectors. 
n_support_

array-like, 
dtype=int32, 
shape = [n_class] 
It represents the number of support vectors for 
each class. 
dual_coef_
: array, shape = [n_class-
1,n_SV] 
These are the coefficient of the support vectors in 
the decision function. 
coef_
: array, shape = [n_class * (n_class-
1)/2, n_features] 
This attribute, only available in case of linear 
kernel, provides the weight assigned to the 
features.
intercept_
: array, shape = [n_class * 
(n_class-1)/2] 
It represents the independent term (constant) in 
decision function. 
fit_status_
: int
The output would be 0 if it is correctly fitted. The 
output would be 1 if it is incorrectly fitted.
classes_
: array of shape = [n_classes] 
It gives the labels of the classes. 
Implementation Example 
Like other classifiers, SVC also has to be fitted with following two arrays: 

An array 
X
holding the training samples. It is of size [n_samples, n_features]. 

An array 
Y
holding the target values i.e. class labels for the training samples. It is 
of size [n_samples].
Following Python script uses 
sklearn.svm.SVC
class



Scikit-Learn
68 
import numpy as np 
X = np.array([[-1, -1], [-2, -1], [1, 1], [2, 1]]) 
y = np.array([1, 1, 2, 2]) 
from sklearn.svm import SVC 
SVCClf = SVC(kernel='linear',gamma='scale', shrinking=False,) 
SVCClf.fit(X, y) 
Output 
SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0, 
decision_function_shape='ovr', degree=3, gamma='scale', kernel='linear', 
max_iter=-1, probability=False, random_state=None, shrinking=False, 
tol=0.001, verbose=False)
Now, once fitted, we can get the weight vector with the help of following python script 
SVCClf.coef_ 

Yüklə 1,92 Mb.

Dostları ilə paylaş:
1   ...   58   59   60   61   62   63   64   65   ...   124




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə