Case 1. A tutorial decision tree in pure PHP

Implementation in pure PHP

In this case we build a minimal tutorial decision tree: we compute entropy and information gain for a simple split, pick the best threshold for a feature, and show how the dataset is split into left and right branches.

Graph:

Decision Tree
Result: Memory: 0.008 Mb Time running: < 0.001 sec.
Best split:
Feature: visits
Threshold: 5
Information Gain: 1

Left branch:
[1, 2, passive]
[2, 3, passive]
[3, 4, passive]

Right branch:
[5, 10, active]
[7, 15, active]
[6, 8, active]