INNER CODE UNIT · Python
perform_split
ankonzoid/LearningX · basic_ML/classification/decision_tree.py:26
def perform_split(X, y):
N, d = X.shape
loss_best = 9E99
X_left, y_left = [], []
X_right, y_right = [], []
threshold_best = None
j_threshold_best = None
for j in range(d):
for i in range(N):
# Set threshold
threshold = X[i, j]
# Split data by threshold
X_left_split, y_left_split = [], []
X_right_split, y_right_split = [], []
for X_i, y_i in zip(X, y):
if X_i[j] <= threshold: