cc_tk.relationship package
Submodules
cc_tk.relationship.distribution module
Module for computing distribution of data.
- cc_tk.relationship.distribution.categorical_distribution(categorical_features: DataFrame) DataFrame[source]
Compute the distribution of all categorical features.
- Parameters:
categorical_features (pd.DataFrame) – Categorical features to compute the distribution of.
- Returns:
Distribution of the features.
- Return type:
pd.DataFrame
- cc_tk.relationship.distribution.numeric_distribution(numeric_features: DataFrame) DataFrame[source]
Compute the distribution of all numeric features.
- Parameters:
numeric_features (pd.DataFrame) – Numeric features to compute the distribution of.
- Returns:
Distribution of the features.
- Return type:
pd.DataFrame
- cc_tk.relationship.distribution.summary_distribution_by_target(features: DataFrame, target: Series) Tuple[DataFrame, DataFrame][source]
Compute the distribution of all features by target group.
- Parameters:
features (pd.DataFrame) – Features to compute the distribution of.
target (pd.Series) – Target to group by. It must be categorical.
- Returns:
numeric_summary, catecorigal_summary – Distribution of the features by target group.
- Return type:
Tuple[pd.DataFrame, pd.DataFrame]
cc_tk.relationship.schema module
Defines the schema for the relationship module.
- class cc_tk.relationship.schema.SeriesType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
str,EnumDefines the type of a series.
- CATEGORICAL = 'categorical'
- NUMERIC = 'numeric'
- cc_tk.relationship.schema.all_columns_categorical(df: DataFrame) bool[source]
Check if all columns in a DataFrame are categorical.
- Parameters:
df (pd.DataFrame) – The DataFrame to check.
- Returns:
True if all columns are categorical, False otherwise.
- Return type:
bool
- cc_tk.relationship.schema.all_columns_numeric(df: DataFrame) bool[source]
Check if all columns in a DataFrame are numeric.
- Parameters:
df (pd.DataFrame) – The DataFrame to check.
- Returns:
True if all columns are numeric, False otherwise.
- Return type:
bool
- cc_tk.relationship.schema.check_input_index(*arg_names: str) Callable[source]
Check that the specified arguments have the same index.
- Parameters:
*arg_names (str) – The names of the arguments to check.
- Returns:
The decorator.
- Return type:
Callable
- cc_tk.relationship.schema.check_input_types(*type_specs: Tuple[str, SeriesType]) Callable[source]
Check the types of the arguments of the decorated function.
- Parameters:
*type_specs (Tuple[str, SeriesType]) – A tuple of tuples, each tuple contains the name of the argument and the expected type of the argument.
- Returns:
The decorator.
- Return type:
Callable
- cc_tk.relationship.schema.check_series_in_signature(func: Callable, *arg_names: str) Signature[source]
Check that the specified arguments are pd.Series.
- Parameters:
func (Callable) – The function to check.
*arg_names (str) – The names of the arguments to check.
- Returns:
The signature.
- Return type:
Signature
- Raises:
ValueError – If an argument does not exist.
TypeError – If an argument is not a pd.Series.
cc_tk.relationship.significance module
Significance functions for different input types and significance types.
- cc_tk.relationship.significance.get_significance(feature_type: Literal[VariableType.NUMERIC], target_type: Literal[VariableType.NUMERIC], significance_type: SignificanceType) SignificanceNumericNumeric[source]
- cc_tk.relationship.significance.get_significance(feature_type: Literal[VariableType.NUMERIC], target_type: Literal[VariableType.CATEGORICAL], significance_type: SignificanceType) SignificanceNumericCategorical
- cc_tk.relationship.significance.get_significance(feature_type: Literal[VariableType.CATEGORICAL], target_type: Literal[VariableType.NUMERIC], significance_type: SignificanceType) SignificanceCategoricalNumeric
- cc_tk.relationship.significance.get_significance(feature_type: Literal[VariableType.CATEGORICAL], target_type: Literal[VariableType.CATEGORICAL], significance_type: SignificanceType) SignificanceCategoricalCategorical
Get significance function based on variable types and significance type.
- Parameters:
feature_type (VariableType) – Input type of the feature.
target_type (VariableType) – Input type of the target.
significance_type (SignificanceType) – Significance type.
**kwargs – Additional keyword arguments passed to the significance initialization.
- Returns:
Significance instance.
- Return type:
Significance
- Raises:
ValueError – If the feature type and target type are not supported or incompatible with the significance type.
cc_tk.relationship.summary module
Significance functions for different input types and significance types.
- cc_tk.relationship.significance.get_significance(feature_type: Literal[VariableType.NUMERIC], target_type: Literal[VariableType.NUMERIC], significance_type: SignificanceType) SignificanceNumericNumeric[source]
- cc_tk.relationship.significance.get_significance(feature_type: Literal[VariableType.NUMERIC], target_type: Literal[VariableType.CATEGORICAL], significance_type: SignificanceType) SignificanceNumericCategorical
- cc_tk.relationship.significance.get_significance(feature_type: Literal[VariableType.CATEGORICAL], target_type: Literal[VariableType.NUMERIC], significance_type: SignificanceType) SignificanceCategoricalNumeric
- cc_tk.relationship.significance.get_significance(feature_type: Literal[VariableType.CATEGORICAL], target_type: Literal[VariableType.CATEGORICAL], significance_type: SignificanceType) SignificanceCategoricalCategorical
Get significance function based on variable types and significance type.
- Parameters:
feature_type (VariableType) – Input type of the feature.
target_type (VariableType) – Input type of the target.
significance_type (SignificanceType) – Significance type.
**kwargs – Additional keyword arguments passed to the significance initialization.
- Returns:
Significance instance.
- Return type:
Significance
- Raises:
ValueError – If the feature type and target type are not supported or incompatible with the significance type.
cc_tk.relationship.utils module
Utility functions to perform caracterisation.
- cc_tk.relationship.utils.cut_influence(influence_values: Series) Series[source]
Cut influence values into categories.
Influence values define the impact of a given feature on another one, this function helps categorizing these influences into 6 categories: - –: Strong negative influence. - -: Weak negative influence. - `` or ` : No influence. - `+: Weak positive influence. - ++: Strong positive influence.
- Parameters:
influence_values (pd.Series) – Influence values to cut.
- Returns:
Categorical influence values.
- Return type:
pd.Series
Module contents
relationship module is dedicated to testing statistical relationship.