src

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2020 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccumPlatt

func AccumPlatt(c int, colSum *mat64.Vector, plattAB *mat64.Dense, plattASet *mat64.Dense, plattBSet *mat64.Dense, plattCountSet *mat64.Dense)

func AccumThres

func AccumThres(c int, colSum *mat64.Vector, thresSet *mat64.Dense, thres *mat64.Dense)

func AccumTsYdata

func AccumTsYdata(iFold int, c int, colSum *mat64.Vector, tsYh *mat64.Dense, tsY *mat64.Dense, tsX *mat64.Dense, indAccum []int, YhPlattSet map[int]*mat64.Dense, YhPlattSetCalibrated map[int]*mat64.Dense, yPlattSet map[int]*mat64.Dense, iFoldMarker map[int]*mat64.Dense, yPredSet map[int]*mat64.Dense, xSet map[int]*mat64.Dense, rawThres *mat64.Dense)

func AveThres

func AveThres(cBest int, thresSet *mat64.Dense, plattCountSet *mat64.Dense) (aveThres *mat64.Dense)

func BestHyperParameterSetByMeasure

func BestHyperParameterSetByMeasure(trainMeasure *mat64.Dense, index int) (cBest int, value float64)

func BinPredByAlpha

func BinPredByAlpha(Yh *mat64.Dense, rankCut int, outBin bool) (binYh *mat64.Dense, detectNanInf bool)

func ColMaxMin

func ColMaxMin(data *mat64.Dense)

func ColScale

func ColScale(data *mat64.Dense, rebaData *mat64.Dense) (scaleData *mat64.Dense)

func ColStackMatrix

func ColStackMatrix(X *mat64.Dense, addX *mat64.Dense) (X2 *mat64.Dense)

func ComputeAccuracy

func ComputeAccuracy(tsYdata *mat64.Dense, Yhat *mat64.Dense, isWeighted bool) (accuracy float64)

func ComputeAupr

func ComputeAupr(Y *mat64.Vector, Yh *mat64.Vector, beta float64) (aupr float64, pAupr float64, maxFscore float64, optThres float64)

func ComputeF1_3

func ComputeF1_3(Y *mat64.Vector, Yh *mat64.Vector, thres float64) (F1 float64, tp int, fp int, fn int, tn int)

func DefaultThres

func DefaultThres(tsYdata *mat64.Dense, tsYhat *mat64.Dense) (thres *mat64.Dense)

func DistanceTopK

func DistanceTopK(k int, rowIdx int, tsYhat *mat64.Dense, yProbTrain *mat64.Dense) (idxArr []int)

func EcocRun

func EcocRun(tsXdata *mat64.Dense, tsYdata *mat64.Dense, trXdata *mat64.Dense, trYdata *mat64.Dense, rankCut int, reg bool, kSet []int, lamdaSet []float64, nFold int, nK int, wg *sync.WaitGroup, mutex *sync.Mutex) (YhSet map[int]*mat64.Dense, colSum *mat64.Vector)

func EleCopy

func EleCopy(data *mat64.Dense) (data2 *mat64.Dense)

func FeatureDataStack

func FeatureDataStack(sPriorData *mat64.Dense, tsRowName []string, trRowName []string, idIdx map[string]int, tsXdata *mat64.Dense, trXdata *mat64.Dense, trYdata *mat64.Dense, ind []int) (tsXdata1 *mat64.Dense, trXdata1 *mat64.Dense)

func Flat

func Flat(Y *mat64.Dense) (vec *mat64.Vector)

func FscoreThres

func FscoreThres(tsYdata *mat64.Dense, tsYhat *mat64.Dense, beta float64, isParAuprThres bool) (thres *mat64.Dense)

func HyperParameterSet

func HyperParameterSet(maxDim int, lbL float64, hbL float64, nStep int) (kSet []int, sigmaFctsSet []float64, lamdaSet []float64)

func IOC_MFADecoding

func IOC_MFADecoding(nRowTsY int, rowIdx int, tsY_Prob *mat64.Dense, tsY_C *mat64.Dense, sigma *mat64.Dense, Bsub *mat64.Dense, k int, sigmaFcts float64, nLabel int) (tsYhatData []float64)

func Init

func Init(resFolder string) (logFIle *os.File)

func LabelRelationship

func LabelRelationship(trYdata *mat64.Dense) (posLabelRls *mat64.Dense, negLabelRls *mat64.Dense)

func MSE

func MSE(trY *mat64.Vector, trYh *mat64.Vector) (mse float64)

func MaskZeroByThres

func MaskZeroByThres(tsYhat *mat64.Dense, thresData *mat64.Dense) (tsYhat2 *mat64.Dense)

func MulEleByFloat64

func MulEleByFloat64(value float64, M *mat64.Dense) (M2 *mat64.Dense)

func MultiLabelRecalibrate

func MultiLabelRecalibrate(kNN int, tsYhat *mat64.Dense, xTest *mat64.Dense, yPlattTrain *mat64.Dense, yPredTrain *mat64.Dense, xTrain *mat64.Dense, posLabelRls *mat64.Dense, negLabelRls *mat64.Dense, wg *sync.WaitGroup, mutex *sync.Mutex) (tsYhatCal *mat64.Dense)

func NetworkEnhance

func NetworkEnhance(network *mat64.Dense) (networkEnhanced *mat64.Dense)

func ParaCov

func ParaCov(data *mat64.Dense, goro int) (covmat *mat64.Dense, err error)

Multiple threads PCC

func Platt

func Platt(trYhat *mat64.Dense, trY *mat64.Dense, tsYhat *mat64.Dense, lamdaArr []float64) (tsYhh *mat64.Dense, plattAB *mat64.Dense, mseArr []float64)

func PlattChopScale

func PlattChopScale(tsY *mat64.Dense, tsYhh *mat64.Dense) (maxArr []float64)

chop scale to 0 - 1 range

func PlattParameterEst

func PlattParameterEst(Yh *mat64.Vector, Y *mat64.Vector) (A float64, B float64)

func PlattScale

func PlattScale(Yh *mat64.Vector, A float64, B float64) (Yhh []float64)

func PlattScaleSet

func PlattScaleSet(Yh *mat64.Dense, plattAB *mat64.Dense) (Yhh *mat64.Dense)

func PlattScaleSetPseudoLabel

func PlattScaleSetPseudoLabel(tsYhat *mat64.Dense, trYdata *mat64.Dense, thres *mat64.Dense) (tsYhat2 *mat64.Dense, thres2 *mat64.Dense)

func Pop

func Pop(pToSlice *[]float64) float64

func PosSelect

func PosSelect(tsYdata *mat64.Dense, colSum *mat64.Vector) (tsYdataFilter *mat64.Dense)

func PrintMemUsage

func PrintMemUsage()

func PropagateSet

func PropagateSet(network *mat64.Dense, trYdata *mat64.Dense, idIdx map[string]int, idArr []string, trGeneMap map[string]int, isDada bool, alpha float64, wg *sync.WaitGroup, mutex *sync.Mutex) (sPriorData *mat64.Dense, ind []int)

func PropagateSetWithPrior

func PropagateSetWithPrior(priorData *mat64.Dense, priorGeneID map[string]int, priorIdxToId map[int]string, network *mat64.Dense, trYdata *mat64.Dense, idIdx map[string]int, idxToId map[int]string, idArr []string, trGeneMap map[string]int, isDada bool, alpha float64, wg *sync.WaitGroup, mutex *sync.Mutex) (sPriorData *mat64.Dense, ind []int)

func QuantileNorm

func QuantileNorm(data *mat64.Dense, thresData *mat64.Dense, isTransThres bool) (normData *mat64.Dense, normThresData *mat64.Dense)

func RandListFromUniDist

func RandListFromUniDist(length int, length2 int) (values []float64)

func RankPred

func RankPred(Yh *mat64.Dense, thres *mat64.Dense) (rankYh *mat64.Dense, rankThres *mat64.Dense)

func ReadFile

func ReadFile(inFile string, rowName bool, colName bool) (dataR *mat64.Dense, rName []string, cName []string, err error)

func ReadIDfile

func ReadIDfile(inFile string) (rName []string)

func ReadNetwork

func ReadNetwork(inNetworkFile string) (network *mat64.Dense, idIdx map[string]int, idxToId map[int]string)

func ReadNetworkPropagate

func ReadNetworkPropagate(trRowName []string, tsRowName []string, trYdata *mat64.Dense, inNetworkFile []string, priorMatrixFile []string, isAddPrior bool, isDada bool, alpha float64, wg *sync.WaitGroup, mutex *sync.Mutex) (tsXdata *mat64.Dense, trXdata *mat64.Dense, indAccum []int)

func ReadNetworkPropagateCV

func ReadNetworkPropagateCV(f int, folds map[int][]int, trRowName []string, tsRowName []string, trYdata *mat64.Dense, inNetworkFile []string, priorMatrixFile []string, isAddPrior bool, isDada bool, alpha float64, wg *sync.WaitGroup, mutex *sync.Mutex) (cvTrain []int, cvTest []int, trXdataCV *mat64.Dense, indAccum []int)

func RebalanceData

func RebalanceData(trYdata *mat64.Dense) (rebaData *mat64.Dense)

func RefillIndCol

func RefillIndCol(tsX *mat64.Dense, ind []int) (tsX2 *mat64.Dense)

func Report

func Report(tsYdata *mat64.Dense, tsYhat *mat64.Dense, thresData *mat64.Dense, rankCut int, isVerbose bool) (microF1 float64, accuracy float64, macroAupr float64, microAupr float64, kPrec float64, firstAupr float64)

func Report(tsYdata *mat64.Dense, tsYhat *mat64.Dense, rebaData *mat64.Dense, rankCut int, isVerbose bool) (microF1 float64, accuracy float64, macroAupr float64, microAupr float64) {

func RescaleData

func RescaleData(data *mat64.Dense, thresData *mat64.Dense) (scaleData *mat64.Dense)

func SOIS

func SOIS(trY *mat64.Dense, nFold int, ratio int, isOutInfo bool) (folds map[int][]int)

func SelectPlattAB

func SelectPlattAB(cBest int, plattASet *mat64.Dense, plattBSet *mat64.Dense, plattCountSet *mat64.Dense) (plattAB *mat64.Dense)

func Shift

func Shift(pToSlice *[]string) string

func Sigmoid

func Sigmoid(x float64) (y float64)

func SigmoidMatrix

func SigmoidMatrix(data *mat64.Dense) (scaleData *mat64.Dense)

func Single_compute

func Single_compute(tsYdata *mat64.Dense, tsYhat *mat64.Dense, rankCut int) (microF1 float64, accuracy float64, macroAupr float64, microAupr float64)

func SoftThresScale

func SoftThresScale(tsYhat *mat64.Dense, thresData *mat64.Dense) (tsYhat2 *mat64.Dense, thresData2 *mat64.Dense)

func SubSetTrain

func SubSetTrain(iFold int, Y *mat64.Dense, Yh *mat64.Dense, predBinY *mat64.Dense, X *mat64.Dense, iFoldmat *mat64.Dense) (yPlattTrain *mat64.Dense, yPredTrain *mat64.Dense, xTrain *mat64.Dense, xTest *mat64.Dense, tsYhat *mat64.Dense, tsYfold *mat64.Dense)

func TestDataPlattChopScale

func TestDataPlattChopScale(tsYhh *mat64.Dense, maxArr []float64)

chop scale to 0 - 1 range

func TmmFilterForPlatt

func TmmFilterForPlatt(inTrYhat *mat64.Vector, inTrY *mat64.Vector, lamda float64) (trYhat *mat64.Vector, trY *mat64.Vector)

func TopKprec

func TopKprec(tsYdata *mat64.Dense, Yhat *mat64.Dense, k int) (kPrec float64)

func TrainRLS_Regress_CG

func TrainRLS_Regress_CG(trFoldX *mat64.Dense, trFoldY *mat64.Dense, lamda float64, randValues []float64) (weights *mat64.Dense)

func TuneAndPredict

func TuneAndPredict(nFold int, fBetaThres float64, nK int, nKnn int, isFirst bool, isKnn bool, kSet []int, lamdaSet []float64, reg bool, rankCut int, trainFold []CvFold, testFold []CvFold, indAccum []int, tsXdata *mat64.Dense, tsYdata *mat64.Dense, trXdata *mat64.Dense, trYdata *mat64.Dense, trainMeasure *mat64.Dense, testMeasure *mat64.Dense, posLabelRls *mat64.Dense, negLabelRls *mat64.Dense, wg *sync.WaitGroup, mutex *sync.Mutex) (trainMeasureUpdated *mat64.Dense, testMeasureUpdated *mat64.Dense, tsYhat *mat64.Dense, thres *mat64.Dense, Yhat *mat64.Dense, YhatCalibrated *mat64.Dense, Ylabel *mat64.Dense)

func WriteFile

func WriteFile(outFile string, data *mat64.Dense, name []string, isRowID bool) (err error)

func WriteNetwork

func WriteNetwork(outFile string, data *mat64.Dense, idxToId map[int]string) (err error)

func WriteOutputFiles

func WriteOutputFiles(isVerbose bool, resFolder string, trainMeasure *mat64.Dense, testMeasure *mat64.Dense, posLabelRls *mat64.Dense, negLabelRls *mat64.Dense, tsYhat *mat64.Dense, thres *mat64.Dense, Yhat *mat64.Dense, YhatCalibrated *mat64.Dense, Ylabel *mat64.Dense)

func YhPlattSetUpdate

func YhPlattSetUpdate(iFold int, c int, YhPlattSetCalibrated map[int]*mat64.Dense, tsYhat *mat64.Dense, iFoldmat *mat64.Dense)

func Zscore

func Zscore(data *mat64.Dense) (scaleData *mat64.Dense)

Types

type ByValue

type ByValue []kv

func (ByValue) Len

func (a ByValue) Len() int

func (ByValue) Less

func (a ByValue) Less(i, j int) bool

func (ByValue) Swap

func (a ByValue) Swap(i, j int)

type CvFold

type CvFold struct {
	X        *mat64.Dense
	Y        *mat64.Dense
	IndAccum []int
}

for cross validation

func (*CvFold) SetXYinNestedTraining

func (f *CvFold) SetXYinNestedTraining(idxArr []int, matX *mat64.Dense, matY *mat64.Dense, indAccum []int)

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model contains a pointer to C's struct model (i.e., `*C.struct_model`). It is returned after training and used for predicting.

func Train

func Train(X, y *mat64.Dense, bias float64, solverType int, c_, p, eps float64, classWeights map[int]float64) *Model

Wrapper for the `train` function in liblinear.

`model* train(const struct problem *prob, const struct parameter *param);`

The explanation of parameters are:

solverType:

for multi-class classification
       0 -- L2-regularized logistic regression (primal)
       1 -- L2-regularized L2-loss support vector classification (dual)
       2 -- L2-regularized L2-loss support vector classification (primal)
       3 -- L2-regularized L1-loss support vector classification (dual)
       4 -- support vector classification by Crammer and Singer
       5 -- L1-regularized L2-loss support vector classification
       6 -- L1-regularized logistic regression
       7 -- L2-regularized logistic regression (dual)
for regression
      11 -- L2-regularized L2-loss support vector regression (primal)
      12 -- L2-regularized L2-loss support vector regression (dual)
      13 -- L2-regularized L1-loss support vector regression (dual)

eps is the stopping criterion.

C_ is the cost of constraints violation.

p is the sensitiveness of loss of support vector regression.

classWeights is a map from int to float64, with the key be the class and the value be the weight. For example, {1: 10, -1: 0.5} means giving weight=10 for class=1 while weight=0.5 for class=-1

If you do not want to change penalty for any of the classes, just set classWeights to nil.

func (*Model) Label

func (f *Model) Label() int

func (*Model) W

func (f *Model) W() []float64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL