コード例 #1
0
ファイル: predict.py プロジェクト: EdwardBetts/kaggle_otto
totalvalid = totaltest = 0

for name in names:

	net = NNet.load(filepath = join(BASE_DIR, 'results', 'nets', name))

	for nm, val in net.get_params().iteritems():
		print '{0:s} = {1:}'.format(nm, val)

	#for nm, data in [('val', valid), ('tst', test)]:
		#probs = net.predict_proba(data)
		#save(join(SUBMISSIONS_DIR, '{0}_{1}_raw.npy'.format(name, nm)), probs)
		#makeSubmission(probs, fname = join(SUBMISSIONS_DIR, '{0}_{1}_rescale.csv'.format(name, nm)), digits = 8)
	probs = net.predict_proba(valid)
	probs = scale_to_priors(probs, priors = PRIORS)
	save(join(SUBMISSIONS_DIR, '{0}_valid.npy'.format(name)), probs)
	totalvalid += probs

	probs = net.predict_proba(test)
	probs = scale_to_priors(probs, priors = PRIORS)
	save(join(SUBMISSIONS_DIR, '{0}_test.npy'.format(name)), probs)
	makeSubmission(probs, fname = join(SUBMISSIONS_DIR, '{0}_test.csv'.format(name)), digits = 8)
	totaltest += probs


save(join(SUBMISSIONS_DIR, 'total_valid.npy'), totalvalid)
save(join(SUBMISSIONS_DIR, 'total_valid.npy'), totaltest)
makeSubmission(totaltest, fname = join(SUBMISSIONS_DIR, 'total_test.csv'), digits = 8)
print 'saved predictions'

コード例 #2
0
		'nn__weight_decay': [1.0e-05, 0],
	},
	fit_params = {
	},
	n_iter = 10,
	n_jobs = 10,
	scoring = log_loss_scorer,
	iid = False,
	refit = True,
	#pre_dispatch = cpus + 2,
	cv = ShuffleSplit(
		n = train.shape[0],
		n_iter = 1,
		test_size = 0.2,
		#random_state = random,
	),
	#random_state = random,
	verbose = bool(VERBOSITY),
	error_score = -1000000,
)

opt.fit(train, labels)

with open(join(LOGS_DIR, 'debug_{0:.4f}.json'.format(-opt.best_score_)), 'w+') as fh:
	print 'saving results (no scaling to priors) for top score {0:.4f}:'.format(-opt.best_score_), opt.best_params_
	dump(opt.best_params_, fp = fh, indent = 4)
probs = opt.best_estimator_.predict_proba(test)
makeSubmission(probs, fname = join(SUBMISSIONS_DIR, 'debug_{0:.4f}.csv'.format(-opt.best_score_)), digits = 8)


コード例 #3
0
ファイル: ensemble.py プロジェクト: EdwardBetts/kaggle_otto
    testmodels = (foresttest1, gradienttest1, boostedtest1, foresttest2,
                  gradienttest2, boostedtest2, foresttest3, gradienttest3,
                  boostedtest3, svmtest, nntest, knn4test, knn32test,
                  knn256test, treeboosttest)

    ptest = np.hstack(testmodels)
    ptest = stack_predictions(ptest, len(testmodels))
    print "ptest", np.shape(ptest)

    weights = [1, 24, 28, 0, 0, 31, 38, 1, 34, 18, 0, 0, 4]
    #weights = bestfitness[1]

    trainfeat = np.load('data/testmat.npy')
    testfeat, _ = get_testing_data()

    classi = classifierEnsemble(p, trueclasses, ptest, trainfeat[:, 1:],
                                testfeat)
    #mean = mean_ensemble(ptest, weights)

    from utils.ioutil import makeSubmission
    import os
    if os.path.isfile('classsub.csv'):
        os.remove('classsub.csv')
    makeSubmission(classi, 'classsub.csv')
    #if os.path.isfile('meansub.csv'):
    #    os.remove('meansub.csv')
    #makeSubmission(mean, 'meansub.csv')

    print "Done making submission"