网格搜索报错
来源:4-6 网格搜索与k近邻算法中更多超参数

慕仰7403133
2018-04-20
%%time
grid_serach.fit(X_train,y_train)
---------------------------------------------------------------------------TypeError Traceback (most recent call last)<ipython-input-70-d0e074bcca21> in <module>()----> 1 get_ipython().run_cell_magic('time', '', 'grid_serach.fit(X_train,y_train)')D:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py in run_cell_magic(self, magic_name, line, cell) 2113 magic_arg_s = self.var_expand(line, stack_depth) 2114 with self.builtin_trap:-> 2115 result = fn(magic_arg_s, cell) 2116 return result 2117 <decorator-gen-60> in time(self, line, cell, local_ns)D:\Anaconda3\lib\site-packages\IPython\core\magic.py in <lambda>(f, *a, **k) 186 # but it's overkill for just that one bit of state. 187 def magic_deco(arg):--> 188 call = lambda f, *a, **k: f(*a, **k) 189 190 if callable(arg):D:\Anaconda3\lib\site-packages\IPython\core\magics\execution.py in time(self, line, cell, local_ns) 1174 if mode=='eval': 1175 st = clock2()-> 1176 out = eval(code, glob, local_ns) 1177 end = clock2() 1178 else:<timed eval> in <module>()D:\Anaconda3\lib\site-packages\sklearn\model_selection\_search.py in fit(self, X, y, groups) 943 train/test set. 944 """--> 945 return self._fit(X, y, groups, ParameterGrid(self.param_grid)) 946 947 D:\Anaconda3\lib\site-packages\sklearn\model_selection\_search.py in _fit(self, X, y, groups, parameter_iterable) 548 n_candidates * n_splits)) 549 --> 550 base_estimator = clone(self.estimator) 551 pre_dispatch = self.pre_dispatch 552 D:\Anaconda3\lib\site-packages\sklearn\base.py in clone(estimator, safe) 65 % (repr(estimator), type(estimator))) 66 klass = estimator.__class__---> 67 new_object_params = estimator.get_params(deep=False) 68 for name, param in six.iteritems(new_object_params): 69 new_object_params[name] = clone(param, safe=False)TypeError: get_params() missing 1 required positional argument: 'self'
这个是什么问题
1回答
-
请尝试运行课程的官方代码看是否报错?传送门:https://github.com/liuyubobobo/Play-with-Machine-Learning-Algorithms
如果运行课程的官方代码没有问题,请仔细比对自己的代码哪里有问题:)
加油!
012018-04-22
相似问题