mlCommom
This commit is contained in:
@@ -19,7 +19,7 @@ func GetCategory(num int) string {
|
||||
}
|
||||
}
|
||||
|
||||
//Activation function - two class classifier.
|
||||
// Activation function - two class classifier.
|
||||
func BinaryClassifier(z float64) int {
|
||||
if z >= 0.5 {
|
||||
return 1
|
||||
@@ -28,12 +28,12 @@ func BinaryClassifier(z float64) int {
|
||||
}
|
||||
}
|
||||
|
||||
//Sigmoid function.
|
||||
// Sigmoid function.
|
||||
func Sigmoid(z float64) float64 {
|
||||
return 1.0 / (1 + math.Exp(-1*z))
|
||||
}
|
||||
|
||||
//Net input (z.)
|
||||
// Net input (z.)
|
||||
func NetInput(w []float64, intercept float64, x []float64) float64 {
|
||||
var z float64 = 0
|
||||
|
||||
@@ -44,7 +44,7 @@ func NetInput(w []float64, intercept float64, x []float64) float64 {
|
||||
return z + intercept
|
||||
}
|
||||
|
||||
// Standard Scaler.
|
||||
// Standard Scaler. done for normalization
|
||||
func StdScaler(x []float64, mu []float64, std []float64) []float64 {
|
||||
scaledX := []float64{}
|
||||
|
||||
@@ -58,10 +58,10 @@ func StdScaler(x []float64, mu []float64, std []float64) []float64 {
|
||||
// Offline values of means , standard deviation from standard scaling and weights.
|
||||
func ModelParameters() ([]float64, float64, []float64, []float64) {
|
||||
// Weights from logistic regression
|
||||
f, errWt := os.Open(constants.WeightsFile)
|
||||
f, errWt := os.Open(constants.WeightsFile) //weights.txt
|
||||
|
||||
if errWt != nil {
|
||||
logrus.Info(errWt)
|
||||
logrus.Info(errWt) //break
|
||||
}
|
||||
|
||||
defer f.Close()
|
||||
|
Reference in New Issue
Block a user