INNER CODE UNIT · Python

loss

ankonzoid/LearningX · basic_ML/classification/decision_tree.py:59

                    loss = (N_left/N)*loss_left + (N_right/N)*loss_right

                    # Is this the best split?
                    if loss < loss_best:
                        X_left, y_left = X_left_split, y_left_split
                        X_right, y_right = X_right_split, y_right_split
                        loss_best = loss
                        threshold_best = threshold
                        j_threshold_best = j

            # Split?
            split = len(X_left)>0 and len(X_right)>0

            return X_left, y_left, X_right, y_right, split, threshold_best, j_threshold_best

        def build_tree(X, y):
            X_left, y_left, X_right, y_right, split, threshold, j_threshold = perform_split(X, y)
            if split:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…