actableai.data_imputation.auto_fixer package

Submodules

actableai.data_imputation.auto_fixer.auto_fixer module

class actableai.data_imputation.auto_fixer.auto_fixer.AutoFixer

Bases: abc.ABC

Abscract class for auto fixers.

Parameters
ABC – Abstract Base Class
Raises
NotImplementedError – If the method is not implemented.
abstract fix(df: pandas.core.frame.DataFrame, all_errors: actableai.data_imputation.error_detector.cell_erros.CellErrors, current_column: actableai.data_imputation.meta.column.RichColumnMeta) actableai.data_imputation.auto_fixer.fix_info.FixInfoList

Abstract method for fixing errors.

Parameters
  • df – DataFrame to fix.
  • all_errors – All errors in the dataframe.
  • current_column – Current column to fix.
Raises

NotImplementedError – If the method is not implemented.

Returns

List of fix information.

Return type

FixInfoList

actableai.data_imputation.auto_fixer.auto_gluon_fixer module

class actableai.data_imputation.auto_fixer.auto_gluon_fixer.AutoGluonFixer

Bases: actableai.data_imputation.auto_fixer.auto_fixer.AutoFixer

fix(df: pandas.core.frame.DataFrame, all_errors: actableai.data_imputation.error_detector.cell_erros.CellErrors, current_column: actableai.data_imputation.meta.column.RichColumnMeta, ag_hyperparameters: Optional[Tuple[str, dict]] = None) actableai.data_imputation.auto_fixer.fix_info.FixInfoList

Fixes the missing values for a single column

Parameters
  • df – Input dataframe
  • all_errors – All errors of the dataframe
  • current_column – The column to fix the missing values for
Returns

The fix information for the column

Return type

FixInfoList

actableai.data_imputation.auto_fixer.datetime_fixer module

class actableai.data_imputation.auto_fixer.datetime_fixer.DatetimeFixer

Bases: actableai.data_imputation.auto_fixer.auto_fixer.AutoFixer

fix(df: pandas.core.frame.DataFrame, all_errors: actableai.data_imputation.error_detector.cell_erros.CellErrors, current_column: actableai.data_imputation.meta.column.RichColumnMeta) actableai.data_imputation.auto_fixer.fix_info.FixInfoList

Fixes datetime errors.

Parameters
  • df – DataFrame to fix.
  • all_errors – All errors in the dataframe.
  • current_column – Current column to fix.
Returns

List of fix information.

Return type

FixInfoList

actableai.data_imputation.auto_fixer.errors module

exception actableai.data_imputation.auto_fixer.errors.EmptyTrainDataException

Bases: Exception

actableai.data_imputation.auto_fixer.fix_info module

class actableai.data_imputation.auto_fixer.fix_info.FixInfo(col: str, index: int, options: actableai.data_imputation.auto_fixer.fix_info.FixValueOptions)

Bases: object

property best_guess: Union[str, int, bool, float, complex]
col: str
index: int
options: actableai.data_imputation.auto_fixer.fix_info.FixValueOptions
property sorted_options: List[actableai.data_imputation.auto_fixer.fix_info.FixValue]
class actableai.data_imputation.auto_fixer.fix_info.FixInfoList(fix_info_list: List[actableai.data_imputation.auto_fixer.fix_info.FixInfo] = ())

Bases: object

append(fix_info: actableai.data_imputation.auto_fixer.fix_info.FixInfo)
property columns: Iterable[str]
extend(fix_info_list: actableai.data_imputation.auto_fixer.fix_info.FixInfoList)
find(index: int, column: str, value: Union[str, int, bool, float, complex]) actableai.data_imputation.auto_fixer.fix_info.FixValue
get_item(index: int, column: str) Optional[actableai.data_imputation.auto_fixer.fix_info.FixInfo]
get_via_index(index: int) Iterable[actableai.data_imputation.auto_fixer.fix_info.FixInfo]
property index: Iterable[int]
replace(*fix_infos: actableai.data_imputation.auto_fixer.fix_info.FixInfo)
class actableai.data_imputation.auto_fixer.fix_info.FixValue(value: Union[str, int, bool, float, complex], confidence: float)

Bases: object

confidence: float
value: Union[str, int, bool, float, complex]
class actableai.data_imputation.auto_fixer.fix_info.FixValueOptions(options: List[actableai.data_imputation.auto_fixer.fix_info.FixValue])

Bases: object

options: List[actableai.data_imputation.auto_fixer.fix_info.FixValue]

actableai.data_imputation.auto_fixer.helper module

actableai.data_imputation.auto_fixer.helper.finalize_columns(original_df: pandas.core.frame.DataFrame, fixed_df: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame

Use columns in fixed_df to replace original_df columns, due to original_df might have some unsupported columns :param original_df: the original df waiting to fix :param fixed_df: the fixed df, but might have some columns missing from original_df due to they are not support to

be fixed
Returns
the complete dataframe
actableai.data_imputation.auto_fixer.helper.fulfil_fix_back(df_to_fix: pandas.core.frame.DataFrame, fix_info_list: actableai.data_imputation.auto_fixer.fix_info.FixInfoList) pandas.core.frame.DataFrame
actableai.data_imputation.auto_fixer.helper.get_df_with_only_error(df: pandas.core.frame.DataFrame, errors: Union[actableai.data_imputation.error_detector.cell_erros.CellErrors, actableai.data_imputation.error_detector.cell_erros.ColumnErrors]) pandas.core.frame.DataFrame

Return a dataframe with only errors.

Parameters
  • df – DataFrame with errors
  • errors – Errors to remove.
Returns

DataFrame with only errors.

Return type

pd.DataFrame

actableai.data_imputation.auto_fixer.helper.get_df_without_error(df: pandas.core.frame.DataFrame, errors: Union[actableai.data_imputation.error_detector.cell_erros.CellErrors, actableai.data_imputation.error_detector.cell_erros.ColumnErrors]) pandas.core.frame.DataFrame

Return a dataframe without errors.

Parameters
  • df – DataFrame with errors
  • errors – Errors to remove.
Returns

DataFrame without errors.

Return type

pd.DataFrame

actableai.data_imputation.auto_fixer.helper.merge_num_with_tag_columns(df_fixed: pandas.core.frame.DataFrame, column_types: actableai.data_imputation.type_recon.type_detector.DfTypes) pandas.core.frame.DataFrame

actableai.data_imputation.auto_fixer.misplaced_refiner module

class actableai.data_imputation.auto_fixer.misplaced_refiner.MisplacedRefiner(error_detector: actableai.data_imputation.error_detector.error_detector.ErrorDetector)

Bases: actableai.data_imputation.auto_fixer.refiner.Refiner

refine(processed_fixed_df: pandas.core.frame.DataFrame) Tuple[pandas.core.frame.DataFrame, actableai.data_imputation.auto_fixer.fix_info.FixInfoList]

actableai.data_imputation.auto_fixer.neighbor_fixer module

class actableai.data_imputation.auto_fixer.neighbor_fixer.NeighborFixer

Bases: actableai.data_imputation.auto_fixer.auto_fixer.AutoFixer

Simple imputer using IterativeImputer

Parameters
AutoFixer – AutoFixer Abstract class
fix(df: pandas.core.frame.DataFrame, all_errors: actableai.data_imputation.error_detector.cell_erros.CellErrors, current_column: actableai.data_imputation.meta.column.RichColumnMeta) actableai.data_imputation.auto_fixer.fix_info.FixInfoList

Fixes errors.

Parameters
  • df – DataFrame to fix.
  • all_errors – All errors in the dataframe.
  • current_column – Current column to fix.
Raises

EmptyTrainDataException – If the DataFrame only contains errors.

Returns

List of fix information.

Return type

FixInfoList

actableai.data_imputation.auto_fixer.refiner module

class actableai.data_imputation.auto_fixer.refiner.Refiner(error_detector: actableai.data_imputation.error_detector.error_detector.ErrorDetector)

Bases: abc.ABC

abstract refine(processed_fixed_df: pandas.core.frame.DataFrame) Tuple[pandas.core.frame.DataFrame, actableai.data_imputation.auto_fixer.fix_info.FixInfoList]

actableai.data_imputation.auto_fixer.single_category_fixer module

class actableai.data_imputation.auto_fixer.single_category_fixer.SingleCategoryFixer

Bases: actableai.data_imputation.auto_fixer.auto_fixer.AutoFixer

fix(df: pandas.core.frame.DataFrame, all_errors: actableai.data_imputation.error_detector.cell_erros.CellErrors, current_column: actableai.data_imputation.meta.column.RichColumnMeta) actableai.data_imputation.auto_fixer.fix_info.FixInfoList

Abstract method for fixing errors.

Parameters
  • df – DataFrame to fix.
  • all_errors – All errors in the dataframe.
  • current_column – Current column to fix.
Raises

NotImplementedError – If the method is not implemented.

Returns

List of fix information.

Return type

FixInfoList

actableai.data_imputation.auto_fixer.strategy module

class actableai.data_imputation.auto_fixer.strategy.FixStrategy(value)

Bases: enum.Enum

An enumeration.

AUTO = 1
AUTOGLUON = 3
DATETIME = 7
NEIGHBOR = 2
SINGLE_CATEGORY = 4
UNABLE_TO_FIX = 6
UNDECIDED = 5
actableai.data_imputation.auto_fixer.strategy.determine_fix_strategy(series: pandas.core.series.Series, column_type: actableai.data_imputation.meta.types.ColumnType, errors: actableai.data_imputation.error_detector.cell_erros.ColumnErrors) actableai.data_imputation.auto_fixer.strategy.FixStrategy

Determine the fix strategy.

Parameters
  • series – Series to fix.
  • column_type – Column type.
  • errors – Errors to fix.
Returns

The fixing strategy.

Return type

FixStrategy

actableai.data_imputation.auto_fixer.strategy.determine_refine_strategy(series: pandas.core.series.Series, errors: actableai.data_imputation.error_detector.cell_erros.ColumnErrors) actableai.data_imputation.auto_fixer.strategy.FixStrategy

Determine the refine strategy.

Parameters
  • series – Series to refine.
  • errors – Errors to refine.
Returns

The refining strategy.

Return type

FixStrategy

actableai.data_imputation.auto_fixer.strategy.get_fixer(strategy: actableai.data_imputation.auto_fixer.strategy.FixStrategy) actableai.data_imputation.auto_fixer.auto_fixer.AutoFixer

Return a fixer according to the strategy.

Parameters
strategy – FixStrategy
Raises
NotImplementedError – If strategy is not implemented.
Returns
A fixer.
Return type
AutoFixer
actableai.data_imputation.auto_fixer.strategy.get_quick_fixer_for_debug(column_type: actableai.data_imputation.meta.types.ColumnType) actableai.data_imputation.auto_fixer.auto_fixer.AutoFixer

Return a quick fixer for debug.

Parameters
column_type – ColumnType
Returns
Single category fixer if column type is category.
else return a neighbor fixer.
Return type
AutoFixer

actableai.data_imputation.auto_fixer.validation_refiner module

class actableai.data_imputation.auto_fixer.validation_refiner.ValidationRefiner(error_detector: actableai.data_imputation.error_detector.error_detector.ErrorDetector)

Bases: actableai.data_imputation.auto_fixer.refiner.Refiner

refine(processed_fixed_df: pandas.core.frame.DataFrame) Tuple[pandas.core.frame.DataFrame, actableai.data_imputation.auto_fixer.fix_info.FixInfoList]

Module contents

exception actableai.data_imputation.auto_fixer.EmptyTrainDataException

Bases: Exception

class actableai.data_imputation.auto_fixer.FixStrategy(value)

Bases: enum.Enum

An enumeration.

AUTO = 1
AUTOGLUON = 3
DATETIME = 7
NEIGHBOR = 2
SINGLE_CATEGORY = 4
UNABLE_TO_FIX = 6
UNDECIDED = 5