pub struct PyBayesianRidge { /* private fields */ }Expand description
Bayesian ridge regression.
Fit a Bayesian ridge model. See the Notes section for details on this implementation and the optimization of the regularization parameters lambda (precision of the weights) and alpha (precision of the noise).
§Parameters
max_iter : int, default=300 Maximum number of iterations. Should be greater than or equal to 1.
tol : float, default=1e-3 Stop the algorithm if w has converged.
alpha_init : float, default=1.0 Initial value for alpha (precision of the weights). If not provided, alpha_init is set to 1.0.
lambda_init : float, default=1.0 Initial value for lambda (precision of the noise). If not provided, lambda_init is set to 1.0.
fit_intercept : bool, default=True Whether to calculate the intercept for this model. The intercept is not treated as a probabilistic parameter and thus has no associated variance. If set to False, no intercept will be used in calculations (i.e. data is expected to be centered).
compute_score : bool, default=False If True, compute the log marginal likelihood at each iteration of the optimization.
copy_X : bool, default=True If True, X will be copied; else, it may be overwritten.
§Attributes
coef_ : array-like of shape (n_features,) Coefficients of the regression model (mean of distribution)
intercept_ : float
Independent term in decision function. Set to 0.0 if
fit_intercept = False.
alpha_ : float Estimated precision of the weights.
lambda_ : float Estimated precision of the noise.
sigma_ : array-like of shape (n_features, n_features) Estimated variance-covariance matrix of the weights
scores_ : array-like of shape (n_iter_ + 1,) If computed_score is True, value of the log marginal likelihood (to be maximized) at each iteration of the optimization. The array starts with the value of the log marginal likelihood obtained for the initial values of alpha and lambda and ends with the value obtained for the estimated alpha and lambda.
n_iter_ : int The actual number of iterations to reach the stopping criterion.
n_features_in_ : int Number of features seen during fit.
§Examples
from sklears_python import BayesianRidge import numpy as np X = np.array([[1, 1], [1, 2], [2, 2], [2, 3]])
§y = 1 * x_0 + 2 * x_1 + 3
y = np.dot(X, [1, 2]) + 3 reg = BayesianRidge() reg.fit(X, y) BayesianRidge() reg.predict([[1, 0]]) array([4.]) reg.coef_ array([1., 2.])
§Notes
There exist several strategies to perform Bayesian ridge regression. This implementation is based on the algorithm described in Appendix A of (Tipping, 2001) where updates of the regularization parameters are done as suggested in (MacKay, 1992). Note that according to A New View of Automatic Relevance Determination (Wipf and Nagarajan, 2008) these update rules do not guarantee that the marginal likelihood is increasing between two consecutive iterations of the optimization.
§References
D. J. C. MacKay, Bayesian Interpolation, Computation and Neural Systems, Vol. 4, No. 3, 1992.
M. E. Tipping, Sparse Bayesian Learning and the Relevance Vector Machine, Journal of Machine Learning Research, Vol. 1, 2001.
Trait Implementations§
Source§impl<'py> IntoPyObject<'py> for PyBayesianRidge
impl<'py> IntoPyObject<'py> for PyBayesianRidge
Source§type Target = PyBayesianRidge
type Target = PyBayesianRidge
Source§type Output = Bound<'py, <PyBayesianRidge as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <PyBayesianRidge as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl PyClass for PyBayesianRidge
impl PyClass for PyBayesianRidge
Source§impl PyClassImpl for PyBayesianRidge
impl PyClassImpl for PyBayesianRidge
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§type ThreadChecker = SendablePyClass<PyBayesianRidge>
type ThreadChecker = SendablePyClass<PyBayesianRidge>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyClassNewTextSignature<PyBayesianRidge> for PyClassImplCollector<PyBayesianRidge>
impl PyClassNewTextSignature<PyBayesianRidge> for PyClassImplCollector<PyBayesianRidge>
fn new_text_signature(self) -> Option<&'static str>
Source§impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a PyBayesianRidge
impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a PyBayesianRidge
Source§impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a mut PyBayesianRidge
impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a mut PyBayesianRidge
Source§impl PyMethods<PyBayesianRidge> for PyClassImplCollector<PyBayesianRidge>
impl PyMethods<PyBayesianRidge> for PyClassImplCollector<PyBayesianRidge>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for PyBayesianRidge
impl PyTypeInfo for PyBayesianRidge
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
Source§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
impl DerefToPyAny for PyBayesianRidge
Auto Trait Implementations§
impl Freeze for PyBayesianRidge
impl RefUnwindSafe for PyBayesianRidge
impl Send for PyBayesianRidge
impl Sync for PyBayesianRidge
impl Unpin for PyBayesianRidge
impl UnwindSafe for PyBayesianRidge
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
Source§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self into an owned Python object, dropping type information.