利用 sklearn 生成交叉特征:
-------------------------------------
-------------------------------------
--------------------------------------------------------------
源码贴在下面,欢迎相互交流
import numpy as np from sklearn.preprocessing import PolynomialFeatures x = np.arange(9).reshape(3,3) print(x) poly = PolynomialFeatures(2) poly.fit_transform(x)
--------------------------------------------------------------
import numpy as np from sklearn.preprocessing import PolynomialFeatures print(x) poly = PolynomialFeatures(degree=3,interaction_only=True) poly.fit_transform(x)
风雨兼程,前程可待!