Kaggle competition: Spooky Author Identification
digit_test.to_csv('submission_knn.csv', columns=["ImageId","Label"], index=False )<train_model>
train_df = pd.read_csv('.. /input/train.csv')
 train_df.shape
train_df.head()
train_df['author_num'] = train_df.author.map({'EAP':0, 'HPL':1, 'MWS':2})
 train_df=shuffle(train_df)
 train_df.head()
testing=pd.read_csv(".. /input/test.csv")
 testing.head()
start_time = time.perf_counter()
clf_mlp = MLPClassifier(hidden_layer_sizes=(784,), warm_start=True)
 print(clf_mlp)
 clf_mlp = clf_mlp.fit(features_train, target_train)
 target_predicted_mlp = clf_mlp.predict(features_test)
 print(time.perf_counter() - start_time, "seconds" )<compute_train_metric>
X = train_df['text']
y = train_df['author_num']
print(X.shape)
 print(y.shape)
start_time = time.perf_counter()
scores_mlp = cross_val_score(clf_mlp, features_train, target_train, cv=10, n_jobs=-1, scoring='accuracy')
 print("Cross Validation Score for MLP",scores_mlp)
 print("Accuracy: %0.2f(+/- %0.2f)" %(scores_mlp.mean() , scores_mlp.std() * 2))
print(time.perf_counter() - start_time, "seconds" )<feature_engineering>
stopset = set(stopwords.words('english'))
vect = CountVectorizer(lowercase=False, token_pattern=r'\w+|\,')
 X_cv=vect.fit_transform(X )
digit_test['Label'] = pd.Series(target_predicted_mlp)
 digit_test['ImageId'] = pd.Series(range(1,28001))<save_to_csv>
models=[('MultiNB', MultinomialNB(alpha=0.01)) ]
models.append(( 'Logit', LogisticRegression(C=30)))
 clf1 = VotingClassifier(models, voting='soft', weights=[3,3])
 clf1.fit(X_cv,y)
 y_pred_test=clf1.predict_proba(X_cv)
digit_test.to_csv('submission_mlp.csv', columns=["ImageId","Label"], index=False )<import_modules>
all_test=testing["text"]
all_test_v=vect.transform(all_test)
 final_result=clf1.predict_proba(all_test_v )
<prepare_x_and_y><EOS> 
result=pd.DataFrame(final_result)
 result.columns = ['EAP', 'HPL', 'MWS']
result.insert(0, 'id', testing["id"])
 result.to_csv("resultfinal.csv", index=False )