-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWinePrediction.R
44 lines (37 loc) · 1.04 KB
/
WinePrediction.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
rm(list=ls())
wine<-read.csv("C:/Users/ZAHID/Downloads/wine.csv")
str(wine)
summary(wine)
model1= lm(Price ~ AGST, data=wine)
summary(model1)
model1$residuals
SSE <- sum(model1$residuals^2)
SSE
model2 = lm(Price ~ AGST + HarvestRain, data=wine)
summary(model2)
SSE = sum(model2$residuals^2)
SSE
model3 = lm(Price~AGST + HarvestRain + WinterRain+ Age + FrancePop, data=wine)
summary(model3)
SSE = sum(model3$residuals^2)
SSE
model=lm(Price ~ HarvestRain+WinterRain,data=wine)
summary(model)
model4=lm(Price ~ AGST +HarvestRain + WinterRain + Age, data=wine)
summary(model4)
#How to fine correlation between varibales
cor(wine$WinterRain, wine$Price)
cor(wine$Age, wine$FrancePop)
cor(wine$HarvestRain, wine$WinterRain)
cor(wine)
model5=lm(Price ~ AGST + HarvestRain + WinterRain, data=wine)
summary(model5)
summary(model)
#Lets predict
wineTest=read.csv("C:/Users/ZAHID/Downloads/wine_test.csv")
wineTest
predictTest=predict(model4, newdata=wineTest)
predictTest
SSE=sum((wineTest$Price-predictTest)^2)
SST=sum((wineTest$Price-mean(wine$Price))^2)
1-SSE/SST