In [1]:
#
# LogisticRegression Example
#
# @author becxer
# @email becxer87@gmail.com
#
import numpy as np
from pytrain.LogisticRegression import LogisticRegression
In [2]:
# Simple dataset
train_mat = [[0.12, 0.25],\
[3.24, 4.33],\
[0.14, 0.45],\
[7.30, 4.23],]
train_label = [[0,1],\
[1,0],\
[0,1],\
[1,0]]
test_a = [0.10,0.33]
test_b = [4.0,4.5]
In [3]:
# Train model
logit_reg = LogisticRegression(train_mat, train_label)
logit_reg.fit(lr = 0.001, epoch = 10000, batch_size =4)
In [5]:
# Test model
res_a = np.rint(logit_reg.predict(test_a))
res_b = np.rint(logit_reg.predict(test_b))
print("X %s => Y %s" % (test_a, res_a))
print("X %s => Y %s" % (test_b, res_b))