-
Notifications
You must be signed in to change notification settings - Fork 209
/
lr.py
55 lines (32 loc) · 962 Bytes
/
lr.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
39
# -*- coding:utf-8 -*-
'''
-------------------------------------------------
Description : LR
Author : machinelp
Date : 2020-06-13
-------------------------------------------------
'''
import sys
import logging
import numpy as np
from textmatch.config.config import cfg
from sklearn.linear_model import LogisticRegression
from textmatch.config.constant import Constant as const
class LR:
def __init__(self):
self.other_params = {}
for k, v in cfg.lr.items():
print ('LR params:',k,'>>>>',v)
self.other_params[k] = v
self.clf = LogisticRegression(**self.other_params)
pass
def fit(self, train_x, train_y):
self.clf.fit(train_x, train_y)
return self
def predict(self, X_test):
predict = self.clf.predict_proba(X_test)[:,1]
return predict
def save_model(self):
pass
def load_model(self):
pass