利用 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)

 

posted @ 2018-10-27 21:57  星涅爱别离  阅读(1266)  评论(0编辑  收藏  举报