Skip to content

mpd

sgp.models.mpd.Optimizers module-attribute

Optimizers = Literal['Scipy-LBFGSB', 'Scipy-NelderMead', 'Scipy-Powell', 'Scipy-TNC', 'SKO-DE', 'SKO-GA', 'SKO-PSO', 'SKO-SA', 'SKO-AFSA']

sgp.models.mpd.config module-attribute

config = Config(verbose=lower() in trues, password=get('SGP_PASSWORD', ''), numba_enabled=get('NUMBA_DISABLE_JIT', '0') == '0', language=value('language', name()))

sgp.models.mpd.distributions module-attribute

distributions = dict(su=johnsonsu, sb=johnsonsb, sl=lognorm)

sgp.models.mpd.registry module-attribute

sgp.models.mpd.DistributionResult

Bases: HashableBaseModelIO

Result of a distribution prediction.

sgp.models.mpd.HashableBaseModelIO

Bases: BaseModel

Input/output utilities for the models with support for the following features:

  • Hashing of the model
  • Conversion to and from dictionaries, json, toml, and yaml files
  • Compatibility with pydantic v1 and v2

sgp.models.mpd.HashableBaseModelIO.exclude property

exclude: set[int] | set[str] | dict[int, Any] | dict[str, Any] | None

Fields to exclude from the model, typically used to exclude arbitrary types when it is allowed in the pydantic model to avoid hashing issues.

sgp.models.mpd.HashableBaseModelIO.__hash__

__hash__() -> int

Return the hash of the model.

sgp.models.mpd.HashableBaseModelIO.fromBytes classmethod

fromBytes(*, binary: bytes | None = None, path: str | None = None, **kwargs) -> Self

Load the model from a binary string or file if a path is provided.

sgp.models.mpd.HashableBaseModelIO.fromCryptography classmethod

fromCryptography(*, binary: bytes | None = None, path: str | None = None, **kwargs) -> Self

Decrypt the model using the key.

sgp.models.mpd.HashableBaseModelIO.fromDict classmethod

fromDict(*, data: dict, **kwargs) -> Self

Load the model from a dictionary.

sgp.models.mpd.HashableBaseModelIO.fromJson classmethod

fromJson(*, string: str | None = None, path: str | None = None, **kwargs)

Load the model from a json string or file if a path is provided.

sgp.models.mpd.HashableBaseModelIO.fromToml classmethod

fromToml(*, string: str | None = None, path: str | None = None, **kwargs)

Load the model from a toml string or file if a path is provided.

sgp.models.mpd.HashableBaseModelIO.fromYaml classmethod

fromYaml(*, string: str | None = None, path: str | None = None, **kwargs)

Load the model from a yaml string or file if a path is provided.

sgp.models.mpd.HashableBaseModelIO.toBytes

toBytes(path: Path | str | None = None, **kwargs) -> bytes | None

Convert the model to a binary string or save it to a file if a path is provided.

sgp.models.mpd.HashableBaseModelIO.toCryptography

toCryptography(path: Path | str | None = None, **kwargs) -> bytes | None

Encrypt the model using the key.

sgp.models.mpd.HashableBaseModelIO.toDict

toDict(**kwargs) -> dict

Convert the model to a dictionary.

sgp.models.mpd.HashableBaseModelIO.toJson

toJson(path: Path | str | None = None, **kwargs) -> str | None

Convert the model to a json string or save it to a file if a path is provided.

sgp.models.mpd.HashableBaseModelIO.toToml

toToml(path: Path | str | None = None, **kwargs) -> str | None

Convert the model to a toml string or save it to a file if a path is provided.

sgp.models.mpd.HashableBaseModelIO.toYaml

toYaml(path: Path | str | None = None, **kwargs) -> str | None

Convert the model to a yaml string or save it to a file if a path is provided.

sgp.models.mpd.HashableBaseModelIO.update

update(data: dict = None, **kwargs) -> Self

Update the options of the optimizer

sgp.models.mpd.Johnson

Bases: HashableBaseModelIO

Johnson distribution model.

sgp.models.mpd.Johnson.X2Y classmethod

X2Y(X: ArrayLike | Number, type: Literal['su', 'sb', 'sl'], aX: float, bX: float, aY: float, bY: float) -> ndarray | Number

Denormalize the data from the Johnson distribution.

sgp.models.mpd.Johnson.Y2X classmethod

Y2X(Y: ArrayLike | Number, type: Literal['su', 'sb', 'sl'], aX: float, bX: float, aY: float, bY: float) -> ndarray | Number

Normalize the data to the Johnson distribution.

sgp.models.mpd.Johnson.__call__

__call__(z: Sequence[float], data: ArrayLike) -> float

Calculate the fitness of the Johnson distribution.

sgp.models.mpd.Johnson.dist classmethod

dist(type: Literal['su', 'sb', 'sl'], aX: float, bX: float, aY: float, bY: float, mu: float = 0.0, sigma: float = 1.0) -> Tuple[rv_continuous, Tuple, Dict[str, ...]]

Get the distribution object and distribution parameters.

sgp.models.mpd.Johnson.fit

fit(data: ArrayLike, z: float) -> Tuple[Literal['su', 'sb', 'sl'], float, float, float, float]

Fit the Johnson distribution to the data.

sgp.models.mpd.Johnson.fitness

fitness(z: Sequence[float], data: ArrayLike) -> float

Calculate the fitness of the Johnson distribution.

sgp.models.mpd.Johnson.kstest_pvalue

kstest_pvalue(z: Sequence[float], data: ArrayLike) -> float

Calculate the p-value of the Johnson distribution.

sgp.models.mpd.Johnson.kstest_statistic

kstest_statistic(z: Sequence[float], data: ArrayLike) -> float

Calculate the statistic of the Johnson distribution.

sgp.models.mpd.MPD

Bases: PredictionBase

Multivariate Distribution (MPD) model.

sgp.models.mpd.MPD.corr_bootstrap

corr_bootstrap(X: ndarray) -> ndarray

Calculate the correlation matrix.

sgp.models.mpd.MPD.dist

Get the distributional results.

sgp.models.mpd.MPD.fit

fit()

Fit the Johnson distribution to the data.

RETURNS DESCRIPTION
A tuple containing the distributions, the optimization results, the statistics, and the p-values.

sgp.models.mpd.MPD.optimize

optimize(df: DataFrame, *, method: Optimizers, **kwargs)

Optimize the z-value for the Johnson distribution.

sgp.models.mpd.MPDConditionalResult

sgp.models.mpd.MPDDistributionalResult

Bases: HashableBaseModelIO

sgp.models.mpd.MPDDistributionalResult.dist property

dist: Tuple[Literal['su', 'sb', 'sl'], float, float, float, float]

Get the distribution parameters.

sgp.models.mpd.MPDDistributionalResults

Bases: HashableBaseModelIO

sgp.models.mpd.MPDDistributionalResults.C property

Get the correlation matrix.

sgp.models.mpd.MPDDistributionalResults.X property

Get the normalized data from the Johnson distribution.

sgp.models.mpd.MPDDistributionalResults.Y property

Get the converted data for Johnson fitting.

sgp.models.mpd.MPDDistributionalResults.Y0 property

Y0: ndarray

Get the original data.

sgp.models.mpd.OptimizerResult

Bases: HashableBaseModelIO

OptimizeResult for the optimizers

sgp.models.mpd.PredictionBase

Bases: HashableBaseModelIO

Base class for prediction models.

sgp.models.mpd.PredictionBase.predict abstractmethod

predict(**inputs: float) -> Dict[str, float | HashableBaseModelIO]

Predict the output from the input.

sgp.models.mpd.corr_bootstrap

corr_bootstrap(X: ndarray, bootstraps: int = 1000) -> ndarray

Calculate the bootstrapping correlation matrix.

sgp.models.mpd.hashkey

hashkey(*args, **kwargs)

Return a cache key for the specified hashable arguments, convert non-hashable arguments to hashable ones.

sgp.models.mpd.timing

timing(func: Callable = None, *, target: Callable[[str], Any] = print)

Print the time taken for a function to execute.

PARAMETER DESCRIPTION
func

Function to be timed, by default None

TYPE: Callable DEFAULT: None

target

Function to print the timing information, by default print

TYPE: Callable[[str], Any] DEFAULT: print