Skip to content

MeanComparison

MeanComparison

The function conducts a test to compare means of two samples. It implies both parametric t-test and non-parametric Kruskal-Wallis H-test.

Parameters:

  • x_train_0: pd.Series()
    A pd.Series of a feature of 0 group.
  • x_train_1: pd.Series()
    A pd.Series of a feature of 2 group.
  • equal_var: bool, optional, default = False
    An indicator of the assumption of equal variance.
  • alternative: str, {'two-sided', 'less', 'greater'}, optional, default = 'two-sided'
    Type of alternative hypothesis.

Returns:

  • final_data: dict
  • Keys: ttest
    kruskal
  • Values: tt: tuple(statistic, pvalue) - results of conducted t-test.
    kruskal: tuple(statistic, pvalue) - results of conducted Kruskal-Wallis H-test.

Exceptions:

  • TypeError:
    Raised if x_train_0 parameter is not a pd.Series.
    Raised if x_train_1 parameter is not a pd.Series.
    Raised if equal_var parameter is not logical.

  • ValueError:
    Raised if alternative parameter is not in ('two-sided', 'less', 'greater').

Example:

import pandas as pd
from combat.short_list import MeanComparison

# Sample input data
x_train_0 = pd.Series([1, 2, 3, 4, 5])
x_train_1 = pd.Series([6, 7, 8, 9, 10])
equal_var = False
alternative = 'two-sided'

# Perform mean comparison
result = MeanComparison(x_train_0, x_train_1, equal_var, alternative)
print(result)