本文整理汇总了Golang中github.com/xlvector/hector/algo.Regressor.Init方法的典型用法代码示例。如果您正苦于以下问题:Golang Regressor.Init方法的具体用法?Golang Regressor.Init怎么用?Golang Regressor.Init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/xlvector/hector/algo.Regressor
的用法示例。
在下文中一共展示了Regressor.Init方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RegAlgorithmRun
/* Regression */
func RegAlgorithmRun(regressor algo.Regressor, train_path string, test_path string, pred_path string, params map[string]string) (float64, []*eval.RealPrediction, error) {
global, _ := strconv.ParseInt(params["global"], 10, 64)
train_dataset := core.NewRealDataSet()
err := train_dataset.Load(train_path, global)
if err != nil {
return 0.5, nil, err
}
test_dataset := core.NewRealDataSet()
err = test_dataset.Load(test_path, global)
if err != nil {
return 0.5, nil, err
}
regressor.Init(params)
rmse, predictions := RegAlgorithmRunOnDataSet(regressor, train_dataset, test_dataset, pred_path, params)
return rmse, predictions, nil
}
示例2: RegAlgorithmTest
func RegAlgorithmTest(regressor algo.Regressor, test_path string, pred_path string, params map[string]string) (float64, []*eval.RealPrediction, error) {
global, _ := strconv.ParseInt(params["global"], 10, 64)
model_path, _ := params["model"]
regressor.Init(params)
if model_path != "" {
regressor.LoadModel(model_path)
} else {
return 0.0, nil, nil
}
test_dataset := core.NewRealDataSet()
err := test_dataset.Load(test_path, global)
if err != nil {
return 0.0, nil, err
}
rmse, predictions := RegAlgorithmRunOnDataSet(regressor, nil, test_dataset, pred_path, params)
return rmse, predictions, nil
}
示例3: RegAlgorithmTrain
func RegAlgorithmTrain(regressor algo.Regressor, train_path string, params map[string]string) error {
global, _ := strconv.ParseInt(params["global"], 10, 64)
train_dataset := core.NewRealDataSet()
err := train_dataset.Load(train_path, global)
if err != nil {
return err
}
regressor.Init(params)
regressor.Train(train_dataset)
model_path, _ := params["model"]
if model_path != "" {
regressor.SaveModel(model_path)
}
return nil
}