Skip to content

Commit

Permalink
Bump version to 0.5.1; update metric name formatting in bootstrap_ccr…
Browse files Browse the repository at this point in the history
…am and permutation_test_ccram functions for clarity; enhance tests to reflect changes
  • Loading branch information
DhyeyMavani2003 committed Jan 30, 2025
1 parent 0d856fc commit 96d1256
Show file tree
Hide file tree
Showing 7 changed files with 413 additions and 349 deletions.
2 changes: 1 addition & 1 deletion discopula/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
permutation_test_ccram,
)

__version__ = "0.5.0"
__version__ = "0.5.1"
__all__ = [
"GenericCheckerboardCopula",
"gen_contingency_to_case_form",
Expand Down
19 changes: 10 additions & 9 deletions discopula/checkerboard/gencopula.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,36 +345,37 @@ def get_category_predictions_multi(

return result

def calculate_scores(self, axis):
"""Calculate checkerboard scores for the specified axis.
def calculate_scores(self, var_index):
"""Calculate checkerboard scores for the specified variable index.
Parameters
----------
axis : int
var_index : int
1-Indexed axis of the variable for which to calculate scores
Returns
-------
numpy.ndarray
Array containing checkerboard scores for the given axis
"""
parsed_axis = axis - 1
parsed_axis = var_index - 1
return self.scores[parsed_axis]

def calculate_variance_S(self, axis):
"""Calculate the variance of score S for the specified axis.
def calculate_variance_S(self, var_index):
"""Calculate the variance of score S for the specified variable index.
Parameters
----------
axis : int
Index of the axis for which to calculate variance
var_index : int
1-Indexed axis of the variable for which to calculate variance
Returns
-------
float
Variance of score S for the given axis
"""
return self._calculate_sigma_sq_S_vectorized(axis)
parsed_axis = var_index - 1
return self._calculate_sigma_sq_S_vectorized(parsed_axis)

def _calculate_conditional_pmf(self, target_axis, given_axes):
"""Helper Function: Calculate conditional PMF P(target|given)."""
Expand Down
9 changes: 5 additions & 4 deletions discopula/checkerboard/genstatsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def bootstrap_ccram(contingency_table: np.ndarray,
predictors = [predictors]

# Format metric name
predictors_str = ",".join(map(str, predictors))
metric_name = f"{'SCCRAM' if scaled else 'CCRAM'} ({predictors_str})->{response}"
predictors_str = ",".join(f"X{i}" for i in predictors)
metric_name = f"{'SCCRAM' if scaled else 'CCRAM'} ({predictors_str}) to X{response}"

# Calculate observed value
gen_copula = GenericCheckerboardCopula.from_contingency_table(contingency_table)
Expand Down Expand Up @@ -439,8 +439,9 @@ def permutation_test_ccram(contingency_table: np.ndarray,
parsed_predictors.append(pred_axis - 1)
parsed_response = response - 1

predictors_str = ",".join(map(str, predictors))
metric_name = f"{'SCCRAM' if scaled else 'CCRAM'} ({predictors_str})->{response}"
# Format metric name
predictors_str = ",".join(f"X{i}" for i in predictors)
metric_name = f"{'SCCRAM' if scaled else 'CCRAM'} ({predictors_str}) to X{response}"

cases = gen_contingency_to_case_form(contingency_table)
source_data = [cases[:, axis] for axis in parsed_predictors]
Expand Down
Loading

0 comments on commit 96d1256

Please sign in to comment.