-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmapper.py
35 lines (29 loc) · 1.01 KB
/
mapper.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
#!/usr/lib/python2.6 python
import sys
from base64 import b64encode as encode
from pickle import dumps
from utilities import MRLogisticRegression, MRData
from numpy import Inf
# Pre-specified limits of the variables
limits = [(0, 1), # Revolving utilization
(20, 100), # Age
(0, 30), # Number of times 30-59 days past due
(0, 1), # Debt ratio
(0, Inf), # Monthly income
(0, 30), # Number open credit lines
(0, 10), # Number of times 90 days or more past due
(0, 10), # Number of real estate loans
(0, 30), # Number of times 60-89 days past due
(0, 50)] # Number of dependents
# Creating model
model = MRLogisticRegression()
# Extracting data
data = MRData()
X, y = data.read(sys.stdin)
X = data.process(X, limits=limits, normalize=True)
# Computing gradient and Hessian
g, H = model.mapper(X, y)
# Printing mapper results
key = encode(dumps(X[0, :]))
value = encode(dumps((g, H)))
print >> sys.stdout, "%s\t%s" % (key, value)