Professional Documents
Culture Documents
Class Assignment 2
Class Assignment 2
SUBMITTED BY:
ANDREW B BUHPHANG(PGP/0050/004)
1) Multiple regression:-
View(airquality)
print(model)
a = coef(model)[1]
print(a)
xSolar.R = coef(model)[2]
xWind = coef(model)[3]
xTemp = coef(model)[4]
print(xSolar.R)
print(xWind)
print(xTemp)
print(result)
OUTPUT
Call:
lm(formula = Ozone ~ Solar.R + Wind + Temp, data = input)
Coefficients:
(Intercept) Solar.R Wind Temp
-64.34208 0.05982 -3.33359 1.65209
> a = coef(model)[1]
> print(a)
(Intercept)
-64.34208
> xSolar.R = coef(model)[2]
> xWind = coef(model)[3]
> xTemp = coef(model)[4]
> print(xSolar.R)
Solar.R
0.05982059
> print(xWind)
Wind
-3.333591
> print(xTemp)
Temp
1.652093
> result = a + (xSolar.R)*190 + (xWind)*7.4 + (xTemp)*67
> print(result)
(Intercept)
33.04548
2) RANDOM FOREST:
library(randomForest)
View(readingSkills)
#crate the input data frame
input = readingSkills[c(1:200),]
#crate the random forest
output = randomForest(nativeSpeaker~age+score,data = input)
#plot the random forest
plot(output)
print(output)
Output :-
Call:
randomForest(formula = nativeSpeaker ~ age + score, data = input)
Type of random forest: classification
Number of trees: 500
No. of variables tried at each split: 1
OOB estimate of error rate: 2%
Confusion matrix:
no yes class.error
no 97 3 0.03
yes 1 99 0.01
3) DECISION TREE