【问题标题】:Which combinations between features with a polynomial degree less than or equal to a specified polynomial degree count as polynomial combinations?多项式次数小于或等于指定多项式次数的特征之间的哪些组合算作多项式组合?
【发布时间】:2019-02-20 18:16:43
【问题描述】:

有一个特征矩阵 X 有 2 个特征。下面的代码打印所有度数小于或等于 3 的特征的多项式组合。

import numpy as np
from sklearn.preprocessing import PolynomialFeatures

X = np.ones((3,2))
pf = PolynomialFeatures(3)
pf.fit(X)
print(pf.get_feature_names())

['1', 'x0', 'x1', 'x0^2', 'x0 x1', 'x1^2', 'x0^3', 'x0^2 x1', 'x0 x1^2', 'x1^3']

哪个规则用于决定特征之间的哪些组合算作多项式组合?

为什么例如组合 x0^3 x1、x0^3 x1^2 甚至 x0^2 x1^2 不能算作多项式组合?

【问题讨论】:

  • 这些是多项式组合,但它们的度数不小于或等于3。

标签: python machine-learning scikit-learn


【解决方案1】:

这是基本代数。您展示的示例没有 3 级。

对于两个变量,多项式中各项的幂是各项指数的和,多项式的次数是最大的。

你的例子:

x0^3 x1     Degree = 4
x0^3 x1^2   Degree = 5
x0^2 x1^2   Degree = 4 

请查看以下资源:

【讨论】:

  • 对我来说很有意义。谢谢!
猜你喜欢
  • 1970-01-01
  • 2019-07-05
  • 1970-01-01
  • 2021-03-09
  • 2020-06-27
  • 2021-12-02
  • 2020-01-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多