In Step 2, we used the typical scikit-learn approach to train a machine learning model. First, we created the object of the DecisionTreeClassifier class (using all the default settings). Then, we fitted the model to the training data (we needed to pass both the features and the target), using the fit method. Lastly, we obtained the predictions by using the predict method.
How it works...
Using the predict method results in an array of predicted classes (in this case, it is either a 0 or a 1). However, there are cases when we are interested in the assigned probabilities. To obtain them, we can use the predict_proba method and obtain an n_test_observations x n_classes array, where each row contains all the possible class probabilities (they ...
Get Python for Finance Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.