大家好,我正在努力学习机器学习,仍然是初学者
我想问我们是否要适合我们的svm模型
svm_clf_sentanalysis=sklearn.svm.SVC(kernel="linear",gamma='auto')
svm_clf_sentanalysis.fit(X_train_sentanalysis,Y_train_sentanalysis,X_train_sentanalysis_punc,Y_train_sentanalysis_punc)
或两次将
svm_clf_sentanalysis
放入X_train_sentanalysis,Y_train_sentanalysis
其他,用于
X_train_sentanalysis_punc,Y_train_sentanalysis_punc
我也遇到了
TypeError: fit() takes from 3 to 4 positional arguments but 5 were given, when including my three features in fit.
请提供协助。
最佳答案
假设X_train_sentanalysis_punc,Y_train_sentanalysis_punc是用于测试的数据帧。
您应该将X_train_sentanalysis,Y_train_sentanalysis传递到.fit()函数中进行训练。
即svm_clf_sentanalysis.fit(X_train_sentanalysis,Y_train_sentanalysis)
对于测试,您应该使用.score()函数。
即svm_clf_sentanalysis.score(X_train_sentanalysis_punc,Y_train_sentanalysis_punc)
。
关于python - 机器学习和SVM,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59622985/