An Exact Algorithm for F-Measure Maximization
Paper · 2011 · Krzysztof Dembczyński, Willem Waegeman, Weiwei Cheng et al.
Summary
When a prediction can contain several labels, choosing the most probable labels does not always give the best expected F-measure. The score rewards overlap with the correct label set, but the value of a correct prediction also depends on how many labels are present and how many the classifier predicts. A label that tends to occur in short correct sets can therefore contribute more than a more probable label that typically appears in long ones. The authors ask how to find the best prediction when a probability distribution describes which labels can occur together.
Their General F-measure Maximizer, or GFM, divides the search by the number of labels the prediction will contain. For each possible prediction size, it gives every label a score based on its probability of occurring at each possible true set size. It then takes the highest-scoring labels for that size and compares the resulting predictions, including the empty prediction. These calculations need only an array of joint probabilities and the probability that the true set is empty. The array grows quadratically with the number of labels. Given exact probabilities, the method returns a prediction that maximizes expected F-measure for any joint distribution of the labels.
The authors also show why two familiar shortcuts have different limits. An earlier method that reconstructs the joint distribution from individual label probabilities can perform very poorly when the labels are dependent. Allowing a method to choose the best possible threshold on those individual probabilities still leaves a problem. Some distributions have an optimal label set that no such threshold can select. GFM avoids both restrictions by allowing the order of the labels to change with the proposed prediction size.
In artificial experiments, the independence-based method did best when independence held, and GFM approached its performance as the sample grew. GFM fared better in the experiment with dependent labels. On four multi-label benchmarks, methods designed for instance-wise F-measure all improved that score over the corresponding Hamming-loss rules, with no consistent winner among the F-measure methods. The clearest practical difference was inference time. On Mediamill, GFM applied to probabilistic classifier chains took 1420.663 seconds, while the approximate independence-based method took 308582.019 seconds with the same kind of classifier. Its exact version failed to finish within the time the authors considered reasonable.
Deep dive: An Exact Algorithm for F-Measure Maximization
The General F-measure Maximizer finds the label set with the highest expected F1 score, even when the labels are statistically dependent. · about 38 minutes to read
The problem and its context
What the F-measure values in a prediction
The F-measure comes from information retrieval, where a system can be judged both by how many of its retrieved items are relevant and by how many relevant items it manages to retrieve. These questions give precision and recall. Precision looks at the items selected by the system. Recall looks at the items that actually belong in the selection. A system can improve one by changing how much it returns while giving up ground on the other. The unweighted F-measure used in the paper, also called F1, combines them through their harmonic mean.
The same counting problem arises whenever the answer consists of a set. In multi-label classification, the input has a list of possible labels and may belong to several of them at the same time. In structured prediction, a binary decision can indicate whether an element of an output should be present. The paper mentions text chunking and named entity recognition as examples of structured tasks where F-measure is used. Even a batch of ordinary binary classifications can be represented as a vector, with one entry per test item and an F-measure for the whole batch. In each case the meaning of a coordinate differs, but the score compares sets of positive entries.
The authors motivate this choice through imbalanced prediction problems. Ordinary classification error and multi-label Hamming loss count errors coordinate by coordinate. When negatives predominate, correctly excluding them can account for much of the apparent success. F-measure focuses on the positive sets. Its numerator counts correct inclusions, and its denominator takes account of the sizes of the true and predicted sets. An excluded label that was absent from the truth leaves all those counts unchanged. This helps explain why the paper treats F-measure as an objective worth optimizing directly.
The denominator also makes the decision harder. Under Hamming loss, adding a label changes the error for that label alone. Under F-measure, adding a label changes the size of the prediction, which changes how the score values every correct inclusion already in it. The same interdependence appears on the truth side. Correctly identifying a label contributes a different amount when the true set is small than when it is large, even if the prediction has the same size in both situations. The optimizer must account for both counts before it can compare alternative decisions.
Inference and training answer different questions
The paper distinguishes learning a predictor from deciding what to return once probabilities are available. Earlier approaches to F-measure described by the authors included extensions of support vector machines and logistic regression for binary classification, as well as procedures that adjusted a decision threshold. The paper also discusses training approaches to structured output and multi-label prediction. Those methods can choose how to fit a classifier or tune its decisions for a target measure. The question here begins with a distribution over possible correct answers and asks which answer will score best on average under that distribution.
This distinction matters even with a well-estimated distribution. A learner can assign probabilities to every possible true label vector in principle, yet the most probable vector need not maximize expected F-measure. The probability of a vector refers to exact agreement with that vector. F-measure also gives credit for partial agreement with other vectors. A candidate prediction can benefit from covering labels that recur across several possible outcomes, even when that candidate itself is seldom the exact outcome. The task is to compare predictions by the score they earn across the distribution.
The authors also distinguish the units over which F-measure is calculated. For instance-wise F-measure, each input has a label vector, and that prediction receives its own score before the scores are averaged. Macro F-measure in the experiments instead calculates a separate score for each label across test inputs and averages those scores. Micro F-measure pools the decisions across labels and inputs and calculates a single score from the pooled counts. Which units share a denominator has consequences for inference. A decision about labels for a single input can be optimized in isolation for the instance-wise objective. With a pooled objective, a change to that decision also changes the denominator governing other inputs.
What marginal probabilities made possible
A marginal label probability answers a simple question about a single coordinate. It says how likely that label is to be present, summing over whatever may happen to the remaining labels. Marginals are natural inputs for a decision rule because they are much easier to handle than an explicit list of all the possible vectors and their probabilities. The earlier methods the paper examines show when they suffice and how that conclusion depends on the distribution.
Under independence, the joint probability of an outcome factors into a contribution from each coordinate. In that case the marginal probabilities specify the joint distribution. Earlier work by Lewis and Jansche also established that an optimal prediction can be chosen from prefixes of the marginal ranking, along with the empty prediction. A prefix consists of the labels from the start of the ranking up to some chosen length. The result means that the search can pick a prediction size and know which labels to include at that size. The remaining difficulty is to work out the expected score for each candidate.
Lewis considered an approximation that uses expected counts for a nonempty prediction and treats the empty case exactly under independence. Jansche's maximum expected utility framework, or MEUF, computes the expected score exactly under that assumption. It exploits the fact that the score can take only as many distinct values as the relevant integer counts allow, even though a large number of truth vectors can produce those counts. The paper reports an exact version and approximate versions with different costs. This gives GFM a natural point of comparison since both exact methods organize their search first by prediction size.
A different special case also supports ranking by marginal probability. In the formulation studied by Del Coz and colleagues, every outcome has exactly one positive label. The prediction can offer several alternatives, but the true set always has the same size. Once the number of predictions is fixed, each candidate label then gets the same weighting for the denominator. The best candidates are the most probable labels, and a stopping rule determines how far to go down the ranking. The structural restriction here is a fixed true set size. The independent-label case has a different justification, since the true set size can vary.
Those special cases help explain the appeal of thresholding. A threshold on individual probabilities produces a prediction from the high end of a shared ranking. It is an economical way to ask how many labels to return. The general problem requires answering a further question about whether the same ranking gives the best labels at all. If a label frequently appears with many other positives, its marginal probability says nothing about how much its correct inclusion tends to contribute to the score. That missing distinction is what GFM recovers from the joint distribution.
The method, step by step
From uncertain truth to a decision
Think of the method as comparing predictions that all have the same size before comparing predictions of different sizes. Within a size, the cost of making a prediction longer is already fixed. Suppose a particular correct label is present in some possible true vectors. For each of those outcomes, its contribution is greater when fewer labels are present in the truth. GFM groups the outcomes by true set size so it can calculate that contribution without visiting every true vector during the search.
This produces a score for each label at the chosen prediction size. Since each label contributes by addition within that size, the method can fill the available places directly with the labels having the highest scores. A different prediction size changes the weights that go into the label scores, so GFM calculates them again for that size. After finding the best choice at every size, it compares their expected F-measures. The empty prediction is handled separately because it receives credit precisely when the true vector is empty.
Finding the prediction with maximum expected F-measure
The steps in order.
The score for a known true vector
The authors represent a true label set by a binary vector y and a predicted label set by a binary vector h. The vectors have the same length and refer to the same labels in the same order. Their score for a given pair is as follows.
F(y, h) = (2 Σᵢ₌₁ᵐ yᵢhᵢ) / (Σᵢ₌₁ᵐ yᵢ + Σᵢ₌₁ᵐ hᵢ)
Here F is the F-measure, m is the number of label positions, and i identifies a position. The sum sign Σ adds over all positions from 1 through m. The indicators yᵢ and hᵢ give the true and predicted values at position i. A product yᵢhᵢ is 1 when the label is both present and predicted and is 0 otherwise. Its sum counts correct inclusions. The two sums in the denominator count true positives in the sense of all labels present in the truth and predicted positives in the sense of all labels selected by the prediction, respectively. The factor 2 gives the unweighted F-measure its normalization. The score ranges from 0 to 1, and the authors define 0/0 as 1 for the case where both sets are empty.
With nonempty denominators, precision measures correct inclusions relative to the predicted set.
prec(y, h) = (Σᵢ₌₁ᵐ yᵢhᵢ) / (Σᵢ₌₁ᵐ hᵢ)
The symbol prec denotes precision, y and h are the true and predicted vectors, i indexes the m labels, and Σ sums the indicated terms across those labels. The product yᵢhᵢ contributes when the label occurs in both vectors, while hᵢ contributes whenever the prediction includes it.
Recall measures the same correct inclusions relative to the true set.
rec(y, h) = (Σᵢ₌₁ᵐ yᵢhᵢ) / (Σᵢ₌₁ᵐ yᵢ)
Here rec denotes recall, y and h are the true and predicted vectors, i runs through the m positions, and Σ denotes the sum. The numerator again counts overlap through yᵢhᵢ. The denominator sums yᵢ to count all labels present in the truth. GFM uses the count formula for F directly, including its convention for the empty pair.
Averaging over possible truths
The true vector is unknown at prediction time. The paper denotes it by the random vector Y and considers a distribution that assigns each possible realization y a probability. A prediction earns a score for every such realization. Its expected score is the sum of those scores weighted by the corresponding probabilities. The target decision is written as follows.
h*ꜰ = arg maxₕ∈{0,1}ᵐ Σᵧ∈{0,1}ᵐ p(Y = y) F(y, h)
The symbol h*ꜰ denotes a maximizing prediction, with the subscript identifying the F-measure objective and the star indicating optimality. The operator arg max chooses an h attaining the largest objective value. The set {0,1}ᵐ consists of binary vectors of length m. The sum Σ ranges over possible true vectors y in that set, p(Y = y) is the probability of that vector, and F(y, h) gives the score for predicting h on that outcome.
This formulation has two potential sources of exponential work. The candidate predictions range over all subsets of the labels. For each candidate, the expected score as written also ranges over all subsets that could be true. GFM addresses both issues by changing what it enumerates. It looks at counts to organize the candidates and uses probabilities that have already pooled the truth vectors with the same relevant counts. The important question is which pools keep enough information to make the decision exactly.
Fixing the number of predictions
The authors adopt the inner and outer maximizations already used by Jansche. The inner problem fixes the number of predictions and asks which labels to include. The set of eligible vectors can be written as follows.
Hₖ = {h ∈ {0,1}ᵐ : Σᵢ₌₁ᵐ hᵢ = k}
The symbol Hₖ denotes the set of allowable predictions at size k. The notation h ∈ {0,1}ᵐ means that h is a binary prediction vector of length m. The index i runs through its positions, hᵢ is the inclusion indicator for position i, and Σ adds these indicators. Their sum must equal k, the desired number of predicted labels.
h*(k) = arg maxₕ∈Hₖ E[F(Y, h)]
Here h*(k) is a best prediction among the vectors in Hₖ, the allowable set of size k. The operator arg max chooses a maximizing vector h, E denotes expectation with respect to the distribution of Y, and F(Y, h) is the score against the random truth. The star marks the solution within the specified size.
h*ꜰ = arg maxₕ∈{h*(0),…,h*(m)} E[F(Y, h)]
Here hꜰ is a best prediction across all sizes. The candidate set runs from h(0), the best empty prediction, through h*(m), the best prediction containing all m labels. The ellipsis includes the best candidate at each intervening size. The symbols h, Y, F, and E denote a candidate, the random truth, the F-measure, and expectation, respectively. The operator arg max selects a candidate whose expected score is highest.
The outer comparison is exact because every possible prediction belongs to one of the size classes. Any candidate that loses within its own size class can be replaced by that class's best candidate without reducing the expected score. Once a representative has been chosen for each class, the remaining task is a comparison of their scores. Most of the work lies in finding the representatives reliably and efficiently.
Seeing where independence enters the older rules
Let pᵢ denote the marginal probability that label i is present. Under independence, the probability of an entire vector can be reconstructed from those marginal probabilities.
p(Y = y) = Πᵢ₌₁ᵐ pᵢʸⁱ (1 − pᵢ)¹⁻ʸⁱ
Here p(Y = y) is the probability that the random vector Y equals y, and Π multiplies factors for positions i from 1 through m. The symbol pᵢ is the probability that Yᵢ equals 1. In the exponents, the superscript ʸⁱ represents the entry yᵢ of the proposed true vector. An entry of 1 contributes pᵢ and an entry of 0 contributes its complement, 1 − pᵢ. The product rule in this form assumes independence of the coordinates.
Lewis's approximation for a nonempty prediction illustrates another way the marginals can enter. The expected number of correct inclusions goes into the numerator, and the expected true set size goes into the denominator.
E[F(Y, h)] ≃ (2 Σᵢ₌₁ᵐ pᵢhᵢ) / (Σᵢ₌₁ᵐ pᵢ + Σᵢ₌₁ᵐ hᵢ)
Here E is expectation, F(Y, h) is the score against the random truth Y, and ≃ denotes an approximation. The symbol h is a nonempty prediction, hᵢ is its entry at position i, pᵢ is the marginal probability for that position, and m is the number of labels. Each Σ sums over those labels. The factor 2 comes from the F-measure, the numerator sum gives the expected overlap, and the denominator adds the expected true set size to the fixed predicted size. The approximation replaces the expectation of the quotient by a quotient involving expected counts.
The empty case uses a separate expression under independence.
E[F(Y, 𝟎)] = Πᵢ₌₁ᵐ (1 − pᵢ)
The symbol 𝟎 denotes the vector with every entry equal to 0. The left-hand side is the expected F-measure of that vector against Y. On the right, Π multiplies the probabilities of label absence, 1 − pᵢ, for all m positions indexed by i. Independence makes that product the probability that every label is absent. The F-measure convention gives the empty prediction a score of 1 on precisely that event.
For the special case with exactly one true label, the paper gives the earlier stopping condition as well.
Σⱼ₌₁ᵏ pⱼ ≥ (1 + k)pₖ₊₁
Here the probabilities pⱼ are ordered from highest to lowest, j indexes the ranked labels, and k is the current length of the prefix. The sum Σ adds the probabilities of the labels already in it. The quantity pₖ₊₁ is the probability of the next label, and 1 + k is the score's denominator at the current size because the true set has size 1. The condition says that the next label's probability is at most the sum already collected divided by the current denominator. The rule takes the first k at which this holds, or selects all the labels if no such stopping point is found.
These formulas use marginals for different reasons. The product expression relies on independence to recover information about the entire vector. The stopping condition relies on the denominator being the same across all true outcomes of interest at a fixed prediction size. In GFM, the true size may vary and labels can be dependent. Its alternative is to retain the relationship between each label and the true size explicitly.
Grouping outcomes by how many labels are present
For a fixed prediction size k, consider two possible true vectors of the same size. Each has the same denominator when scored against any candidate at that prediction size. They may contribute different labels to the numerator, but a correct inclusion receives the same weight for both. It is therefore enough to add up the joint probability of a particular label being present over all true vectors of that size.
sᵧ = Σᵢ₌₁ᵐ yᵢ
Here sᵧ is the number of active labels in the true vector y, i indexes its m entries, yᵢ is the binary entry at i, and Σ adds those entries. Outcomes with the same sᵧ share the same true size even if they contain different labels.
pᵢₛ = p(Yᵢ = 1, sᵧ = s)
The symbol pᵢₛ denotes the probability of a joint event under the truth distribution p. The entry Yᵢ of the random vector must equal 1, and the size sᵧ of its realization must equal s. The label index i specifies a row of the probability matrix P, while s specifies a column for a positive true set size. An outcome with several active labels contributes its probability to the row for each of those labels in the column for its own size. Each cell represents joint probability mass, with no normalization by the probability of that size.
This grouping retains information omitted by the marginal. Summing a row over the size columns recovers the label's marginal probability. Following the row across columns reveals whether that probability is concentrated among short or long true sets. The optimizer can weight the row differently for different prediction sizes. Two labels can have the same marginal probability and still have different contributions because their probability mass lies in different columns.
The grouping also explains why the full joint distribution is unnecessary for this decision. At fixed k, the number of correct inclusions is a sum of contributions from individual labels. After separating the sum over labels from the sum over truth outcomes, each label's contribution needs only the probability that it is present at the relevant size. The full composition of those outcomes has already done its work by determining the joint probabilities in P. GFM does not need to reconstruct their composition afterward.
The expected score for any fixed nonempty candidate can now be expressed in terms of these entries.
E[F(Y, h)] = 2 Σᵢ₌₁ᵐ hᵢ Σₛ₌₁ᵐ pᵢₛ / (s + k)
Here E averages over the random truth Y, F is the score, and h is a candidate with k predicted labels. The outer Σ runs through labels i, with hᵢ determining which ones are included. The inner Σ runs through positive true set sizes s, with pᵢₛ giving the joint probability of label i and size s. The denominator s + k is the total of the true and predicted sizes in that group. The factor 2 comes from the score. The group with true size 0 contributes nothing for a nonempty prediction because no label in the prediction can match it.
This identity contains the main step in the proof. Start by writing the probability of an outcome times the score for that outcome. Rewrite the overlap in the numerator as a sum of products of true and predicted indicators. At fixed prediction size the denominator has the same form for every candidate. The expected score can therefore be written with the label sum on the outside and the outcome sum inside. For a particular label and true size, the outcome sum just collects the mass of vectors that contain that label. Each of those terms shares the same denominator, so the sum of their probabilities gives precisely the entry in P.
The empty prediction still has its own score.
E[F(Y, 𝟎)] = p(Y = 𝟎)
Here 𝟎 is the all-zero vector, Y is the random truth, p(Y = 𝟎) is the probability that the truth is empty, and E gives the expected value of F against that truth. The empty prediction has no overlap with a nonempty true set and earns 1 on an empty true set. This is the additional probability the algorithm takes alongside the m² entries of P.
Computing label scores and choosing the winners
The authors collect the denominator weights in a matrix W. Its rows index true sizes and its columns index prediction sizes.
wₛₖ = 1 / (s + k)
The entry wₛₖ belongs to row s and column k of W. Both s, the true size, and k, the predicted size, range over positive sizes up to m. The reciprocal is defined throughout this matrix because the sum in the denominator is positive.
F = PW
Here F denotes the matrix of label scores, P is the matrix of joint label-and-size probabilities, and W is the matrix of reciprocal weights. Writing PW denotes matrix multiplication. Each column of the resulting F matrix corresponds to a positive prediction size. The matrix shares its letter with the F-measure, while the use of F with vector arguments denotes the score function.
fᵢₖ = Σₛ₌₁ᵐ pᵢₛwₛₖ
The entry fᵢₖ is the score for label i at prediction size k. The sum Σ goes through all positive true sizes s up to the number of labels m. For each size, pᵢₛ is the joint probability of its occurrence with label i, and wₛₖ weights that event for the chosen prediction size. The entry gives the label's expected contribution before the common factor 2 is applied.
The inner search can now be rewritten directly in terms of the column for k.
h*(k) = arg maxₕ∈Hₖ 2 Σᵢ₌₁ᵐ hᵢfᵢₖ
Here h*(k) is a maximizing prediction of size k, Hₖ is the set of vectors of that size, and arg max selects a candidate h with the greatest objective value. The index i runs through the m labels and Σ adds their terms. The entry hᵢ includes or excludes fᵢₖ, the label score in column k. The factor 2 converts their sum to the expected F-measure for that candidate.
If an included label has a smaller score than an excluded label in the same column, exchanging them preserves the prediction size and raises the objective. Hence the best candidate uses the k highest entries. Tied entries at the selection boundary can produce multiple candidates of equal value. The implementation needs one maximizing candidate per size to make the outer comparison. Once the chosen entries are summed and the factor applied, that value can be compared directly with the scores for all other sizes and with the probability of the empty truth.
The possibility of a different ordering in each column is central. As k varies, the denominator changes for every group, but the effects on different groups need not be proportional. A label associated principally with small true sets gets a different pattern of weights from a label associated principally with large ones. The result of the inner search can therefore change in composition as well as in size. There is no requirement that the best set at one size be a subset of the best set at the next size.
What the running-time guarantee includes
A selection algorithm can identify the highest k entries of a column in linear time in the number of entries. It can do so without sorting every entry into a complete ranking. Repeating selection across the columns and comparing the resulting candidates leave matrix multiplication as the dominant cost in the authors' analysis. Ordinary multiplication of the square matrices takes O(m³) time, where m is the number of labels and O bounds the growth rate. The paper cites a faster multiplication algorithm with an O(m²·³⁷⁶) bound, with 2.376 as the exponent, and accordingly states the GFM inference guarantee as o(m³). The lower-case o expresses a growth rate below cubic in the asymptotic comparison.
The authors observe that less work is needed if only some true set sizes have non-zero probability. Those are the only size columns of P that can contribute to the product. They also distinguish the faster matrix multiplication bound from practical behavior, noting that the cited method is useful relative to ordinary multiplication only at very large matrix sizes. The runtime theorem starts after P and the empty probability are available. Time spent fitting a classifier or obtaining probability estimates lies outside that theorem.
The comparison with MEUF exposes a tradeoff. The paper gives the exact MEUF procedure an overall cost of O(m⁴), and its recommended approximate version costs O(m³). MEUF needs m marginal probabilities. GFM uses m² + 1 probability inputs and gives the exact optimum for the joint distribution summarized by them. Access to those inputs makes inference tractable, while the statistical cost of estimating them depends on how the probabilities are obtained and how much information is available.
A variant that keeps the marginal order
The authors also evaluate GFM-T, which uses GFM's expected-score calculation to choose a threshold. It first obtains the marginal probabilities from the rows of P.
pᵢ = Σₛ₌₁ᵐ pᵢₛ
Here pᵢ is the marginal probability for label i, pᵢₛ is the joint probability of label i occurring and the true set having size s, and Σ adds those probabilities across positive sizes up to m. The zero-size group is absent because label i cannot be present in it.
The threshold rule takes the following form.
hᵢ = 1 if pᵢ ≥ θ, and hᵢ = 0 otherwise
Here hᵢ is the prediction indicator for label i, pᵢ is that label's marginal probability, and θ is the threshold. The inequality includes a label when its probability reaches or exceeds θ. The output value 0 excludes it.
The marginal order determines which labels a threshold can include. GFM-T uses the joint size probabilities to evaluate the expected F-measure of the permitted choices. For a candidate size, it needs the weighted entries only for the labels in the corresponding marginal prefix. This can save work on the matrix of label scores. The authors also note that a search can be shortened further by checking a limited set of thresholds. GFM-T thus helps distinguish the value of dependence information in scoring a candidate from the value of allowing that information to change the membership of the candidate itself.
Obtaining the probabilities for a test input
For the benchmark experiments, the authors apply GFM to multi-label classification. The input x is a vector of n real-valued attributes, the output y is a vector of m binary labels, and the classifier is fitted on N paired training examples. For a test input, the quantities of interest are conditional on that particular x. Different inputs can give different distributions of true sizes, different label scores, and different numbers of predicted labels.
To estimate a joint conditional distribution, the authors use probabilistic classifier chains, abbreviated PCC. A chain places the labels in an order and fits a probabilistic classifier at each position. The classifier at the start has access to the input attributes. Later classifiers also have access to the values of the earlier labels in the chain. The joint probability is computed through repeated conditioning.
p(Y = y | x) = Πₖ₌₁ᵐ p(Yₖ = yₖ | x, y₁, …, yₖ₋₁)
Here p(Y = y | x) is the probability of the full vector y conditional on the attribute vector x. The product symbol Π multiplies the conditional probabilities along the m chain positions. The index k identifies the current position. The variable Yₖ takes the proposed value yₖ with a probability conditional on x and the preceding values y₁ through yₖ₋₁. The first conditional has no preceding label values. The vertical bar marks conditioning, and the ellipsis stands for the intervening positions in the chosen order.
This factorization allows dependence because the conditional probability of a label can change when earlier label values change. The authors fit a separate linear, regularized logistic regression classifier for each chain position. In training, each such classifier uses the input attributes together with the preceding label values from the training vector. Regularization controls the fitted coefficients, and its setting is tuned by 3-fold cross-validation. The paper notes that the log-linear form allows pairwise label dependencies to be represented.
For inference, the chain provides a way to generate complete label vectors without enumerating them. Given a test input, the first classifier supplies the probability for drawing the first value. The second uses that drawn value along with the attributes to supply its own probability. Continuing along the chain yields a sample vector. The authors draw 200 such vectors per benchmark test input. The relative frequency of the empty vector estimates its probability. For each other vector, its size identifies a column of P, and the included labels identify which entries receive a count. Relative frequencies in those entries estimate the joint probabilities for GFM.
There are consequently distinct sources of error in the benchmark application. The fitted chain may assign different probabilities from the true conditional distribution, and the sample may differ from the probabilities assigned by the chain. GFM solves the decision problem for the supplied estimates. This separation is what allows the experiments to compare decision rules fed from the same fitted chain, while the theorem characterizes the inference given its probability inputs.
Experiments and results
Artificial distributions and benchmark splits
The artificial experiments examine the effect of the label distribution and the amount of sampling. For the independent case, the paper uses m = 25 labels and assigns each label marginal probability pᵢ = 0.12. This gives the marginal-based method the distributional structure it assumes. The dependent case uses a chain of logistic conditionals. The linear part uses the count of earlier positive labels alongside an offset that changes with position. Thus the probability at a given position can depend on what was drawn earlier in the vector. The authors compare F-measure as the sample size varies in both settings. A separate timing comparison varies the number of labels at a sample size of 200. The artificial results are averaged over 50 trials.
The benchmark experiments use datasets with established training and test sets, drawn from the MULAN and LibSVM repositories. Scene has 6 labels, with 1211 training and 1169 test instances. Yeast has 14 labels, with 1500 training and 917 test instances. Enron has 53 labels, with 1123 training and 579 test instances. Mediamill has 101 labels, with 30,999 training and 12,914 test instances. The authors fit the classifiers on the training data and use the designated test instances for the scores in the benchmark comparison. With these splits, the datasets also differ in how many separate inferences contribute to the reported times.
The decision rules and what was measured
The PCC comparisons use the same kind of fitted classifier chain and differ in how they turn probabilities into decisions. The rule called H predicts each label whose estimated marginal is at least 0.5. This threshold minimizes expected Hamming loss, since each coordinate can be decided on its own for that objective. The exact MEUF rule applies the independence calculation to the estimated marginals. MEUF Approx uses the earlier method's approximate cubic-time version with the settings from that work. GFM and GFM-T use the estimated label-and-size probabilities, with the latter limiting the candidates to marginal thresholds.
The paper also compares binary relevance, abbreviated BR. This approach fits each label independently using the same type of base classifier as the chain. The plain BR row gives the predictions from those binary classifiers. Other BR rows apply exact or approximate MEUF to their marginals. The distinction between PCC and BR matters when reading the table. Comparisons among PCC rows change the inference rule while holding the kind of probability estimator fixed. Comparisons between PCC and BR rows can also reflect differences in the estimated probabilities.
The principal outcome is instance-wise F-measure on the test set. For each example, the score compares its true and predicted label vectors, then those scores are averaged. The paper additionally gives Hamming loss, macro F-measure, micro F-measure, and inference time in seconds. Hamming loss counts the share of incorrect binary decisions. The macro score gives each label its own calculation across inputs, and the micro score pools all test decisions before applying the F-measure. These measures give the reader ways to inspect how the changed decision rule affects behavior beyond its stated objective.
Instance-wise F-measure on the test sets
Scene gives a clear example of the improvement from using the target score in inference. PCC H obtains 0.6673 instance-wise F-measure on the Scene test set. Both independence-based PCC variants obtain 0.7131. GFM-T reaches 0.7154, and GFM reaches 0.7159. The BR rows show a similar benefit from adjusting the decision objective. Plain BR gives 0.6591, while either version of MEUF applied to BR marginals gives 0.7048. The result compares decisions learned or inferred from the same split, with each method evaluated against the same test truths.
Inference methods on the Scene test set by instance-wise F-measure
The methods that target F-measure improve on their corresponding default decision rules, with PCC GFM highest.
The numbers
| System or setting | instance-wise F-measure |
|---|---|
| PCC H | 0.6673 |
| PCC MEUF Approx | 0.7131 |
| PCC MEUF | 0.7131 |
| PCC GFM-T | 0.7154 |
| PCC GFM (this paper) | 0.7159 |
| BR | 0.6591 |
| BR MEUF Approx | 0.7048 |
| BR MEUF | 0.7048 |
The Yeast test results show the same gain from changing objectives, with a different ordering among the F-measure rules. PCC H obtains 0.6391. PCC GFM and PCC GFM-T reach 0.6554 and 0.6553, respectively. Approximate PCC MEUF reaches 0.6551, and exact PCC MEUF reaches 0.6557. The highest instance-wise result on Yeast comes from approximate MEUF with BR probabilities, at 0.6601. Exact MEUF with BR gives 0.6591, while plain BR obtains 0.6299. Which probability estimator supplies the marginals can matter as much to the outcome as which of the closely placed F-measure methods uses them.
On Enron, PCC H gives 0.3633 on the test set. PCC GFM obtains 0.4034, matching exact PCC MEUF at the reported precision. Approximate PCC MEUF gives 0.4030 and PCC GFM-T reaches 0.4039. Plain BR records 0.3349, while approximate and exact MEUF using BR marginals give 0.4098 and 0.4096. The best instance-wise score again comes from approximate MEUF with BR, even though those marginal inputs leave out the dependence information available to GFM. The theoretical guarantee applies to expected score under the supplied distribution. The benchmark averages scores against the actual held-out outcomes.
Mediamill is the largest of the benchmark tasks both by number of labels and by number of test instances. PCC H scores 0.5577 instance-wise on the test set. PCC GFM obtains 0.5849 and the threshold-constrained variant obtains 0.5854. Approximate PCC MEUF returns 0.5871. Applied to BR, the approximate method gives the highest completed instance-wise result, 0.5889, while plain BR gives 0.5623. The exact MEUF rows are missing for this dataset because inference did not complete in the time the authors allowed. Their absence matters when comparing the methods by score alone.
Inference time and the other measures
In the small Scene task, some of the total inference times are close. PCC GFM takes 0.985 seconds and PCC GFM-T takes 1.031 seconds for the test set. Exact PCC MEUF takes 1.297 seconds and its approximation takes 1.406 seconds. Those times illustrate the difference between an asymptotic bound and the measured result for a particular workload. Approximate MEUF finishes ahead of exact PCC MEUF on the larger benchmark cases that have both measurements, but the ordering in Scene goes the other way.
On Yeast, the PCC GFM inference time is 3.796 seconds, compared with 10.000 seconds for PCC MEUF Approx and 11.453 seconds for exact PCC MEUF. For Enron, GFM takes 194.889 seconds with PCC, compared with 1081.837 seconds for the approximate PCC MEUF method and 6676.145 seconds for exact PCC MEUF. These results show a larger separation as the benchmarks move to label sets with more positions, although the datasets also differ in their other properties. The artificial timing experiment varies label count separately to examine its effect under a fixed sample size.
Inference time for completed PCC methods on the Mediamill test set
GFM and its threshold variant finish close to the Hamming rule and far ahead of approximate MEUF.
The numbers
| System or setting | seconds |
|---|---|
| PCC H | 1405.772 |
| PCC GFM (this paper) | 1420.663 |
| PCC GFM-T | 1464.147 |
| PCC MEUF Approx | 308582.019 |
Mediamill exposes the practical cost of the earlier inference procedures. With BR marginals, approximate MEUF takes 258431.125 seconds, alongside the 308582.019 seconds for its PCC counterpart. Neither exact MEUF run completed in a reasonable time, which the paper describes in terms of several days. The measurements were made on a typical desktop computer. GFM-T's restricted search does not guarantee a lower measured time than GFM in these runs. On Mediamill the threshold variant takes 1464.147 seconds, while GFM takes 1420.663 seconds. Their similar scores and times allow the effect of that restriction to be judged in this implementation without assuming how it would behave on a different one.
The Hamming results show that targeting a different score changes the decisions in observable ways. On Scene, plain BR has Hamming loss of 0.1023 and PCC H has 0.1030, while PCC GFM has 0.1341. The ordering is different for instance-wise F-measure. On Enron, plain BR has Hamming loss of 0.0468 and PCC H records 0.0471, compared with 0.0521 for PCC GFM. The lower Hamming losses of the default binary rules are consistent with their purpose. Giving more attention to coverage of the positive sets can change whether particular labels are included, and Hamming loss counts the resulting errors with its own coordinate-wise objective.
The macro and micro scores do not always rank the F-measure rules in the same way as the instance-wise score. On Scene, PCC GFM obtains macro F-measure of 0.6915 and micro F-measure of 0.7101. The corresponding PCC GFM-T scores are 0.6908 and 0.7094. On Enron, GFM-T has the higher instance-wise score of those two methods and obtains macro and micro scores of 0.5948 and 0.6011. GFM obtains 0.5943 and 0.6006 on those Enron measures. The paper includes the pooled and label-wise results for reference because each one measures a different aggregation of the decisions.
Across the four benchmarks, the paper finds clear gains from using inference procedures tailored to instance-wise F-measure. It finds no consistent score winner among those procedures. The computational comparison gives GFM a more distinct advantage over MEUF, especially when inference must be repeated for many test instances with large label vectors. The artificial comparisons then help explain why the score gap depends more strongly on the label distribution than the timing gap does in these experiments.
What the ablations show
Changing the assumptions behind inference
The paper uses controlled comparisons and worst-case analyses in place of a component-by-component ablation. Its independent artificial distribution makes the comparison particularly informative about sampling. The marginals carry the information MEUF requires, and dependence contributes nothing extra to the optimum. MEUF leads in this setting, and GFM approaches its performance as more samples are used. The result is consistent with the authors' statistical argument. Even when the true joint distribution factors, GFM still estimates probabilities for the separate true sizes at which each label occurs. At small sample sizes those estimates have more opportunity to vary than the simpler marginal estimates.
The dependent artificial case changes the distributional premise. The conditional probability of a label in the chain can change with earlier labels, so the marginals no longer specify the joint behavior that matters to the score. In the paper's comparison, MEUF performs poorly in this case even as more samples are supplied. More samples improve the information available about the marginals. They cannot make the independence reconstruction account for dependence. GFM uses additional frequencies from each whole sampled vector, allowing the same additional sample to inform both the presence of a label and the size of the outcome in which it was observed.
The paper reports that the approximate variants behave similarly to their unrestricted or exact counterparts in the artificial comparisons. The reasons for approximation differ. MEUF Approx changes how the expected utility is computed under the independence assumption. GFM-T retains the joint score calculation for the candidates it considers and restricts which label sets enter the search. Their close performance in these cases shows how much the restriction or approximation cost on the tested distributions. The comparison does not imply that the two simplifications are equivalent or that either will have the same effect elsewhere.
How much the independence assumption can cost
The worst-case result for MEUF formalizes the risk of supplying marginals for a dependent joint distribution. Regret is the gap between the expected F-measure of an optimal prediction and the expected F-measure of the prediction that MEUF produces. Both predicted vectors are evaluated under the actual distribution. For each number of labels, the analysis considers the largest gap attainable over the possible joint distributions. The paper gives the limiting result as follows.
limₘ→∞ supₚ E[F(Y, h*ꜰ) − F(Y, hⱼ)] = 1
Here m is the number of labels, limₘ→∞ is the limit as that number grows, and supₚ is the supremum over joint distributions p of Y. The expectation E is taken under the distribution being considered. The function F evaluates the random truth Y against a prediction. The symbol h*ꜰ denotes the prediction that maximizes expected F-measure under that distribution, and hⱼ is the prediction from Jansche's MEUF. The value 1 is the limiting worst-case gap on the F-measure scale.
This statement concerns distributions chosen for their effect on the method. It explains a failure that can persist even with precisely known marginals. If the marginals describe a dependent distribution, MEUF's expected-score calculation answers the question for the independent distribution obtained from those marginals. Evaluating its choice under the actual joint distribution can then yield a very different result. The dependent artificial experiment illustrates the direction of that effect under a particular construction. The benchmark scores show that very large losses are not needed to explain the empirical ranking of these inference methods.
Separating threshold choice from candidate choice
The authors also analyze a threshold rule with access to the best possible threshold for the true distribution. In that analysis, the fact that the correct threshold may be difficult to estimate has been set aside. The remaining constraint is that a rule must include labels according to the order of their marginal probabilities. If the set with the best expected F-measure omits a label ranked ahead of one it includes, tuning the threshold cannot recover that set.
supₚ E[F(Y, h*ꜰ) − F(Y, hₜ)] ≥ max(0, 1/6 − 2/(m + 4))
Here supₚ is the supremum over joint distributions p of the truth vector Y. The symbol E denotes expectation under the chosen distribution, F is the F-measure, h*ꜰ is a maximizing prediction over all vectors, and hₜ is the best prediction obtainable by thresholding the true marginals. The inequality gives a lower bound on worst-case regret. The function max takes the larger of 0 and the expression involving m, the number of labels. The constants 1, 6, 2, and 4 are those in the paper's bound.
The distinction between the bounds is important. The MEUF result asks what can go wrong when an independence-based decision is evaluated on a joint distribution that violates independence. The threshold result gives the restricted rule the distributional knowledge it needs to find the best threshold, and still shows that its search may exclude a better prediction. Thus, exact scoring of a restricted candidate list and exact optimization over all vectors are different properties.
The full GFM and GFM-T comparison brings this distinction into the benchmark experiments. Both use joint size probabilities to evaluate candidates. Full GFM can choose the best labels independently at every size, while GFM-T inherits the marginal order. Their held-out instance-wise scores are close on the reported datasets. GFM has the higher score on Scene, and GFM-T has the higher score on Enron and Mediamill. Full GFM's larger search space gives it at least as good an optimum on a shared set of probability inputs. The held-out ordering can differ because the experiment measures realized performance after estimation and sampling. The paper does not isolate a cause for any individual reversal.
The Hamming comparison isolates a further decision. H selects each label by its own estimated probability and a fixed threshold of 0.5. MEUF changes the criterion used to choose a prediction while still working with marginals. GFM changes the information used about each label as well as the criterion. The observed gains in instance-wise F-measure for the methods tailored to it show that there is value in changing the criterion even in settings where the extra freedom of unrestricted GFM yields little measured advantage over other F-measure rules.
Limitations
Limits identified by the authors
The authors make exactness conditional on the availability of the required probabilities. The quadratic-sized array is a sufficient description for this decision, but it contains more entries than the marginal description used by MEUF. The paper points out that estimating those extra probabilities can be more difficult. Its artificial experiment with independent labels demonstrates an advantage for the simpler method in a setting where the simpler description is correct. Its benchmark results give no consistent instance-wise lead to GFM, and the authors conclude that the number of estimated parameters appears to have little practical effect on the benchmark comparison they report.
The runtime claim also has a specific starting point. The proof assumes that the entries of P and the probability of an empty vector have already been obtained. It then bounds the work of calculating a maximizing prediction. The faster subcubic bound depends on a multiplication method that the authors describe as mainly of theoretical significance for matrices outside very large sizes. Ordinary multiplication and efficient selection still give a polynomial procedure. The timings on the desktop show a practical advantage over the MEUF implementations, while the complexity claim and the measured runtimes answer different questions.
The analysis of marginal thresholding leaves the exact supremum of its regret as an open question. The lower bound establishes that even the best threshold can be substantially suboptimal for some distributions. It does not characterize the largest possible gap for every label count. The limiting MEUF result, in turn, concerns the worst case as the number of labels grows. Neither result assigns a regret value to the distributions occurring in a specific benchmark.
The authors focus their optimization and practical tests on instance-wise F-measure. They discuss a possible use for macro F-measure in an earlier Bayesian online setting where integrating over fitted parameters induces dependence. They also consider direct optimization for micro F-measure in principle and describe the computational burden as high. In the discussion, they observe that equal denominators across test examples make the instance-wise and micro calculations coincide. If those denominators vary, the micro calculation pools overlap and sizes, while the instance-wise calculation gives each example its own score. Variation in the sizes can therefore produce an appreciable difference between the two measures.
Structured prediction is another proposed application. The authors say that a structured predictor that supports sampling from a joint distribution could supply GFM with the necessary probabilities. Their experiments concern multi-label classification. In ordinary binary classification, they regard independence of the responses as relatively reasonable and discuss MEUF or threshold methods as choices for that setting, subject to computational cost. The generality of the proof permits those applications, while the practical case for using it depends on the prediction setting.
Limits visible in the experimental setup
On the benchmarks, the entries of P come from a finite sample from a fitted chain for each test input. Even if the chain gives sensible probabilities, an event that receives little mass may occur infrequently in that sample. Uncertainty about a probability associated with a label and a true size can affect its weighted score. If candidates are close, that uncertainty can affect which of them wins. The exact inference algorithm preserves the information in its supplied inputs. It cannot resolve the sampling or estimation uncertainty in those inputs.
The benchmark design can compare decision rules within PCC and can show what happens when MEUF is applied to BR marginals. It does not separately vary all the factors that determine how well P can be estimated. The paper uses linear logistic classifiers for the chains and draws 200 samples per test example in the benchmark runs. The artificial experiments vary sample size to study how inference responds under controlled distributions. Those experiments cannot establish how another classifier, another sample size, or a different distribution of rare labels would change the benchmark ranking. The reported aggregate test scores also do not quantify uncertainty around the close results between the F-measure rules. Small differences in the table alone leave the reliability of the ranking unresolved.
Timing comparisons across the real datasets also reflect their test-set sizes and the costs of processing those inputs. Mediamill has many more test examples than the other benchmark datasets in the paper. Its run is a useful demonstration of the cumulative burden of a costly inference rule, while the artificial timing experiment with fixed sampling gives a more controlled comparison as the number of labels varies. The missing exact MEUF outcomes on Mediamill document a computational limitation of that run. They leave its test scores unknown.
Finally, the score's treatment of an empty prediction depends on the convention the authors chose. Assigning a score of 1 when both the truth and prediction are empty means the probability of an empty true set can decide the outcome of the outer search. This is an explicit part of the mathematical objective. A task that evaluates empty pairs differently would have a different comparison for that candidate, and the reported results use the convention in the paper. The analysis of nonempty candidates concerns the unweighted F-measure, which is the form the authors set out to optimize.
What came after
The paper describes possible follow-on applications, with structured prediction the clearest next step. It points to earlier methods such as Search-based structured prediction and distinguishes the objective used during optimization from the metric reported at evaluation. Its proposed application would use a structured predictor that can generate samples from a joint distribution, then use GFM to select the output with the highest expected instance-wise F-measure. That application was planned future work in the paper.
The authors also identify a route to macro F-measure through an earlier Bayesian procedure that samples predictions to choose thresholds. With dependence induced by integrating over parameters, GFM could enlarge the search beyond those threshold decisions. These are directions the paper proposes. The subsequent results of either application are undocumented here.
Cite
Cite as Krzysztof Dembczyński, Willem Waegeman, Weiwei Cheng and Eyke Hüllermeier. 2011. An Exact Algorithm for F-Measure Maximization. Ghent University Academic Bibliography (Ghent University).
@inproceedings{dembczynski2011exact,
title = {{An Exact Algorithm for F-Measure Maximization}},
author = {Krzysztof Dembczyński, Willem Waegeman, Weiwei Cheng and Eyke Hüllermeier},
booktitle = {Ghent University Academic Bibliography (Ghent University)},
year = {2011},
url = {http://hdl.handle.net/1854/LU-2913412}
}This page in Markdown https://md.research.elamur.ai/free/en/papers/dembczynski-2011-exact-algorithm-f-measure-maximization/