Is it Possible to Make Machine Learning Algorithms without Coding?
By: Julian Herrera
Tags: Machine Learning, Data Science, Random Forest, Data Analytics, Data Visualization

5. What tool are we going to use?

Orange is an open-source tool that allows us to perform a wide range of data-manipulation tasks such as data visualization, exploration, preprocessing and modeling creation without the need to use Python, R or any other piece of code. It’s ideal if you’re taking your first steps in this long learning-path.

It’s also suitable for more advanced users as it includes Python widgets to input Python scripts to complement the widgets it has to offer. Go to the following link to proceed with the installation of the program.

1. Open a new file

Initial user interface — Image by Author

2. Drag the File widget to the canvas and browse the dataset in your local server by double clicking in the File widget.

In this case, I’ll be utilizing a dataset containing a sample of 150.000 clients of a financial institution. The column “SeriousDlqin2yrs” will be the target variable upon preparing our model.

You can find the dataset in this link to my GitHub.

Note: Don’t worry about the gray “Apply” button as it’s only used to confirm changes made to the values in each feature, for e.g. after modifying “Role” or “Values” tabs.

File loading interface— Image by Author

3. Visualize default features and distributions of the dataset

Drag the “Feature Statistics” and “Distribution” widgets from the “Data” and “Model” and “Visualize” from the left-side panels. With these tools, you’ll get a better view of the descriptive statistics of each feature in the dataset, such as mean, dispersion, minimum, maximum and missing values.

Feature Statistics Widget — Image by Author

Distributions Widget — Image by Author

4. Select Rows

Filter columns data to avoid incorrect values that interfere in the accuracy of the analysis. We can set conditions for the features such as values below X amount of equal to Y amount.

Select Rows— Image by Author

5. Select Columns

Select important features for your analysis from the original dataset and create a new dataset with only those features utilizing the widget “Select Columns”. This is the widget in which you can determine selected columns and indicate target variable for further analysis.

Select Columns interface— Image by Author

6. Data Sampler

Data Sampler widget is used to split the filtered dataset into train and test subsets. In Orange’s interface we can select a “Sampling Type” to input our desired sampling method. Particularly, I selected 70% of the entire data to be included as “Train sample” leaving the remaining 30% as “Test sample”. As mentioned earlier in the article, data-selection for the subsets is performed randomly and with stratified samples, as Orange’s interface reflects.

Data Sampler interface — Image by Author

7. Imbalanced Dataset Resolution

In order to solve the Imbalanced Dataset problem explained above, I decided to perform the Oversampling technique instead of a SMOTE as I believe that the widget for this feature is not included in Orange.

1 . Select “Default” values, which are the minority class from the training subset, as we want to randomly replicate the observations to balance the dataset. In the visualization, you will see that links or edges between the widgets have legends, in which you must indicate what data you want to pass to the “receiving” widget. In this case, “Select Rows” widget contains a Train subset, from which “Matching data” or “Defaults” will be sent. On the other hand, we find “Unmatched data” , which are “No defaults” from the Train subset, that are directly sent to the “Concatenate ”widget.

An advantage of Oversampling method is that it leads to no information loss in relation to Undersampling. Its disadvantage is that, since it simply adds replicated observations in the original data set, it ends up adding multiple observations of several types, thus leading to overfitting.

2. Data Sample widget randomly replicates a fixed number of observations

3. Concatenate widget joins both new observations with “old” ones, in order to finally obtain a balanced dataset to submit to our model.

Orange Canvas — Image by Author

8. Perform prediction on balanced train dataset with Random Forest

Let’s move on to the fun part: Modeling Random Forest. To perform this task, select the widget “Random Forest” from the “Models” sections and link it to the balanced train dataset.

We will test the “depth ” Hyperparameter in an effort to optimize the model. Hyperparameters are a sort of “setting ” of the model that can be adjusted to enhance performance. In the case of Random Forest, Hyperparameters include:

Number of decision trees in the forest Number of features considered by each tree when splitting a node, also known as “depth” or “growth” of the model.

As it’s shown in the images below, the first model has a 3-tree depth limit and the second has no limit in how “deep” the model will grow in the optimization.

Random Forest with 3-trees depth limit — Image by Author

Random Forest with no depth limit — Image by Author

9. Test & Score widget

This widget is used to evaluate the results of the model based on the training dataset. It will perform cross-validation based on the number of folds defined. These folds are the number of subsets created from the train sample which will run on rounds to evaluate the whole dataset.

The resulting interface is a listing of the utilized models as a comparison of performance with the metrics obtained. In the next step I’ll explain the meaning of each metric.

Test & Score interface — Image by Author

10. Confusion Matrix

To simplify the exercise, I’ll explain using the most effective model from the two we ran. Confusion Matrix is a performance-measurement tool that it’s utilized to evaluate a machine learning model based on predetermined metrics. The output is a table with a combination of values as follows:

Sarang Narkhede, Understanding Confusion Matrix

True Positive results (TP): The model correctly predicted the positive outcome (e.g. It predicted it would “Not Default” and ended not doing so). True Negative results (TN): The model correctly predicted the negative outcome (e.g. It predicted it would “Default” and ended doing so). False Positive results (FP): The model failed to predict the positive outcome (e.g. It predicted it would “Default” and ended not doing so). False Negative results (FN): The model failed to predict the negative outcome (e.g. It predicted it would “Not Default” and ended doing so).

This Matrix is included as a widget in Orange and has the following interface:

Confusion Matrix interface — Image by Author

It is extremely useful for measuring Recall, Precision, F1 Score, Accuracy and AUC-ROC Curve:

Accuracy: Proportion of predictions that the models successfully classified.

Precision: Portion of correctly predicted outcomes among all positive predictions.

Recall: Portion of positive outcomes that the model predicted correctly.

F1 Score: It’s a combination of both precision and recall, also used to measure test’s accuracy.

Conclusion

The motivation of this article was to show how to apply sophisticated Machine Learning algorithms without a single line of code, but I additionally ended up considering it as a theory facilitator that hopefully serves as a motivator for everyone that reads this post.

References