<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Ravi&apos;s Homepage</title>
    <description>Software Engineer @ SS Software Solutions LLC | AI Security &amp; MLOps | M.Tech Data Science &amp; AI (IIIT Ranchi)</description>
    <link>https://er-ravi-srivastava.github.io/</link>
    <atom:link href="nathanrooy.github.io/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Wed, 04 Nov 2026 13:27:12 +0000</pubDate>
    <lastBuildDate>Wed, 04 Nov 2026 13:27:12 +0000</lastBuildDate>
    <generator>Jekyll v3.10.0</generator>
      
    
    <item>
        <title>Correct Looks Better</title>
        <description>&lt;center style=&quot;display: flex; justify-content: center; gap: 20px;&quot;&gt;
&lt;a href=&quot;https://arxiv.org/abs/2606.09409&quot;&gt;Paper&lt;/a&gt;
&lt;span&gt;·&lt;/span&gt;
&lt;a href=&quot;https://github.com/socialfoundations/correct-looks-better&quot;&gt;Code&lt;/a&gt;
&lt;span&gt;·&lt;/span&gt;
&lt;span&gt;ICML 2026&lt;/span&gt;
&lt;/center&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; Pairwise comparison-based ranking reflects the accuracy-based ranking of models on verifiable tasks.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;motivation&quot;&gt;Motivation&lt;/h2&gt;

&lt;p&gt;When we evaluate large language models, we often care about ranking them in one way or another. If the task is well-defined and we have ground truth labels, we can rank them by accuracy, which reflects how well they perform on the task. However, benchmarks measuring accuracy are not our only option for ranking models. In &lt;a href=&quot;https://lmarena.ai/&quot;&gt;Chatbot Arena&lt;/a&gt;&lt;sup id=&quot;fnref:5&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:5&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; models are evaluated on a diverse set of open-ended tasks using pairwise comparisons. The concern is that pairwise judgments are heavily biased to select the output that &lt;em&gt;appears&lt;/em&gt; to be correct rather than selecting the output that &lt;em&gt;is&lt;/em&gt; correct &lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;&lt;sup id=&quot;fnref:4&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:4&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;. So the question arises:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;Can pairwise comparison-based ranking reflect task performance?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We set out to answer this question by applying pairwise comparisons on a range of benchmarks, and checking whether the resulting ranking aligns with the accuracy-based ranking of the models.&lt;/p&gt;

&lt;h2 id=&quot;what-we-found&quot;&gt;What we found&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;High alignment with accuracy-based ranking&lt;/strong&gt;: high rank and score correlation across 5 benchmarks.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Outperforms baseline in weak model setting&lt;/strong&gt;: using a weak model (a model that’s not good at the task) directly as a judge (&lt;em&gt;LLM-as-judge&lt;/em&gt;) is significantly worse than using it to collect pairwise comparisons.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Rankings robust to judge biases&lt;/strong&gt;: correcting for style &lt;sup id=&quot;fnref:1:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;sup id=&quot;fnref:2:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt; and self-preference bias &lt;sup id=&quot;fnref:3:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;4&lt;/a&gt;&lt;/sup&gt; had minor impact on the ranking.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Echo influences judgment on non-discriminative pairs&lt;/strong&gt;: on pairs where both candidate answers are correct (or both are incorrect), the judge tends to choose answers that do not have any sequence repetition (&lt;em&gt;echo&lt;/em&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;figure&gt;
  &lt;img src=&quot;/images/post_pics/2026-06-16/fig1.png&quot; style=&quot;display:block; margin-left:auto; margin-right:auto; width:70%&quot; /&gt;
  &lt;figcaption&gt;&lt;center&gt;&lt;i&gt;Accuracy (x-axis) vs. Bradley-Terry score (y-axis). Each point represents a model evaluated on a specific benchmark. Bottom: judge model accuracy.&lt;/i&gt;&lt;/center&gt;&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h3 id=&quot;main-results&quot;&gt;Main results&lt;/h3&gt;

&lt;p&gt;Preference-based rankings align closely with accuracy-based rankings across all five benchmarks.
We observe both high rank correlation (\(ρ &amp;gt; 0.9\)) and high score correlation (\(r &amp;gt; 0.87\)) across all judge models.
What this means in practice is that&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;on 4 out of 5 benchmarks, only &lt;strong&gt;6-9%&lt;/strong&gt; of model pairs need to be swapped to recover the accuracy-based ranking.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;img src=&quot;/images/post_pics/2026-06-16/rank-distance.png&quot; style=&quot;display:block; margin-left:auto; margin-right:auto&quot; /&gt;
    &lt;figcaption&gt;&lt;center&gt;&lt;i&gt;Accuracy-based ranking (left) vs. Bradley-Terry based ranking (right). Bottom: Kendall&apos;s distance.&lt;/i&gt;&lt;/center&gt;&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h3 id=&quot;direct-judge-baseline&quot;&gt;Direct Judge Baseline&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Is it better to use the model directly as a judge?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A natural alternative to pairwise comparisons is to use the judge to directly classify each answer as correct or incorrect — this is what we call the &lt;em&gt;Direct Judge&lt;/em&gt; baseline. This is a strictly harder task: the judge must assess answers in isolation, without the relative signal a comparison provides. A weak judge that struggles with individual classification may still reliably pick the better of two answers.
When the selected judge does well on the task, both the Bradley-Terry and the Direct Judge approach perform well. However,&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;when the judge is weak, the Direct Judge &lt;em&gt;doubles&lt;/em&gt; the rank distance on SimpleQA (\(K_D=0.2 \rightarrow 0.382\)).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;img src=&quot;/images/post_pics/2026-06-16/baseline.png&quot; style=&quot;display:block; margin-left:auto; margin-right:auto; width:60%&quot; /&gt;
    &lt;figcaption&gt;&lt;center&gt;&lt;i&gt;Rank correlation of &quot;strong judge&quot; (03, 59.3% acc.) vs &quot;weak judge&quot; (gpt-oss-20b, 4.9% acc.) on SimpleQA.&lt;/i&gt;&lt;/center&gt;&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;In other words, Bradley-Terry outperforms the Direct Judge when the judge model has low accuracy on the task. This robustness may prove useful in frontier settings, where it’s difficult to say whether the selected judge is “weak” or “strong”.&lt;/p&gt;

&lt;h3 id=&quot;judge-bias&quot;&gt;Judge bias&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Does rank correlation improve after bias correction?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Style and self-preference biases are well-documented in pairwise evaluation — judges tend to favour longer, more formatted answers (&lt;em&gt;style bias&lt;/em&gt;), or outputs from their own model family (&lt;em&gt;self-preference bias&lt;/em&gt;). While such biases may affect absolute scores, their effect on relative model rankings is less clear. We corrected for both and found that&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;bias correction has a minor effect on rank correlation.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;img src=&quot;/images/post_pics/2026-06-16/bias.png&quot; style=&quot;display:block; margin-left:auto; margin-right:auto; width:60%&quot; /&gt;
    &lt;figcaption&gt;&lt;center&gt;&lt;i&gt;Rank correlation after bias correction (original in red). m = number of ranked models. &lt;/i&gt;&lt;/center&gt;&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;Importantly, this does not imply the &lt;em&gt;absence&lt;/em&gt; of bias — only that such biases have limited impact on model ranking in our evaluation.&lt;/p&gt;

&lt;h3 id=&quot;echo&quot;&gt;Echo&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;What drives the signal in non-discriminative pairs?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;On 60% of pairs, correctness provides no discriminating signal. We call these &lt;em&gt;non-discriminative&lt;/em&gt; pairs, where both answers are either correct or incorrect. The judge has to rely on superficial cues. And yet, we find that on such pairs rank correlation is still surprisingly high. One strong cue we identified is &lt;em&gt;echo&lt;/em&gt;: a failure mode where a model fails to stop after its final answer and repeats content, such as phrase or sequence repetition.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;We found echo to be a &lt;em&gt;causal driver&lt;/em&gt; of judge preference: \(P(A&amp;gt;B)\) drops from 0.81 to 0.29 (\(\Delta=−0.52\)) depending on which answer has echo. This effect &lt;em&gt;disappears&lt;/em&gt; on discriminative pairs (\(\Delta=−0.07\)).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;img src=&quot;/images/post_pics/2026-06-16/echo.png&quot; style=&quot;display:block; margin-left:auto; margin-right:auto; width:60%&quot; /&gt;
    &lt;figcaption&gt;&lt;center&gt;&lt;i&gt;Judge preference conditional on echo on BBH. Non-discriminative (left) vs discriminative pairs (right). &lt;/i&gt;&lt;/center&gt;&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h2 id=&quot;closing-thoughts&quot;&gt;Closing thoughts&lt;/h2&gt;

&lt;p&gt;Of course, it’s important that our model rankings are not influenced by subjective biases. On questions where some answers are objectively better, we found that pairwise comparisons (and the resulting rankings) often indeed reflect the objective choice (picking the model with higher accuracy). This means that on &lt;em&gt;discriminative&lt;/em&gt; pairs the judge picks the correct answer. On pairs where this objective choice is not possible, however, the judge falls back to appearance-based cues — it avoids picking answers that contain &lt;em&gt;echo&lt;/em&gt; — which are also correlated with higher model accuracy. This doesn’t mean the biases can be ignored: they could still be exploited adversarially to inflate a model’s ranking.&lt;/p&gt;

&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Acknowledgements&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cover image &lt;a href=&quot;https://artvee.com/dl/design-for-a-ceiling-3#00&quot;&gt;source&lt;/a&gt;. Drawing by Mariano Salvador Maella.&lt;/em&gt;&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:5&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;W. Chiang, L. Zheng, Y. Sheng, et al. “Chatbot Arena: An open platform for evaluating LLMs by human preference.” ICML 2024. &lt;a href=&quot;#fnref:5&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Y. Dubois, P. Liang, T. Hashimoto. “Length-controlled AlpacaEval: A simple debiasing of automatic evaluators.” ICML 2024. &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt; &lt;a href=&quot;#fnref:1:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;sup&gt;2&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;T. Li, A. Angelopoulos, W. Chiang. “Does style matter? Disentangling style and substance in Chatbot Arena.” LMSYS Blog, 2024. &lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt; &lt;a href=&quot;#fnref:2:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;sup&gt;2&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;K. Wataoka, T. Takahashi, R. Ri. “Self-preference bias in LLM-as-a-judge.” NeurIPS Safe Generative AI Workshop, 2024. &lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt; &lt;a href=&quot;#fnref:3:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;sup&gt;2&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:4&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;G.H. Chen, S. Chen, Z. Liu, F. Jiang, B. Wang. “Humans or LLMs as the judge? A study on judgement bias.” EMNLP 2024. &lt;a href=&quot;#fnref:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
        <pubDate>Tue, 16 Jun 2026 00:00:00 +0000</pubDate>
        
        <link>/posts/2026-06-16/correct-looks-better.html</link>
          
        
            <category>LLMs</category>
        
            <category>pairwise comparisons</category>
        
            <category>model evaluation</category>
        
            <category>ranking</category>
        
            <category>ICML</category>
        
          
        
            <category>posts</category>
        
          
      </item>
    
    <item>
        <title>F-score and G-mean</title>
        <description>&lt;p&gt;Everyone should be more-or-less familiar with the following two metrics that we commonly use in Machine Learning: F-score and G-mean. The &lt;a href=&quot;https://en.wikipedia.org/wiki/F-score&quot;&gt;F-score&lt;/a&gt; is defined as follows:&lt;/p&gt;

\[F=\frac{2*Pr*Re}{Pr+Re} = \bar{H}(Pr,Re)\]

&lt;p&gt;which is the harmonic mean (\(\bar{H}\)) of precision (\(Pr\)) and recall (\(Re\)). Similarly, the somewhat less-known &lt;a href=&quot;https://imbalanced-learn.org/dev/references/generated/imblearn.metrics.geometric_mean_score.html&quot;&gt;G-mean&lt;/a&gt; is another average of two very commonly used metrics; sensitivity (\(Se\)) and specificity (\(Sp\)):&lt;/p&gt;

\[\bar{G}(Se, Sp)=\sqrt{Se*Sp}\]

&lt;p&gt;Here, a geometric mean (\(\bar{G}\)) is used. 
I couldn’t help but wonder: Why do we use the &lt;em&gt;harmonic mean&lt;/em&gt; for precision and recall, while we use the &lt;em&gt;geometric mean&lt;/em&gt; for sensitivity and specificity? It turns out, that this choice is not entirely arbitrary. Diving into this question was a useful exercise for me to understand these metrics better.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/post_pics/2024-11-25/mean.png&quot; alt=&quot;image&quot; style=&quot;display:block; margin-left:auto; margin-right:auto&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;what-are-we-measuring&quot;&gt;What are we measuring?&lt;/h2&gt;

&lt;p&gt;Before going into why we use one definition of mean over the other, let’s take a closer look at what we are actually trying to measure. We will be talking about the following scores:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Precision is the number of true positives (TP), divided by all positive predictions (PP).&lt;/li&gt;
  &lt;li&gt;Recall (or sensitivity) is the number of true positives (TP), divided by all actual positives (P).&lt;/li&gt;
  &lt;li&gt;Specificity is the number of true negatives (TN), divided by all actual negatives (N).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And the following averages (for two inputs):&lt;/p&gt;

&lt;p&gt;Harmonic mean: \(\bar{H}(x_1, x_2) = \frac{2*x_1*x_2}{x_1+x_2}\)&lt;/p&gt;

&lt;p&gt;Geometric mean: \(\bar{G}(x_1, x_2) = \sqrt{x_1*x_2}\)&lt;/p&gt;

&lt;h2 id=&quot;the-usual-argument&quot;&gt;The usual argument&lt;/h2&gt;
&lt;p&gt;If you search on the internet “Why do we use harmonic mean for F-score?” you will typically find the same (somewhat unsatisfying) answer: if either precision or recall are zero, the mean will be zero too. Or conversely: both precision and recall have to be relatively high for the mean to be high. This is easy to verify just by looking at the numerator of the F-score: multiplying precision and recall have this effect. But wait - we could also just use the geometric mean&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; because it contains the same multiplicative expression. So why does it make (more) sense to use harmonic mean instead?&lt;/p&gt;

&lt;h2 id=&quot;harmonic-mean-preserves-units&quot;&gt;Harmonic mean preserves units&lt;/h2&gt;
&lt;p&gt;Typically you will want to use the harmonic mean when you are measuring the rate of something. Precision and recall both count the rate of true positives.
The nice thing about applying the harmonic mean is that the result preserves the original unit: it is the rate of true positives over the total number of examined cases. Revisiting the F-score formula:&lt;/p&gt;

\[F=\frac{2*Pr*Re}{Pr+Re} = \frac{2TP}{2TP+FP+FN} \quad \left[\frac{\texttt{#TP}}{\texttt{#cases}}\right]\]

&lt;p&gt;The right hand side of the equation becomes clearer when you look at a visual representation of what you are counting. It is the total number of true positive (\(2TP\)) predictions, over the number of positive samples (\(P=TP+FN\)) plus the number of positive predictions (\(PP=TP+FP\)). The result is the rate of true positives among samples that are either positive or predicted positive.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/post_pics/2024-11-25/venn-pred.jpeg&quot; alt=&quot;image&quot; style=&quot;display:block; margin-left:auto; margin-right:auto&quot; /&gt;&lt;/p&gt;

&lt;p&gt;For precision and recall, it just makes sense to choose the harmonic mean over the geometric mean to preserve the original unit because it makes the result more interpretable.
Sensitivity and specificity on the other hand measure the rate of two different things: true positives and true negatives. Here, we don’t have a common unit, so using either mean seems appropriate.&lt;/p&gt;

&lt;h3 id=&quot;no-deeper-meaning&quot;&gt;No deeper meaning&lt;/h3&gt;
&lt;p&gt;I don’t want to imply that choosing either mean over the other has a special meaning in Machine Learning.
Usually, the average has an important connection to some &lt;em&gt;total value&lt;/em&gt; depending on how we define it. &lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;
For G-means, I don’t have an intuitive interpretation for the product of scores like sensitivity and specificity.
If you do have in intuition for these total values in the context of Machine Learning, please let me know! But for now my conclusion is that the choice of means is not that deep.&lt;/p&gt;

&lt;h2 id=&quot;when-to-use-f-score-or-g-mean&quot;&gt;When to use F-score or G-mean?&lt;/h2&gt;
&lt;p&gt;Notice that the F-score does not factor in the number of true negatives (\(TN\)). I would say that it is a useful metric when predicting the positive class correctly is more important for some reason. This is typically true for predicting diseases - you care about correctly predicting people with the disease correctly (who may represent 1% of the population). 
The F-score for the negative class is not meaningful in this highly imbalanced case, since a predictor saying no one is sick would have both very high precision and recall&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;.
If you have an imbalanced dataset, and both classes are equally important, then the G-mean is probably a better choice.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Harmonic mean preserves the unit
    &lt;ul&gt;
      &lt;li&gt;makes sense for F-score (rate of true positives)&lt;/li&gt;
      &lt;li&gt;otherwise, no reason to choose one over the other&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Use F-score when you care about correctly predicting the positive class&lt;/li&gt;
  &lt;li&gt;Use G-mean when you care about both classes in an imbalanced dataset&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Acknowledgements&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cover image &lt;a href=&quot;https://www.artthugmagazine.com/home-2/bookreviews/coalescinggeometries&quot;&gt;source&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Footnotes&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;In fact, it seems that we do have a metric called the &lt;a href=&quot;https://en.wikipedia.org/wiki/Fowlkes%E2%80%93Mallows_index&quot;&gt;Fowlkes–Mallows index&lt;/a&gt;, which is the geometric mean of precision and recall. I personally never heard of it before, but it reinforced my belief that the choice of means is not that important. &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I recommend watching this &lt;a href=&quot;https://www.youtube.com/watch?v=V1_4nNm8a6w&quot;&gt;youtube video&lt;/a&gt; for a good intuition on means. &lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Recall would be perfect (1), since everyone is predicted healthy. Precision would be 0.99, because 99% of the population is actually healthy. &lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
        <pubDate>Mon, 25 Nov 2024 00:00:00 +0000</pubDate>
        
        <link>/posts/2024-11-25/F-and-G-score-and-what-they-mean.html</link>
          
        
            <category>mean</category>
        
            <category>F-score</category>
        
            <category>G-mean</category>
        
          
        
            <category>posts</category>
        
          
      </item>
    
    <item>
        <title>Driver fingerprinting</title>
        <description>&lt;p&gt;Perhaps it doesn’t come as a surprise that we all have unique driving styles.
My father is a calm, sometimes even slow driver. 
My mother is more temperamental in her driving ways - always cutting the line where she can (this was a highly useful skill when we were late to school).
When I close my eyes, I can immediately tell whether my mother or father is behind the wheel.&lt;/p&gt;

&lt;p&gt;But so can &lt;em&gt;anybody&lt;/em&gt; - using in-vehicle logs.
Turns out that these driving styles can translate to bits and bytes that our in-vehicle sensors record.&lt;/p&gt;
&lt;h1 id=&quot;in-vehicle-sensors&quot;&gt;In-vehicle sensors&lt;/h1&gt;
&lt;p&gt;There are a number of systems built in our cars for various purposes - to regulate
emission, to optimize engine performance or to log and detect malfunctions.
Think of your dashboard for example - you can see your speed, consumption and RPM all at a glance!
The data required for these comes from in-vehicle sensors. This data is converted
and processed by ECUs (Electronic Control Unit), which are essentially small
computers inside our cars. The ECUs communicate with each other through
the so-called CAN-bus (CAN - Controller Area Network).&lt;/p&gt;

&lt;h2 id=&quot;the-can-bus-whisperer-obd-dongle&quot;&gt;The CAN-bus whisperer: OBD dongle&lt;/h2&gt;
&lt;p&gt;The data sent over the CAN-bus can be easily captured.
For example, so-called ”insurance dongles” (or On-Board Diagnostics dongles) can collect and send in-vehicle sensor data to insurance companies.
They use this information to give you discounts for example, if you drive safely.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Another similar approach to lowering insurance premiums is using telematics data, as described &lt;a href=&quot;https://www.intelligent-mobility-xperience.com/how-telematics-data-is-transforming-car-insurance-a-917765/&quot;&gt;here&lt;/a&gt;.
The biggest difference however, is that telematics data are currently subject to data protection laws, unlike CAN logs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The OBD dongles connect to the ODBII interface of the vehicle.
These devices are not expensive at all (prices start at 10$), and can come with mobile apps so you can look at your data from your phone!&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;In some cases, we cannot access CAN logs directly through an OBD port (or at least not all parts of it).
There is usually a gateway regulating access to these data.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Even though CAN-bus data can be readily accessible (and not encrypted), the interpretation of the messages is still a challenge.
There is no global standard, and the structure of the messages varies from manufacturer to manufacturer. 
Without the cooperation of manufacturer, it is hard to reverse engineer these messages… but not impossible! 
If you want to know how to do it using machine learning techniques, check out my talented colleagues’ paper (&lt;a href=&quot;https://arxiv.org/abs/1902.08956&quot;&gt;Lestyan et al., 2019&lt;/a&gt;)!&lt;/p&gt;

&lt;div style=&quot;text-align: center&quot;&gt;&lt;img src=&quot;/images/post_pics/2020-10-21/obd_dongle.jpg&quot; width=&quot;50%&quot; height=&quot;50%&quot; /&gt;&lt;/div&gt;

&lt;h1 id=&quot;driver-fingerprinting&quot;&gt;Driver fingerprinting&lt;/h1&gt;
&lt;p&gt;So what can we do with the obtained CAN-bus data? 
Turns out, that we can use it to determine who was behind the wheel.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot;&gt;How it works&lt;/h2&gt;
&lt;p&gt;Driver fingerprinting or driver re-identification uses the data collected from the CAN logs (called &lt;em&gt;traces&lt;/em&gt;) to correctly identify drivers.
From these traces, we can extract the data from one sensor to obtain a &lt;em&gt;time series&lt;/em&gt; (measuring speed for example).&lt;/p&gt;

&lt;p&gt;The input of such a model can consist of multiple time series, like in the example image below.
However, to obtain these time series, first we need to &lt;strong&gt;reverse-engineer&lt;/strong&gt; them.
Then, we can use &lt;strong&gt;Machine Learning&lt;/strong&gt; to make predictions on the driver’s identity.&lt;/p&gt;

&lt;div style=&quot;text-align: center&quot;&gt;&lt;img src=&quot;/images/post_pics/2020-10-21/main_idea.png&quot; width=&quot;80%&quot; height=&quot;80%&quot; /&gt;&lt;/div&gt;

&lt;p&gt;For my 2018 Scientific Students’ Association &lt;a href=&quot;https://tdk.bme.hu/VIK/ViewPaper/Vezeto-Azonositas-es-Szemelyes-Adatok1&quot;&gt;paper&lt;/a&gt; I used the measurements of 5 sensors (namely &lt;em&gt;brake&lt;/em&gt;, &lt;em&gt;clutch&lt;/em&gt;, &lt;em&gt;gaspedal&lt;/em&gt;, &lt;em&gt;rpm&lt;/em&gt; and &lt;em&gt;speed&lt;/em&gt;). 
&lt;em&gt;Brake&lt;/em&gt;, &lt;em&gt;clutch&lt;/em&gt; and &lt;em&gt;gaspedal&lt;/em&gt; sensors measure the position of the respective pedals.
As for the rest: &lt;em&gt;rpm&lt;/em&gt; records the revolutions per minute and &lt;em&gt;speed&lt;/em&gt; measures the vehicle’s speed.
I was also able to work on data collected from 33 drivers, whereas state-of-the-art driver re-identification papers only published results on models that had to distinguish 2-15 drivers.
My model achieved a 66% mean accuracy, given a mere 10 second trace as input!&lt;/p&gt;

&lt;p&gt;One might think that this time-window can be pushed down even further - 
theorizing that the distinguishing part in everyone’s driving could be the part where 
they accelerate or shift gears, which is about 2-3 seconds long. 
However, when driving in a city there are a lot of situations where one must stand
still (in morning traffic, in front of a stoplight, or while letting that old lady cross
the street). &lt;a href=&quot;https://arxiv.org/abs/1708.04636&quot;&gt;Related work&lt;/a&gt;  suggests that all the information needed to identify a
driver can be obtained from the measurements of a single turn.
This confirms the intuition that someone’s driving can be quite accurately 
distinguished based on how they slow down, switch gears and accelerate.&lt;/p&gt;

&lt;p&gt;After writing this paper me and my colleagues were motivated to extend this research by eliminating the first step: reverse engineering the raw data.&lt;/p&gt;

&lt;h2 id=&quot;driver-re-identification-on-raw-data&quot;&gt;Driver re-identification on raw data&lt;/h2&gt;
&lt;p&gt;In our paper titled &lt;a href=&quot;https://arxiv.org/abs/1911.09508&quot;&gt;Automatic Driver Identification from In-Vehicle Network Logs&lt;/a&gt; 
we demonstrated that it is possible to achieve the same results &lt;strong&gt;without having to reverse engineer and pre-select signals&lt;/strong&gt; from the CAN log.&lt;/p&gt;

&lt;div style=&quot;text-align: center&quot;&gt;&lt;img src=&quot;/images/post_pics/2020-10-21/our_work.png&quot; width=&quot;80%&quot; height=&quot;80%&quot; /&gt;&lt;/div&gt;

&lt;p&gt;We collected 72 time series from unknown sensors and trained a Deep Learning model on each of them.
Not all time series were equally good inputs for the re-identification task, which is why we combined the top-10 performing classifiers into one mixture model.
We achieved a mean accuracy of 75-85%  for  CAN  traces  whose length varied between 20 and 120 seconds.&lt;/p&gt;

&lt;p&gt;Great! Acquiring an OBD dongle that can read CAN logs is not only cheap, 
it turns out you don’t have to &lt;em&gt;understand&lt;/em&gt; the data to build a working driver-fingerprinting classifier with it.&lt;/p&gt;

&lt;h1 id=&quot;privacy-implications&quot;&gt;Privacy implications&lt;/h1&gt;
&lt;p&gt;So now that we know that our in-vehicle data could potentially identify us, why should we protect it?
I mean, aside from well-wishing insurance companies who give us discounts, who could possibly get our data?&lt;/p&gt;

&lt;p&gt;Except if… car companies were motivated to sell CAN logs to 3rd parties. 
And currently they could do so. Without our consent (because it is not considered to be personal data as of yet). Uh-oh.&lt;/p&gt;

&lt;h2 id=&quot;driving-data-the-car-industrys-new-cash-cow&quot;&gt;Driving data: the car industry’s new cash cow?&lt;/h2&gt;
&lt;p&gt;Many sources suggest the lucrativity of driving data – &lt;a href=&quot;https://www.mckinsey.com/industries/automotive-and-assembly/our-insights/monetizing-car-data#&quot;&gt;McKinzey&amp;amp;Co&lt;/a&gt;,
a management consulting firm, estimates that ”data from connected cars will be worth
up to $750 billion by 2030”. 
Companies are already preparing for the market
for data from cars, which is expected to be even bigger than the market for the
cars themselves acording to this &lt;a href=&quot;https://www.forbes.com/sites/petercohan/2017/09/29/this-startup-is-helping-daimler-and-bmw-compete-with-google-for-10-trillion-market/#250ab5121342&quot;&gt;Forbes article&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Future ideas include selling data to mapping firms looking to provide more accurate
traffic information, or selling consumption-related and other statistics to
operators of larger vehicle fleets.
And if driver identification is possible, it opens all kinds of doors.
For instance, you can use driver identification to notify you any time someone else is driving your car.
Or your car could “memorize” your driving fingerprint, and adjust your seat, and radio to your liking as soon as you turn the corner.
Neat, right? 
But wait, something is missing from the list - the biggest cash-grabber of them all: ad revenues.
In the hands of 3rd party advertisers, our cars could be yet another gateway to personalised advertisements.&lt;/p&gt;

&lt;p&gt;Just like with any other personal information that could potentially identify us: using such data should require our explicit &lt;strong&gt;consent&lt;/strong&gt;!&lt;/p&gt;

&lt;h2 id=&quot;gdpr-and-awareness&quot;&gt;GDPR and awareness&lt;/h2&gt;

&lt;p&gt;Because of how new these findings are, it is still unclear whether drivers are completely
informed about the wealth of personal information that their CAN logs potentially reveal.
Hopefully this post was an eye-opener to the inevitable future 
where even our driving data will be on the market.&lt;/p&gt;

&lt;p&gt;Although car companies stress  that  the  collected  network  logs  are  “anonymized”, 
the  proper  anonymization  of  such  high-dimensional  data  is notoriously difficult in practice 
without significantly degrading accuracy (&lt;a href=&quot;https://dl.acm.org/doi/abs/10.5555/1083592.1083696&quot;&gt;Aggarwal et al., 2005&lt;/a&gt;).
Even aggregated metrics aren’t always completely safe (&lt;a href=&quot;https://www.researchgate.net/publication/221559640_Revealing_Information_while_Preserving_Privacy&quot;&gt;Dinur and Nissim, 2004&lt;/a&gt;). 
The feasibility to identify (and/or profile)
a driver means that CAN logs are indeed personal data and, as
such, are subject to the European General Data Protection Regulation (GDPR)
as of 25 May 2018. It is a fundamental duty of companies handling
such data to adequately inform drivers and protect their personal data.
Failing to do so does not only ruin customer trust, but can also result in a
fine up to &lt;a href=&quot;https://www.mckinsey.com/industries/automotive-and-assembly/our-insights/monetizing-car-data#&quot;&gt;20 million Euros&lt;/a&gt;.&lt;/p&gt;

&lt;h1 id=&quot;closing-thoughts&quot;&gt;Closing thoughts&lt;/h1&gt;

&lt;p&gt;We have seen that it is fairly easy to access this data, and will probably become even more accessible in the not-so-distant future of connected vehicles.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Massachusets has &lt;a href=&quot;https://tech.slashdot.org/story/20/11/04/2018202/massachusetts-voters-overwhelmingly-pass-car-right-to-repair-ballot-initiative?sdsrc=rel&quot;&gt;voted&lt;/a&gt; (Nov. 4th, 2020) on &lt;strong&gt;standardizing access to car data&lt;/strong&gt; (to extend the state’s right-to-repair law)! 
This could set a standard for the vehicles to come…&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We have also seen that even without the reverse-engineering of the logs, identifying drivers is still possible. 
Turns out, our phones aren’t the only devices that store and/or process information which could potentially identify us. :)&lt;/p&gt;

&lt;p&gt;I don’t know what driving fingerprint I posess, but I hope I can eventually get the best from both of my parents: my father’s calm (but ultimately safe) driving and my mother’s mad parking skills!&lt;/p&gt;

&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;A special thank you to the following people who have provided me with useful feedback and suggestions:&lt;/em&gt; 
&lt;em&gt;Gergely Ács, Andris Gazdag, Ferenc Huszár and Viktor Remeli.&lt;/em&gt;&lt;/p&gt;
</description>
        <pubDate>Tue, 17 Nov 2020 00:00:00 +0000</pubDate>
        
        <link>/posts/2020-11-17/Driver-fingerprinting.html</link>
          
        
            <category>driver fingerprinting</category>
        
            <category>privacy</category>
        
          
        
            <category>posts</category>
        
          
      </item>
    
  </channel>
</rss>
