pcntoolkit.regression_model.test_model#
Classes#
Test model for regression model testing. |
Module Contents#
- class TestModel(name: str, success_ratio: float = 1.0)#
Bases:
pcntoolkit.regression_model.regression_model.RegressionModelTest model for regression model testing.
Initialize the test model.
- Args:
name: The name of the model. success_ratio: The ratio of successful fits.
- backward(X: xarray.DataArray, be: xarray.DataArray, Z: xarray.DataArray) xarray.DataArray#
Compute points in feature space for given z-scores
- Parameters:
X (
xr.DataArray containing covariates)be (
xr.DataArray containing batch effects)Y (
xr.DataArray containing covariates)
- Returns:
Data with Y values derived from Z-scores
- Return type:
xr.DataArray
- elemwise_logp(X: xarray.DataArray, be: xarray.DataArray, Y: xarray.DataArray) xarray.DataArray#
Compute the log-probability of the data under the model.
- fit(X: xarray.DataArray, be: xarray.DataArray, be_maps: dict[str, dict[str, int]], Y: xarray.DataArray) None#
Fit the model to the data.
- Parameters:
X (
xr.DataArray containing covariates)be (
xr.DataArray containing batch effects)be_maps (
dictionaryofdictionaries mapping batch effecttoindices)Y (
xr.DataArray containing covariates)
- Return type:
Nothing
- forward(X: xarray.DataArray, be: xarray.DataArray, Y: xarray.DataArray) xarray.DataArray#
Compute Z-scores for provided Y values
- Parameters:
X (
xr.DataArray containing covariates)be (
xr.DataArray containing batch effects)Y (
xr.DataArray containing covariates)
- Returns:
Data with Z-scores derived from Y values
- Return type:
xr.DataArray
- classmethod from_args(name: str, args: dict) pcntoolkit.regression_model.regression_model.RegressionModel#
Create model instance from arguments dictionary.
Used for instantiating models from the command line.
- Parameters:
- Returns:
New instance of the regression model
- Return type:
RegressionModel- Raises:
NotImplementedError – Must be implemented by concrete subclasses
- classmethod from_dict(my_dict: dict, path: str) pcntoolkit.regression_model.regression_model.RegressionModel#
Create model instance from dictionary representation.
Used for loading models from disk.
- Parameters:
- Returns:
New instance of the regression model
- Return type:
RegressionModel- Raises:
NotImplementedError – Must be implemented by concrete subclasses
- to_dict(path: str | None = None) dict#
Convert model instance to dictionary representation.
Used for saving models to disk.
- Parameters:
path (
str | None, optional) – Path to save any associated files, by default None- Returns:
Dictionary containing model parameters and configuration
- Return type:
- transfer(X: xarray.DataArray, be: xarray.DataArray, be_maps: dict[str, dict[str, int]], Y: xarray.DataArray) pcntoolkit.regression_model.regression_model.RegressionModel#
Transfer the model to a new dataset.
- Parameters:
X (
xr.DataArray containing covariates)be (
xr.DataArray containing batch effects)be_maps (
dictionaryofdictionaries mapping batch effecttoindices)Y (
xr.DataArray containing covariates)
- Returns:
New instance of the regression model, transfered to the new dataset
- Return type:
RegressionModel
- property has_batch_effect: bool#
Check if model includes batch effects.
- Returns:
True if model includes batch effects, False otherwise
- Return type:
- success_ratio = 1.0#