Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (17.6k points)

I have gone through multiple questions that help divide your dataframe into train and test, with scikit, without etc.

But my question is I have 2 different csvs ( 2 different dataframes from different years). I want to use one as train and other as test?

How to do so for LinearRegression / any model?

1 Answer

0 votes
by (41.4k points)

reg = LinearRegression()

4.Use the test set to predict the output after training.

# Load the data

Follow the below steps to accomplish your task:

1.Load the datasets individually.

2. They should be in the same format of rows and columns .

3.Use the train set to fit the model.

train = pd.read_csv('train.csv')

test = pd.read_csv('test.csv')

# Fit (train) model

reg.fit(X_train, y_train)

# Predict

pred = reg.predict(X_test)

# Score

accuracy = reg.socre(X_test, y_test)

If you wish to learn about Python visit this Python Course.

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.5k answers

500 comments

108k users

Browse Categories

...