This error pops up when using "flip" as a parameter value for qoi in the ShaRP object.
Steps/Code to Reproduce
This is an incomplete code example to reproduce the bug. Will try to edit this later with a fully reproducible example.
xai = ShaRP(
qoi="flip",
target_function=target_authenticity,
measure="shapley",
random_state=42,
sample_size=2,
)
xai.fit(X)
# NOTE: temporary fix to said bug
# xai.qoi_.X = X
xai.individual(X_synth.values[0].reshape(1, -1))
Expected Results
Shapley values for an individual observation.
Actual Results
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[205], line 15
9 xai.fit(X)
11 # NOTE: temporary fix to a bug
12 # xai.qoi_.X = X
13
14 # ind_values =
---> 15 xai.individual(X_synth.values[0].reshape(1, -1))
File ~/miniconda3/envs/mlresearch/lib/python3.12/site-packages/sharp/base.py:110, in ShaRP.individual(self, sample, X, y, **kwargs)
107 if X is None:
108 X = self.qoi_.X
--> 110 X_, y_ = check_inputs(X, y)
112 if "set_cols_idx" in kwargs.keys():
113 set_cols_idx = kwargs["set_cols_idx"]
File ~/miniconda3/envs/mlresearch/lib/python3.12/site-packages/sharp/utils/_checks.py:27, in check_inputs(X, y)
24 if y is not None:
25 y = np.array(y)
---> 27 return check_array(X, dtype="object"), y
File ~/miniconda3/envs/mlresearch/lib/python3.12/site-packages/sklearn/utils/validation.py:930, in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, estimator, input_name)
927 if ensure_2d:
928 # If input is scalar raise error
929 if array.ndim == 0:
--> 930 raise ValueError(
931 "Expected 2D array, got scalar array instead:\narray={}.\n"
932 "Reshape your data either using array.reshape(-1, 1) if "
933 "your data has a single feature or array.reshape(1, -1) "
934 "if it contains a single sample.".format(array)
935 )
936 # If input is 1D raise error
937 if array.ndim == 1:
ValueError: Expected 2D array, got scalar array instead:
array=None.
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
Describe the bug
This error pops up when using "flip" as a parameter value for
qoi
in theShaRP
object.Steps/Code to Reproduce
This is an incomplete code example to reproduce the bug. Will try to edit this later with a fully reproducible example.
Expected Results
Shapley values for an individual observation.
Actual Results
Versions
No response