forked from 4everer/GZY_JData
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
32 lines (26 loc) · 998 Bytes
/
test.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
#!/usr/bin/env python
from __future__ import division
import pandas as pd
import numpy as np
import base
import random
import forest
if __name__ == '__main__':
import sys
if len(sys.argv) < 2:
print "Need to specify data file number"
sys.exit()
file_num = sys.argv[1]
ft = forest.ForestTrainer()
train_data = np.load('sku_train/train_data{}.npy'.format(file_num))
test_data = np.load('sku_train/test_data{}.npy'.format(file_num))
train_label = np.load('sku_train/train_label{}.npy'.format(file_num))
test_label = np.load('sku_train/test_label{}.npy'.format(file_num))
print "Partitions: ", (train_data.shape[1] - 2) / 4
ft.train(train_data, train_label)
print ft.clf_randomCV.best_params_
test_predict = ft.predict(test_data)
train_predict = ft.predict(train_data)
print forest.score_func(train_label, train_predict)
print forest.score_func(test_label, test_predict)
ft.save('sku_model' + str(file_num))