R语言红酒模型实战

R语言数据分析 告

使用软件:R studio
一、对数据的基本分析
在这一次的数据分析 告我选取的是对红酒质量的一个数据分析。我从kaggle上下载了一个1599×12的数据集,其中对于红酒质量影响因素一共有11个因素,分别是:fixed.acidity volatile.acidity Citric.acid Residual.sugar chlorides free.sulfur.dioxide total.sulfur.dioxide density pH sulphates alcohol。接下来开始对该数据集进行分析。
我准备使用多元线性回归模型来对这个数据集建模,得到有关质量的一个回归模型。
首先先装载所需要用到的逻辑包:

R语言红酒模型实战
Quality=4.43-1.01volatile-2.017chlorides+0.005free-0.0035total-0.48pH+0.88sulphates+0.29alcohol。
对计算公式进行代入数值计算,发现结果基本吻合。
3. 结论
结论:在对红酒质量的数据分析中,一共有11个变量,在经过筛选之后,得出volatile.acidity+chlorides + free.sulfur.dioxide + total.sulfur.dioxide + pH + sulphates + alcohol这七个因素才是影响红酒质量的因素,并且可以根据构建的回归模型,得到一个和红酒质量有关的计算公式:Quality=4.43-1.01
volatile-2.017chlorides+0.005free-0.0035total-0.48pH+0.88sulphates+0.29alcohol。
附录一:代码整合:
library(plyr)
library(car)
library(MASS)

setwd(“D:作业r语言数据处理”)
file View(file)
summary(file)
par(mfrow=c(3,4))
boxplot(t1 f i x e d . a c i d i t y , m a i n = " f i x e d . a c i d i t y " ) b o x p l o t ( t 1 fixed.acidity,main="fixed.acidity") boxplot(t1 fixed.acidity,main=fixed.acidity)boxplot(t1volatile.acidity,main=“volatile.acidity”)
boxplot(t1 c i t r i c . a c i d , m a i n = " c i t r i c . a c i d " ) b o x p l o t ( t 1 citric.acid,main="citric.acid") boxplot(t1 citric.acid,main=citric.acid)boxplot(t1residual.sugar,main=“residual.sugar”)
boxplot(t1 c h l o r i d e s , m a i n = " c h l o r i d e s " ) b o x p l o t ( t 1 chlorides,main="chlorides") boxplot(t1 chlorides,main=chlorides)boxplot(t1free.sulfur.dioxide,main=“free.sulfur.dioxide”)
boxplot(t1 t o t a l . s u l f u r . d i o x i d e , m a i n = " t o t a l . s u l f u r . d i o x i d e " ) b o x p l o t ( t 1 total.sulfur.dioxide,main="total.sulfur.dioxide") boxplot(t1 total.sulfur.dioxide,main=total.sulfur.dioxide)boxplot(t1density,main=“density”)
boxplot(t1 p H , m a i n = " p H " ) b o x p l o t ( t 1 pH,main="pH") boxplot(t1 pH,main=pH)boxplot(t1sulphates,main=“sulphates”)
boxplot(t1 a l c o h o l , m a i n = " a l c o h o l " ) n e w d a t a < ? f i l e [ o r d e r ( f i l e alcohol,main="alcohol") newdata<-file[order(file alcohol,main=alcohol)newdata?file[order(filequality),]
quality summary(quality)
crPlot(quality)
outlierTest(quality)
stepAIC(quality, direction=“backward”)
anova(test1,quality)
AIC(quality,test1)
confint(quality)
state t2 coef(t2)
test anova(test,quality)

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2019年5月15日
下一篇 2019年5月15日

相关推荐