You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ethos behind SR is interpretability.
However, in the event that a complex equation has much better fit to test data, the resulting equation, although much easier to work with than a blackbox model, is difficult to interpret.
How do you tackle this problem?
I have played around with using the SHAP library?
The permutation in SHAP is very slow and I am doubtful this is the best approach, but it does allow for feature importance.
This would give me this example output:
import shap
class CustomModel:
def __init__(self, equation_str):
self.equation_str = equation_str
def predict(self, X):
results = []
for _, row in X.iterrows():
sample_values = get_sample_values(row)
result = eval(self.equation_str, sample_values)
results.append(result)
return np.array(results)
selected_equation_index = 38 # Change this to select a different equation
selected_equation = equation_strs[selected_equation_index]
model = CustomModel(selected_equation)
# Prepare the data using only relevant columns for SHAP
relevant_columns = list(variable_mapping.values())
X = combined_df[relevant_columns] # Use combined_df instead of df
y_true = combined_df[target_variable] # Use combined_df instead of df
# Ensure all data types are numeric, coerce errors
X = X.apply(pd.to_numeric, errors='coerce')
y_true = y_true.apply(pd.to_numeric, errors='coerce')
# Drop any remaining rows with NaN values
X = X.dropna()
y_true = y_true.loc[X.index]
# Generate SHAP values using Permutation Explainer
explainer = shap.Explainer(model.predict, X, algorithm="permutation")
shap_values = explainer(X)
shap.summary_plot(shap_values, X, plot_type="bar")
shap.summary_plot(shap_values, X)
shap.plots.beeswarm(shap_values)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The ethos behind SR is interpretability.
However, in the event that a complex equation has much better fit to test data, the resulting equation, although much easier to work with than a blackbox model, is difficult to interpret.
How do you tackle this problem?
I have played around with using the SHAP library?
The permutation in SHAP is very slow and I am doubtful this is the best approach, but it does allow for feature importance.
This would give me this example output:
Beta Was this translation helpful? Give feedback.
All reactions