python - float() argument must be a string or a number in Stochastic Gradient Descent of scikit learn -


i trying use svm classifier text classification,

self.clf = linear_model.sgdclassifier(alpha=1e-3,loss="hinge", penalty="l2") data_folder = self.root_dir + "/trec_data" train_dataset = load_files(data_folder) text in self.data_train.data:     text = self.modifyquery(text.decode('utf-8','ignore'))     training_data.append(text) raw_x = (self.token_ques(text) text in training_data) rbf_feature = rbfsampler(gamma=1, random_state=1) x_train = rbf_feature.fit_transform(raw_x) y_train = self.data_train.target 

which gives me error @ x_train = rbf_feature.fit_transform(raw_x).

traceback (most recent call last):   file "classifier_lessclass.py", line 167, in trainclassifier     x_train = rbf_feature.fit_transform(np.array(raw_x))   file "/usr/local/lib/python2.7/dist-packages/scikit_learn-0.16b1-py2.7-linux-i686.egg/sklearn/base.py", line 433, in fit_transform     return self.fit(x, **fit_params).transform(x)   file "/usr/local/lib/python2.7/dist-packages/scikit_learn-0.16b1-py2.7-linux-i686.egg/sklearn/kernel_approximation.py", line 76, in fit     x = check_array(x, accept_sparse='csr')   file "/usr/local/lib/python2.7/dist-packages/scikit_learn-0.16b1-py2.7-linux-i686.egg/sklearn/utils/validation.py", line 341, in check_array     array = np.array(array, dtype=dtype, order=order, copy=copy) typeerror: float() argument must string or number 

i tried converting raw_x float() still same error. tried np.array(raw_x) gives same error.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -