-
Notifications
You must be signed in to change notification settings - Fork 5
/
predictfreq.py
48 lines (43 loc) · 1.35 KB
/
predictfreq.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
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Predict frequencies from logistic regression
"""
import dill
import pyDOE
import numpy as np
import pandas as pd
with open("data/p4.dat", "rb") as dill_file:
stn = dill.load(dill_file)
mlhs = pyDOE.lhs(len(stn.products), samples=500, criterion="maximin")*400 + 100
df = pd.DataFrame(mlhs, columns=stn.products)
with open("data/p4freq.pkl", "rb") as f:
lr = dill.load(f)
# j = "Heater"
# tms = ["Heating-Slow", "Heating-Normal"]
# for tm in tms:
# lrtm = lr[j, tm]
# probas = lrtm.predict_proba(mlhs)
# classes = lrtm.classes_.astype(float)
# import ipdb; ipdb.set_trace() # noqa
# meanfreq = probas * classes
# meanfreq = meanfreq.sum(axis=1)
# pred = classes[np.argmax(probas, axis=1)]
# df[tm + "-mean"] = meanfreq
# df[tm + "-max"] = pred
# df.to_pickle("../results/toypreds.pkl")
# df.to_csv("../results/toypreds.csv")
j = "R1"
tms = ["T1-Slow", "T1-Normal", "T1-Fast", "T2-Slow",
"T2-Normal", "T2-Fast"]
for tm in tms:
lrtm = lr[j, tm]
probas = lrtm.predict_proba(mlhs)
classes = lrtm.classes_.astype(float)
meanfreq = probas * classes
meanfreq = meanfreq.sum(axis=1)
pred = classes[np.argmax(probas, axis=1)]
df[tm + "-mean"] = meanfreq
df[tm + "-max"] = pred
df.to_pickle("results/p4predsR1.pkl")
df.to_csv("results/p4predsR1.csv")