forked from benhamner/CauseEffectPairsChallenge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
predict.py
33 lines (25 loc) · 952 Bytes
/
predict.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
import data_io
import numpy as np
import pickle
def historic():
print("Calculating correlations")
calculate_pearsonr = lambda row: abs(pearsonr(row["A"], row["B"])[0])
correlations = valid.apply(calculate_pearsonr, axis=1)
correlations = np.array(correlations)
print("Calculating causal relations")
calculate_causal = lambda row: causal_relation(row["A"], row["B"])
causal_relations = valid.apply(calculate_causal, axis=1)
causal_relations = np.array(causal_relations)
scores = correlations * causal_relations
def main():
print("Reading the valid pairs")
valid = data_io.read_valid_pairs()
print("Loading the classifier")
classifier = data_io.load_model()
print("Making predictions")
predictions = classifier.predict(valid)
predictions = predictions.flatten()
print("Writing predictions to file")
data_io.write_submission(predictions)
if __name__=="__main__":
main()