Answer the question
In order to leave comments, you need to log in
How to parse strings in naive bayes classifier?
Good evening friends! Created a program that makes classification using a naive bayes classifier. I am implementing a program in python3.6
First, I connect the module:
Then the classifier itselffrom sklearn.naive_bayes import GaussianNB
model = GaussianNB()
model.fit(x_training, y_training)
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).
FutureWarning)
x_training = np.array(x_training, dtype=np.complex)
builtins.TypeError: must be real number, not str (on the same line)
Answer the question
In order to leave comments, you need to log in
I have never used this module and most likely I am writing nonsense, but according to the description from here , you must specify the parameters in the form model.fit((array: number of samples, sample?),(x_training or array x_training, y_training)):
fit(X, y, sample_weight=None)[source]
Fit Gaussian Naive Bayes according to X, y
Parameters:
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.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question