python在PolynomialFeatures函数中具有'.powers_'属性,想要在pyspark的PolynomialExpansion函数中找到类似的属性

时间:2019-04-08 14:35:52

标签: pyspark apache-spark-mllib

我正在尝试为.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)

0 个答案:

没有答案