Skip to content

Commit

Permalink
Merge branch '1.4.0.dev1' of https://github.com/tjkessler/ecnet into …
Browse files Browse the repository at this point in the history
…1.4.0.dev1
  • Loading branch information
tjkessler committed Jun 9, 2018
2 parents 56785f7 + 256c321 commit 76603d1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
21 changes: 5 additions & 16 deletions ecnet/error_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ def calc_rmse(y_hat, y):
try:
return(np.sqrt(((np.asarray(y_hat)-np.asarray(y))**2).mean()))
except:
print("Error in calculating RMSE. Check input data format.")
raise
sys.exit()
raise ValueError("Error in calculating RMSE. Check input data format.")

# Calculates the mean average error between two arguments of equal length
def calc_mean_abs_error(y_hat, y):
Expand All @@ -31,9 +29,7 @@ def calc_mean_abs_error(y_hat, y):
try:
return(abs(np.asarray(y_hat)-np.asarray(y)).mean())
except:
print("Error in calculating mean average error. Check input data format.")
raise
sys.exit()
raise ValueError("Error in calculating mean average error. Check input data format.")

# Calculates the median absoltute error between two arguments of equal length
def calc_med_abs_error(y_hat, y):
Expand All @@ -43,10 +39,7 @@ def calc_med_abs_error(y_hat, y):
try:
return(np.median(np.absolute(np.asarray(y_hat)-np.asarray(y))))
except:
return("Error in calculating median absolute error. Check input data format.")
raise
sys.exit()

raise ValueError("Error in calculating median absolute error. Check input data format.")

# Calculates the correlation of determination, or r-squared value, between two arguments of equal length
def calc_r2(y_hat, y):
Expand All @@ -59,9 +52,7 @@ def calc_r2(y_hat, y):
y_form.append(y[i][0])
y_mean = sum(y_form)/len(y_form)
except:
print("Error in calculating r-squared. Check input data format.")
raise
sys.exit()
raise ValueError("Error in calculating r-squared. Check input data format.")
try:
s_res = np.sum((y_hat-y)**2)
s_tot = np.sum((y-y_mean)**2)
Expand All @@ -72,6 +63,4 @@ def calc_r2(y_hat, y):
s_tot = np.sum((np.asarray(y)-y_mean)**2)
return(1 - (s_res/s_tot))
except:
print("Error in calculating r-squared. Check input data format.")
raise
sys.exit()
raise ValueError("Error in calculating r-squared. Check input data format.")
5 changes: 3 additions & 2 deletions ecnet/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def test_neural_network(values):
amountOfEmployers = amt_employers)

# Run the artificial bee colony
abc.printInfo(self.vars['project_print_feedback'])
new_hyperparameters = abc.runABC()

# Set Server hyperparameters to ABC-calculated hyperparameters
Expand Down Expand Up @@ -394,7 +395,7 @@ def calc_error(self, *args, dset = None):
return error_dict

'''
Outputs the *results* to a specified *filename*
Outputs the *results* obtained from "use_model()" to a specified *filename*
'''
def output_results(self, results, filename = 'my_results.csv'):

Expand Down Expand Up @@ -567,4 +568,4 @@ def __error_fn(self, arg, y_hat, y):
elif arg == 'med_abs_error':
return ecnet.error_utils.calc_med_abs_error(y_hat, y)
else:
raise Exception('ERROR: Unknown/unsupported error function')
raise Exception('ERROR: Unknown/unsupported error function')
4 changes: 2 additions & 2 deletions examples/limit_input_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
# Import data (change 'my_data.csv' to your database name)
sv.import_data('my_data.csv')

# Limit the input dimensionality to 15, save to 'my_data_limite.csv'
# Limit the input dimensionality to 15, save to 'my_data_limited.csv'
sv.limit_parameters(15, 'my_data_limited.csv')


# Use this line instead for limiting the input dimensionality using a genetic algorithm
sv.limit_parameters(15, 'my_data_limited.csv', use_genetic = True)
sv.limit_parameters(15, 'my_data_limited_genetic.csv', use_genetic = True)

0 comments on commit 76603d1

Please sign in to comment.