sklearn.datasets.make_multilabel_classification?

sklearn.datasets.make_multilabel_classification(n_samples=100, n_features=20, *, n_classes=5, n_labels=2, length=50, allow_unlabeled=True, sparse=False, return_indicator='dense', return_distributions=False, random_state=None)

[源碼]

生成隨機的多標簽分類問題。

對于每個樣本,生成過程為:

  • 選擇標簽數:n?Poisson(n_labels)
  • n次,選擇一個類c:c?多項式(theta)
  • 選擇文檔長度:k?泊松(長度)
  • k次,選擇一個單詞:w?多項式(theta_c)

在上述過程中,使用拒絕采樣來確保n永遠不為零或大于n_classes,并且文檔長度永遠不為零。同樣,我們拒絕已經選擇的類。

在用戶指南中閱讀更多內容。

參數 說明
n_samples nt, optional (default=100)
樣本數。
n_features int, optional (default=20)
功能總數。
n_classes int,可選(默認值= 5)
分類問題的類數。
n_labels int, optional (default=2)
每個實例的平均標簽數。更準確地說,每個樣本的標簽數是從泊松分布中以n_labels作為其期望值得出的,但是樣本受n_class限制(使用拒絕采樣),并且如果allow_unlabeled為False,則該值必須為非零。
length int, optional (default=50)
特征的總和(如果是文檔,則為單詞數)是從具有此期望值的泊松分布中得出的。
allow_unlabeled bool, optional (default=True)
如果為True,則某些實例可能不屬于任何類。
sparse bool, optional (default=False)
如果為True,則返回一個稀疏特征矩陣
0.17版中的新功能:允許稀疏輸出的參數。
return_indicator ‘dense’ (default),‘sparse’,False
如果為dense,則以密集二進制指示符格式返回Y。 如果為'sparse',則以稀疏二進制指示符格式返回Y。 False返回標簽列表的列表。
return_distributions bool, optional (default=False)
如果為True,則返回給定類別的特征的先驗類別概率和條件概率,并從中得出數據。
random_state int, RandomState instance, default=None
確定用于生成數據集的隨機數生成。 為多個函數調用傳遞可重復輸出的int值。 請參閱詞匯表
返回值 說明
X array of shape [n_samples, n_features]
生成的樣本。
Y array or sparse CSR matrix of shape [n_samples, n_classes]
標簽集。
p_c array, shape [n_classes]
繪制每個類的概率。僅在return_distributions = True時返回。
p_w_c array, shape [n_features, n_classes]
給每個類別繪制每個要素的概率。僅在return_distributions = True時返回。

sklearn.datasets.make_multilabel_classification使用示例?