1. 程式人生 > >Multi-label && Multi-label classification

Multi-label && Multi-label classification

lac cannot binary svm 比賽 kaggle 輸出 edi expect

  • Multi-label classification with Keras

In today’s blog post you learned how to perform multi-label classification with Keras.

Performing multi-label classification with Keras is straightforward and includes two primary steps:

  1. Replace the softmax activation at the end of your network with a sigmoid activation
  2. Swap out categorical cross-entropy for binary cross-entropy for your loss function

From there you can train your network as you normally would.

The end result of applying the process above is a multi-class classifier.

You can use your Keras multi-class classifier to predict multiple labels with just a single

forward pass.

However, there is a difficulty you need to consider:

You need training data for each combination of categories you would like to predict.

Just like a neural network cannot predict classes it was never trained on, your neural network cannot predict multiple class labels for combinations it has never seen. The reason for this behavior is due to activations of neurons inside the network.

If your network is trained on examples of both (1) black pants and (2) red shirts and now you want to predict “red pants” (where there are no “red pants” images in your dataset), the neurons responsible for detecting “red” and “pants” will fire, but since the network has never seen this combination of data/activations before once they reach the fully-connected layers, your output predictions will very likely be incorrect (i.e., you may encounter “red” or “pants”but very unlikely both).

Again, your network cannot correctly make predictions on data it was never trained on(and you shouldn’t expect it to either). Keep this caveat in mind when training your own Keras networks for multi-label classification.

多類分類(multiclass classification)學習的分類器旨在對一個新的實例指定唯一的分類類別,常用的策略有兩類:基於後驗概率或距離一次給出所有類別的度量,選擇度量值最大的類別作為預測類別;將多類分類分解為許多二元分類問題,然後組合所有二元分類的結果。

多標簽分類(multilabel classification)分類器給一個新的實例指定多個類別。這個分類模型有很廣泛的實際應用,如:一個文檔可能同時屬於多個分類;一個蛋白質可能具有多個功能。並且,多個標簽之間可能存在一定的依賴或約束關系,如蛋白質的所有功能組成的Go(gene ontology)。這個依賴或約束關系具有層次特性,經常可以描述為樹或有向無環圖結構,機器學習社團稱之為層次多標簽分類。由於模型的輸出具有層次結構,因此層次多標簽分類又屬於另外一個近來非常活躍的研究領域:結構預測。層次多標簽分類和結構預測都是嶄新的、富有挑戰性的研究領域。
使用scikit-learn實現多類別及多標簽分類算法 。多標簽分類格式 :對於多標簽分類問題而言,一個樣本可能同時屬於多個類別。如一個新聞屬於多個話題。這種情況下,因變量yy需要使用一個矩陣表達出來。而多類別分類指的是y的可能取值大於2,但是y所屬類別是唯一的。它與多標簽分類問題是有嚴格區別的。所有的scikit-learn分類器都是默認支持多類別分類的。但是,當你需要自己修改算法的時候,也是可以使用scikit-learn實現多類別分類的前期數據準備的。多類別或多標簽分類問題,有兩種構建分類器的策略:One-vs-All及One-vs-One。

多類分類(Multiclass Classification)

一個樣本屬於且只屬於多個類中的一個,一個樣本只能屬於一個類,不同類之間是互斥的。

典型方法:

One-vs-All or One-vs.-rest:

將多類問題分成N個二類分類問題,訓練N個二類分類器,對第i個類來說,所有屬於第i個類的樣本為正(positive)樣本,其他樣本為負(negative)樣本,每個二類分類器將屬於i類的樣本從其他類中分離出來。

one-vs-one or All-vs-All:

訓練出N(N-1)個二類分類器,每個分類器區分一對類(i,j)。

多標簽分類(multilabel classification)

又稱,多標簽學習、多標記學習,不同於多類分類,一個樣本可以屬於多個類別(或標簽),不同類之間是有關聯的。

典型方法

問題轉換方法

問題轉換方法的核心是“改造樣本數據使其適應現有學習算法”。該類方法的思路是通過處理多標記訓練樣本,使其適應現有的學習算法,也就是將多標記學習問題轉換為現有的學習問題進行求解。

代表性學習算法有一階方法Binary Relevance,該方法將多標記學習問題轉化為“二類分類( binary classification )”問題求解;二階方法Calibrated Label Ranking,該方法將多標記學習問題轉化為“標記排序( labelranking )問題求解;高階方法Random k-labelset,該方法將多標記學習問題轉化為“多類分類(Multiclass classification)”問題求解。

算法適應方法

算法適應方法的核心是“改造現有的單標記學習算法使其適應多標記數據”。該類方法的基本思想是通過對傳統的機器學習方法的改進,使其能夠解決多標記問題。

代表性學習算法有一階方法ML-kNN},該方法將“惰性學習(lazy learning )”算法k近鄰進行改造以適應多標記數據;二階方法Rank-SVM,該方法將“核學習(kernel learning )”算法SVM進行改造以適應多標記數據;高階方法LEAD,該方法將“貝葉斯學習(Bayes learning)算法”Bayes網絡進行改造以適應多標記數據。

  • 幾種分類問題的區別:多類分類,多標簽分類,多示例學習,多任務學習

  • 多標簽分類(multilabel classification )

  • 相關比賽:Multi-label classification of printed media articles to topics(kaggle),阿裏天池的fashionAI服飾屬性標簽分類;查看相關paper

Multi-label && Multi-label classification