⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 svm2weight.pl.txt.htm

📁 svm(支持向量机)分类算法本质上是二类分类器
💻 HTM
字号:
<html>#!perl
# Compute the weight vector of linear SVM based on the model file
# Author: Thorsten Joachims (thorsten@joachims.org)
# Call: perl svm2weight.pl model

open(M,$ARGV[0]) || die();

$l=<M>;
if(($l=<M>) != 0) { die("Not linear Kernel!\n"); }
$l=<M>;
$l=<M>;
$l=<M>;
$l=<M>;
$l=<M>;
$l=<M>; 
$l=<M>;
$l=<M>;
$l=<M>;

if($l !~ /threshold b/) { die("Parsing error!\n"); }

while($l=<M>) {
    ($features,$comments)=split(/#/,$l);
    ($alpha,@f)=split(/ /,$features);
    for $p (@f) {
	($a,$v)=split(/:/,$p);
	$w[$a]+=$alpha*$v;
    }
}

for($i=1;$i<=$#w;$i++) {
    print "$i:$w[$i]\n";
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -