Add files via upload

This commit is contained in:
Silviu Marian Udrescu 2020-04-16 00:00:35 -04:00 committed by GitHub
parent ae3d4e9a8d
commit 23184662e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 12 deletions

View file

@ -25,9 +25,16 @@ def get_symbolic_expr_error(pathdir,filename,expr):
check_var = "x"+str(i)
if check_var in np.array(variables).astype('str'):
real_variables = real_variables + [data[:,i]]
# Remove accidental nan's
good_idx = np.where(np.isnan(f(*real_variables))==False)
# use this to get rid of cases where the loss gets complex because of transformations of the output variable
if isinstance(np.mean((f(*real_variables)-data[:,-1])**2), complex):
return 1000000
else:
return np.sqrt(np.mean((f(*real_variables)-data[:,-1])**2))/np.sqrt(np.mean(data[:,-1]**2))
try:
return np.sqrt(np.mean((f(*real_variables)[good_idx]-data[good_idx][:,-1])**2))/np.sqrt(np.mean(data[good_idx][:,-1]**2))
except:
# use this for the case in which the expression is just one number (i.e. not array)
return np.sqrt(np.mean((f(*real_variables)-data[:,-1])**2))/np.sqrt(np.mean(data[:,-1]**2))