Kaggle competition: IES Data Mining(WS 18/19)
def polynomial_trend(deg,X_train,y_true,X_test):
pf = PolynomialFeatures(degree=deg)
 pr = pf.fit_transform(X_train)
 lrm = LinearRegression()
lrm.fit(pr, y_true)
 y_valid = lrm.predict(pf.fit_transform(X_train))
y_pred = lrm.predict(pf.fit_transform(X_test))
y_valid = cut_neg(y_valid)
 y_pred = cut_neg(y_pred)
 return y_valid,y_pred<compute_test_metric>
pca = PCA(n_components=19)
 pca.fit(data)
 data = pca.transform(data)
 data_for_submission = pca.transform(data_for_submission)
 skf = StratifiedKFold(n_splits=5, shuffle=False)
 classifier = MLPClassifier(alpha=1, learning_rate='adaptive', max_iter=750, hidden_layer_sizes=(38, 76))
accuracy_list = []
for train_index, test_index in skf.split(data, label):
train_data = data[train_index]
train_label = label.iloc[train_index]
test_data = data[test_index]
test_label = label.iloc[test_index]
classifier.fit(train_data, train_label)
 accuracy_list.append(classifier.score(test_data, test_label))
prediction_labels = classifier.predict(data_for_submission)
 predicted_data = pd.DataFrame([data_for_submission_id,prediction_labels] ).transpose()
predicted_data.columns = ['id ','label']
predicted_data.to_csv('submission.csv',index=False,header=True )