r/pythontips • u/hellomasters • Apr 08 '25
Module explain me this ???
Explain the process that is going on in these lines:
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
model = LinearRegression()
model.fit(X_train, y_train)
0
Upvotes
3
u/kuzmovych_y Apr 08 '25
This line doesn't train any model. It only splits your data. So yeah, very fair questions
2
u/BiomeWalker Apr 08 '25
The train_test_split() function returns a tupple with 4 elements, by lining up several variables on the left of the equals sign you break it up into 4 variables.
1
u/ninhaomah Apr 08 '25
sorry but this post is to ask about linear regression in python or to ask if the manager was wrong to ask those questions ?
And he stopped you there and asked you those questions before going over the rest of the script ?