text_plain_output_1.png
#machine learning
    train_data = train_df.values
    test_data = test_df.values
    X_train = train_data[:,1:]
    y_train = train_data[:,0]
    X_test = test_data[:,1:]
    idx = test_data[:,0]
    #random forest classifier
    rfc = RandomForestClassifier(n_estimators=100)  
    rfc.fit(X_train, y_train)
    score_rfc = rfc.score(X_train, y_train)
    out_rfc = rfc.predict(X_test)
    print ("random forest classifier score: %f", score_rfc)
    #logistic regression
    logreg = LogisticRegression()
    logreg.fit(X_train, y_train)
    score_logreg = logreg.score(X_train, y_train)
    out_logreg = logreg.predict(X_test)
    print ("logistic regression score: %f", score_logreg)
    #SVM
    svc = SVC()
    svc.fit(X_train, y_train)
    score_svc = svc.score(X_train, y_train)
    out_svc = svc.predict(X_test)    
    print ("SVM score: %f", score_svc)
    #knn classifier
    knn = KNeighborsClassifier(n_neighbors=5)
    knn.fit(X_train, y_train)
    score_knn = knn.score(X_train, y_train)
    out_knn = knn.predict(X_test)
    print ("knn score: %f", score_knn)
    #write out predictions 
    #predictions_file = open("titanic_pred.csv", "wb")
    #open_file_object = csv.writer(predictions_file)
    #open_file_object.writerow(["PassengerId","Survived"])
    #open_file_object.writerows(zip(idx, out_rfc))
    #predictions_file.close()