from sklearn.model_selection import train_test_split
from sklearn.naive_bayes import GaussianNB
from sklearn.metrics import accuracy_score,confusion_matrix
import pandas as pd
df=pd.read_csv('weather.csv',delimiter=',')
print(df)
x=df.values[:,0:df.shape[1]-1]
y=df.values[:,df.shape[1]-1]
x_train,y_train,x_test,y_test = train_test_split(x,y,test_size=0.5,random_state=0)
gnb=GaussianNB()
y_pred=gnb.fit(x_train,y_train).predict(x_test)
print(y_test,y_pred)
print("Number of misplaced points out of a total %d points : %d" % (x_test.shape[0],y_test!=y.pred).sum())
print(accuracy_score(y_test,y_pred))
print(confusion_matrix(y_test,y_pred)
The above is my code which I tried in Google Colab. But here it shows one error :
"y should be a 1d array, got an array of shape {} instead.".format(shape)"
This is error is shown in the line
y_pred=gnb.fit(x_train,y_train).predict(x_test)
Please help me to solve this error. I am a beginner so answer the question with elaboration