Project 3: Decision Tree Classifier
Applied Machine Learning February 23, 2022
1 DTC Function
Write your own decision tree classifier function in R. This function should be called DTC and it should take two inputs: 1. formula describing the model that learning should be performed on 2. data denoting the data-frame in which the data reside on. This function should output a decision tree calculated based on the data and the formula. Please note that the main function in your program that builds the tree needs to be recursive. This is a hard requirement. You can follow the pseudo-code provided in the lecture notes. Your program can only rely on the following external functions:
Copyright By PowCoder代写 加微信 powcoder
is.formula, is.data.frame, is.vector, is.na, as.vector, is.null, length, match, levels, nlevels, array, table, sum, matrix, in addition to func-
tions from the igraph library.
Please note that you should reuse your code from Project 2 on using and parsing formulas.
Hint: similar to Project 2, start by implementing how the Resturant exam- ple discussed during class can be implemented in R.
1.1 Examples:
## Warning: package ¡¯igraph¡¯ was built under R version 3.4.4
## Attaching package: ¡¯igraph¡¯
## The following objects are masked from ¡¯package:stats¡¯:
## decompose, spectrum
## The following object is masked from ¡¯package:base¡¯:
## union
data <- read.csv("Resturant.csv") formula <- WillWait ~ Alt + Bar + Fri + Hun + Pat + Price + Rain + DTC(formula,data) Res + Type + Est Italian Thai data <- read.csv("Tennis.csv") formula <- Play ~ Outlook + Temperature + Humidity + Wind DTC(formula,data) OvercastRain Strong Weak High Normal 程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com