How to parse strings in the naive Bayesian classifier?

0 like 0 dislike
Good evening, friends! Created a program that makes the classification using naive Bayes classifier. Implement a program to python3.6

To begin connect module:
from sklearn.naive_bayes import GaussianNB

Then the classifier itself
model = GaussianNB(), y_training)

In the end this error:
FutureWarning: Beginning in version 0.22, arrays of bytes/strings will be converted to decimal numbers if dtype='numeric'. It is recommended that you convert the array to a float dtype before using it in scikit-learn, for example by using your_array = your_array.astype(np.float64).

Tried to cure this way:
x_training = np.array(x_training, dtype=np.complex)

But this led to a new error:
builtins.TypeError: must be real number, not str (in the same row)

Have any ideas solutions? I would be very grateful
by | 8 views

1 Answer

0 like 0 dislike
I've never used this module and likely writing nonsense, but as described here it is necessary to specify the parameters in the of samples, the sample?),(x_training or array x_training, y_training)):
fit(X, y, sample_weight=None)[source]
Fit Gaussian Naive Bayes according to X, y
X : array-like, shape (n_samples, n_features)
Training vectors, where n_samples is the number of samples and n_features is the number of features.
y : array-like, shape (n_samples,)
Target values.
110,608 questions
257,186 answers
32,713 users