You are on page 1of 6

Post production

# Conditional Inference Regression Random Forest Model (using party package and cforest function)

install.packages("party")

install.packages("caret")

library(party)

library(caret)

data()<-read.csv(file.choose(),header=T)

names(data)

testdata<-read.csv(file.choose(),header=T)

set.seed(1000)

train<-sample(1:84,60,replace = FALSE)

traindata<-data[train,]

testdata<-data[-train,]

fit<-cforest(Profitability~.,data=traindata,controls =cforest_unbiased(ntree=500,mtry=2))

fit

cforestStats(fit)

rev(sort(varimp(fit)))

rev(sort(varimp(fit,pre1.0_0 = TRUE)))

pred<-predict(fit,newdata=testdata,type="response")
pred

print(testdata$Profitability,pred)

cor(pred,testdata$Profitability)^2

> pred
Profitability
[1,] 3.965384
[2,] 1.500185
[3,] 1.797076
[4,] 2.003410
[5,] 1.728604
[6,] 2.125023
[7,] 1.331991
[8,] 1.602208
[9,] 1.777876
[10,] 2.453328
[11,] 2.120370
[12,] 1.414692
[13,] 2.832213
[14,] 1.502565
[15,] 3.849889
[16,] 2.759182
[17,] 2.262293
[18,] 2.297035
[19,] 1.221546
[20,] 1.333580
[21,] 2.110685
[22,] 1.343835
[23,] 1.934358
[24,] 2.480966
Production

> pred
Profitability
[1,] 3.703009
[2,] 3.150543
[3,] 2.464799
[4,] 3.150930
[5,] 4.062737
[6,] 2.245963
[7,] 3.546882
[8,] 1.961261
[9,] 3.560661
[10,] 3.687878
[11,] 3.324031
[12,] 1.838912
[13,] 3.011516
[14,] 3.407576
[15,] 4.709846
[16,] 1.738729
[17,] 1.801540
[18,] 3.398891
[19,] 2.400426
[20,] 3.769704
[21,] 2.993556
[22,] 2.070921
[23,] 3.283022
[24,] 1.696205
Pre Production

> pred
Budget
[1,] 0.2557644
[2,] 0.2508325
[3,] 0.3558776
[4,] 0.3028808
[5,] 0.1933489
[6,] 0.3332051
[7,] 0.2633859
[8,] 0.2247102
[9,] 0.2532498
[10,] 0.2518183
[11,] 0.3580504
[12,] 0.2505597
[13,] 0.3140662
[14,] 0.3518860
[15,] 0.2833863
[16,] 0.1794410
[17,] 0.2967658
[18,] 0.3453223
[19,] 0.2739529
[20,] 0.3069306
[21,] 0.2817900
[22,] 0.3642041
[23,] 0.1921790
[24,] 0.2936054

>

Pre classification

You might also like