我正在尝试训练我的模型,但是当我想运行这个Y_pred = m.predict(X_test)
时出现错误。我真的不明白发生了什么事?您能帮我吗,谢谢您
from pandas import read_excel
import numpy as np
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import confusion_matrix, accuracy_score
from gmdhpy.gmdh import Classifier
dataset = read_excel("database.xlsx")
X = dataset.iloc[:, 1:len(dataset.columns)].values
Y = dataset.iloc[:, 0].values
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.2, random_state=0)
sc = StandardScaler()
X_train = sc.fit_transform(X_train)
X_test = sc.transform(X_test)
# print(X_train)
# print(X_test)
model = Classifier()
# model = Classifier(('linear_cov'), criterion_minimum_width=5, max_layer_count=50)
m = model.fit(X_train, Y_train)
Y_pred = m.predict(X_test)
我遇到的错误:
train layer0 in 0.74 sec
train layer1 in 3.04 sec
train layer2 in 2.97 sec
train layer3 in 2.96 sec
train layer4 in 2.97 sec
train layer5 in 2.99 sec
train layer6 in 2.96 sec
train layer7 in 2.95 sec
train layer8 in 2.96 sec
train layer9 in 2.95 sec
train layer10 in 2.97 sec
train layer11 in 2.97 sec
Traceback (most recent call last):
File "D:/KPI/DIPLOM/Program/c-predictor/Test.py", line 23, in <module>
Y_pred = m.predict(X_test)
File "D:\KPI\DIPLOM\Program\c-predictor\classif.py", line 925, in predict
return self.le.transform(np.argmax(self.predict_proba(data_x)))
File "C:\Python36\lib\site-packages\sklearn\preprocessing\label.py", line 128, in transform
y = column_or_1d(y, warn=True)
File "C:\Python36\lib\site-packages\sklearn\utils\validation.py", line 583, in column_or_1d
raise ValueError("bad input shape {0}".format(shape))
ValueError: bad input shape ()