-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change treatment of generic column type object
#1415
Merged
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f5aa1a4
rename `auto-sklearn/autosklearn/pipeline/components/data_preprocessi…
Louquinze 83a6a7a
rename `auto-sklearn/autosklearn/pipeline/components/data_preprocessi…
Louquinze 0560ee7
change treatment of generic column dtype `object` for pandas dataframes.
Louquinze acca511
Merge branch 'automl:development' into development
Louquinze da91a88
change treatment of generic column dtype `object` for pandas dataframes.
Louquinze 9431b99
change treatment of generic column dtype `object` for pandas dataframes.
Louquinze 7587a7f
change treatment of generic column dtype `object` for pandas dataframes.
Louquinze b00a250
change treatment of generic column dtype `object` for pandas dataframes.
Louquinze 8d9e159
change treatment of generic column dtype `object` for pandas dataframes.
Louquinze File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
from typing import Dict, List, Optional, Tuple, Union, cast | ||
|
||
import logging | ||
import warnings | ||
|
||
import numpy as np | ||
import pandas as pd | ||
|
@@ -304,16 +305,13 @@ def get_feat_type_from_columns( | |
# TypeError: data type not understood in certain pandas types | ||
elif not is_numeric_dtype(X[column]): | ||
if X[column].dtype.name == "object": | ||
raise ValueError( | ||
f"Input Column {column} has invalid type object. " | ||
"Cast it to a valid dtype before using it in Auto-Sklearn. " | ||
"Valid types are numerical, categorical or boolean. " | ||
"You can cast it to a valid dtype using " | ||
"pandas.Series.astype ." | ||
"If working with string objects, the following " | ||
"tutorial illustrates how to work with text data: " | ||
"https://scikit-learn.org/stable/tutorial/text_analytics/working_with_text_data.html" # noqa: E501 | ||
warnings.warn( | ||
f"Input Column {column} has generic type object. " | ||
f"Autosklearn will treat this column as string. " | ||
f"Please ensure that this setting is suitable for your task." | ||
) | ||
X[column] = X[column].astype("string") | ||
feat_type[column] = "string" | ||
elif pd.core.dtypes.common.is_datetime_or_timedelta_dtype( | ||
X[column].dtype | ||
): | ||
|
@@ -327,7 +325,7 @@ def get_feat_type_from_columns( | |
else: | ||
raise ValueError( | ||
"Input Column {} has unsupported dtype {}. " | ||
"Supported column types are categorical/bool/numerical dtypes. " | ||
"Supported column types are categorical/bool/numerical/string dtypes. " # noqa: E501 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is necessary. Please reformat the string so the lines fit within the line limit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i change it |
||
"Make sure your data is formatted in a correct way, " | ||
"before feeding it to Auto-Sklearn.".format( | ||
column, | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work for random objects? Could we have a test that the feature validator correctly handles random objects? In general, could you please extend the tests under
test/test_data/test_feature_validator.py
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will check the behavior and then update
test/test_data/test_feature_validator.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.