成都创新互联网站制作重庆分公司

svm代码java svm代码实现

java中svm_scale怎么用?

public class TestScale {

十年的双柏网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。全网营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整双柏建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联从事“双柏网站设计”,“双柏网站推广”以来,每个客户项目都认真落实执行。

public static void main(String[] args) throws IOException {

String reafile = " "; // 文件路径

svm_scale svms = new svm_scale();

String[] srg = { reafile };//在这可以添加相关的系数"-l","0","-u","1","-s".以及要保存的scale参数文件

svms.main(srg);

}

}

手撕SVM(公式推导+代码实现)(三)

前面我们进行了很多的理论性研究,下面我们开始用代码进行实现。

这个数据集显然线性可分。

[-1.0,

-1.0,

1.0,

-1.0,

1.0,

1.0,

1.0,

-1.0,

-1.0,

-1.0,

-1.0,

-1.0,

-1.0,

1.0,

-1.0,

1.0,

1.0,

-1.0,

1.0,

-1.0,

-1.0,

-1.0,

1.0,

-1.0,

-1.0,

1.0,

1.0,

-1.0,

-1.0,

-1.0,

-1.0,

1.0,

1.0,

1.0,

1.0,

-1.0,

1.0,

-1.0,

-1.0,

1.0,

-1.0,

-1.0,

-1.0,

-1.0,

1.0,

1.0,

1.0,

1.0,

1.0,

-1.0,

1.0,

1.0,

-1.0,

-1.0,

1.0,

1.0,

-1.0,

1.0,

-1.0,

-1.0,

-1.0,

-1.0,

1.0,

-1.0,

1.0,

-1.0,

-1.0,

1.0,

1.0,

1.0,

-1.0,

1.0,

1.0,

-1.0,

-1.0,

1.0,

-1.0,

1.0,

1.0,

1.0,

1.0,

1.0,

1.0,

1.0,

-1.0,

-1.0,

-1.0,

-1.0,

1.0,

-1.0,

1.0,

1.0,

1.0,

-1.0,

-1.0,

-1.0,

-1.0,

-1.0,

-1.0,

-1.0]

可以看出来,这里使用的类别标签是-1和1

SMO算法的伪代码:

L==H

第0次迭代 样本:1, alpha优化次数:1

第0次迭代 样本:3, alpha优化次数:2

第0次迭代 样本:5, alpha优化次数:3

L==H

第0次迭代 样本:8, alpha优化次数:4

L==H

j not moving enough

j not moving enough

L==H

L==H

j not moving enough

L==H

第0次迭代 样本:30, alpha优化次数:5

第0次迭代 样本:31, alpha优化次数:6

L==H

L==H

第0次迭代 样本:54, alpha优化次数:7

L==H

L==H

第0次迭代 样本:71, alpha优化次数:8

L==H

L==H

L==H

第0次迭代 样本:79, alpha优化次数:9

L==H

第0次迭代 样本:92, alpha优化次数:10

j not moving enough

L==H

迭代次数:0

第0次迭代 样本:1, alpha优化次数:1

j not moving enough

j not moving enough

j not moving enough

j not moving enough

j not moving enough

L==H

L==H

j not moving enough

j not moving enough

j not moving enough

j not moving enough

L==H

j not moving enough

L==H

L==H

j not moving enough

j not moving enough

第0次迭代 样本:37, alpha优化次数:2

第0次迭代 样本:39, alpha优化次数:3

第0次迭代 样本:52, alpha优化次数:4

j not moving enough

j not moving enough

j not moving enough

j not moving enough

j not moving enough

第0次迭代 样本:71, alpha优化次数:5

j not moving enough

j not moving enough

j not moving enough

j not moving enough

j not moving enough

迭代次数:0

j not moving enough

j not moving enough

j not moving enough

第0次迭代 样本:8, alpha优化次数:1

L==H

j not moving enough

第0次迭代 样本:23, alpha优化次数:2

L==H

j not moving enough

j not moving enough

L==H

j not moving enough

j not moving enough

j not moving enough

第0次迭代 样本:39, alpha优化次数:3

L==H

j not moving enough

第0次迭代 样本:52, alpha优化次数:4

j not moving enough

第0次迭代 样本:55, alpha优化次数:5

L==H

L==H

L==H

L==H

L==H

j not moving enough

第0次迭代 样本:79, alpha优化次数:6

第0次迭代 样本:92, alpha优化次数:7

迭代次数:0

j not moving enough

L==H

j not moving enough

j not moving enough

L==H

j not moving enough

第0次迭代 样本:23, alpha优化次数:1

j not moving enough

j not moving enough

j not moving enough

j not moving enough

j not moving enough

j not moving enough

j not moving enough

L==H

L==H

第0次迭代 样本:51, alpha优化次数:2

j not moving enough

j not moving enough

j not moving enough

j not moving enough

L==H

第0次迭代 样本:69, alpha优化次数:3

L==H

j not moving enough

第0次迭代 样本:94, alpha优化次数:4

j not moving enough

j not moving enough

迭代次数:0

j not moving enough

j not moving enough

j not moving enough

j not moving enough

j not moving enough

...

迭代次数:497

j not moving enough

j not moving enough

j not moving enough

迭代次数:498

j not moving enough

j not moving enough

j not moving enough

迭代次数:499

j not moving enough

j not moving enough

j not moving enough

迭代次数:500

如何调用libsvm 的java 库函数

第一步:下载java版libsvm3.12,解压。

第二步:打开java文件夹

第三步:建立项目,引用lib.svm包

第五步:把第二步中的文件夹中四个文件复制到一个自定义的包中

第六步:写程序调用,代码如下,贴出来供大家学习,有不对的地方,欢迎拍砖。

import java.io.IOException;

import libsvm.svm;

import libsvm.svm_model;

public class SVMTest {

public static void main(String[] args) throws IOException {

svm_train svmt = new svm_train();

svm_predict svmp = new svm_predict();

String[] argvTrain = {

"C:\\Users\\baolong\\Desktop\\KDD\\other\\svm\\train\\TR1.data",// 训练文件

"C:\\Users\\baolong\\Desktop\\KDD\\other\\svm\\model\\MO1.model"// 模型文件

};

String[] argvPredict = {

"C:\\Users\\baolong\\Desktop\\KDD\\other\\svm\\predict\\PR1.data",// 预测文件

"C:\\Users\\baolong\\Desktop\\KDD\\other\\svm\\model\\MO1.model", // 模型文件

"C:\\Users\\baolong\\Desktop\\KDD\\other\\svm\\result\\RE1.out" // 预测结果文件

};

try {

svmt.main(argvTrain);

svmp.main(argvPredict);

} catch (IOException e) {

e.printStackTrace();

}

double[] record = { -1, 12, 12, 78 };

libsvm.svm_model model = svm

.svm_load_model("C:\\Users\\baolong\\Desktop\\KDD\\other\\svm\\model\\MO1.model");

System.out.println(svmp.predictPerRecord(record, model));

}

}


文章标题:svm代码java svm代码实现
分享路径:http://cxhlcq.com/article/hejhhs.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部