Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLease complete this ML COURSE - python > discrete input, discrete output > real input, real output > real input, discrete output > discrete input,
PLease complete this ML COURSE - python > discrete input, discrete output > real input, real output > real input, discrete output > discrete input, real output """ import numpy as np import pandas as pd import matplotlib.pyplot as plt from .utils import entropy, information_gain, gini_index np.random.seed(42) class DecisionTree(): def __init__(self, criterion, max_depth): """ Put all infromation to initialize your tree here. Inputs: > criterion : {"information_gain", "gini_index"} # criterion won't be used for regression > max_depth : The maximum depth the tree can grow to """ pass def fit(self, X, y): """ Function to train and construct the decision tree Inputs: X: pd.DataFrame with rows as samples and columns as features (shape of X is N X P) where N is the number of samples and P is the number of columns. y: pd.Series with rows corresponding to output variable (shape of Y is N) """ pass def predict(self, X): """ Funtion to run the decision tree on a data point Input: X: pd.DataFrame with rows as samples and columns as features Output: y: pd.Series with rows corresponding to output variable. THe output variable in a row is the prediction for sample in corresponding row in X. """ pass def plot(self): """ Function to plot the tree Output Example: ?(X1 > 4) Y: ?(X2 > 7) Y: Class A N: Class B N: Class C Where Y => Yes and N => No """ pass
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started