-
Notifications
You must be signed in to change notification settings - Fork 0
/
xval_demo.py
executable file
·51 lines (41 loc) · 1.23 KB
/
xval_demo.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
49
50
'''
a playground for evaluating classifiers
'''
import kddutil
import cPickle as pickle
import sys
import sklearn
from sklearn import svm, tree, lda, qda, metrics, cross_validation, grid_search, datasets, ensemble, linear_model, naive_bayes
if len(sys.argv) <= 1:
print "so what pkl do you want me to read, hm?"
sys.exit()
randomForest = ensemble.RandomForestClassifier(verbose=False
, n_estimators=80
, min_samples_split=10
, max_depth=14
, bootstrap=False
, n_jobs=16
)
randomForestRegress = ensemble.RandomForestClassifier(verbose=True
, n_estimators=80
, min_samples_split=10
, max_depth=14
, n_jobs=15
)
gradBoost = ensemble.GradientBoostingClassifier(verbose=True
, n_estimators=100
, min_samples_split=10
, max_depth=7
)
with open(sys.argv[1]) as infile:
train, _ = pickle.load(infile)
if type(train[1][0]) == list:
ids, info, labels = kddutil.notrash(*train)
info = kddutil.bound(info, max=10000, min=-10000)
else:
ids, info, labels = train
print "assuming compacted data; skip preprocessing"
print "Random Forest"
print kddutil.evaluate_k(randomForest, ids, info, labels, fold=3)#, postprocess=kddutil.disambiguate)
#print "Gradient Boosting"
#print kddutil.evaluate(gradBoost, ids, info, labels)