多输出深度森林(gcForest)

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)



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值