import matplotlib.pyplot as plt
import pandas as pd
dataset = pd.read_csv('poly.csv')
x = dataset.iloc[:,1:2].values
y = dataset.iloc[:,3:4].values
from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(x,y,train_size = 0.8, shuffle= False, random_state = 0)
from sklearn.preprocessing import PolynomialFeatures
poly_reg = PolynomialFeatures(degree=3)
x_poly = poly_reg.fit_transform(x)
poly_reg.fit(x_poly, y)
from sklearn.linear_model import LinearRegression
reg = LinearRegression()
reg.fit(x_poly, y)
reg.predict([[13000]])
DataSet
https://drive.google.com/open?id=10kbNBEEvShSZ_svxrYxPNXinB9Jw1f61
ошибка:
> ...: reg.predict([[13000]])
> C:\ProgramData\Anaconda3\lib\site-packages\sklearn\model_selection\_split.py:2026:
> FutureWarning: From version 0.21, test_size will always complement
> train_size unless both are specified. FutureWarning) Traceback (most
> recent call last):
>
> File "<ipython-input-1-f94f25f36c83>", line 24, in <module>
> reg.predict([[13000]])
>
> File
> "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\linear_model\base.py",
> line 256, in predict
> return self._decision_function(X)
>
> File
> "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\linear_model\base.py",
> line 241, in _decision_function
> dense_output=True) + self.intercept_
>
> File
> "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\utils\extmath.py",
> line 140, in safe_sparse_dot
> return np.dot(a, b)
>
> ValueError: shapes (1,1) and (4,1) not aligned: 1 (dim 1) != 4 (dim 0)