Decision Trees
import numpy as np import matplotlib.pyplot as plt from public_tests import * from utils import * %matplotlib inline X_train = np.array([[1,1,1],[1,0,1],[1,0,0],[1,0,0],[1,1,1],[0,1,1],[0,0,0],[1,0,1],[0,1,0],[1,0,0]]) y_train = np.array([1,1,0,0,1,0,0,1,1,0]) print("First few elements of X_train:\n", X_train[:5]) print("Type of X_train:",type(X_train)) print("First few elements of y_train:", y_train[:5]) print("Type of y_train:",type(y_train)) print ('The shape of X_train is:', X_train.shape) print ('The shape of y_train is: ', y_train.shape) print ('Number of training examples (m):', len(X_train)) def compute_entropy(y): """ Computes the entropy for Args: y (ndarray): Numpy array indicating whether each example at a node is edible (`1`) or poisonous (`0`) Returns: entropy (flo...