Skip to content

Commit 43d47f6

Browse files
Jordan StompsCloseChoice
andauthored
code suggestions from @CloseChoice
Co-authored-by: Tobias Pitters <31857876+CloseChoice@users.noreply.github.com>
1 parent 5f6e58a commit 43d47f6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

shap/maskers/_tabular.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ def fit(self, data):
331331
Array to impute missing values for, should be masked
332332
using missing_value.
333333
"""
334+
if len(data.shape) != 2:
335+
raise NotImplementedError(f"Currently only 2 dimensional data can by processed with the LinearImpute class. You provided {len(data.shape)}. If this is crucial to you, feel free to open an issue: https://github.com/shap/shap/issues.")
334336
self.data = pd.DataFrame(data)
335337
self.data = self.data.replace(self.missing_value, np.NaN)
336338
interpolated = self.data.interpolate(
@@ -376,7 +378,7 @@ def __init__(self, data, max_samples=100, method="mean"):
376378
methods = ["linear", "mean", "median", "mode", "knn"]
377379
if isinstance(method, str):
378380
if method not in methods:
379-
raise NotImplementedError("Given imputation method is not supported.")
381+
raise NotImplementedError(f"Given imputation method is not supported. Please provide one of the following methods: {', '.join(methods)}")
380382
elif method == "knn":
381383
impute = KNNImputer(missing_values=0)
382384
elif method == "linear":

0 commit comments

Comments
 (0)