-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from hachmannlab/wrapper_aatish
Updated documentation, tutorials, regression metrics
- Loading branch information
Showing
31 changed files
with
110,165 additions
and
272 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
def error_metric(y_true,y_pred): | ||
y_true = np.asarray(y_true) | ||
y_pred = np.asarray(y_pred) | ||
ndata = len(y_true) | ||
y_mean = np.mean(y_true) | ||
e = y_true - y_pred | ||
ae = np.absolute(e) | ||
se = np.square(e) | ||
var = np.mean(np.square(y_true - y_mean)) | ||
MAE = np.mean(ae) | ||
return MAE |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
def ga_eval(indi): | ||
|
||
layers = [indi[i] for i in range(2,5) if indi[i] != 0] | ||
#print(np.exp(indi[0])) | ||
|
||
#count iterations of GA | ||
count=open("tmp.txt", "a") | ||
count.write("GA search iteration in process... \n") | ||
count.close() | ||
file = open("tmp.txt","r") | ||
Counter = 0 | ||
# Reading number of lines from file | ||
Content = file.read() | ||
CoList = Content.split("\n") | ||
for i in CoList: | ||
if i: | ||
Counter += 1 | ||
print("GA search iteration in process... ",Counter) | ||
mlp = MLPRegressor(alpha=np.exp(indi[0]), activation=indi[1], hidden_layer_sizes=tuple(layers),learning_rate='invscaling', max_iter=10,early_stopping=True) | ||
ga_search = single_obj(mlp=mlp, x=X.values, y=Y.values,n_splits=n_splits) | ||
#print("GA search iteration in process...") | ||
f=open("GA.txt", "a") | ||
f.write("%f %s %d %d %d %f \n" %(float(np.exp(indi[0])), str(indi[1]), int(indi[2]), int(indi[3]), int(indi[4]),float(ga_search))) | ||
f.close() | ||
#gui_return ={"ga_search": ga_search} | ||
#print(gui_return) | ||
return ga_search |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
def single_obj(mlp, x, y, n_splits=n_splits): | ||
n_splits=n_splits | ||
kf = KFold(n_splits) # cross validation based on Kfold (creates 5 validation train-test sets) | ||
accuracy_kfold = [] | ||
for training, testing in kf.split(x): | ||
mlp.fit(x[training], y[training]) | ||
y_pred = mlp.predict(x[testing]) | ||
y_pred, y_act =y_pred.reshape(-1,1), y[testing].reshape(-1,1) | ||
model_accuracy=mae(y_act,y_pred) # evaluation metric: mae | ||
accuracy_kfold.append(model_accuracy) # creates list of accuracies for each fold | ||
#print("def single_obj - completed") | ||
return np.mean(accuracy_kfold) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
space = ({'alpha': {'uniform': [np.log(0.0001), np.log(0.1)], 'mutation': [0, 1]}},{'activation': {'choice': ['identity', 'logistic', 'tanh', 'relu']}},{'neurons1': {'choice': range(0,220,20)}},{'neurons2': {'choice': range(0,220,20)}},{'neurons3': {'choice': range(0,220,20)}}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
def test_hyp(mlp, x, y, xtest, ytest): | ||
mlp.fit(x, y) | ||
ypred = mlp.predict(xtest) | ||
acc=mae(ytest,ypred) | ||
# print(" test_hyp completed ") | ||
return np.mean(acc) |
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
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
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
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
Oops, something went wrong.