Reputation: 61
I have a problem with this code:
from sklearn import svm
model_SVC = SVC()
model_SVC.fit(X_scaled_df_train, y_train)
svm_prediction = model_SVC.predict(X_scaled_df_test)
The error message is
NameError
Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_14392/1339209891.py in ----> 1 svm_prediction = model_SVC.predict(X_scaled_df_test)NameError: name 'model_SVC' is not defined
Any ideas?
Upvotes: 3
Views: 5586
Reputation: 1
I came across this post while coding with the help of tutorialspoint.com where i was learning about svm and its usage in python implementing in A.I. the code was
Svc_classifier = svm_classifier.SVC(kernel='linear',
C=C, decision_function_shape = 'ovr').fit(X, y)
Z = svc_classifier.predict(X_plot)
Z = Z.reshape(xx.shape)
so revised code would be
svc_classifier = svm.SVC(kernel='linear',
C=C, decision_function_shape = 'ovr').fit(X, y)
Z = svc_classifier.predict(X_plot)
Z = Z.reshape(xx.shape)
Upvotes: 0
Reputation: 5597
The line from sklearn import svm
was incorrect. The correct way is
from sklearn.svm import SVC
The documentation is sklearn.svm.SVC. And when I choose this model, I'm mindful of the dataset size. Extracted:
The fit time scales at least quadratically with the number of samples and may be impractical beyond tens of thousands of samples. For large datasets consider using LinearSVC instead.
from sklearn.svm import LinearSVC
For more info you could read When should one use LinearSVC or SVC?
Upvotes: 1