From sklearn.model_selection
family I have imported train_test_split
and I want to train my model and test the model in order to predict variable y
.
I assigned string data type as my X
(features/variable of my dataset) and my y
is an integer dataset (response).
After doing that I have imported LinearRegression
function/method from sklearn.linear_model
family, now when I try to fit the model it displays an error
can’t convert strings(X) to variable y
Why?
X = df[['Avg. Area Income', 'Avg. Area House Age', 'Avg. Area
Number of Rooms',
'Avg. Area Number of Bedrooms', 'Area Population', 'Price',
'Address']]
y = df['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.40 , random_state=101)
from sklearn.linear_model import LinearRegression
lm = LinearRegression()
lm.fit(X_train,y_train)