我正在尝试为.powers_ attribute
中的函数PolynomialFeatures
找到与PolynomialExpansion
(python函数)中的pyspark
类似的属性(python函数)
我做了一些研究但是找不到它
'''pypsark'''
''' 从pyspark.ml.feature导入PolynomialExpansion
from pyspark.ml.linalg import Vectors
df = spark.createDataFrame([
(Vectors.dense([1,2,3]),),
(Vectors.dense([1,2,3]),),
(Vectors.dense([1,2,3]),)
], ["features"])
polyExpansion=
PolynomialExpansion(degree=2,inputCol="features",outputCol="po
lyFeatures")
polyDF = polyExpansion.transform(df)
polyDF.show()
'''python'''
poly = PolynomialFeatures(degree=2, interaction_only=False,
include_bias=False)
res = poly.fit_transform(poly_df)
poly.powers_(this is available in python,looking for a similar attribute
in pyspark)
'''''为.poly.powers_'在python中生成结果'''
array([[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1],
[2, 0, 0, 0],
[1, 1, 0, 0],
[1, 0, 1, 0],
[1, 0, 0, 1],
[0, 2, 0, 0],
[0, 1, 1, 0],
[0, 1, 0, 1],
[0, 0, 2, 0],
[0, 0, 1, 1],
[0, 0, 0, 2]], dtype=int64)