# 数据分享|R语言逻辑回归、线性判别分析LDA、GAM、MARS、KNN、QDA、决策树、随机森林、SVM分类葡萄酒交叉验证ROC（下）

# 绘制测试ROC图
ocmas <- roctestataqua, tes.pred.rob4god)
## Stting level: conrol = god, case= poor
## Settig diectio: cntrols> caseplot(ro.mars legac.axes = TRE, prin.auc= RUE)
plot(soothroc.mars), co = 4, ad =TRUE)

errr.tria.mas <-man(tainat$qul ! trai.red.ars)### KNNGrid < epa.gri(k seq(from = 1, to = 40, by = 1)) seted(1fknnrainqual ~., dta = trnData, mthd ="knn"metrrid = kid) ggplot(fitkn # 建立混淆矩阵ts.re.po7 < prdi(ft.kn, ewdt = estDaatype = "prb" ### QDAseteed1)%>% pyr:c-ual),y= trataq ethod "d"mric = "OC",tContol =ctl)# 建立混淆矩阵tet.pprob <-pedct(mol.da,nedaa = teDta,te = "pb") testred6<- rep(o", leng(est.ped.pob6$goo))

# 树方法

# 分类ctr <- tintol(meod ="cv", number = 10,smmryFuton= twoClassSma
et.se(1rart_grid = a.fra(cp = exp(eq(10,-, len =0)))clsste = traqua~., rainDta,metho ="rprt
tueGrid = patid,
trCtrl  cr)
ggt(class.tee,highight =TRE)

## 计算测试误差rpartpred = icla.te edta =testata, ye = "aw)
te.ero.sree = mean(testa$a !=rartpre) rprred_trin reic(ss.tre,newdta = raiata, tye "raw") # 建立混淆矩阵 teste.pob8 <-rdic(cste, edata =tstData,pe = "po" tet.pd8 - rpgod" legthtetred.rb8d)) # 绘制测试ROC图 ro.r <-oc(testaual, tstedrob$od)pot(rc.ctreegy.axes  TU pit.a = TRE)plo(ooth(c.tre, col= 4, ad = TRE

# 随机森林和变量重要性
ctl <traontr(mthod= "cv, numbr = 10,clasPos = RUEoClssSummry)
rf.grid - xpa.gr(mt = 1:10,
spltrule "gini"min.nd.sie =seq(from = 1,to  12, by = 2))se.sed(1)
rf.fit <- inqual
mthd= "ranger",
meric = "ROC",
= ctrl
gglt(rf.it,hiliht  TRE)

scle.ermutatin.iportace  TRU)barplt(sort(rangr::imoranc(random

# 支持向量机

st.seed(svl.fi <- tain(qual~ . ,data = trainDatamehod= "mLar2",tueGri = data.frae(cos = ep(seq(-25,ln = 0))

## 带径向核的SVMsvmr.grid  epand.gid(C = epseq(1,4,le=10)),
iga = expsq(8,len=10)))
svmr.it<- tan(qual ~ .,
da = taiDataRialSigma",
preProcess= c("cer" "scale"),
tunnrol = c)

rsam = rsmes(list(summary(resamp)

comrin = sumaryes)$satitics$ROr_quare  smary(rsamp)saisis\$sqrekntr::ableomris$,1:6$)

bpot(remp meic = "ROC")

f<- datafram(dl\_Name, TainError,Test\_Eror, Tes_RC)

knir::abe(df)

# 结论

|
2月前
|

35 1
|
2月前
|

R语言逻辑回归logistic模型ROC曲线可视化分析2例：麻醉剂用量影响、汽车购买行为2
R语言逻辑回归logistic模型ROC曲线可视化分析2例：麻醉剂用量影响、汽车购买行为
63 2
|
2月前
|

【R语言实战】——kNN和朴素贝叶斯方法实战
【R语言实战】——kNN和朴素贝叶斯方法实战
43 2
|
2月前
|

R语言逻辑回归logistic模型ROC曲线可视化分析2例：麻醉剂用量影响、汽车购买行为1
R语言逻辑回归logistic模型ROC曲线可视化分析2例：麻醉剂用量影响、汽车购买行为
45 0
|
2月前
|

R语言逻辑回归、GAM、LDA、KNN、PCA主成分分析分类预测房价及交叉验证|数据分享
R语言逻辑回归、GAM、LDA、KNN、PCA主成分分析分类预测房价及交叉验证|数据分享
37 0
|
2月前
|

【R语言实战】聚类分析及可视化
【R语言实战】聚类分析及可视化
57 2
|
2月前
|

402 3
|
2月前

52 3
|
2月前
|
Web App开发 数据可视化 数据挖掘

220 2
|
2月前
|

R语言分类回归分析考研热现象分析与考研意愿价值变现
R语言分类回归分析考研热现象分析与考研意愿价值变现
53 2