@@ -105,7 +105,7 @@ def __init__(self, impl, kernel, degree, gamma, coef0,
105
105
self .sparse = sparse
106
106
self .class_weight = class_weight
107
107
108
- def fit (self , X , y , sample_weight = None ):
108
+ def fit (self , X , y , class_weight = None , sample_weight = None ):
109
109
"""Fit the SVM model according to the given training data.
110
110
111
111
Parameters
@@ -135,6 +135,11 @@ def fit(self, X, y, sample_weight=None):
135
135
matrices as input.
136
136
"""
137
137
self ._sparse = sp .isspmatrix (X ) if self .sparse == "auto" else self .sparse
138
+ if class_weight != None :
139
+ warnings .warn ("'class_weight' is now an initialization parameter."
140
+ "Using it in the 'fit' method is deprecated." ,
141
+ DeprecationWarning )
142
+ self .class_weight = class_weight
138
143
fit = self ._sparse_fit if self ._sparse else self ._dense_fit
139
144
fit (X , y , sample_weight )
140
145
return self
@@ -595,7 +600,7 @@ def _get_solver_type(self):
595
600
+ error_string )
596
601
return self ._solver_type_dict [solver_type ]
597
602
598
- def fit (self , X , y ):
603
+ def fit (self , X , y , class_weight = None ):
599
604
"""Fit the model according to the given training data.
600
605
601
606
Parameters
@@ -617,6 +622,12 @@ def fit(self, X, y):
617
622
Returns self.
618
623
"""
619
624
625
+ if class_weight != None :
626
+ warnings .warn ("'class_weight' is now an initialization parameter."
627
+ "Using it in the 'fit' method is deprecated." ,
628
+ DeprecationWarning )
629
+ self .class_weight = class_weight
630
+
620
631
X = atleast2d_or_csr (X , dtype = np .float64 , order = "C" )
621
632
y = np .asarray (y , dtype = np .int32 ).ravel ()
622
633
self ._sparse = sp .isspmatrix (X )
0 commit comments