ValueError Bad Shape

File “C:\Users\Usuario\Anaconda3\lib\site-packages\sklearn\utils\”, line 760, in column_or_1d raise ValueError(“bad input shape {0}”.format(shape))

ValueError: bad input shape (768, 8)

I’ve been having this error while doing a assignment on Python, and can’t seem to get it working. COuld you guys help me understad what exactly it is?

Hi @Lfvbf, can you provide a full traceback and the command or code that led to the error?

import pandas as pd

df = pd.read_csv(‘archivesname.csv’, delimiter=’;’, decimal=’,’)

previsores = df.iloc[:, 0:8].values y1 = df.iloc[:, 8].values y2 = df.iloc[:, 9].values

from sklearn.preprocessing import LabelEncoder, OneHotEncoder labelencoder_previsores = LabelEncoder() previsores[:, :8] = labelencoder_previsores.fit_transform(previsores[:, :8]) previsores[:, 8] = labelencoder_previsores.fit_transform(previsores[:, 8]) previsores[:, 9] = labelencoder_previsores.fit_transform(previsores[:, 9])

onehotencoder = OneHotEncoder(categorical_features = [0,1,2,3,4,5,6,7]) previsores = onehotencoder.fit_transform(previsores).toarray()

labelencoder_y1 = LabelEncoder() labelencoder_y2 = LabelEncoder() y1 = labelencoder_y1.fit_transform(y1) y2 = labelencoder_y2.fit_transform(y2)

from sklearn.preprocessing import StandardScaler scaler = StandardScaler() previsores = scaler.fit_transform(previsores)

from sklearn.model_selection import train_test_split previsores_treinamento, previsores_teste, y1_treinamento, y1_teste = train_test_split(previsores, y1, test_size=0.15, random_state=0) previsores_treinamento, previsores_teste, y2_treinamento, y2_teste = train_test_split(previsores, y2, test_size=0.15, random_state=0)

from sklearn.ensemble import RandomForestClassifier classificador = RandomForestClassifier(n_estimators=40, criterion=‘entropy’, random_state=0), y1_treinamento) previsoes = classificador.predict(previsores_teste)

from sklearn.metrics import confusion_matrix, accuracy_score precisao = accuracy_score(y1_teste, previsoes) matriz = confusion_matrix(y1_teste, previsoes)

I’m brazillian so please ignore the translated words. Sorry @erohmensing it took so long to respond

Ok, looks like this is not rasa code> the issue seems to lie either within pandas or scikitlearn