Ejemplo n.º 1
0
from image import Image
from preprocess import Preprocess
from classifier import Classifier
from log_loss import log_loss
from postprocess import PostProcess

genders = Image.genders()
d, _ = Image.data()
matrix = Preprocess.to_matrix(d)
print matrix.shape
matrix = Preprocess.remove_constants(matrix)
print matrix.shape
matrix = Preprocess.scale(matrix)
matrix = Preprocess.polynomial(matrix, 2)
matrix = Preprocess.scale(matrix)
print matrix.shape
matrix = matrix.tolist()
half = len(matrix)/2
train, cv = matrix[:half], matrix[half:]
train_genders, cv_genders = genders[:half], genders[half:]
cv_genders = cv_genders[0::4]
preds = Classifier.ensemble_preds(train, train_genders, cv)
print "Score: ", log_loss(preds, cv_genders)
from image import Image
from preprocess import Preprocess
from classifier import Classifier
from postprocess import PostProcess

genders = Image.genders()
all_data, ids = Image.all()
matrix = Preprocess.to_matrix(all_data)
matrix = Preprocess.remove_constants(matrix)
matrix = Preprocess.scale(matrix)
matrix = Preprocess.polynomial(matrix, 2)
matrix = Preprocess.scale(matrix)
matrix = matrix.tolist()
train = matrix[:1128]
test = matrix[1128:]
test_ids = ids[1128:]
print len(train)
print len(test)
print len(test_ids)
print len(ids)
print len(matrix)
preds = Classifier.ensemble_preds(train, genders, test)  # real
# preds = Classifier.ensemble_preds(train, genders, train) # fake

# for creating submission file
PostProcess.submission(test_ids, preds)