1
votes

I got 2 CSV named train.csv and test.csv.

Both files have the same structure, and I want to use train.csv as train data and test.csv as test data.

The thing is, I can't find anywhere how to use scikit-learn linear regression without using split, every tutorial/documentation I find uses the function train_test_split(), but if I understand correctly it's used to split one file (let's say data.csv) as both train and test data.

Is it even possible? If no, what alternative can I use?

1
Just don't use the split function. Read your train.csv as the train dataset and your test.csv as your test dataset. - Scratch'N'Purr

1 Answers

0
votes

If you have separate train, test data,

define X_train and y_train

  • X_train is the features excluding the target variable
# Sudo Code
X_train = train.drop(target, axis=1)
  • y_train is the target variable
# Sudo Code
y_train = train[target]
from sklearn.linear_model import LinearRegression
reg = LinearRegression().fit(X_train, y_train)