-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.py
38 lines (37 loc) · 1.3 KB
/
demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# -*- coding: utf-8 -*-
'''
司马懿:“善败能忍,然厚积薄发”
——李叔说的
code is far away from bugs with the god animal protecting
I love animals. They taste delicious.
┏┓ ┏┓
┏┛┻━━━┛┻┓
--┃ ☃ ┃--
┃ ┳┛ ┗┳ ┃
┃ ┻ ┃
┗━┓ ┏━┛
┃ ┗II━II┓
┃ 神兽保佑 ┣┓
┃ 永无BUG! ┏┛
┗┓┓┏━┳┓┏┛
┃┫┫ ┃┫┫
┗┻┛ ┗┻┛
@Belong = 'LogisticRegression' @MadeBy = 'PyCharm'
@Author = 'steven' @DateTime = '2019/4/10 15:55'
'''
import numpy as np
from LogisticRegression import LogisticRegression
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
data = load_iris()
x = data['data']
y = (data['target'] > 0).astype(np.int8)
trainX, testX, trainY, testY = train_test_split(x, y, test_size=0.2)
trainX = trainX.T
testX = testX.T
trainY = trainY.reshape(1, -1)
testY = testY.reshape(1, -1)
featureNum = 4
lg = LogisticRegression(featureNum, {'lr': 0.00001})
lg.fit(trainX, trainY, 2000)
lg.eva(testX, testY)