fit() missing 1 required positional argument: 'self'

Katya

I try to fit SVC in skikit-learn, but got TypeError: fit() missing 1 required positional argument: 'self' in the line SVC.fit(X=Xtrain, y=ytrain)

from sklearn.svm import SVC
import seaborn as sns; sns.set()


from sklearn.datasets.samples_generator import make_circles
from sklearn.model_selection import train_test_split
from sklearn.model_selection import cross_val_score


X, y = make_circles(100, factor=.2, noise=.2)
Xtrain, Xtest, ytrain, ytest = train_test_split(X,y,random_state=42)

svc = SVC(kernel = "poly")
SVC.fit(X=Xtrain, y=ytrain)
predictions = SVC.predict(ytest)
Kenry Sanchez

The problem is that you are creating the model here svc = SVC(kernel = "poly"), but you're calling the fit with a non-instantiable model.

You must change the object to:

svc_model = SVC(kernel = "poly")
svc_model.fit(X=Xtrain, y=ytrain)
predictions = svc_model.predict(Xtest)

I suggest you to Indique the test size, normally the best practice is with 30% for test and 70% for training. So you can indicate.

Xtrain, Xtest, ytrain, ytest = train_test_split(X,y,test_size=0.30, random_state=42)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Getting TypeError fit() missing 1 required positional argument: 'self'

Missing 1 required positional argument: 'self' missing

save() missing 1 required positional argument 'self'

python: missing 1 required positional argument: 'self'

TypeError: Missing 1 required positional argument: 'self'

main() missing 1 required positional argument: 'self'

missing 1 required positional argument: 'self' in class

missing 1 required positional argument: 'self' in odoo?

missing 1 required positional argument:'self'

method1() missing 1 required positional argument: 'self'

TypeError: fit() missing 1 required positional argument: 'y' please

sklearn: TypeError: fit() missing 1 required positional argument: 'x"

TypeError: fit() missing 1 required positional argument: 'y',

Keras TypeError: fit() missing 1 required positional argument: 'y'

TypeError: fit_transform() missing 1 required positional argument: 'X'

program is not working "TypeError: fit() missing 1 required positional argument: 'y'"

TypeError: fit_resample() missing 1 required positional argument: 'y'

TypeError: fit() missing 1 required positional argument: 'X'

StandardScaler: TypeError: fit() missing 1 required positional argument: 'X'

How to remove this error?fit() missing 1 required positional argument: 'y'

DecisionTreeClassifier TypeError: fit() missing 1 required positional argument: 'y'

__init__() missing 1 required positional argument: 'self'

Django Formset.is_valid missing 1 required positional argument: 'self'

How to Solve this " TypeError: read() missing 1 required positional argument: 'self' "

Why do I get "missing 1 required positional argument: 'self'"?

mock.patch decorator: missing 1 required positional argument: 'self'

Python class showing "missing 1 required positional argument: 'self'"

TypeError: gassens() missing 1 required positional argument: 'self'

TypeError: save() missing 1 required positional argument: 'self' : DjangoRestframework