コード例 #1
0
ファイル: models.py プロジェクト: vanshkumar/kaggle155
def exampleUsage():
    '''This is just here to show how to run the models'''
    training_data = data.loadTraining()
    out = gaussianNBayes(training_data['xlabels'], training_data['ylabels'], \
                         training_data['xlabels'])
    out1 = ridgeRegression(training_data['xlabels'], training_data['ylabels'], \
                         training_data['xlabels'], 3)
    out2 = randomForest(training_data['xlabels'], training_data['ylabels'], \
                         training_data['xlabels'])
コード例 #2
0
ファイル: mlp.py プロジェクト: vanshkumar/kaggle155
import pkg_resources
import sys
import os 
import sklearn 
import numpy as np
from sklearn.neural_network import MLPClassifier
from sklearn.grid_search import GridSearchCV
from sklearn import cross_validation
import dataIO as data
import datetime
from grid_search import grid_search
import time

full_train = data.loadTraining()
x_train = full_train['xlabels']
y_train = full_train['ylabels']
full_test  = data.loadTest()
x_test = full_test['xlabels']

# the 2 values for alpha are needed because there needs to be 2 parameters for
# the grid search.  Could just remove the grid search
parameters = {'hidden_layer_sizes': [tuple([10] * 1)],\
              'activation': ['logistic'],  \
              'learning_rate': ['constant'], \
              'alpha': [7.0] * 2
              }



num_folds = np.prod(np.array([len(parameters[key]) for key in parameters]))
print "Number of folds: " + str(num_folds)
コード例 #3
0
ファイル: NN_blend.py プロジェクト: vanshkumar/kaggle155
                     'rf_regress_train.csv',
                     'rf_regress_train_2.csv',
                     'svm_regress_train.csv'
                     ]

testDataFiles = ['ada_regress_test.csv', 
                 'gnb_class_test.csv', 
                 'knn_regress_test.csv', 
                 'log_regress_test.csv', 
                 'nn_class_test.csv',
                 'rf_regress_test.csv',
                 'rf_regress_test_2.csv',
                 'svm_regress_test.csv'
                 ]

y_train = data.loadTraining()['ylabels']
x_train = np.zeros((len(trainingDataFiles), len(y_train)))
x_train = np.transpose([loadModelOut(model) for model in trainingDataFiles])

x_test = np.zeros((len(testDataFiles), len(y_train)))
x_test = np.transpose([loadModelOut(model) for model in testDataFiles])


in_layer = len(trainingDataFiles)

parameters = {'hidden_layer_sizes': ((in_layer,), (in_layer, in_layer/2), (in_layer, 2*in_layer/3, in_layer/3)),
              'alpha': np.logspace(-5, -3, 15),
              'learning_rate': ('constant', 'invscaling')
              }

kf_total = cross_validation.KFold(len(x_train), n_folds=10,\