feat: add features names options for example samples#48
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the ability to specify custom feature_names in the explanation method, updating the documentation and example notebook to demonstrate this new capability. A review comment suggests adding validation to ensure that the length of the provided feature_names matches the number of features in the training data, which would prevent potential runtime errors when constructing the pandas DataFrame.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if feature_names is None: | ||
| feature_names = [f"feature_{j}" for j in range(self.train_X.shape[1])] |
There was a problem hiding this comment.
When feature_names is provided, there is no validation to ensure that its length matches the number of features in the training data (self.train_X.shape[1]). If the lengths do not match, pd.DataFrame will raise a ValueError with an unclear error message. Adding a validation check improves robustness and provides a clear error message to the user.
if feature_names is None:
feature_names = [f"feature_{j}" for j in range(self.train_X.shape[1])]
elif len(feature_names) != self.train_X.shape[1]:
raise ValueError(
f"Length of feature_names ({len(feature_names)}) must match "
f"the number of features ({self.train_X.shape[1]})."
)
No description provided.