Training your model

The following model is a new module, as it has different features compared to the other models. Since the features have changed, we need to find the best hyperparameters for the RandomForestClassifier module using the GridSearchCV module. So, perhaps the previously found best parameters are not the best for these new features; therefore, we will run the GridSearchCV algorithm again:

As shown in the following screenshot, in this case the best combination of parameters for these new features is max _depth of 30, max_features in auto, and n_estimators (number of estimators) should be 100:

Now, let's evaluate this new model that we have built using feature engineering, and let's compare it with the previous metrics that we have from the previously built model:

As you can see in the preceding screenshot, we are using a threshold of 0.2. This model generates a recall of 71.39% and a precision of 37.38. Here, the precisions are similar, but, as mentioned earlier, the recall might be the metric that we should care about, as it's slightly different compared to the previous one. We got a little better recall for this model; the change may only be 2% or 3% , which might not look like much, but remember that in these financial applications, an improvement of 1% or 2% could, in practice, mean a lot of money. So, we got a slight improvement in the predictive power of our model using this little feature engineering technique; let's take a look at the feature importance in the following screenshot:

You can assess whether this feature importance make sense in the following screenshot of the random forest model:

You can compare this feature importance with the previous ones. There are a lot of things that you can do after you have applied feature engineering. We may improve performance and gain insight from the model. It's been observed that we improved our model a little bit by using this technique. Now, you can come up with different ways to combine the existing features to improve the model even more. This was just a small, simple example to show you that you can actually play around with the features in a way that actually makes sense.