-
Notifications
You must be signed in to change notification settings - Fork 107
Open
Description
So i am doing XAI on Timeseries and therefore testing SHAP and MACE. I am doing nothing different to the data but it is working with SHAP and not with MACE.
SHAP:
train_df = pd.DataFrame(df.iloc[:1000])
test_df = pd.DataFrame(df.iloc[1000:1500])
THRESHOLD = np.percentile(train_df.values, 90)
def detector(ts: Timeseries):
anomaly_scores = np.sum((ts.values > THRESHOLD).astype(int))
return anomaly_scores / ts.shape[0]
explainers = ShapTimeseries(
training_data = Timeseries.from_pd(train_df),
predict_function=detector,
mode="anomaly_detection"
)
explanations = explainers.explain(Timeseries.from_pd(test_df))
fig = explanations.plot(index=0, max_num_variables_to_plot=4)
MACE:
`train_df = pd.DataFrame(df.iloc[:1000])
test_df = pd.DataFrame(df.iloc[1000:1500])
threshold = np.percentile(train_df.values, 90)
#Detektieren der Anomalien
def detector(ts: Timeseries):
anomaly_scores = np.sum((ts.values > threshold).astype(int))
return anomaly_scores / ts.shape[0]
#Aufsetzen des Explainers
explainers = MACEExplainer(
training_data = Timeseries.from_pd(train_df),
predict_function=detector,
mode="anomaly_detection",
threshold = 0.1
)
explanations = explainers.explain(Timeseries.from_pd(test_df))
#Darstellen der Explanations
fig = explanations.plot(index=0, max_num_variables_to_plot=18)
plt.savefig("mace.png")`
With MACE I am getting an Index Error (IndexError: index 1 is out of bounds for axis 0 with size 1). Can you help me?
Metadata
Metadata
Assignees
Labels
No labels