but before we can use the test dataset on the learned regression linewe need to make sure the attributes have been through the same preprocessing in both training and testing sets since we transformed categorical variables into their one hot encodings in the train datasetin the following snippet we perform the same actions on the test dataset as well in [ ]test_encoded_attr_list [for enc in encoded_attr_listcol_name enc['col_name'le enc['label_enc'ohe enc['ohe_enc'test_encoded_attr_list append({'feature_df':transform_ohe(x_testle,ohecol_name)'col_name':col_name}test_feature_df_list [x_test[numeric_feature_cols]test_feature_df_list extend([enc['feature_df'for enc in test_encoded_attr_list if enc['col_name'in subset_cat_features]test_df_new pd concat(test_feature_df_listaxis= print("shape::{}format(test_df_new shape)the transformed test dataset is shown in figure - figure - test dataset after transformations the final piece of the puzzle is to use the predict(function of the linearregression object and compare our results/predictions the following snippet performs the said actions in [ ]x_test test_df_new y_test y_test total_count values reshape(- , y_pred lin_reg predict(x_testresiduals y_test-y_pred we also calculate the residuals and use them to prepare the residual plotsimilar to the one we created during training step the following snippet plots the residual plot on the test dataset in [ ]figax plt subplots(ax scatter(y_testresiduals