# Tag Info

## Hot answers tagged multilabel-classification

34

Assuming your target is (0,1), then the classifier would output a probability matrix of dimension (N,2). The first index refers to the probability that the data belong to class 0, and the second refers to the probability that the data belong to class 1. These two would sum to 1. You can then output the result by: probability_class_1 = model....

22

I will try to answer this question through logistic regression, one of the simplest linear classifiers. The simplest case of logistic regression is if we have a binary classification task ($y \in\{0,1\})$and only one input feature ($x \in R$). In this case the output of logistic regression would be: $$\hat y = σ(w \cdot x + b)$$ where $w$ and $b$ are ...

5

It could be a bug in your code, problems with your training set (maybe you don't have the file format quite right), or some other implementation issue. Are you sure you want to use a sigmoid activation function in your last layer? I would have expected that the normal approach would be to use a softmax as the last layer (so that you can treat the outputs ...

5

Adding class weight but not changing the way you measure performance will usually degrade overall performance as it is designed to allow increased loss on lower-weighted classes. I would recommend also weighting your accuracy measures. This is a bit tricky with accuracy/precision etc. so maybe calculated the weighted logloss and compare it to the unweighted ...

5

Where exactly in the computations are these underflows manifesting? See here for a brief explanation around the extremes of the softmax. Quick fixes could be to either increase the precision of your model (using 64-bit floats instead of, presumably, 32 bit floats), or just introduce a function that caps your values, so anything below zero or exactly zero is ...

5

Generally, the scoring metrics you are looking at are defined as following (see for example Wikipedia): $$precision = \frac{TP}{TP+FP}$$ $$recall= \frac{TP}{TP+FN}$$ $$F1 = \frac{2 \times precision \times recall}{precision + recall}$$ For the multi-class case scikit learn offers the following parameterizations (see here for example): 'micro': ...

4

Spark only recently implemented CountVectorizer, which will take the labels (as strings) and encode them as your 100-dimensional vector (assuming all 100 labels show up somewhere in your dataset). Once you have those vectors, it should be a simple step to threshold them to make them 0/1 instead of a frequency.

4

Both ways are valid and both are commonly used. Sometimes, a classifier that claims to be multilabel may just be separating the labels into multiple OneVsRest classifiers under-the-hood and conveniently joining the results together at the end. However, there are cases where the methods are fundamentally different. For instance, in training a neural net with ...

4

RNNs were not producing good enough results and are also hard to train so I went with CNNs. Because a specific animal sound is only a few seconds long we can divide the spectrogram into chunks. I used a length of 3 seconds. We then perform classification on each chunk and average the outputs to create a single prediction per audio file. This works really ...

4

For automatic speech recognition (ASR), filter bank features perform as good as CNN on spectrograms Table 1. You can train a DBN-DNN system on fbank for classifying animals sounds. In practice longer speech utterances are divided into shorter utterances since Viterbi decoding doesn't work well for longer utterances. You could do the same. You can divide ...

4

You learn a lot by comparing to a naive model. A naive model is one without any features. As a default, it will always predict the most likely Target. Note that this is exactly what your model is doing. This indicates that the features are not helping with making a prediction. Have you done a basic distribution analysis to see what are the features ...

4

You have one classification task and one regression task, but sklearn's multioutput meta-estimators only support two tasks of the same type. The best solution here is to train two models: A binary classifier to predict $target1$ A regressor to predict $target2$ For example: from sklearn.cross_validation import train_test_split from sklearn.ensemble ...

4

Multi-label classification (Wiki): Given $K$ classes, find a map $f:X \rightarrow \{0, 1\}^K$. Fuzzy classification (a good citation is needed!): Given $K$ classes, find a map $p: X \rightarrow [0, 1]^K$ where $\sum_{k=1}^{K} p(k)=1$. In multi-label classification, as defined, there is no "resource limit" on classes compared to fuzzy classification. ...

4

First, to directly answer your question, the easiest way to get Feature Importance using scikit learn is this, where model is the variable holding your classifier. print(model.feature_importances_) However, this method only exists on some of the Ensemble models, namely: AdaBoostClassifier AdaBoostRegressor ExtraTreesClassifier ExtraTreesRegressor ...

4

So when we generate labels via machine learning models like clustering above, is it a recommended approach? Only if you can really make highly distinct 2 clusters/groups. This will be highy unlikely, especially for complicated and high dimensional datasets. One of the reasons is that clustering algorithms are just weaker than the supervised algorithms. If ...

3

After I read the source code, I find out that keras.datasets.imdb.load_data doesn't actually load the plain text data and convert them into vector, it just loads the vector which has been converted before. As for your problem, I assume you want to convert your job_description into vector. Maybe you can try sklearn.feature_extraction.text.CountVectorizer. ...

3

(1) Data quality. The single best way to improve your accuracy. Garbage in garbage out. You already said your data is suspect. Some data was mis-classified; data only has single label, when multiple labels are possible. This is the biggie - this will improve your accuracy more than any other technique: improve the quality of your training data. One way to go ...

3

TensorFlow is a general purpose library for numerical computation using data flow graphs. It is primarily used for neural networks but can be used for any mathematical operations on multidimensional data arrays (tensors). Thus, TensorFlow can be used to estimate binary logistic regression with explanatory categorical variables. An example can be found in ...

3

In the MultiOutputClassifier, you're treating the two outputs as separate classification tasks; from the docs you linked: This strategy consists of fitting one classifier per target. So the two arrays in the resulting list represent each of the two classifiers / dependent variables. The arrays then are the binary classification outputs (columns that are ...

3

I'll think you'll find what you're looking for in this question on Open Data. I've checked the Pew Research Center data, and found this poll about cyber-security that seems to be something like what you look for.

3

Semi-supervised learning. You label 1% manually, let the algorithm learn, then it labels unknown data, learns from it and labels again.

3

The error you're getting indicates it cannot do a stratified split because one of your classes has only one sample. You need at least two samples of each class in order to put one in the training split and one in the test split. You should examine what your class breakdown is to find the culprit.

3

I'll go for you questions one by one: What is the rationale behind using it in classification tasks? LSTM Networks for classifcation tasks are mainly due to NLP. In particular, Sentiment Analysis. What is the sentiment/polarization of a tweet? By "understanding" natural language, a model can guess whether it is positive or negative towards a given issue. ...

3

Class imbalance is a common problem, there are several ways in which people tackle this problem, below are few. If possible try augmenting the class for which the data is less. (Some might call it oversampling). You can use class weighting which penalizes less (during training) the class whose data is not sufficient. Using Focal Loss, an example of it can ...

3

Yes. With y being a 1d array of integers (as after LabelEncoder), sklearn treats it as a multiclass classification problem. With y being a 2d binary array (as after LabelBinarizer), sklearn treats it as a multilabel problem. Presumably, the multilabel model is predicting no labels for some of the rows. (With your actual data not being multilabel, the sum ...

2

First of all, I think that your accuracy is already very high for text classification. I want to provide some ideas for additional features and approaches though. Topic models Topic models such as Latent Dirichlet Allocation (LDA) are quite frequently used when studying text corpora. You already wrote that you used LDA for coming up with cosine ...

2

I suggest you try building multiple networks: one network for building type (outputs "house", "apartment", or "condominum"), another network for build year, another for garage (yes vs no), and so on. This keeps the number of classes small for each network, and allows each network to tune itself for the specific task it is focusing on. If you want to avoid ...

2

It's hard to say without knowing the data. Often times the classes are imbalanced. This could cause your problems. So let's say that the "features are right" for 5% of your data and they belong to class $A$. You would expect the 5% to be classified correctly as $A$ almost all the time. But what about the remaining 95% in class $B$? The classifier learns ...

2

Assuming all the labels have the same importance you can have a sigmoid for every class at the output. For each of the classes it will ask, is this class part of this sentence or not? The loss is just the sum of the individual log losses for the outputs. If some labels are more important you can scale them accordingly in your loss function.

Only top voted, non community-wiki answers of a minimum length are eligible