Documentation ¶
Overview ¶
** Copyright 2014 Edward Walker ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http ://www.apache.org/licenses/LICENSE2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. ** ** Description: Caches Q matrix rows. The cache implements a LRU (Last Recently Used) eviction policy. ** @author: Ed Walker
** Copyright 2014 Edward Walker ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http ://www.apache.org/licenses/LICENSE2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. ** ** Description: Implements the linear, radialbasis function, sigmoid, and polynomial kernels ** @author: Ed Walker
** Copyright 2014 Edward Walker ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http ://www.apache.org/licenses/LICENSE2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. ** ** Description: Model describes the properties of the Support Vector Machine after training. ** @author: Ed Walker
** Copyright 2014 Edward Walker ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http ://www.apache.org/licenses/LICENSE2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. ** ** Description: Input/output routines for the Support Vector Machine model ** @author: Ed Walker
** Copyright 2014 Edward Walker ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http ://www.apache.org/licenses/LICENSE2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. ** ** Description: Useful types/methods for running loops in parallel. ** @author: Ed Walker
** Copyright 2014 Edward Walker ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http ://www.apache.org/licenses/LICENSE2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. ** ** Description: Describes the parameters of the Supper Vector Machine solver ** @author: Ed Walker
** Copyright 2014 Edward Walker ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http ://www.apache.org/licenses/LICENSE2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. ** ** Description: Prediciton related APIs ** @author: Ed Walker
** Copyright 2014 Edward Walker ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http ://www.apache.org/licenses/LICENSE2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. ** ** Description: Probability estimation APIs ** @author: Ed Walker
** Copyright 2014 Edward Walker ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http ://www.apache.org/licenses/LICENSE2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. ** ** Description: Describes problem, i.e. label/vector set ** @author: Ed Walker
** Copyright 2014 Edward Walker ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http ://www.apache.org/licenses/LICENSE2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. ** ** Description: Q matrix for Support Vector Classification (svcQ), Support Vector Regression (svrQ), ** and OneClass Support Vector Machines (oneClassQ) ** @author: Ed Walker
** Copyright 2014 Edward Walker ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http ://www.apache.org/licenses/LICENSE2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. ** ** Description: Sequential Minimal Optimization (SMO) solver ** Ref: C.C. Chang, C.J. Lin. "LIBSVM: A library for support vector machines". ACM Transactions on Intelligent Systems and Technology 2 (2011) ** @author: Ed Walker
** Copyright 2014 Edward Walker ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http ://www.apache.org/licenses/LICENSE2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. ** ** Description: Functions for calling the solver for different problem scenerios, i.e. SVC, SVR, or OneClass ** @author: Ed Walker
** Copyright 2014 Edward Walker ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http ://www.apache.org/licenses/LICENSE2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. ** ** Description: Useful functions used in various parts of the library ** @author: Ed Walker
** Copyright 2014 Edward Walker ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http ://www.apache.org/licenses/LICENSE2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. ** ** Description: Workingset selection ** Ref: R.E. Fan, P.H. Chen, and C.J. Lin. "Working set selection using second order information for training SVM". Journal of Machine Learning Research 6 (2005) ** @author: Ed Walker
** Copyright 2014 Edward Walker ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http ://www.apache.org/licenses/LICENSE2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. ** ** Description: Cross validation API ** @author: Ed Walker
Index ¶
 Constants
 func CrossValidation(prob *Problem, param *Parameter, nrFold int) (target []float64)
 func MapToSnode(m map[int]float64) []snode
 func SnodeToMap(x []snode) map[int]float64
 type Model
 func (model *Model) Dump(file string) error
 func (model Model) NrClass() int
 func (model Model) Predict(x map[int]float64) float64
 func (model Model) PredictProbability(x map[int]float64) (returnValue float64, probabilityEstimate []float64)
 func (model Model) PredictValues(x map[int]float64) (returnValue float64, decisionValues []float64)
 func (model *Model) ReadModel(file string) error
 func (model *Model) ReadModelStream(f io.Reader) error
 func (model *Model) Train(prob *Problem) error
 type Parameter
 type Problem
 type SquareErrorComputer
Constants ¶
const ( LOWER_BOUND = iota UPPER_BOUND = iota FREE = iota )
const LibSvmGoVersion = 0.318
const TAU float64 = 1e12
Variables ¶
This section is empty.
Functions ¶
func CrossValidation ¶
*
 This function conducts cross validation. Data are separated to nrFold folds. Under given parameters, sequentially each fold is validated using the model from training the remaining. Predicted labels (of all prob's instances) in the validation process are stored in the slice called target.
func MapToSnode ¶
func SnodeToMap ¶
Types ¶
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
func NewModelFromFile ¶
func NewModelFromFileStream ¶
func (Model) Predict ¶
*
This function does classification or regression on a test vector x given a model.
For a classification model, the predicted class for x is returned. For a regression model, the function value of x calculated using the model is returned. For an oneclass model, +1 or 1 is returned.
func (Model) PredictProbability ¶
func (model Model) PredictProbability(x map[int]float64) (returnValue float64, probabilityEstimate []float64)
*
This function does classification or regression on a test vector x given a model with probability information.
For a classification model with probability information, this function gives nrClass probability estimates in the slice probabilityEstimate. The class with the highest probability is returned in returnValue. For regression/oneclass SVM, probabilityEsstimate is nil, and returnValue is the same as that of Predict.
func (Model) PredictValues ¶
*
This function gives decision values on a test vector x given a model, and return the predicted label (classification) or the function value (regression).
For a classification model with nrClass classes, this function gives nrClass*(nrClass1)/2 decision values in the slice decisionValues. The order is label[0] vs. label[1], ..., label[0] vs. label[nr_class1], label[1] vs. label[2], ..., label[nrClass2] vs. label[nrClass1]. The returned returnValue is the predicted class for x. Note that when nrClass = 1, this function does not give any decision value.
For a regression model, decisionValues[0] and the returned returnValue are both the function value of x calculated using the model. For a oneclass model, decisionValues[0] is the decision value of x, while the returned returnValue is +1/1.
type Parameter ¶
type Parameter struct { SvmType int // Support vector type KernelType int // Kernel type Degree int // Degree used in polynomial kernel Gamma float64 // Gamma used in rbf, polynomial, and sigmoid kernel Coef0 float64 // Coef0 used in polynomial and sigmoid kernel Eps float64 // stopping criteria C float64 // penality NrWeight int WeightLabel []int Weight []float64 Nu float64 P float64 Probability bool // Should probability estimation be performed? CacheSize int // Size of Q matrix cache QuietMode bool // quiet mode NumCPU int // Number of CPUs to use }
func NewParameter ¶
func NewParameter() *Parameter
type Problem ¶
type Problem struct {
// contains filtered or unexported fields
}
func (*Problem) Begin ¶
func (problem *Problem) Begin()
*
 Initialize the start of iterating through the labels and vectors in the problem set
func (*Problem) GetLine ¶
*
 Return one label and vector from the problem set
 @return y label
 @return x vector (map of dimension/value)
func (*Problem) Next ¶
func (problem *Problem) Next()
*
 Move to the next label and vector in the problem set
func (*Problem) ProblemSize ¶
*
 Returns number of label and vectors in the problem set
 @return problem set size
type SquareErrorComputer ¶
type SquareErrorComputer struct {
// contains filtered or unexported fields
}
func NewSquareErrorComputer ¶
func NewSquareErrorComputer() SquareErrorComputer
func (*SquareErrorComputer) MeanSquareError ¶
func (s *SquareErrorComputer) MeanSquareError() (err float64)
func (*SquareErrorComputer) SquareCorrelationCoeff ¶
func (s *SquareErrorComputer) SquareCorrelationCoeff() (coeff float64)
func (*SquareErrorComputer) Sum ¶
func (s *SquareErrorComputer) Sum(predict, target float64)
Source Files ¶
Directories ¶
Path  Synopsis 

cmds


svmpredict
** Copyright 2014 Edward Walker ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License.

** Copyright 2014 Edward Walker ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. 
svmtrain
** Copyright 2014 Edward Walker ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License.

** Copyright 2014 Edward Walker ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. 