forked from princewen/tensorflow_practice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLR.py
More file actions
29 lines (15 loc) · 616 Bytes
/
Copy pathLR.py
File metadata and controls
29 lines (15 loc) · 616 Bytes
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
from sklearn.linear_model import LogisticRegression
import pandas as pd
import math
data = pd.read_table('/Users/meituan_sxw/Downloads/flower.txt',header=None)
data.columns = ['f1','f2','f3','f4','flower']
data['label'] = data['flower'].map(lambda x:0 if x=='setosa' else 1)
print(data)
x = data[['f1','f2','f3','f4']].values.tolist()
y = data[['label']]
lr = LogisticRegression(penalty="l2",fit_intercept=False)
lr.fit(x,y)
print(lr.predict_proba(x))
print(1 / (1 + math.pow(math.e,5.1*(-0.40247392)+3.5*(-1.46382925)+1.4*2.23785648+0.2 * 1.00009294+(-0.25906453))))
print(lr.coef_)
print(lr.__dict__)