sklearn_rvm.em_rvm
.EMRVR¶
-
class
sklearn_rvm.em_rvm.
EMRVR
(kernel='rbf', degree=3, gamma='auto_deprecated', coef0=0.0, tol=0.001, threshold_alpha=1000000000.0, beta_fixed='not_fixed', alpha_max=10000000000.0, init_alpha=None, bias_used=True, max_iter=5000, compute_score=False, epsilon=1e-08, verbose=False)[source]¶ Relevance Vector Regressor.
Implementation of the relevance vector regressor using the algorithm based on expectation maximization.
- Parameters
- kernelstring, optional (default=”rbf”)
Specifies the kernel type to be used in the algorithm. It must be one of “linear”, “poly”, “rbf”, “sigmoid” or “precomputed”. If none is given, “rbf” will be used.
- degreeint, optional (default=3)
Degree of the polynomial kernel function (“poly”). Ignored by all other kernels.
- gamma{“auto”, “scale”} or float, optional (default=”auto”)
Kernel coefficient for “rbf”, “poly” and “sigmoid”.
Current default is “auto” which uses 1 / n_features, if
gamma="scale"
is passed then it uses 1 / (n_features * X.var()) as value of gamma.- coef0float, optional (default=0.0)
Independent term in kernel function. It is only significant in “poly” and “sigmoid”.
- tolfloat, optional (default=1e-6)
Tolerance for stopping criterion.
- threshold_alphafloat, optional (default=1e5)
Threshold for alpha selection criterion.
- beta_fixed{“not_fixed”} or float, optional (default=”not_fixed”)
Fixed value for beta. If “not_fixed” selected, the beta is updated at each iteration.
- alpha_maxint, optional (default=1e9)
Basis functions associated with alpha value beyond this limit will be purged. Must be a positive and big number.
- init_alphaarray-like of shape (n_sample) or None, optional (default=None)
Initial value for alpha. If None is selected, the initial value of alpha is defined by init_alpha = 1 / M ** 2.
- bias_usedboolean, optional (default=False)
Specifies if a constant (a.k.a. bias) should be added to the decision function.
- max_iterint, optional (default=5000)
Hard limit on iterations within solver.
- compute_scoreboolean, optional (default=False)
Specifies if the objective function is computed at each step of the model.
- verboseboolean, optional (default=False)
Enable verbose output.
See also
EMRVC
Relevant Vector Machine for Classification.
Notes
References: The relevance vector machine.
- Attributes
- relevance_array-like, shape (n_relevance)
Indices of relevance vectors.
- relevance_vectors_array-like, shape (n_relevance, n_features)
Relevance vectors (equivalent to X[relevance_]).
- alpha_array-like, shape (n_samples)
Estimated alpha values.
- gamma_array-like, shape (n_samples)
Estimated gamma values.
- Phi_array-like, shape (n_samples, n_features)
Estimated phi values.
- Sigma_array-like, shape (n_samples, n_features)
Estimated covariance matrix of the weights.
- mu_array-like, shape (n_relevance, n_features)
Coefficients of the regression model (mean of posterior distribution)
- coef_array, shape (n_class * (n_class-1) / 2, n_features)
Coefficients of the regression model (mean of posterior distribution). Weights assigned to the features. This is only available in the case of a linear kernel.
coef_
is a readonly property derived frommu
andrelevance_vectors_
.
Methods
compute_marginal_likelihood
(self, upper_inv, …)Calculate marginal likelihood.
fit
(self, X, y)Fit the RVR model according to the given training data.
get_params
(self[, deep])Get parameters for this estimator.
predict
(self, X[, return_std])Predict using the RVR model.
score
(self, X, y[, sample_weight])Return the coefficient of determination R^2 of the prediction.
set_params
(self, \*\*params)Set the parameters of this estimator.
-
__init__
(self, kernel='rbf', degree=3, gamma='auto_deprecated', coef0=0.0, tol=0.001, threshold_alpha=1000000000.0, beta_fixed='not_fixed', alpha_max=10000000000.0, init_alpha=None, bias_used=True, max_iter=5000, compute_score=False, epsilon=1e-08, verbose=False)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
compute_marginal_likelihood
(self, upper_inv, ed, n_samples, y)[source]¶ Calculate marginal likelihood.
-
fit
(self, X, y)[source]¶ Fit the RVR model according to the given training data.
- Parameters
- Xarray-like, shape (n_samples, n_features)
Training vectors.
- yarray-like, shape (n_samples,)
Target values.
- Returns
- selfobject
-
get_params
(self, deep=True)[source]¶ Get parameters for this estimator.
- Parameters
- deepbool, default=True
If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns
- paramsmapping of string to any
Parameter names mapped to their values.
-
predict
(self, X, return_std=False)[source]¶ Predict using the RVR model.
In addition to the mean of the predictive distribution, its standard deviation can also be returned.
- Parameters
- Xarray-like, shape (n_samples, n_features)
Query points to be evaluate.
- return_stdbool, optional (default=False)
If True, the standard-deviation of the predictive distribution at the query points is returned along with the mean.
- Returns
- y_meanarray, shape (n_samples, n_output_dims)
Mean of predictive distribution at query points
- y_stdarray, shape (n_samples,), optional
Standard deviation of predictive distribution at query points. Only returned when return_std is True.
-
score
(self, X, y, sample_weight=None)[source]¶ Return the coefficient of determination R^2 of the prediction.
The coefficient R^2 is defined as (1 - u/v), where u is the residual sum of squares ((y_true - y_pred) ** 2).sum() and v is the total sum of squares ((y_true - y_true.mean()) ** 2).sum(). The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a R^2 score of 0.0.
- Parameters
- Xarray-like of shape (n_samples, n_features)
Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead, shape = (n_samples, n_samples_fitted), where n_samples_fitted is the number of samples used in the fitting for the estimator.
- yarray-like of shape (n_samples,) or (n_samples, n_outputs)
True values for X.
- sample_weightarray-like of shape (n_samples,), default=None
Sample weights.
- Returns
- scorefloat
R^2 of self.predict(X) wrt. y.
Notes
The R2 score used when calling
score
on a regressor will usemultioutput='uniform_average'
from version 0.23 to keep consistent withr2_score
. This will influence thescore
method of all the multioutput regressors (except forMultiOutputRegressor
). To specify the default value manually and avoid the warning, please either callr2_score
directly or make a custom scorer withmake_scorer
(the built-in scorer'r2'
usesmultioutput='uniform_average'
).
-
set_params
(self, **params)[source]¶ Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form
<component>__<parameter>
so that it’s possible to update each component of a nested object.- Parameters
- **paramsdict
Estimator parameters.
- Returns
- selfobject
Estimator instance.