How do you fix inconsistent numbers of samples when using GaussianNB()? Also, is it possible for input pandas dataframe as arguments for model.fit function?
Asked
Active
Viewed 235 times
1 Answers
2
The issue is that GaussianNB
is expecting weather
to be in the shape (n_samples, n_features)
. You currently have it as a one-dimensional array, so GaussianNB
is interpreting it as a 1 sample with 14 features.
To convert to the right shape, you can use weather[:,None]
as described in this answer. So, the following should do the trick:
model.fit(weather[:,None], play)
-
No problem. Also, looking at your code, note that you can just do `play = df_numeric.play.values` to get a numpy array from a dataframe column. – root Mar 11 '16 at 19:34