CPM Regression
CPMRegression
This class handles the process of performing CPM Regression with cross-validation and permutation testing.
__init__(results_directory, cv=KFold(n_splits=10, shuffle=True, random_state=42), inner_cv=None, edge_selection=UnivariateEdgeSelection(edge_statistic=['pearson'], edge_selection=[PThreshold(threshold=[0.05], correction=[None])]), select_stable_edges=True, stability_threshold=0.8, impute_missing_values=True, n_permutations=0, atlas_labels=None)
Initialize the CPMRegression object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
results_directory
|
str
|
Directory to save results. |
required |
cv
|
Union[BaseCrossValidator, BaseShuffleSplit]
|
Outer cross-validation strategy. |
KFold(n_splits=10, shuffle=True, random_state=42)
|
inner_cv
|
Union[BaseCrossValidator, BaseShuffleSplit]
|
Inner cross-validation strategy for edge selection. |
None
|
edge_selection
|
UnivariateEdgeSelection
|
Method for edge selection. |
UnivariateEdgeSelection(edge_statistic=['pearson'], edge_selection=[PThreshold(threshold=[0.05], correction=[None])])
|
impute_missing_values
|
bool
|
Whether to impute missing values. |
True
|
n_permutations
|
int
|
Number of permutations to run for permutation testing. |
0
|
atlas_labels
|
str
|
CSV file containing atlas and regions labels. |
None
|
calculate_p_values(true_results, perms)
staticmethod
Calculate p-values based on true results and permutation results.
:param true_results: DataFrame with the true results. :param perms: DataFrame with the permutation results. :return: DataFrame with the calculated p-values.
estimate(X, y, covariates)
Estimates a model using the provided data and conducts permutation testing. This method first fits the model to the actual data and subsequently performs estimation on permuted data for a specified number of permutations. Finally, it calculates permutation results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
Union[DataFrame, ndarray]
|
|
required |
y
|
Union[Series, DataFrame, ndarray]
|
|
required |
covariates
|
Union[Series, DataFrame, ndarray]
|
|
required |
load_configuration(results_directory, config_filename)
Load configuration from a file.
:param results_directory: Directory to set for results. :param config_filename: Path to the configuration file.
save_configuration(config_filename)
Saves the current configuration settings to a file in Pickle format. All attributes related to the configuration of the object are serialized and stored in a file with the same base name as the provided filename, but with a .pkl extension.
:param config_filename: The base name of the file where the configuration will be saved. :return: None