How to apply my model in a new dataset with same column names

I had two csv files. One was for training and the other one had to be used for further prediction. I used the training file to create my linear regression model. Now I imported the test dataset. The training and the test dataset has the same name for input columns, only the target column is missing in the test dataset. So, I tried to directly use model.predict but it did not work.

I am not able to understand how do I tell python to now take data from the test dataset only

i used the following for model making

input_cols = [‘clicks’, ‘impressions’, ‘cost’, ‘conversions’, ‘adgroup 1’, ‘adgroup 2’, ‘adgroup 3’, ‘adgroup 4’]
inputs, targets = train_csv[input_cols], train_csv[‘revenue’]

Create and train the model

model = LinearRegression().fit(inputs, targets)

Generate predictions

predictions = model.predict(inputs)

then imported my test dataset which has all the column names same as train dataset but the target column is missing. Now, I do not know how to apply my model formed previously on this dataset.

Hey @komalsinghal1017, welcome to the community.
You need to apply any imputation/scaling/encoding you have done for the training set into the test set. Don’t fit the imputer/scaler just use transform. After you have prepared the data you can just run model.predict(test_inputs) to get predictions for test set.