Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python SVC:索引器的网格搜索错误:数组的索引太多_Python_Scikit Learn_Svm_Grid Search_Svc - Fatal编程技术网

Python SVC:索引器的网格搜索错误:数组的索引太多

Python SVC:索引器的网格搜索错误:数组的索引太多,python,scikit-learn,svm,grid-search,svc,Python,Scikit Learn,Svm,Grid Search,Svc,我正在尝试使用GridSearchCV为SVC找到最佳参数 from sklearn.svm import SVC from sklearn import svm, grid_search from sklearn.model_selection import GridSearchCV param_grid = [ {'C': [1,5,10,100]}, ] algo = SVC(kernel="poly", degree=5, coef0=2) grid_

我正在尝试使用
GridSearchCV
SVC
找到最佳参数

from sklearn.svm import SVC
from sklearn import svm, grid_search
from sklearn.model_selection import GridSearchCV

param_grid = [
        {'C': [1,5,10,100]},
        ]
algo = SVC(kernel="poly",  degree=5, coef0=2)
grid_search = GridSearchCV(algo, param_grid, cv=3, scoring='neg_mean_squared_error')
grid_search.fit(X_train, y_train)
print(grid_search.best_params_) #line 162
我得到以下错误:

  File "main.py", line 162, in <module>
  IndexError: too many indices for array
我得到一个分数。

接受目标值作为一个数组,如
y
形状
[n\u样本]
[n\u样本,n\u输出]

在您的情况下,
(892,)
。因此,对y\U列车进行重塑:

y_train = y_train.reshape(892,)

y\u train.shape
的输出是什么?y\u train.shape的输出是(892,1),X\u train.shape的输出是(892,14)在
grid\u search.fit(X\u train,y\u train)
之前使用
y\u train=y\u train.重塑(892,)
。现在有错误吗?是的!!谢谢出了什么问题?为什么(892,)有效(没有其他属性),而(892,1)无效?
y_train = y_train.reshape(892,)