-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_attr.py
49 lines (36 loc) · 1.47 KB
/
test_attr.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 python
import neukrill_net.utils as utils
import neukrill_net.image_processing as image_processing
import neukrill_net.highlevelfeatures as highlevelfeatures
import csv
import pickle
from sklearn.externals import joblib
import numpy as np
import glob
import os
def main():
# this should be parsed from json, but hardcoded for now
#attributes_settings = ['width','height']
#pkl_file = 'imsizeLR.pkl'
#out_fname = 'submission_imsizeLR.csv'
#attributes_settings = ['width','height']
#pkl_file = 'imsizeSVM.pkl'
#out_fname = 'submission_imsizeSVM.csv'
#attributes_settings = ['numpixels','aspectratio']
#pkl_file = 'imsizeLR_alt.pkl'
#out_fname = 'submission_imsizeLR_alt.csv'
attributes_settings = ['width','height','mean','stderr','propwhite','propbool','propblack']
pkl_file = 'imattr1.pkl'
out_fname = 'submission_imattr1.csv'
# Get global settings, providing file names of test data
settings = utils.Settings('settings.json')
# Make the wrapper function
processing = highlevelfeatures.attributes_wrapper(attributes_settings)
# Load the test data, with the processing applied
X, names = utils.load_data(settings.image_fnames, processing=processing,
verbose=False)
clf = joblib.load(pkl_file)
p = clf.predict_proba(X)
utils.write_predictions(out_fname, p, names, settings.classes)
if __name__ == '__main__':
main()