from sklearn.datasets import make_classification from GCForest import * from sklearn.utils import shuffle import numpy as np X, y1 = make_classification(n_samples=10, n_features=100, n_informative=30, n_classes=3, random_state=1) # 生成分类数据集,10个样本,100个特征,30个有效特征,3种分类 y2 = shuffle(y1, random_state=1) # 分类结果随机排序 y3 = shuffle(y1, random_state=2) # 分类结果随机排序 Y = np.vstack((y1, y2, y3)).T # 多种分类结果组合成 print('多输出多分类器真实输出分类:\n',Y) n_samples, n_features = X.shape # 10,100 n_outputs = Y.shape[1] # 3个输出 n_classes = 3 # 每种输出有3种分类 print(X.shape) forest1 = gcForest(shape_1X=100, window=2, tolerance=0.0) # 生成随机森林多分类器 forest2 = gcForest(shape_1X=100, window=2, tolerance=0.0) # 生成随机森林多分类器 forest3 = gcForest(shape_1X=100, window=2, tolerance=0.0) # 生成随机森林多分类器 forest1.fit(X, Y[:, 0]) pred1 = forest1.predict(X) forest2.fit(X, Y[:, 1]) pred2 = forest2.predict(X) forest3.fit(X, Y[:, 2]) pred3 = forest3.predict(X) result = np.vstack((pred1, pred2, pred3)) print(result.T)
多输出深度森林(gcForest)
最新推荐文章于 2023-10-17 20:14:22 发布