Last active
January 9, 2017 01:03
-
-
Save aiscool/b1f399120a9e26c29104151d898ca20c to your computer and use it in GitHub Desktop.
Baseline.csv : 97.72% , full.csv : 86.36%
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from sklearn.metrics import accuracy_score | |
from sklearn.neural_network import MLPClassifier | |
df = pd.read_csv('Baseline.csv') #Baseline.csv dengan full.csv | |
maxi = 0 | |
max_i = 0 | |
max_j = 0 | |
for i in range(10): | |
data = df.sample(frac=0.7, random_state=i) | |
data_t = df.drop(data.index) | |
train_in = data.drop('Features',1); | |
train_out = data['Features']; | |
test_in = data_t.drop('Features',1); | |
test_out = data_t['Features']; | |
for j in range(10): | |
clf = MLPClassifier(max_iter = 500, solver='lbfgs', alpha=1e-5,hidden_layer_sizes=(100), random_state=j) | |
clf = clf.fit(train_in,train_out) | |
predicted = clf.predict(test_in) | |
if maxi < accuracy_score(test_out,predicted): | |
maxi = accuracy_score(test_out,predicted) | |
max_i = i | |
max_j = j | |
print(str(maxi*100)+"% "+str(max_i)+" "+str(max_j)) | |
print("The best is : "+str(maxi*100)+"% "+str(max_i)+" "+str(max_j)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment