Page MenuHomec4science

create_submission_poly.py
No OneTemporary

File Metadata

Created
Mon, Feb 24, 03:57

create_submission_poly.py

import numpy as np
from proj1_helpers import *
from functions import *
import datetime
def predict_labels_modified(weights, data):
"""Generates class predictions given weights, and a test data matrix"""
y_pred = np.dot(data, weights)
y_pred[np.where(y_pred <= 0.5)] = -1
y_pred[np.where(y_pred > 0.5)] = 1
return y_pred
def normalize2(x, x_helper):
minimum = min(np.min(x),np.min(x_helper))
maximum = max(np.max(x),np.max(x_helper))
range_x = maximum - minimum
x -= minimum
x = x/range_x
return x
#y_tr, x_tr_noisy, ids_tr = load_csv_data("train.csv")
#y_te,x_te,ids_te = load_csv_data("test.csv")
x_tr1 = real_mean(x_tr)
x_te1 = real_mean2(x_te,x_tr)#format_data2(xx,x_tr_noisy)
x_te_touse = normalize2(x_te1,x_tr1)
degree = 7
tx_te = build_poly_matrix(x_te_touse,degree)
y_pred = predict_labels(w_final, tx_te)
create_csv_submission(ids_te, y_pred, "new_submission")

Event Timeline