Unanswered
Hi Everyone, Has Someone Of You Tried To Track Your Shap Plots With Clearml? Somehow In My Dashboard The Tracked Plots Are Empty. Might They Be Too Complex Or Something? Br Sophie
Notice that in your example you have
plt.figure()
This actually clears the matplotlib figure, this is why we are getting a first white image then the actual plot,
once I removed it I got a single plot (no need for the manual reporting)
X, y = make_regression(
n_samples=100, # Number of samples
n_features=10, # Number of features
noise=0.1, # Number of informative features
random_state=42 # For reproducibility
)
# Convert to DataFrame for better feature naming
feature_names = [f"Feature {i+1}" for i in range(X.shape[1])]
X = pd.DataFrame(X, columns=feature_names)
# Step 2: Split Data into Train/Test Sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Step 3: Train a Simple Model
model = RandomForestRegressor(random_state=42)
model.fit(X_train, y_train)
# Step 4: Use SHAP to Explain Model Predictions
explainer = shap.Explainer(model, X_train)
shap_values = explainer(X_test) # Returns a SHAP Explanation object in new SHAP versions
shap_plot = shap.summary_plot(shap_values, X_test) # Show top 5 features
plt.show()
45 Views
0
Answers
2 months ago
2 months ago