-
Notifications
You must be signed in to change notification settings - Fork 0
/
sklearn_logit.py
27 lines (24 loc) · 754 Bytes
/
sklearn_logit.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
# !/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@File : sklearn_logit.py
@Time : 2021/10/12
@Author : Yuanting Ma
@Version : 1.0
@Site : https://github.com/YuantingMaSC
@Contact : [email protected]
"""
from sklearn.linear_model import LogisticRegression
import pandas as pd
import numpy as np
max_min_scaler = lambda x : (x-np.mean(x))/np.std(x)
data = pd. read_csv("fakedata_generated.csv")
data['x1']=data[['x1']].apply(max_min_scaler)
data['x2']=data[['x2']].apply(max_min_scaler)
data['x0'] = np.random.randint(0,1,len(data['x1']))+1
data = data.loc[data.index<10000]
X =data[['x1','x2','x3','x4']]
Y = data['y']
model = LogisticRegression(solver='liblinear',max_iter=10000)
re = model.fit(X,Y)
print(re.coef_)