簡體   English   中英

具有結果數據而不是分類器的Sklearn集成模型

[英]Sklearn ensemble model with result data instead of classifiers

例如, VotingClassifier期望一個估計器列表,但是在我的情況下,不同的估計器已經為訓練數據集以及結果生成了結果(以每個可能的標簽的概率形式,例如[0.8, 0.2, 0.0, 0.0] 0.8,0.2,0.0,0.0 [0.8, 0.2, 0.0, 0.0] )數據集。 有沒有辦法使用它而不是實際的分類器?

如果已經計算出概率,則可以使用簡單的等效numpy代碼。 請注意,您需要將示例推廣到具有許多預測的情況:)

import numpy as np

class_1 = [0.5, 0.4, 0.1, 0.0]
class_2 = [0.0, 0.4, 0.6, 0.0] 
class_3 = [0.5, 0.4, 0.05, 0.05] 
class_combined = np.array([class_1, class_2, class_3])
class_combined

# VotingClassifier(voting='hard')
hard_voting = np_matrix.argmax(axis=1)
hard = np.bincount(voting).argmax()
0

# VotingClassifier(voting='soft')
soft_sum = class_combined.sum(axis=0)
soft = soft_sum.argmax()
1

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM