Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion odeformer/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def compute_metrics(predicted, true, predicted_tree=None, tree=None, metrics="r2
else:
try:
l1_error = np.mean(np.abs((true[i] - predicted[i])))
if np.isnan(l1_error): results[metric].append(np.infty)
if np.isnan(l1_error): results[metric].append(np.inf)
else: results[metric].append(l1_error)
except Exception as e:
results[metric].append(np.nan)
Expand Down
2 changes: 1 addition & 1 deletion odeformer/model/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def sort_candidates(
metrics = sorting_metric,
)[sorting_metric][0]
if math.isnan(_score):
_score = -np.infty if descending else np.infty
_score = -np.inf if descending else np.inf
_scores.append(_score)
sorted_idx = np.argsort(_scores)
if descending: sorted_idx = list(reversed(sorted_idx))
Expand Down
2 changes: 1 addition & 1 deletion odeformer/model/sklearn_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def sort_candidates(self, times, trajectory, candidates, metric="snmse", verbose
for candidate in candidates:
score = self.evaluate_tree(candidate, times, trajectory, metric)
if math.isnan(score):
score = -np.infty if descending else np.infty
score = -np.inf if descending else np.inf
scores.append(score)
sorted_idx = np.argsort(scores)

Expand Down
2 changes: 1 addition & 1 deletion odeformer/regressors.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def order_data(X, y):

def get_infinite_relative_error(prediction, truth):
abs_relative_error = np.abs((prediction - truth) / (truth + 1e-100))
abs_relative_error = np.nan_to_num(abs_relative_error, nan=np.infty)
abs_relative_error = np.nan_to_num(abs_relative_error, nan=np.inf)
return np.max(abs_relative_error)


Expand Down
2 changes: 1 addition & 1 deletion odeformer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def __init__(self, modules, env, params, path=None, root=None):
m = (m, True) if 'r2' in m else (m, False)
self.metrics.append(m)
self.best_metrics = {
metric: (-np.infty if biggest else np.infty)
metric: (-np.inf if biggest else np.inf)
for (metric, biggest) in self.metrics
}

Expand Down