def make_submission_2012(fn, predictions): # get 2012 ids ids = get_pkl("saved_objs/test_2012.pkl")[1:, 0:1] # If passed 1d array, change to column if (predictions.ndim == 1): predictions = predictions.reshape((-1, 1)) np.savetxt(fn, np.concatenate((ids, predictions), axis=1), delimiter=',', header="id,PES1", comments='', fmt="%d,%d")
import os.path import sys import getopt import numpy as np from pkl_help import get_pkl from pkl_help import read_make_pkl import preprocess_help as ph from sklearn.ensemble import AdaBoostClassifier from submission import make_submission_2008 from submission import make_submission_2012 from sklearn.tree import DecisionTreeClassifier from sklearn.neighbors import KNeighborsClassifier # Get training data X_train_2008 = get_pkl("saved_objs/X_train_2008.pkl") Y_train_2008 = get_pkl("saved_objs/Y_train_2008.pkl") X_test_2008 = get_pkl("saved_objs/X_test_2008.pkl") X_test_2012 = get_pkl("saved_objs/X_test_2012.pkl") X_ver = get_pkl("saved_objs/X_ver_2008.pkl") Y_ver = get_pkl("saved_objs/Y_ver_2008.pkl") def knearest_modified_predict(model, Y): preds = model.predict(Y).reshape(-1, 1) # Debug print("preds.shape: " + str(preds.shape)) return preds def optimize_parameters(): score = 0.0
import os.path import sys import getopt import numpy as np from pkl_help import get_pkl from pkl_help import read_make_pkl import preprocess_help as ph from sklearn.ensemble import VotingClassifier from submission import make_submission_2008 from submission import make_submission_2012 from round_predictions import round_predictions X_train_2008 = get_pkl("saved_objs/X_train_2008.pkl") Y_train_2008 = get_pkl("saved_objs/Y_train_2008.pkl") X_test_2008 = get_pkl("saved_objs/X_test_2008.pkl") X_test_2012 = get_pkl("saved_objs/X_test_2012.pkl") X_ver = get_pkl("saved_objs/X_ver_2008.pkl") Y_ver = get_pkl("saved_objs/Y_ver_2008.pkl") def modified_predict(model, Y): preds = model.predict(Y).reshape(-1, 1) # Debug print("preds.shape: " + str(preds.shape)) return preds xgb_score = 0.77900 adaboost_ran_forest_score = 0.77838 adaboost_score = 0.77525 lasso_score = 0.77225
import os.path import sys import getopt import numpy as np from pkl_help import get_pkl from pkl_help import read_make_pkl import preprocess_help as ph from sklearn.ensemble import VotingClassifier from submission import make_submission_2008 from submission import make_submission_2012 from sklearn.linear_model import RidgeClassifierCV # Get training data X_train_2008 = get_pkl("saved_objs/X_train_2008.pkl") Y_train_2008 = get_pkl("saved_objs/Y_train_2008.pkl") X_test_2008 = get_pkl("saved_objs/X_test_2008.pkl") X_test_2012 = get_pkl("saved_objs/X_test_2012.pkl") X_ver = get_pkl("saved_objs/X_ver_2008.pkl") Y_ver = get_pkl("saved_objs/Y_ver_2008.pkl") # Grab all models we have. ridge = RidgeClassifierCV().fit(X_train_2008, Y_train_2008) # lasso = get_pkl("saved_objs/lasso.pkl") mlp = get_pkl("saved_objs/mlp.pkl") rand_forest = get_pkl("saved_objs/rand_forest.pkl") adaboost = get_pkl("saved_objs/adaboost.pkl") # knn = get_pkl("saved_objs/knearest.pkl") def voting_modified_predict(model, Y): preds = model.predict(Y).reshape(-1, 1)