scikit-learn 1.3. Kernel ridge regression
来源:互联网 发布:股票买卖软件 编辑:程序博客网 时间:2024/05/21 13:34
核岭回归是结合岭回归(线性最小二乘L2范数正则化)与内核的技巧。因此,它在各自的内核和数据中学习空间中的线性函数。对于非线性核,这对应于原始空间中的非线性函数。
学习KernelRidge模式的形成是支持向量回归(SVR)相同。然而,使用不同的损失函数:KRR采用平方误差损失而支持向量回归使用\ε不敏感损失,两者结合L2正则化。相反,SVR,拟合kernelridge可以在封闭的形式完成,通常是更快的为中型数据集。另一方面,学习的模型是不稀疏的,因此比SVR慢,在预测时刻学习的稀疏模型
下面的图比较KernelRidge与SVR在人工数据集,它由一个正弦目标函数和强噪声添加到每第五个数据点。获悉KernelRidge模型和SVR的策划,其中的复杂性/正则化和带宽的RBF核已经使用网格搜索优化。学习功能非常相似;然而,拟合KernelRidge是约七倍的速度拟合SVR(都用网格搜索)。然而,100000的目标值的预测是三倍以上速度与SVR已经学到了稀疏模型只使用约1 / 3的100个训练数据作为支持向量。
下图比较了不同大小的训练集的拟合和kernelridge和SVR预测时间。Fitting KernelRidge比SVR中训练集的速度(小于1000份);然而,对于更大的训练集的SVR的尺度更好。关于时间的预测,SVR比所有尺寸的训练集KernelRidge更快因为学到的稀溶液。注意稀疏度和预测时间取决于SVR的参数ε和c;ε=0对应稠密模型
sklearn.kernel_ridge
.KernelRidge
sklearn.kernel_ridge.
KernelRidge
(alpha=1, kernel='linear', gamma=None, degree=3, coef0=1, kernel_params=None)[source]Kernel ridge regression 核岭回归.
Read more in the User Guide.
alpha : {float, array-like}, shape = [n_targets]
Small positive values of alpha improve the conditioning of the problem and reduce the variance of the estimates. Alpha corresponds to
(2*C)^-1
in other linear models such as LogisticRegression or LinearSVC. If an array is passed, penalties are assumed to be specific to the targets. Hence they must correspond in number.更小的正值参数alpha可以提升模型训练效果,并且可以减少训练误差。 这里的alpha为 (2*C)^-1,等同于逻辑回归和线性SVC等其他线性模型减少误差参数的效果,如果一个数组被传递,则假定惩罚是特定于目标的。因此它们必须在数量上相对应。
kernel : string or callable, default=”linear”
Kernel mapping used internally. A callable should accept two arguments and the keyword arguments passed to this object as kernel_params, and should return a floating point number.
gamma : float, default=None
Gamma parameter for the RBF, laplacian, polynomial, exponential chi2 and sigmoid kernels. Interpretation of the default value is left to the kernel; see the documentation for sklearn.metrics.pairwise. Ignored by other kernels.
degree : float, default=3
Degree of the polynomial kernel. Ignored by other kernels.
coef0 : float, default=1
Zero coefficient for polynomial and sigmoid kernels. Ignored by other kernels.
kernel_params : mapping of string to any, optional
Additional parameters (keyword arguments) for kernel function passed as callable object.
dual_coef_ : array, shape = [n_samples] or [n_samples, n_targets]
Representation of weight vector(s) in kernel space
X_fit_ : {array-like, sparse matrix}, shape = [n_samples, n_features]
Training data, which is also required for prediction
See also
Ridge
- Linear ridge regression.
SVR
- Support Vector Regression implemented using libsvm.
References
- Kevin P. Murphy “Machine Learning: A Probabilistic Perspective”, The MIT Press chapter 14.4.3, pp. 492-493
Examples
Methods
fit
(X[, y, sample_weight])Fit Kernel Ridge regression modelget_params
([deep])Get parameters for this estimator.predict
(X)Predict using the kernel ridge modelscore
(X, y[, sample_weight])Returns the coefficient of determination R^2 of the prediction.set_params
(\*\*params)Set the parameters of this estimator.__init__
(alpha=1, kernel='linear', gamma=None, degree=3, coef0=1, kernel_params=None)[source]
fit
(X, y=None, sample_weight=None)[source]Fit Kernel Ridge regression model
Parameters: X : {array-like, sparse matrix}, shape = [n_samples, n_features]
Training data
y : array-like, shape = [n_samples] or [n_samples, n_targets]
Target values
sample_weight : float or numpy array of shape [n_samples]
Individual weights for each sample, ignored if None is passed.
Returns: self : returns an instance of self.
get_params
(deep=True)[source]Get parameters for this estimator.
Parameters: deep : boolean, optional
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns: params : mapping of string to any
Parameter names mapped to their values.
predict
(X)[source]Predict using the kernel ridge model
Parameters: X : {array-like, sparse matrix}, shape = [n_samples, n_features]
Samples.
Returns: C : array, shape = [n_samples] or [n_samples, n_targets]
Returns predicted values.
score
(X, y, sample_weight=None)[source]Returns the coefficient of determination R^2 of the prediction.
The coefficient R^2 is defined as (1 - u/v), where u is the regression sum of squares ((y_true - y_pred) ** 2).sum() and v is the residual sum of squares ((y_true - y_true.mean()) ** 2).sum(). 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: X : array-like, shape = (n_samples, n_features)
Test samples.
y : array-like, shape = (n_samples) or (n_samples, n_outputs)
True values for X.
sample_weight : array-like, shape = [n_samples], optional
Sample weights.
Returns: score : float
R^2 of self.predict(X) wrt. y.
set_params
(**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.Returns: self :
- scikit-learn 1.3. Kernel ridge regression
- scikit-learn : Bayesian Ridge Regression
- scikit-learn学习:岭回归,ridge regression
- scikit-learn 岭回归 ridge regression
- scikit-learn学习笔记(四)Ridge Regression ( 岭回归 )
- scikit-learn : Logistic Regression
- 核岭回归 Kernel Ridge Regression
- scikit-learn中几种regression算法
- ridge regression
- Ridge Regression
- Ridge regression
- ridge regression
- scikit-learn:4.6. Kernel Approximation
- sklearn浅析(六)——Kernel Ridge Regression
- scikit-learn : GBR (Gradient boosting regression)
- scikit-learn/logistic regression识别mnist
- Kernel principal component analysis in scikit-learn
- Lasso regression 和 Ridge Regression
- 如何解决谷歌地球不显示卫星影像的问题
- Hough(霍夫)变换原理
- 【Hadoop--01】Hadoop简介
- HDU 1009 FatMouse' Trade 详解
- windows下提升编码效率的一些利器
- scikit-learn 1.3. Kernel ridge regression
- iOS PanoramaGL(全景展示)用法及集成中的那些坑
- python os.path模块
- 2017-07-17(主页篇)
- HTML&CSS基础篇之六:HTML标准、规范
- 使用jks文件,本地运行没问题,打包到服务器出现java.io.IOException: Invalid keystore format
- MyBatis Mapper ResultMap constructor
- Android开源优秀项目源码
- struct sembuf结构体