Example #1
0
func train(records []creditRecord, iusers []internetUser, match [][]float64) (*lr.LogisticRegression, []string) {
	lr := new(lr.LogisticRegression)
	protos, id2f := constructFeatureVectors(iusers)
	borrower2iuser := make([]int, len(records))

	for iter := 0; iter < 100; iter++ {
		// M-step:
		sampleBorrower2IUser(match, borrower2iuser)
		dataset := constructTrainingData(records, borrower2iuser, protos)
		lr.Init(map[string]string{"learning-rate": "0.1", "regularization": "1.0", "steps": "20"})
		lr.Train(dataset)

		// E-step:
		updateMatch(lr, records, protos, match)
	}

	return lr, id2f
}