API reference#
CompositeKernel#
- class svdynamics.CompositeKernel(kernels: Sequence[KernelSpec], weights: Sequence[float] | None = None, normalize: bool = True, eps: float = 1e-12)[source]#
Bases:
objectWeighted combination of multiple base kernels.
K(X, Y) = sum_m w_m * K_m(X, Y)
Parameters#
- kernels:
Sequence of kernel specifications. Each element can be:
“rbf”, “linear”, “poly”, or “sigmoid”
(“rbf”, {“gamma”: 0.1}), etc.
callable kernel(X, Y) -> ndarray
- weights:
Optional weights for the kernels. If None, uniform weights are used. Weights are normalized to sum to 1.
- normalize:
If True, each base kernel is rescaled using a scalar derived from K(X, X).
- eps:
Small constant used for numerical stability.
- as_callable() Callable[[ndarray, ndarray], ndarray][source]#
Return the composite kernel as a callable.
- fit_scales(X: ndarray) CompositeKernel[source]#
Compute and store per-kernel normalization scales from training data.
Once stored, every later call uses these scales, so a point’s kernel values (and the model’s predictions) do not depend on which other points are passed alongside it.
- min_eigenvalues(X: ndarray) ndarray[source]#
Smallest eigenvalue of each base kernel’s Gram matrix on X.
Optional diagnostic for positive semidefiniteness (PSD). A valid kernel gives values >= 0 up to rounding (about -1e-8 relative to the largest eigenvalue). Sigmoid kernels are not PSD in general and may return clearly negative values. Cost is O(n^3) per kernel, so use a subsample for large X.
AdaptiveCompositeKernel#
- class svdynamics.AdaptiveCompositeKernel(kernels: Sequence[KernelSpec], weights: Sequence[float] | None = None, normalize: bool = True, eps: float = 1e-12)[source]#
Bases:
CompositeKernelComposite kernel with weights learned from training data.
Kernel weights are estimated using normalized kernel-target alignment.
Parameters#
- kernels:
Sequence of kernel specifications.
- weights:
Initial kernel weights. These are replaced by learned weights when fit() is called.
- normalize:
If True, rescale individual kernels when constructing the composite kernel.
- eps:
Small constant used for numerical stability.
- fit(X: ndarray, y: ndarray) AdaptiveCompositeKernel[source]#
Learn kernel weights from training data.
SVDClassifier#
- class svdynamics.SVDClassifier(C: float = 1.0, kernel: KernelArg = 'rbf', degree: int = 3, gamma: str | float = 'scale', coef0: float = 0.0, shrinking: bool = True, probability: bool = False, tol: float = 0.001, cache_size: float = 200.0, class_weight: Dict[Any, float] | None = None, verbose: bool = False, max_iter: int = -1, decision_function_shape: str = 'ovr', break_ties: bool = False, random_state: int | None = None)[source]#
Bases:
BaseEstimator,ClassifierMixinSVC wrapper supporting fixed and adaptive composite kernels.
- fit(X: ndarray, y: ndarray) SVDClassifier[source]#
- kernel: str | CompositeKernel | Any = 'rbf'#
- property predict_log_proba#
Available only when probability estimation is enabled.
- property predict_proba#
Available only when probability estimation is enabled.
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') SVDClassifier#
Request metadata passed to the
scoremethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline. Otherwise it has no effect.Parameters#
- sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
sample_weightparameter inscore.
Returns#
- selfobject
The updated object.
SVDRegressor#
- class svdynamics.SVDRegressor(C: float = 1.0, kernel: KernelArg = 'rbf', degree: int = 3, gamma: str | float = 'scale', coef0: float = 0.0, tol: float = 0.001, epsilon: float = 0.1, shrinking: bool = True, cache_size: float = 200.0, verbose: bool = False, max_iter: int = -1)[source]#
Bases:
BaseEstimator,RegressorMixinSVR wrapper supporting fixed composite kernels.
- fit(X: ndarray, y: ndarray) SVDRegressor[source]#
- kernel: str | CompositeKernel | Any = 'rbf'#
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') SVDRegressor#
Request metadata passed to the
scoremethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline. Otherwise it has no effect.Parameters#
- sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
sample_weightparameter inscore.
Returns#
- selfobject
The updated object.