ETA444 / datasafari

DataSafari simplifies complex data science tasks into straightforward, powerful one-liners.
https://datasafari.dev
GNU General Public License v3.0
2 stars 0 forks source link

Write NumPy docstring for hypothesis_predictor_core_c() #94

Closed ETA444 closed 5 months ago

ETA444 commented 5 months ago

Written and accessible:

help(hypothesis_predictor_core_c)

This solution addresses the issue "Write NumPy docstring for hypothesis_predictor_core_c()" by providing a detailed NumPy-style docstring for the hypothesis_predictor_core_c() function.

Summary:

The function hypothesis_predictor_core_c() conducts categorical hypothesis testing using contingency tables and appropriate statistical tests. It assesses the association between two categorical variables by applying a series of statistical tests. The function evaluates the data's suitability for different tests based on the shape of the contingency table, the minimum expected and observed frequencies, and specific methodological preferences, including Yates' correction for chi-square tests and alternatives for exact tests. The docstring follows the NumPy format and includes details on the parameters, return values, exceptions, and examples.

Docstring Sections Preview:

Description

"""
Conducts categorical hypothesis testing using contingency tables and appropriate statistical tests.

This function assesses the association between two categorical variables by applying a series of statistical
tests. It evaluates the data's suitability for different tests based on the shape of the contingency table,
the minimum expected and observed frequencies, and specific methodological preferences, including Yates' correction
for chi-square tests and alternatives for exact tests.
"""

Parameters

"""
Parameters
----------
contingency_table : pd.DataFrame
    A contingency table of the two categorical variables.
chi2_viability : bool
    Indicates whether chi-square tests should be considered based on the data's suitability.
barnard_viability, boschloo_viability, fisher_viability : bool
    Indicators for the applicability of Barnard's, Boschloo's, and Fisher's exact tests, respectively.
yates_correction_viability : bool
    Determines whether Yates' correction is applicable based on the contingency table's shape and sample size.
alternative : str, optional
    Specifies the alternative hypothesis for exact tests. Options include 'two-sided', 'less', or 'greater'.
    Defaults to 'two-sided'.
"""

Returns

"""
Returns
-------
output_info : dict
    A comprehensive dictionary detailing the outcomes of the statistical tests performed, including test names,
    statistics, p-values, and conclusions about the association between the categorical variables. The dictionary
    also contains specific details about the application of Yates' correction and the chosen alternative hypothesis
    for exact tests.
"""

Raises

"""
Raises
------
TypeError
    - If `contingency_table` is not a pandas DataFrame.
    - If `chi2_viability`, `barnard_viability`, `boschloo_viability`, `fisher_viability`, or `yates_correction_viability` is not a boolean.
    - If `alternative` is not a string indicating the alternative hypothesis ('two-sided', 'less', 'greater').
ValueError
    - If the `contingency_table` is empty, indicating that there's no data to evaluate.
    - If the `alternative` specified does not match one of the expected values: 'two-sided', 'less', or 'greater'.
"""