fix type in featureselection converters#744
Merged
Merged
Conversation
cristian-tamblay
approved these changes
Jun 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The feature selection converters (
SelectKBest,SelectPercentile,SelectFdr,SelectFpr,SelectFwe,GenericUnivariateSelectandVarianceThreshold) hardcoded theirget_output_typeto always returnFloat (float64). Since these converters only drop columns and never modifythe values of the retained ones, this corrupted the type: an integer column was
reported as
float64even though the underlying data stayed integer.Solution
Preserve each retained column's original type:
FeatureSelectionConverterafitthat remembers theinput types and a
get_output_typethat returns the original type per column(falling back to
float64only when the type is unknown). This covers the 6scikit-learn selectors.
get_output_type(and the now-unusedDashAIDataTypeimport) from the 6 selector files, which now inherit the behavior.
VarianceThreshold(same bug, same "only dropscolumns" nature).
Key detail
Types are captured in
fitand not intransform: scikit-learn(
_SetOutputMixin.__init_subclass__) automatically wraps anytransformdefined on a subclass of a sklearn transformer and would coerce the output back
into a pandas
DataFrame.fitis never wrapped, so it is the safe place and italways runs before
transform.Verification
int64, float columns stayfloat64,and the declared type matches the underlying arrow data.
ruff checkclean.test_base_converter_metadata.py).Modified files
DashAI/back/converters/category/feature_selection.pyDashAI/back/converters/scikit_learn/select_k_best.pyDashAI/back/converters/scikit_learn/select_percentile.pyDashAI/back/converters/scikit_learn/select_fdr.pyDashAI/back/converters/scikit_learn/select_fpr.pyDashAI/back/converters/scikit_learn/select_fwe.pyDashAI/back/converters/scikit_learn/generic_univariate_select.pyDashAI/back/converters/scikit_learn/variance_threshold.py