实验报告 支持向量机_第1页
实验报告 支持向量机_第2页
实验报告 支持向量机_第3页
实验报告 支持向量机_第4页
实验报告 支持向量机_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

#实验报告支持向量机实验原理:支持向量机的原理和实现技术。。实验题目:对鸢尾花数据利用SVM技术进行分类预测。实验要求:把鸢尾花数据分成训练集和测试集,然后针对样本SVM预测分类实验题目--分析报告:data(iris)>rm(list=ls())>gc()used(Mb)gctrigger(Mb)maxused(Mb)Ncells25214313.560839432.541051522.0Vcells5284864.1838860864.0160673612.3>library(MASS)>library(MASS)>data(iris)>library(e1071)>summary(iris)Sepal.LengthSepal.WidthMin.:4.300Min.:2.0001stQu.:5.1001stQu.:2.800Median:5.800Median:3.000Mean:5.843Mean:3.0573rdQu.:6.4003rdQu.:3.300Max.:7.900Max.:4.400Petal.LengthPetal.WidthMin.:1.000Min.:0.1001stQu.:1.6001stQu.:0.300Median:4.350Median:1.300Mean:3.758Mean:1.1993rdQu.:5.1003rdQu.:1.800Max.:6.900Max.:2.500Speciessetosa:50versicolor:50virginica:50仅选择Petal.Length和Petal.Width这两个特征时>model<-svm(Petal.Length~Petal.Width,data=iris)>print(model)Call:svm(formula=Petal.Length~Petal.Width,data=iris)Parameters:SVM-Type:eps-regressionSVM-Kernel:radialcost:1gamma:1epsilon:0.1NumberofSupportVectors:80>summary(model)Call:svm(formula=Petal.Length~Petal.Width,data=iris)Parameters:SVM-Type:eps-regressionSVM-Kernel:radialcost:1gamma:1epsilon:0.1NumberofSupportVectors:80>svm(formula=Petal.Length~Petal.Width,data=iris)Call:svm(formula=Petal.Length~Petal.Width,data=iris)Parameters:SVM-Type:eps-regressionSVM-Kernel:radialcost:1gamma:1epsilon:0.1NumberofSupportVectors:80>predict(model,iris)12312341.4238371.4238371.4238371.42383791011121.4238371.4569131.4238371.423837171819201.6164691.4770961.4770961.477096252627281.4238371.4238371.6164691.423837333435361.4569131.4238371.4238371.423837414243441.4770961.4770961.4238372.115572495051521.4238371.4238374.4971394.675747575859604.8369863.4771784.2931204.497139656667684.2931204.4971394.6757473.47717856781.4238371.6164691.4770961.423837131415161.4569131.4569131.4238371.616469212223241.4238371.6164691.4238371.834129293031321.4238371.4238371.4238371.616469373839401.4238371.4569131.4238371.423837454647481.6164691.4770961.4238371.423837535455564.6757474.2931204.6757474.293120616263643.4771784.6757473.4771784.497139697071724.6757473.7845145.1343674.29312073747576777879804.6757474.0568294.2931204.4971394.4971394.9881834.6757473.47717881828384858687883.7845143.4771784.0568294.8369864.6757474.8369864.6757474.29312089909192939495964.2931204.2931204.0568294.4971394.0568293.4771784.2931204.0568299798991001011021031044.2931204.2931203.7845144.2931205.7523445.2771775.5403125.1343671051061071081091101111125.6463545.5403124.9881835.1343675.1343675.7523445.4144235.2771771131141151161171181191205.5403125.4144235.7604485.7228085.1343675.6463545.7228084.6757471211221231241251261271285.7228085.4144235.4144235.1343675.5403125.1343675.1343675.1343671291301311321331341351365.5403124.8369865.2771775.4144235.6463544.6757474.4971395.7228081371381391401411421431445.7604485.1343675.1343675.5403125.7604485.7228085.2771775.7228081451461471481491505.7523445.7228085.2771775.4144235.7228085.134367分割数据集>set.seed(2)>test=sample(1:nrow(iris),100)>iris.train<-iris[-test,]>iris.test<-iris[test,]>dim(iris.train);dim(iris.test)[1]505[1]1005

>model<-svm(Petal.Length~Petal.Width,data=iris.train)prediction<-predict(model,iris.test[,-1])tab<-table(predtab<-table(pred=prediction,trueris.test[,1])tabtrueed4.34.44.64.84.955.1525.4555.6575.85961.476426185233510122142221001001.514934525019011001200100000001.537794306199520001012000010001.696750649553480000011030000001.940503187907960000001000000002.247766796584170000010000000003.593325051594760000110001010013.857169576777270000001001100004.075688311422150000000001011004.254279229338620000000000220004.404109854107820000000100000004.539639007089480000000010100124.675688856047920000000000000014.824398220950480000100000000004.992496243428280000000000000005.17942227280050000000000002005.376786409977140000000000100005.569454200330490000000000000005.738170283834570000000000000005.863218184264910000000000000005.923719404515560000000000000005.92829837440344000000000000100truepred6.16.26.36.46.56.66.76.86.97.27.37.47.77.91.47642618523351000000000000001.51493452501901000000000000001.53779430619952000000000000001.69675064955348000000000000001.94050318790796000000000000002.24776679658417000000000000003.59332505159476000000000000003.85716957677727000000000000004.07568831142215100000000000004.25427922933862001101000000004.40410985410782300001000000004.53963900708948001100100000004.67568885604792001000000100004.82439822095048000000100000004.99249624342828110110100110005.1794222728005001000000001005.37678640997714000000000000015.56945420033049000000011000005.73817028383457000010000000105.86321818426491010100012000105.92371940451556001000100000005.9282983744034400100010000000>classAgreement(tab)$'diag'[1]0.02$kappa[1]-0.01554404$rand[1]0.910101$crand[1]0.05377635>tuned<-tune.svm(Petal.Length~Petal.Width,data=iris.train,gamma=10八(-6:-1),+cost=10八(1:2))>summary(tuned)Parametertuningof‘svm':samplingmethod:10-foldcrossvalidationbestparameters:gammacost0.110bestperformance:0.1490541-Detailedperformanceresults:gammacosterrordispersion11e-06103.47224882.206454121e-05103.42808442.180270331e-0410

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论