diff --git a/epde/interface/equation_translator.py b/epde/interface/equation_translator.py index 572f9d4c..e81723cb 100755 --- a/epde/interface/equation_translator.py +++ b/epde/interface/equation_translator.py @@ -216,7 +216,7 @@ def __init__(self, lp_terms : Union[list, tuple, dict], rp_term : Union[list, tu metaparameters={'terms_number': {'optimizable': False, 'value': len(term_list)}, 'max_factors_in_term': {'optimizable': False, 'value': max_factors}} for var_key in all_vars: - metaparameters[('sparsity', var_key)] = {'optimizable': True, 'value': 1.} + metaparameters[('sparsity', var_key)] = {'optimizable': True, 'value': 0.} self.equation = Equation(pool=pool, basic_structure=terms_aggregated, diff --git a/epde/operators/common/fitness.py b/epde/operators/common/fitness.py index 145a3851..957b982e 100644 --- a/epde/operators/common/fitness.py +++ b/epde/operators/common/fitness.py @@ -200,7 +200,7 @@ def apply(self, objective: Equation, arguments: dict, force_out_of_place: bool = for start_idx in range(0, num_horizons, step_size): end_idx = start_idx + window_size target_window = target_vals[start_idx:end_idx] - eq_window_weights.append(np.abs(np.std(target_window) / np.mean(target_window))) + eq_window_weights.append(np.abs(np.std(target_window) / np.sqrt(np.mean(np.power(target_window, 2))))) lr = np.mean(eq_window_weights) else: features = self.feature_reshape(features_vals) @@ -212,7 +212,7 @@ def apply(self, objective: Equation, arguments: dict, force_out_of_place: bool = estimator.fit(feature_window, target_window, sample_weight=self.g_fun_vals[start_idx:end_idx]) valuable_weights = estimator.coef_[:-1] eq_window_weights.append(valuable_weights) - eq_cv = np.array([np.abs(np.std(_) / (np.mean(_) + 1e-12)) for _ in zip(*eq_window_weights)]) + eq_cv = np.array([np.abs(np.std(_) / np.sqrt(np.mean(np.power(_, 2)))) for _ in zip(*eq_window_weights)]) lr = eq_cv.mean() elif target_vals.ndim == 2: @@ -233,7 +233,7 @@ def apply(self, objective: Equation, arguments: dict, force_out_of_place: bool = target_window = target_vals[start_idx:end_idx, :].reshape(-1) else: target_window = target_vals[:, start_idx:end_idx].reshape(-1) - eq_window_weights.append(np.abs(np.std(target_window) / np.mean(target_window))) + eq_window_weights.append(np.abs(np.std(target_window) / np.sqrt(np.mean(np.power(target_window, 2))))) lr += np.mean(eq_window_weights) else: features = self.feature_reshape(features_vals) @@ -250,7 +250,7 @@ def apply(self, objective: Equation, arguments: dict, force_out_of_place: bool = estimator.fit(feature_window, target_window, sample_weight=self.g_fun_vals.reshape(*data_shape, -1)[:, start_idx:end_idx].reshape(-1)) valuable_weights = estimator.coef_[:-1] eq_window_weights.append(valuable_weights) - eq_cv = np.array([np.abs(np.std(_) / (np.mean(_) + 1e-12)) for _ in zip(*eq_window_weights)]) + eq_cv = np.array([np.abs(np.std(_) / np.sqrt(np.mean(np.power(_, 2)))) for _ in zip(*eq_window_weights)]) lr += eq_cv.mean() elif target_vals.ndim == 3: @@ -269,7 +269,7 @@ def apply(self, objective: Equation, arguments: dict, force_out_of_place: bool = target_window = target_vals[:, start_idx:end_idx, :].reshape(-1) else: target_window = target_vals[:, :, start_idx:end_idx].reshape(-1) - eq_window_weights.append(np.abs(np.std(target_window) / np.mean(target_window))) + eq_window_weights.append(np.abs(np.std(target_window) / np.sqrt(np.mean(np.power(target_window, 2))))) lr += np.mean(eq_window_weights) else: features = self.feature_reshape(features_vals) @@ -290,7 +290,7 @@ def apply(self, objective: Equation, arguments: dict, force_out_of_place: bool = estimator.fit(feature_window, target_window, sample_weight=self.g_fun_vals.reshape(*data_shape, -1)[:, :, start_idx:end_idx].reshape(-1)) valuable_weights = estimator.coef_[:-1] eq_window_weights.append(valuable_weights) - eq_cv = np.array([np.abs(np.std(_) / (np.mean(_) + 1e-12)) for _ in zip(*eq_window_weights)]) + eq_cv = np.array([np.abs(np.std(_) / np.sqrt(np.mean(np.power(_, 2)))) for _ in zip(*eq_window_weights)]) lr += eq_cv.mean() objective.fitness_calculated = True