sklearn_rvm.em_rvm
.EMRVC¶
-
class
sklearn_rvm.em_rvm.
EMRVC
(n_iter_posterior=50, 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 Classifier.
Implementation of Mike Tipping”s Relevance Vector Machine for classification using the scikit-learn API.
The multiclass support is handled according to a one-vs-rest scheme.
For details on the precise mathematical formulation of the provided kernel functions and how
gamma
,coef0
anddegree
affect each other, see the corresponding section in the narrative documentation: Kernel functions.- Parameters
- n_iter_posteriorint, optional (default=50)
Number of iterations to calculate posterior.
- 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.
- gammafloat, 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. The current default of gamma, “auto”, will change to “scale” in version 0.22. “auto_deprecated”, a deprecated version of “auto” is used as a default indicating that no explicit value of gamma was passed.- 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
EMRVR
Relevant Vector Machine for Regression.
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 classifier (mean of posterior distribution)
- coef_array, shape (n_class * (n_class-1) / 2, n_features)
Coefficients of the classfier (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
fit
(self, X, y)Fit the RVC model according to the given training data.
get_params
(self[, deep])Get parameters for this estimator.
predict
(self, X)Predict using the RVC model.
predict_proba
(self, X)Return an array of class probabilities.
score
(self, X, y[, sample_weight])Return the mean accuracy on the given test data and labels.
set_params
(self, \*\*params)Set the parameters of this estimator.
-
__init__
(self, n_iter_posterior=50, 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.
-
fit
(self, X, y)[source]¶ Fit the RVC 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)[source]¶ Predict using the RVC 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.
- Returns
- resultsarray, shape = (n_samples, [n_output_dims])
Mean of predictive distribution at query points
-
score
(self, X, y, sample_weight=None)[source]¶ Return the mean accuracy on the given test data and labels.
In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.
- Parameters
- Xarray-like of shape (n_samples, n_features)
Test samples.
- yarray-like of shape (n_samples,) or (n_samples, n_outputs)
True labels for X.
- sample_weightarray-like of shape (n_samples,), default=None
Sample weights.
- Returns
- scorefloat
Mean accuracy of self.predict(X) wrt. y.
-
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.