INNER CODE UNIT · Python

loss_func

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

        def loss_func(X, y):
            # Gini impurity
            p2 = 0.0
            y_classes = list(set(y))
            for c in y_classes:
                p2 += (np.sum(y == c) / len(y)) ** 2
            loss = 1.0 - p2
            return loss

        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):

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…