Esempio n. 1
0
func main() {
	train, test, pred, method, params := hector.PrepareParams()

	action, _ := params["action"]

	classifier := hector.GetMutliClassClassifier(method)

	profile, _ := params["profile"]
	if profile != "" {
		fmt.Printf("Profile data => %s\n", profile)
		f, err := os.Create(profile)
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}

	if action == "" {
		accuracy, _ := hector.MultiClassRun(classifier, train, test, pred, params)
		fmt.Println("accuracy : ", accuracy)
	} else if action == "train" {
		hector.MultiClassTrain(classifier, train, params)

	} else if action == "test" {
		accuracy, _ := hector.MultiClassTest(classifier, test, pred, params)
		fmt.Println("accuracy", accuracy)
	}
}
Esempio n. 2
0
func main() {
	train_path, _, _, method, params := hector.PrepareParams()
	global, _ := strconv.ParseInt(params["global"], 10, 64)
	profile, _ := params["profile"]
	dataset := core.NewDataSet()
	dataset.Load(train_path, global)

	cv, _ := strconv.ParseInt(params["cv"], 10, 32)
	total := int(cv)

	if profile != "" {
		f, err := os.Create(profile)
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}

	average_accuracy := 0.0
	for part := 0; part < total; part++ {
		train, test := SplitFile(dataset, total, part)
		classifier := hector.GetMutliClassClassifier(method)
		classifier.Init(params)
		accuracy := hector.MultiClassRunOnDataSet(classifier, train, test, "", params)
		fmt.Println("accuracy : ", accuracy)
		average_accuracy += accuracy
		classifier = nil
		train = nil
		test = nil
		runtime.GC()
	}
	fmt.Println(average_accuracy / float64(total))
}