та же программа ML работает, но этот код дает ошибку - PullRequest
0 голосов
/ 23 октября 2019
# other same rule ...programe is executed properly,but this giving error

import pandas as pd
df = pd.read_excel('ml.xlsx')
df.head()

        Milage  Age     Sell_Price
0   39000   2   18000
1   45000   6   15000
2   25000   5   25000
3   64000   5   96000
4   84000   6   24000
5   26000   2   21000
6   67000   7   25000
7   58000   4   64000
8   78000   9   78000
9   98000   2   24000
10  14000   5   65000
11  54000   8   25000
12  67000   2   78000
13  34000   7   89000
14  24000   9   45000
15  14000   4   56000
16  26000   7   12000
17  59000   2   23000
18  58000   5   32000
19  57000   6   21000

x = [[df['Milage'],[df['Age']]]]
y = [df['Sell_Price']]

from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2)

# error:--

#ValueError: 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.

1 Ответ

0 голосов
/ 23 октября 2019

Попробуйте заменить

x = [[df['Milage'],[df['Age']]]] 
y = [df['Sell_Price']]`

на

x = df[['Milage','Age']]
y = df['Sell_Price']`
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...