简体   繁体   中英

How can I solve Data reshape error in anaconda python?

I have a sample data such as : name, AVg, GPA

Here is some part of data I've got. I have 164 rows of data

在此处输入图片说明

sample = pd.read_excel('./data.xlsx')
X = sample.AVG
y = sample.GPA


X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)

clf = DecisionTreeClassifier()
clf.fit(X_train, y_train)

y_pred = clf.predict(X_test)

when I run above code I got error message saying 'With n_samples=1, test_size=0.2 and train_size=None, the resulting train set will be empty. Adjust any of the aforementioned parameters.'

so I added bleow code

X =np.reshape(-1,1)
y=np.reshape(-1,1)

Now I am getting error message saying 'With n_samples=1, test_size=0.2 and train_size=None, the resulting train set will be empty. Adjust any of the aforementioned parameters.'

How Can I remove those error message? Can someone please help me?

通过 X_train=X_train.values.reshape(-1,1) y_train=y_train.values.reshape(-1,1) 解决这个问题

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM