Here I was creating a model based on multiple linear regression, but now I stuck with an error that is " value error: found input variables with inconsistent numbers of samples: [40, 10]
here I am showing you my code.
I am confused, where should I make changes?
in case of assigning the dependent and independent variable to x and y. When I checked y.shape it gives one-dimensional array instead of this it should show two-dimensional array. You can see the whole code as I have given below and screenshots.
import pandas as pd
import numpy as np
import matplotlib.pyplot as mt
dataset = pd.read_csv("50_Startups.csv")
x = dataset.iloc[ :, :-1].values
y = dataset.iloc[ :, 4].values
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import OneHotEncoder
ct = ColumnTransformer( transformers = [('encoder', OneHotEncoder(),)], remainder = 'passthrough')
x = np.array(ct.fit_transform(x))
from sklearn.model_selection import train_test_split
x_train, y_train, x_test, y_test = train_test_split( x, y, test_size = 0.2, random_state = 0 )
from sklearn.linear_model import LinearRegression
regressor = LinearRegression()
regressor.fit( x_train, y_train )