Hello, I'm working on a code that detect fake news and am having the error below. Can i see any assistance here. The aspect of the code producing the error is:
mlc = MLPClassifier(hidden_layer_sizes=3) mlc.fit(fake_news_train_tfidf,label_train) mlc_pred = mlc.predict(fake_news_test_tfidf) print(accuracy_score(label_test,mlc_pred))
The Error stack is: TypeError Traceback (most recent call last) <ipython-input-118-0374c264f5e4> in <module> 1 gbc = GradientBoostingClassifier() ----> 2 gbc.fit(fake_news_train_tfidf,label_train) 3 gbc_pred = gbc.predict(fake_news_test_tfidf) 4 print(accuracy_score(label_test,gbc_pred))
C:\ProgramData\Anaconda3\lib\site-packages\sklearn\ensemble\gradient_boosting.py in fit(self, X, y, sample_weight, monitor) 1402 check_consistent_length(X, y, sample_weight) 1403 -> 1404 y = self._validate_y(y, sample_weight) 1405 1406 if self.n_iter_no_change is not None:
C:\ProgramData\Anaconda3\lib\site-packages\sklearn\ensemble\gradient_boosting.py in validate_y(self, y, sample_weight) 1960 1961 def _validate_y(self, y, sample_weight): -> 1962 check_classification_targets(y) 1963 self.classes, y = np.unique(y, return_inverse=True) 1964 n_trim_classes = np.count_nonzero(np.bincount(y, sample_weight))
C:\ProgramData\Anaconda3\lib\site-packages\sklearn\utils\multiclass.py in check_classification_targets(y) 166 y : array-like 167 """ --> 168 y_type = type_of_target(y) 169 if y_type not in ['binary', 'multiclass', 'multiclass-multioutput', 170 'multilabel-indicator', 'multilabel-sequences']:
C:\ProgramData\Anaconda3\lib\site-packages\sklearn\utils\multiclass.py in type_of_target(y) 285 return 'continuous' + suffix 286 --> 287 if (len(np.unique(y)) > 2) or (y.ndim >= 2 and len(y[0]) > 1): 288 return 'multiclass' + suffix # [1, 2, 3] or [[1., 2., 3]] or [[1, 2]] 289 else:
C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\arraysetops.py in unique(ar, return_index, return_inverse, return_counts, axis) 262 ar = np.asanyarray(ar) 263 if axis is None: --> 264 ret = _unique1d(ar, return_index, return_inverse, return_counts) 265 return _unpack_tuple(ret) 266
C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\arraysetops.py in unique1d(ar, return_index, return_inverse, return_counts) 310 aux = ar[perm] 311 else: --> 312 ar.sort() 313 aux = ar 314 mask = np.empty(aux.shape, dtype=np.bool)
TypeError: '<' not supported between instances of 'float' and 'str'