sklearn.linear_model.OrthogonalMatchingPursuitCV¶
class sklearn.linear_model.OrthogonalMatchingPursuitCV(*, copy=True, fit_intercept=True, normalize=True, max_iter=None, cv=None, n_jobs=None, verbose=False)
交叉验证的正交匹配追踪模型(OMP)。
有关交叉验证估算器,请参阅词汇表条目。
在用户指南中阅读更多内容。
| 参数 | 说明 | 
|---|---|
| copy | bool, optional 设置矩阵X是否必须被算法复制。只有当X已经是Fortran-ordered时,false值才有用,否则无论如何都会复制。  | 
| fit_intercept | boolean, optional 是否计算该模型的截距。如果设置为false,则在计算中将不使用截距(即,数据应居中)。  | 
| normalize | boolean, optional, default Truefit_intercept设置为False 时,将忽略此参数。如果为True,则在回归之前通过减去均值并除以l2-范数来对回归变量X进行归一化。如果你希望标准化,请先使用 sklearn.preprocessing.StandardScaler,然后调用fit 估算器并设置normalize=False。 | 
| max_iter | integer, optional 要执行的最大迭代次数,因此要包含最大特征数, n_features的10%,但至少为5(如果有)。 | 
| cv | int, cross-validation generator or an iterable, optional 确定交叉验证拆分策略。可能的输入是: - None,使用默认的5折交叉验证 - int,用于指定折叠数。 - CV分割器, - 可迭代生成(分割训练、测试)索引数组。 对于int / None输入,使用 KFold。有关可在此处使用的各种交叉验证策略,请参阅用户指南。 在0.22版本中更改: cv如果是“None”,默认值从3折更改为5折。 | 
| n_jobs | int or None, optional (default=None) 交叉验证期间要使用的CPU核心数量。 除非在上下文中设置了 joblib.parallel_backend,否则None表示1 。 -1表示使用所有处理器。有关更多详细信息,请参见词汇表。 | 
| verbose | boolean or integer, optional 设置详细程度  | 
| 属性 | 说明 | 
|---|---|
| intercept_ | float or array, shape (n_targets,) 决策函数中的截距。  | 
| coef_ | array, shape (n_features,) or (n_targets, n_features) 参数向量(问题表述中的w)。  | 
| n_nonzero_coefs_ | int 非零系数的估计数量在交叉验证折叠中给出最佳均方误差。  | 
| n_iter_ | int or array-like 通过交叉验证得到的最佳超参数,用于模型重构的每个目标的活动特征的数量。  | 
另见
orthogonal_mporthogonal_mp_gramlars_pathLarsLassoLarsOrthogonalMatchingPursuitLarsCVLassoLarsCVdecomposition.sparse_encode
示例
>>> from sklearn.linear_model import OrthogonalMatchingPursuitCV
>>> from sklearn.datasets import make_regression
>>> X, y = make_regression(n_features=100, n_informative=10,
...                        noise=4, random_state=0)
>>> reg = OrthogonalMatchingPursuitCV(cv=5).fit(X, y)
>>> reg.score(X, y)
0.9991...
>>> reg.n_nonzero_coefs_
10
>>> reg.predict(X[:1,])
array([-78.3854...])
方法
| 方法 | 说明 | 
|---|---|
fit(X, y) | 
使用X,y作为训练数据拟合模型。 | 
get_params([deep]) | 
获取此估计量的参数。 | 
predict(X) | 
使用线性模型进行预测。 | 
score(X, y[, sample_weight]) | 
返回预测的确定系数R ^ 2。 | 
set_params(**params) | 
设置此估算器的参数。 | 
__init__(*, copy=True, fit_intercept=True, normalize=True, max_iter=None, cv=None, n_jobs=None, verbose=False)
初始化self, 请参阅help(type(self))以获得准确的说明。
fit(X, y)
[源码]
使用X,y作为训练数据拟合模型。
| 参数 | 说明 | 
|---|---|
| X | array-like, shape [n_samples, n_features]  训练数据。  | 
| y | array-like, shape [n_samples] 目标值。如有必要,将强制转换为X的数据类型  | 
| 返回值 | 说明 | 
|---|---|
| self | object  返回估计器实例  | 
get_params(deep=True)
[源码]
获取此估计量的参数。
| 参数 | 说明 | 
|---|---|
| deep | bool, default=True  如果为True,则将返回此估算器和所包含子对象的参数。  | 
| 返回值 | 说明 | 
|---|---|
| params | mapping of string to any  参数名称映射到其值。  | 
predict(X)
[源码]
使用线性模型进行预测。
| 参数 | 说明 | 
|---|---|
| X | array_like or sparse matrix, shape (n_samples, n_features)   样本数据  | 
| 返回值 | 说明 | 
|---|---|
| C | array, shape (n_samples,)  返回预测值。  | 
score(X, y, sample_weight=None)
[源码]
返回预测的确定系数R ^ 2。
系数R ^ 2定义为(1- u / v),其中u是残差平方和((y_true-y_pred)** 2).sum(),而v是总平方和((y_true- y_true.mean())** 2).sum()。可能的最高得分为1.0,并且也可能为负(因为该模型可能会更差)。一个常数模型总是预测y的期望值,而不考虑输入特征,得到的R^2得分为0.0。
| 参数 | 说明 | 
|---|---|
| X | array-like of shape (n_samples, n_features)   测试样本。对于某些估计量,这可以是预先计算的内核矩阵或通用对象列表,形状为(n_samples,n_samples_fitted),其中n_samples_fitted是用于拟合估计器的样本数。  | 
| y | array-like of shape (n_samples,) or (n_samples, n_outputs)   X的真实值。  | 
| sample_weight | array-like of shape (n_samples,), default=None   样本权重。  | 
| 返回值 | 说明 | 
|---|---|
| score | float   预测值与真实值的R^2。  | 
注
调用回归器中的score时使用的R2分数,multioutput='uniform_average'从0.23版开始使用 ,与r2_score默认值保持一致。这会影响多输出回归的score方法( MultiOutputRegressor除外)。
set_params(**params)
[源码]
设置此估计器的参数。
该方法适用于简单的估计器以及嵌套对象(例如管道)。后者具有形式为 <component>__<parameter>的参数,这样就可以更新嵌套对象的每个组件。
| 参数 | 说明 | 
|---|---|
| **params | dict   估计器参数。  | 
| 返回值 | 说明 | 
|---|---|
| self | object   估计器实例。  | 



                            