TypeError: __init__() got an unexpected keyword argument 'n_folds',sentiment_analysis_with_SVM
TypeError: __init__() got an unexpected keyword argument 'n_folds',sentiment_analysis_with_SVM
我正在尝试实施用于情绪分析的 svm,我正在尝试实施此 gitlink https://github.com/jatinwarade/Sentiment-analysis-using-SVM/blob/master/SVM.ipynb。
from sklearn.model_selection import ShuffleSplit
from sklearn.model_selection import StratifiedKFold
我引用了这个,因为它说要将交叉原点更改为 model_selection,因为它已被删除
所以我换成了这个
grid_svm = GridSearchCV(
pipeline_svm, #object used to fit the data
param_grid=param_svm,
refit=True, # fit using all data, on the best detected classifier
n_jobs=-1, # number of cores to use for parallelization; -1 for "all cores" i.e. to run on all CPUs
scoring='accuracy',#optimizing parameter
cv=StratifiedKFold(liked_train,n_folds=5),
)
这个Returns错误:
TypeError Traceback (most recent call last)
<ipython-input-49-61dd1e818fa4> in <module>
5 n_jobs=-1, # number of cores to use for parallelization; -1 for "all cores" i.e. to run on all CPUs
6 scoring='accuracy',#optimizing parameter
----> 7 cv=StratifiedKFold(liked_train,n_folds=5),
8 )
TypeError: __init__() got an unexpected keyword argument 'n_folds'
请帮我解决这个错误
正如您在 model_selected.StrafiedKFold
的文档中看到的那样,没有名为 n_folds
的关键字参数,您确实应该使用 n_splits
.
但是请注意,数据应该 而不是 作为参数传递给验证器,这样做实际上是将 liked_train
作为参数传递对于 n_splits
,这是行不通的。相反,您应该在初始化后仅将数据传递给 grid_svm
的 fit
。
我正在尝试实施用于情绪分析的 svm,我正在尝试实施此 gitlink https://github.com/jatinwarade/Sentiment-analysis-using-SVM/blob/master/SVM.ipynb。
from sklearn.model_selection import ShuffleSplit
from sklearn.model_selection import StratifiedKFold
我引用了这个,因为它说要将交叉原点更改为 model_selection,因为它已被删除
grid_svm = GridSearchCV(
pipeline_svm, #object used to fit the data
param_grid=param_svm,
refit=True, # fit using all data, on the best detected classifier
n_jobs=-1, # number of cores to use for parallelization; -1 for "all cores" i.e. to run on all CPUs
scoring='accuracy',#optimizing parameter
cv=StratifiedKFold(liked_train,n_folds=5),
)
这个Returns错误:
TypeError Traceback (most recent call last)
<ipython-input-49-61dd1e818fa4> in <module>
5 n_jobs=-1, # number of cores to use for parallelization; -1 for "all cores" i.e. to run on all CPUs
6 scoring='accuracy',#optimizing parameter
----> 7 cv=StratifiedKFold(liked_train,n_folds=5),
8 )
TypeError: __init__() got an unexpected keyword argument 'n_folds'
请帮我解决这个错误
正如您在 model_selected.StrafiedKFold
的文档中看到的那样,没有名为 n_folds
的关键字参数,您确实应该使用 n_splits
.
但是请注意,数据应该 而不是 作为参数传递给验证器,这样做实际上是将 liked_train
作为参数传递对于 n_splits
,这是行不通的。相反,您应该在初始化后仅将数据传递给 grid_svm
的 fit
。