I am trying to create one Machine Learning model using LinearRegression model, but I am getting the below error.
import pandas as pd
data = pd.read_csv('db.csv')
x = data['TV']
y = data['Sales']
from sklearn.linear_model import LinearRegression
model = LinearRegression()
model.fit(x,y)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/user/Python.framework/Versions/3.6/lib/python3.6/site-packages/sklearn/linear_model/base.py", line 512, in fit
y_numeric=True, multi_output=True)
File "/user/Python.framework/Versions/3.6/lib/python3.6/site-packages/sklearn/utils/validation.py", line 531, in check_X_y
check_consistent_length(X, y)
File "/user/Python.framework/Versions/3.6/lib/python3.6/site-packages/sklearn/utils/validation.py", line 181, in check_consistent_length
" samples: %r" % [int(l) for l in lengths])
ValueError: Found input variables with inconsistent numbers of samples: [1, 1000]