コード例 #1
0
ファイル: compare.py プロジェクト: hduongtrong/Otto
 def f(mi, s, md, r, c):
     clf = BoostedTreesClassifier(max_iterations = mi,
             step_size = s,
             max_depth = md,
             row_subsample = r,
             column_subsample = c,
             verbose = 0)
     clf.fit(X[valid_idx], y[valid_idx])
     #yhat = clf.predict_proba(X[train_idx])
     #return -log_loss(y[train_idx], yhat)
     return clf.score(X[train_idx], y[train_idx])
コード例 #2
0
ファイル: compare.py プロジェクト: hduongtrong/Otto
X, _ = GetDataset('original')
_, y, _ = LoadData()

from gl import BoostedTreesClassifier
clf = BoostedTreesClassifier(verbose = 0)
clf.fit(X[:10], y[:10])
np.random.seed(1)
if False:
    Cs = [.001, .01, .1, 1., 10.]
    gammas = [.001, .01, .1, 1., 10.]
    res = []; i = 0
    for (C, gamma) in itertools.product(Cs, gammas):
        print i, C, gamma; i += 1
        clf = SVC(C = C, gamma = gamma)
        clf.fit(X[train], y[train])
        res.append(clf.score(X[valid], y[valid]))

    res2 = []
    for i in xrange(len(res)*100):
        C     = 10**uniform(-3.5,5).rvs()
        gamma = 10**uniform(-3.5,5).rvs()
        print i, C, gamma
        clf = SVC(C = C, gamma = gamma)
        clf.fit(X[train], y[train])
        res2.append(clf.score(X[valid], y[valid]))

## 3. Grid
if False:
    grid_max_iterations   = [10, 20, 30]
    grid_step_size        = [.5, .7, .9]
    grid_max_depth        = [ 5,  7,  9]