*
L2-正规化分类
*
L2-SVM线性损耗,L1-SVM线性损耗和logistic回归(LR)
*
L1-正规化分类(版本1.4)
*
L2-SVM线性损耗和logistic回归(LR)
*
L2-支持正规化向量回归(版本1.9)
*
L2-SVR线性损耗和L1-SVR线性损耗。
安装:
这个软件包依赖LIBLINEAR2.1+和Go 1.6+。请通过自制软件或操作系统上的其他软件包管理器先安装这些:
<pre class="brush:cpp ;toolbar: true; auto-links: false;">brew update
brew info liblinear # make sure your formula will install version higher than 2.1
brew install liblinear
brew info go # make sure version 1.6+
brew install go</pre>
用法:
<pre class="brush:cpp ;toolbar: true; auto-links: false;">import linear "github.com/lazywei/lineargo"
// ReadLibsvm(filepath string, oneBased bool) (X, y *mat64.Dense)
X, y := linear.ReadLibsvm("heart_scale", true)
// Train(X, y *mat64.Dense, bias float64, solverType int,
// C_, p, eps float64,// classWeights map[int]float64) (*Model)
// Please checkout liblinear's doc for the explanation for these parameters.
model := linear.Train(X, y, -1, linear.L2R_LR, 1.0, 0.1, 0.01, map[int]float64{1: 1, -1: 1})
y_pred:= linear.Predict(model, X)
fmt.Println(linear.Accuracy(y, y_pred))</pre>