<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>marti.ai tech blog</title>
    <description>Musings around quantitative finance and machine learning.
</description>
    <link>https://www.marti.ai/</link>
    <atom:link href="https://www.marti.ai/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Sun, 12 Jul 2026 15:56:41 +0000</pubDate>
    <lastBuildDate>Sun, 12 Jul 2026 15:56:41 +0000</lastBuildDate>
    <generator>Jekyll v4.4.1</generator>
    
      <item>
        <title>Combining Professional Forecasters with Copulas (Part 3): A Walk-Forward Horserace</title>
        <description>&lt;p&gt;&lt;em&gt;This is the third post in the series. &lt;a href=&quot;/forecasting/2026/07/04/spf-part1-eda.html&quot;&gt;Part 1&lt;/a&gt; introduced the Survey of Professional Forecasters data. &lt;a href=&quot;/forecasting/2026/07/08/spf-part2-copulas.html&quot;&gt;Part 2&lt;/a&gt; developed two copula-based ways to combine point forecasts. This post asks how those ideas behave in a walk-forward empirical test.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The empirical results do not identify a single dominant copula method. In this quarterly macro setting, the strongest methods are mostly parsimonious. The nowcast is hard to beat. Error GLS and shrunk Error GLS perform well because they concentrate on the most informative horizon while correcting for redundant and correlated forecast errors. More flexible copula methods are informative diagnostics, but in this sample their additional flexibility does not translate into better out-of-sample forecasts.&lt;/p&gt;

&lt;h2 id=&quot;from-the-first-two-posts-to-this-horserace&quot;&gt;From the first two posts to this horserace&lt;/h2&gt;

&lt;p&gt;Part 2 separated two probability questions.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;outcome-forecast approach&lt;/strong&gt; models the joint distribution of the realised outcome and the forecasts:&lt;/p&gt;

\[(Y, X_1, \ldots, X_D).\]

&lt;p&gt;Its question is:&lt;/p&gt;

\[\mathbb{E}[\text{outcome rank} \mid \text{forecast ranks}].\]

&lt;p&gt;The &lt;strong&gt;forecast-error approach&lt;/strong&gt; models the dependence structure of the forecast errors:&lt;/p&gt;

\[E_k = X_k - Y.\]

&lt;p&gt;Its question is:&lt;/p&gt;

\[\text{which candidate } y \text{ makes } (X_1-y,\ldots,X_D-y) \text{ plausible?}\]

&lt;p&gt;These two questions can lead to similar linear formulas under restrictive Gaussian assumptions, but they are not the same statistical object. The distinction matters once we evaluate rank skill, level accuracy, nonlinear dependence, and different point summaries of a likelihood.&lt;/p&gt;

&lt;h2 id=&quot;the-target-is-now-an-official-realised-value&quot;&gt;The target is now an official realised value&lt;/h2&gt;

&lt;p&gt;Parts 1 and 2 used an SPF-aligned proxy target constructed from the available survey panel. For the final horserace I rebuild the panel from the Philadelphia Fed’s official SPF evaluation files. This gives a more precise target definition.&lt;/p&gt;

&lt;p&gt;For each variable, the panel contains three realised values:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Target&lt;/th&gt;
      &lt;th&gt;Meaning&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;target_initial&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;first official realised value used for real-time evaluation&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;target_latest&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;latest revised official value&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;target_spf_proxy&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;earlier proxy target used in Parts 1 and 2&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The main experiment uses &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;target_initial&lt;/code&gt;. This is closest to the real-time question: what would the forecast have predicted before later data revisions?&lt;/p&gt;

&lt;p&gt;I keep &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;target_latest&lt;/code&gt; for a revision-sensitivity check. This matters because macro realised values are revised. A forecasting method can look different depending on whether we score it against first releases or later vintages.&lt;/p&gt;

&lt;p&gt;The official-target panel covers RGDP, NGDP, PGDP, UNEMP, CPI, INDPROD, and HOUSING. I exclude CPROF from the main horserace because the same aligned official evaluation structure is not available, and the CPROF definition changes over time.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/spf-part3/fig1_target_vintages.png&quot; alt=&quot;Comparison of SPF proxy, initial release, and latest release targets&quot; style=&quot;width:100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The figure shows why this matters. For unemployment, the different target definitions are almost identical in rank. For growth variables, especially RGDP, the proxy, initial release, and latest revised value can differ materially.&lt;/p&gt;

&lt;h2 id=&quot;evaluation-design&quot;&gt;Evaluation design&lt;/h2&gt;

&lt;p&gt;The main experiment is a &lt;strong&gt;walk-forward expanding-window&lt;/strong&gt; evaluation.&lt;/p&gt;

&lt;p&gt;For each target date, a method is trained only on information from earlier target dates. The training window then expands by one date and the procedure repeats. This is closer to the way a forecast-combination method would be used in practice than a single fixed train/test split.&lt;/p&gt;

&lt;p&gt;The cross-horizon experiment combines SPF consensus forecasts made at leads 0 through 4 for the same target. Lead 0 is the nowcast. Longer leads are progressively earlier forecasts for the same realised quarter.&lt;/p&gt;

&lt;p&gt;The methods are:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Family&lt;/th&gt;
      &lt;th&gt;Methods&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Simple benchmarks&lt;/td&gt;
      &lt;td&gt;persistence, Lead 0, equal weight, trimmed mean, inverse MSE&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Outcome-forecast dependence&lt;/td&gt;
      &lt;td&gt;OLS on raw ranks, Gaussian outcome copula, shrunk Gaussian outcome copula, truncated outcome vine&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Forecast-error dependence&lt;/td&gt;
      &lt;td&gt;Error GLS, shrunk Error GLS, Gaussian error copula, vine error copula&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The rank metric is computed as follows. Actuals and predictions are ranked separately within each macro variable, then those within-variable ranks are stacked and one Spearman correlation is computed. This avoids comparing the level of unemployment directly with the level of GDP growth, while still giving one summary number for the full panel.&lt;/p&gt;

&lt;p&gt;The level metric is scaled RMSE. Each error is divided by the standard deviation of the realised target in the training sample for that variable. This makes the level errors roughly comparable across variables with different units. Scaled bias is the average scaled error, so positive values mean the method tends to overpredict.&lt;/p&gt;

&lt;h2 id=&quot;the-main-result&quot;&gt;The main result&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;/assets/spf-part3/fig2_main_horserace.png&quot; alt=&quot;Walk-forward horserace of forecast-combination methods&quot; style=&quot;width:100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The main table is below. Higher rank correlation is better. Lower scaled RMSE is better.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Method&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Stacked rank rho&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Scaled RMSE&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Scaled bias&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Lead 0&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.788&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.461&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-0.005&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Shrunk Error GLS&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.786&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.459&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-0.007&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Error GLS&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.778&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.461&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-0.004&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Gaussian outcome copula&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.766&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.647&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.014&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;OLS raw ranks&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.766&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.788&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.054&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Gaussian error copula, flat mean&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.757&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.612&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.033&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Vine error copula, flat mean&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.755&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.623&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-0.003&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Inverse MSE&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.716&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.689&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.043&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Truncated outcome vine&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.702&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.746&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-0.087&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Equal weight&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.634&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.822&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.061&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Persistence&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.598&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.179&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.017&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Trimmed mean&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.573&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.919&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.067&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The persistence benchmark is the last observed realised value available in the expanding training sample. The strongest benchmark is not a sophisticated model. It is Lead 0, the nowcast. In this cross-horizon setting there is a structural skill hierarchy: the forecast made closest to the target quarter contains much more information than the forecasts made several quarters earlier.&lt;/p&gt;

&lt;p&gt;The first three rows are very close. Lead 0 has the highest rank correlation, while shrunk Error GLS has the lowest scaled RMSE by a small margin. The nowcast and the two Error GLS variants are therefore broadly comparable at the top of the table. A paired quarter-block bootstrap gives the same interpretation: the gap between Lead 0 and shrunk Error GLS is small relative to sampling variation. Each row below is computed as the first method minus the second method. For RMSE, negative values favour the first method.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Comparison&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Delta rank rho&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;95% bootstrap interval&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Delta scaled RMSE&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;95% bootstrap interval&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Lead 0 minus shrunk Error GLS&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.003&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;[-0.004, 0.009]&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.003&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;[-0.023, 0.029]&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Lead 0 minus Error GLS&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.009&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;[-0.005, 0.027]&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.001&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;[-0.068, 0.058]&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Lead 0 minus Gaussian outcome copula&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.021&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;[0.007, 0.035]&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-0.172&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;[-0.367, -0.036]&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The ranking against equal-weight is less ambiguous. Relative to equal-weight, Lead 0, shrunk Error GLS, Error GLS, and the Gaussian outcome copula all have positive bootstrap intervals for rank correlation and negative intervals for scaled RMSE.&lt;/p&gt;

&lt;p&gt;The Gaussian outcome copula remains a strong rank predictor, but its level RMSE is worse. This level score combines two separate steps: estimating the conditional rank, then mapping that rank back to a level using the empirical training distribution of realised outcomes. The weaker RMSE can therefore come from the marginal calibration and inverse-rank mapping, even when the dependence model orders outcomes well.&lt;/p&gt;

&lt;h2 id=&quot;why-error-gls-holds-up&quot;&gt;Why Error GLS holds up&lt;/h2&gt;

&lt;p&gt;Error GLS estimates the covariance matrix of forecast errors,&lt;/p&gt;

\[\Sigma_E = \operatorname{Cov}(E_1,\ldots,E_D),\]

&lt;p&gt;and uses its inverse, the precision matrix, to form&lt;/p&gt;

\[\hat y =
\frac{\mathbf{1}^{\top}\Sigma_E^{-1}x}
{\mathbf{1}^{\top}\Sigma_E^{-1}\mathbf{1}}.\]

&lt;p&gt;This formula has a simple interpretation. Forecast directions with high error variance count less. Forecast directions that duplicate the same error information also count less. When several horizons are highly correlated, Error GLS avoids treating them as independent pieces of evidence.&lt;/p&gt;

&lt;p&gt;The estimated weights make this visible. Averaged across the walk-forward evaluation, both Error GLS variants put most of the weight on the nowcast. The weights sum to one, but they are not constrained to be positive: Error GLS is correcting correlated forecast errors, not imposing a convex average. The unshrunk estimator uses larger offsetting weights. The shrunk version keeps the same broad pattern, but pulls the secondary weights closer to zero; some average weights can still be negative.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Method&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Lead 0&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Lead 1&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Lead 2&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Lead 3&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Lead 4&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Error GLS, average weight&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.370&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-0.352&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.005&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-0.136&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.112&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Shrunk Error GLS, average weight&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.073&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.007&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-0.062&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-0.056&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.039&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;This is also why Error GLS ends up close to Lead 0 in the leaderboard: it mostly learns to trust the nowcast, while using the other horizons as smaller error-correction terms.&lt;/p&gt;

&lt;p&gt;This is a relatively low-dimensional object to estimate. A full KDE plus error-copula method is more demanding: it estimates each error marginal distribution, fits a multivariate dependence model, and then solves a one-dimensional prediction problem for each new forecast vector. In this sample, the extra flexibility comes with enough estimation variance to offset much of its potential benefit.&lt;/p&gt;

&lt;h2 id=&quot;error-copula-point-summaries&quot;&gt;Error-copula point summaries&lt;/h2&gt;

&lt;p&gt;Part 2 introduced the forecast-error copula through the likelihood of the implied error vector:&lt;/p&gt;

\[f_E(X_1-y,\ldots,X_D-y).\]

&lt;p&gt;The most direct point forecast is the likelihood mode:&lt;/p&gt;

\[\hat y_{\mathrm{mode}}
= \arg\max_y f_E(X_1-y,\ldots,X_D-y).\]

&lt;p&gt;That answers the “most plausible error vector” question. But it is not the only possible point summary. If the evaluation criterion is squared error, a mean of the implied likelihood can be more natural than its mode.&lt;/p&gt;

&lt;p&gt;I therefore compare three summaries:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Summary&lt;/th&gt;
      &lt;th&gt;Definition&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Mode&lt;/td&gt;
      &lt;td&gt;choose the candidate $y$ with maximum error likelihood&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Flat-prior mean&lt;/td&gt;
      &lt;td&gt;average candidate $y$ values using weights proportional to $f_E(X-y\mathbf{1})$&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Outcome-prior mean&lt;/td&gt;
      &lt;td&gt;average candidate $y$ values using weights proportional to $f_E(X-y\mathbf{1}) f_Y(y)$&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;In this experiment, the flat-prior mean is the best of the flexible error-copula summaries. The outcome-prior mean does not clearly help, probably because it adds another estimated object, the marginal density of $Y$. The mode is conceptually clean, but it is not automatically the best summary for RMSE.&lt;/p&gt;

&lt;p&gt;The comparison is similar for the Gaussian error copula and the vine error copula:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Error-copula method&lt;/th&gt;
      &lt;th&gt;Summary&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Stacked rank rho&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Scaled RMSE&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Scaled bias&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Gaussian&lt;/td&gt;
      &lt;td&gt;Mode&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.709&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.694&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.001&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Gaussian&lt;/td&gt;
      &lt;td&gt;Flat-prior mean&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.757&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.612&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.033&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Gaussian&lt;/td&gt;
      &lt;td&gt;Outcome-prior mean&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.745&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.643&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.065&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Vine&lt;/td&gt;
      &lt;td&gt;Mode&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.714&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.703&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-0.042&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Vine&lt;/td&gt;
      &lt;td&gt;Flat-prior mean&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.755&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.623&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;-0.003&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Vine&lt;/td&gt;
      &lt;td&gt;Outcome-prior mean&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.740&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.644&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.040&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The error-copula likelihood ranks candidate outcomes by the plausibility of their implied error vectors. Turning that likelihood into a point forecast requires an additional choice: mode, mean, or another summary matched to the evaluation loss.&lt;/p&gt;

&lt;h2 id=&quot;by-variable-rank-correlations&quot;&gt;By-variable rank correlations&lt;/h2&gt;

&lt;p&gt;The table below reports Spearman rank correlations computed separately for each macro variable.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Variable&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Lead 0&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Shrunk Error GLS&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Error GLS&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Gaussian outcome copula&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Gaussian error copula, flat mean&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Equal weight&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;CPI&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.809&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.803&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.793&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.778&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.794&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.642&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;HOUSING&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.967&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.969&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.973&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.963&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.964&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.894&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;INDPROD&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.777&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.782&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.774&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.762&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.691&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.485&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;NGDP&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.693&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.682&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.650&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.616&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.674&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.493&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;PGDP&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.709&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.710&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.711&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.702&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.715&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.619&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;RGDP&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.571&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.561&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.554&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.550&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.511&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.336&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;UNEMP&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.997&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.995&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.994&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.992&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.961&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.964&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The result is not driven by a single variable. The near-horizon forecast is strong almost everywhere. The two Error GLS variants are especially competitive for HOUSING, INDPROD, PGDP, and UNEMP, with shrunk Error GLS often close to the best method. The Gaussian outcome copula remains competitive as a rank predictor, but it is generally a little weaker than the nowcast/Error GLS group here, and its rank-to-level conversion performs less well for level accuracy.&lt;/p&gt;

&lt;p&gt;This table is mainly a diagnostic for whether the pooled result is driven by one macro series. It is not meant to rank methods precisely within each variable, where several top correlations are very close.&lt;/p&gt;

&lt;p&gt;RGDP remains difficult. Equal weighting performs poorly because it averages a relatively informative nowcast with much weaker longer-horizon forecasts. This is exactly the setting where dependence correction helps: the combination method should not treat all horizons as equally informative.&lt;/p&gt;

&lt;h2 id=&quot;initial-releases-versus-latest-revisions&quot;&gt;Initial releases versus latest revisions&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;/assets/spf-part3/fig3_revision_sensitivity.png&quot; alt=&quot;Sensitivity of method rankings to target vintage&quot; style=&quot;width:100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The same predictions can be scored against initial releases or latest revised values. I use the initial release as the main target because it is the first official realised value available after the target period.&lt;/p&gt;

&lt;p&gt;I also report the same scores against the latest revised value. This is a useful check because later vintages can reflect additional source data, benchmark revisions, or statistical reprocessing after the initial release.&lt;/p&gt;

&lt;p&gt;The broad ranking is similar across the two targets: Lead 0 and Error GLS remain very strong. The level metrics move more than the ranks, especially for the methods closest to the nowcast. This is why I keep the initial-release and latest-revision results side by side.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Method&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Rank rho, initial release&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Rank rho, latest revised&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Scaled RMSE, initial release&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Scaled RMSE, latest revised&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Lead 0&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.788&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.747&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.461&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.512&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Shrunk Error GLS&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.786&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.741&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.459&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.520&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Error GLS&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.778&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.737&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.461&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.531&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Gaussian outcome copula&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.766&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.732&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.647&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.653&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Equal weight&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.634&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.603&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.822&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.821&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The deterioration is larger for the top nowcast and Error GLS methods than for equal-weight, because these methods are more tightly tied to the near-term official release. The ordering remains similar, but the target vintage changes the measured size of the advantage.&lt;/p&gt;

&lt;h2 id=&quot;rolling-performance-through-time&quot;&gt;Rolling performance through time&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;/assets/spf-part3/fig4_learning_curve.png&quot; alt=&quot;Rolling out-of-sample rank correlation through time&quot; style=&quot;width:100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;For each target date, the figure computes one within-variable Spearman correlation using the previous 32 quarters of out-of-sample predictions. It is not a pure sample-size experiment. Later fitted forecasts have more training data available, but they are also evaluated in later macroeconomic periods.&lt;/p&gt;

&lt;p&gt;Equal weight is a fixed rule, so its line does not move because of re-estimation. It moves because the evaluation window changes. For fitted methods, the rolling lines combine two effects: the training sample expands, and the forecast environment changes.&lt;/p&gt;

&lt;p&gt;The main pattern is consistent with the pooled table. Lead 0 and Error GLS remain difficult to separate for much of the sample, while equal weight is usually below them. The gap is not constant through time, which is another reason to treat the single pooled leaderboard as a summary rather than a universal ranking.&lt;/p&gt;

&lt;h2 id=&quot;named-forecaster-case-studies&quot;&gt;Named-forecaster case studies&lt;/h2&gt;

&lt;p&gt;The cross-horizon experiment has a built-in skill hierarchy: lead 0 is usually more informative than lead 4. The classical forecast-combination puzzle is different. It is often about combining forecasters who make predictions for the same target at the same horizon, with similar information sets and similar skill.&lt;/p&gt;

&lt;p&gt;I therefore keep a separate named-forecaster experiment. For CPI, RGDP, and UNEMP, at horizons 1 and 2, I form small panels of individual forecasters and run the same expanding-window evaluation. These variables give three different forecasting problems with enough overlapping individual respondents: inflation, real activity growth, and unemployment. Horizons 1 and 2 keep the comparison at a common forecast horizon while avoiding both the nowcast-dominance issue and the thinner coverage of longer horizons.&lt;/p&gt;

&lt;p&gt;The figure uses three-forecaster panels. For each variable-horizon pair, the panels are the three highest-coverage forecaster trios selected before looking at test performance.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/spf-part3/fig5_named_forecasters.png&quot; alt=&quot;Named-forecaster case studies by variable and horizon&quot; style=&quot;width:100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This named-forecaster check is deliberately smaller than the cross-horizon experiment. To get a usable history, I have to reuse many of the same high-coverage forecasters and target dates across panels. The table therefore gives a useful check on how the combination methods behave when the signals are individual forecasters rather than different lead times, but not many independent repetitions of the same experiment. The point is to contrast two empirical settings:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Setting&lt;/th&gt;
      &lt;th&gt;Main feature&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Cross-horizon consensus forecasts&lt;/td&gt;
      &lt;td&gt;strong structural skill hierarchy across lead times&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Named forecasters at the same horizon&lt;/td&gt;
      &lt;td&gt;closer substitutes with similar information sets&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Across these three-forecaster panels, the ranking is much less decisive than in the cross-horizon experiment. The persistence row is the last observed realised value, not a combination of forecasters. The other rows combine the selected forecasters. I round these summaries to two decimals because the panels overlap and the sample is smaller.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Method or benchmark&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Named-forecaster rank rho&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Scaled RMSE&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Persistence&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.51&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.20&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Shrunk Error GLS&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.48&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.94&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Error GLS&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.47&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.95&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Inverse MSE&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.46&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.93&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Trimmed mean&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.46&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.93&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Equal weight&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.46&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.93&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Gaussian error copula, flat mean&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.45&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.03&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Gaussian outcome copula&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.39&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.97&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;I also reran the same construction with four and five forecasters per panel. Larger panels average more individual forecasts, but they leave fewer usable target quarters: every selected forecaster must have reported a forecast for the same variable, horizon, and target quarter. In this SPF sample, that common-overlap constraint makes larger named-forecaster panels quickly lose observations.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Forecasters per panel&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Median OOS quarters per panel&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Persistence&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Inverse MSE&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Equal weight&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Shrunk Error GLS&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Error GLS&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Gaussian error copula&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;62&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.51&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.46&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.46&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.48&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.47&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.45&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;46&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.48&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.54&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.54&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.54&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.49&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.47&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;31&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.49&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.49&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.48&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.48&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.42&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.39&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The panel-size check does not change the qualitative conclusion. Equal weight, inverse MSE, and shrunk Error GLS remain close to one another, while unshrunk Error GLS and the flexible error-copula do not clearly dominate as the number of forecasters increases. This is closer to the classical forecast-combination puzzle: when forecasters have similar information sets, estimated weights may not improve much on simple regularised averages. Larger panels leave fewer common forecast dates, so I read the table mainly as a robustness check on the named-forecaster exercise.&lt;/p&gt;

&lt;h2 id=&quot;what-i-take-from-the-horserace&quot;&gt;What I take from the horserace&lt;/h2&gt;

&lt;p&gt;First, the nowcast is a serious benchmark. In a cross-horizon SPF combination problem, beating Lead 0 is difficult because the nowcast already reflects much of the relevant information.&lt;/p&gt;

&lt;p&gt;Second, dependence modeling is still useful. Error GLS and shrunk Error GLS are competitive because they estimate a small, interpretable object: the covariance matrix of forecast errors. That is enough to correct for noisy and redundant horizons.&lt;/p&gt;

&lt;p&gt;Third, rank prediction and level prediction are not the same objective. The Gaussian outcome copula is a good rank predictor, but mapping ranks back to levels introduces an additional calibration problem.&lt;/p&gt;

&lt;p&gt;Fourth, flexible copulas need enough stable information. The vine and KDE-based error-copula methods can represent richer dependence, but richer models are not automatically better in SPF-sized macro samples.&lt;/p&gt;

&lt;p&gt;The empirical exercise preserves the main distinction from Part 2. The results do not select one method that is best in every setting. The copula framework is useful here because it makes two different probability questions explicit:&lt;/p&gt;

\[\mathbb{E}[\text{outcome rank} \mid \text{forecast ranks}]\]

&lt;p&gt;is not the same object as&lt;/p&gt;

\[\text{the outcome whose implied forecast-error vector is most plausible}.\]

&lt;p&gt;Once those two objects are separated, the empirical results are easier to interpret. In this implementation, the outcome-side methods first estimate ranks and then require a separate rank-to-level calibration step. The error-copula methods search over candidate outcome levels; for each candidate $y$, they compute implied errors $x_k-y$. The copula coordinates are empirical ranks of those implied errors relative to the training errors, while the marginal density terms are estimated with KDE. Error GLS is the parsimonious version of the error-side idea: it uses only an error covariance matrix. In this SPF horserace, the strongest error-side results come from Error GLS and shrunk Error GLS rather than from the KDE plus error-copula methods.&lt;/p&gt;
</description>
        <pubDate>Sun, 12 Jul 2026 09:00:00 +0000</pubDate>
        <link>https://www.marti.ai/forecasting/2026/07/12/spf-part3-horserace.html</link>
        <guid isPermaLink="true">https://www.marti.ai/forecasting/2026/07/12/spf-part3-horserace.html</guid>
        
        
        <category>forecasting</category>
        
      </item>
    
      <item>
        <title>Combining Professional Forecasters with Copulas (Part 2): Two Approaches to Dependence</title>
        <description>&lt;p&gt;&lt;em&gt;This is the second post in a three-part series. &lt;a href=&quot;/forecasting/2026/07/04/spf-part1-eda.html&quot;&gt;Part 1&lt;/a&gt; introduced the Survey of Professional Forecasters data. This post builds the modelling framework: two ways to use dependence when combining point forecasts. &lt;a href=&quot;/forecasting/2026/07/12/spf-part3-horserace.html&quot;&gt;Part 3&lt;/a&gt; runs the walk-forward empirical horserace on official SPF evaluation targets.&lt;/em&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;where-this-post-fits&quot;&gt;Where this post fits&lt;/h2&gt;

&lt;p&gt;Part 1 described the raw material: professional forecasters report point forecasts for macro variables such as GDP growth, inflation, unemployment, housing starts, and industrial production at several horizons. For a fixed variable and target quarter, write&lt;/p&gt;

\[y_t = \text{realised outcome}, \qquad x_{0,t}, x_{1,t}, \ldots, x_{4,t} = \text{forecasts at leads 0 through 4}.\]

&lt;p&gt;In the main SPF experiment, the $x_{k,t}$ are not individual named forecasters. They are the panel consensus forecasts at different lead times: nowcast, one-quarter-ahead, …, four-quarters-ahead. I will use the word “signal” for any predictor being combined: a lead-time consensus, an individual forecaster, or a model output.&lt;/p&gt;

&lt;p&gt;There are two natural ways to use copulas here.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/spf-part2/fig6_two_routes.png&quot; alt=&quot;Two approaches for combining point forecasts with copulas&quot; style=&quot;width:100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach 1: outcome-forecast dependence.&lt;/strong&gt; Model the joint dependence of&lt;/p&gt;

\[(y_t, x_{0,t}, \ldots, x_{4,t})\]

&lt;p&gt;after rank transformation. The question is:&lt;/p&gt;

\[\mathbb{E}[y_t \mid x_{0,t}, \ldots, x_{4,t}]?\]

&lt;p&gt;In rank space this becomes: given the forecast ranks, what rank should the realised outcome have? The Gaussian copula version reduces to OLS, or best linear prediction, on probit-transformed ranks. A vine copula can replace the Gaussian copula when the target-forecast relationship is nonlinear, asymmetric, or tail-dependent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach 2: forecast-error dependence.&lt;/strong&gt; Model the joint dependence of forecast errors&lt;/p&gt;

\[e_{k,t} = x_{k,t} - y_t.\]

&lt;p&gt;The question is different:&lt;/p&gt;

\[\hat y_t = \arg\max_y f_E(x_{0,t} - y, \ldots, x_{4,t} - y).\]

&lt;p&gt;In words: choose the combined forecast whose implied error vector is most plausible under the learned joint error distribution. This is the direct continuation of my older copula-fusion intuition: learn how predictors err together, then find the value that makes the observed forecasts jointly most likely.&lt;/p&gt;

&lt;p&gt;This post is about &lt;strong&gt;point forecast ranks and point forecast errors&lt;/strong&gt;, not full predictive densities. Copulas are often used to combine density forecasts; here they play a narrower role. They model dependence either between outcome and forecasts, or among forecast errors.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;classical-forecast-combination&quot;&gt;Classical forecast combination&lt;/h2&gt;

&lt;p&gt;Bates and Granger (1969) showed that a weighted average of forecasts can outperform the individual forecasts. For two forecasts with error variances $\sigma_1^2$, $\sigma_2^2$ and error correlation $\rho$, the optimal weight on forecast 1 is&lt;/p&gt;

\[w_1^* = \frac{\sigma_2^2 - \rho\sigma_1\sigma_2}{\sigma_1^2 + \sigma_2^2 - 2\rho\sigma_1\sigma_2}.\]

&lt;p&gt;The formula already contains the main idea: a good combination needs both individual accuracy and error dependence. If two forecasters make the same mistakes, the second one does not add a full new unit of information.&lt;/p&gt;

&lt;p&gt;The practical problem is estimation. Variances and covariances must be learned from finite history. When there are many forecasters, the covariance matrix has many parameters, and the inverse can amplify noise. This is one way the &lt;strong&gt;forecast combination puzzle&lt;/strong&gt; appears: estimated optimal weights often fail to beat the simple average out of sample.&lt;/p&gt;

&lt;p&gt;Granger and Ramanathan (1984) proposed regression-based forecast combination,&lt;/p&gt;

\[y_t = \alpha + \sum_k w_k x_{k,t} + \varepsilon_t,\]

&lt;p&gt;which is flexible but has the same small-sample fragility. A simpler estimated baseline is &lt;strong&gt;inverse MSE weighting&lt;/strong&gt;: estimate each forecast’s recent mean squared error, set $w_k \propto 1/\mathrm{MSE}_k$, and renormalise the weights to sum to one. It detects persistent skill differences without estimating the full error covariance matrix. Genre et al. (2013), in a detailed SPF study, found that simple averages and trimmed means were hard to beat for same-horizon macro forecast combination.&lt;/p&gt;

&lt;p&gt;That is the background tension for the rest of this post. We want to use dependence, but we do not want to overfit it.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;ranks-pseudo-observations-and-probits&quot;&gt;Ranks, pseudo-observations, and probits&lt;/h2&gt;

&lt;p&gt;A copula separates marginal distributions from dependence. The standard first step is to turn each variable into a pseudo-observation:&lt;/p&gt;

\[u_i = \frac{\#\{j : x_j \leq x_i\}}{n+1}.\]

&lt;p&gt;The $+1$ keeps values away from exactly 0 and 1. After this transform, every variable is approximately uniform on $(0,1)$.&lt;/p&gt;

&lt;p&gt;For the Gaussian copula we then apply the &lt;strong&gt;probit&lt;/strong&gt; transform&lt;/p&gt;

\[z_i = \Phi^{-1}(u_i),\]

&lt;p&gt;where $\Phi$ is the standard normal CDF. A median rank $u=0.50$ maps to $z=0$; $u=0.84$ maps to about $z=1$; $u=0.025$ maps to about $z=-1.96$.&lt;/p&gt;

&lt;p&gt;The probit transform preserves the ordering of each individual variable, but it changes the geometry in which linear combinations are formed. A weighted sum of probit ranks need not rank observations exactly like a weighted sum of raw ranks. In this series, the probit transform is a modelling choice: it puts the rank data into the normal-score space where Gaussian conditioning has a closed form.&lt;/p&gt;

&lt;p&gt;Before introducing the error-side approach, it is useful to keep two rank-side methods separate:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Name in this series&lt;/th&gt;
      &lt;th&gt;Data being combined&lt;/th&gt;
      &lt;th&gt;Estimated object&lt;/th&gt;
      &lt;th&gt;Main intuition&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;OLS on raw ranks&lt;/td&gt;
      &lt;td&gt;$u_y$ on $u_1,\ldots,u_D$&lt;/td&gt;
      &lt;td&gt;regression weights in rank space&lt;/td&gt;
      &lt;td&gt;best linear rank predictor without a Gaussian-copula assumption&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Gaussian outcome copula&lt;/td&gt;
      &lt;td&gt;$z_y=\Phi^{-1}(u_y)$ on $z_1,\ldots,z_D$&lt;/td&gt;
      &lt;td&gt;best linear predictor in normal-score space&lt;/td&gt;
      &lt;td&gt;same regression idea, but after the probit map that makes Gaussian conditioning closed form&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Both rank-side methods are primarily &lt;strong&gt;rank predictors&lt;/strong&gt;. They are good for ordering outcomes, comparing forecasters, or measuring Spearman correlation. They are not automatically calibrated level forecasts. To recover a level forecast, one has to map the predicted rank back through an estimated marginal distribution of realised outcomes:&lt;/p&gt;

\[\hat y = \hat F_Y^{-1}(\hat u_y),\]

&lt;p&gt;where $\hat F_Y$ is fitted on the training sample, usually separately by variable. This works as a monotone calibration step, but it inherits the limits of the historical distribution: it struggles to extrapolate beyond past realised values and may be poorly calibrated after regime shifts. That is why the empirical sections mostly evaluate rank skill. Raw-error methods, such as the classical Gaussian GLS average, work directly in the original forecast units. Error-copula methods also search over candidate outcome levels $y$: for each candidate, they compute implied level errors $e_k(y)=x_k-y$, transform those errors through the fitted marginal error distributions, and score the resulting error-rank vector under the fitted copula.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;approach-1-outcome-forecast-dependence&quot;&gt;Approach 1: outcome-forecast dependence&lt;/h2&gt;

&lt;p&gt;Let $u_y$ be the realised outcome rank and let $\mathbf{u}_x = (u_1, \ldots, u_D)$ be the forecast ranks. A copula model for $(u_y, \mathbf{u}_x)$ induces a conditional distribution of the outcome rank given the forecast ranks, which I will denote informally by&lt;/p&gt;

\[C(u_y \mid u_1, \ldots, u_D).\]

&lt;p&gt;A natural rank forecast is a summary of that conditional distribution, such as its mean or median. With a Gaussian copula, the clean closed-form object is the conditional mean in probit space. Define&lt;/p&gt;

\[z_y = \Phi^{-1}(u_y), \qquad \mathbf{z}_x = \Phi^{-1}(\mathbf{u}_x).\]

&lt;p&gt;Assume&lt;/p&gt;

\[\begin{pmatrix} z_y \\ \mathbf{z}_x \end{pmatrix}
\sim \mathcal{N}\left(
0,
\begin{pmatrix}
1 &amp;amp; \rho^\top \\
\rho &amp;amp; \Sigma_{xx}
\end{pmatrix}
\right).\]

&lt;p&gt;Then the conditional mean in normal-score space is&lt;/p&gt;

\[\mathbb{E}[z_y \mid \mathbf{z}_x] = \rho^\top \Sigma_{xx}^{-1}\mathbf{z}_x.\]

&lt;p&gt;Equivalently,&lt;/p&gt;

\[\hat z_y = \mathbf{w}^\top \mathbf{z}_x, \qquad \mathbf{w} = \Sigma_{xx}^{-1}\rho.\]

&lt;p&gt;This is the population OLS coefficient from regressing $z_y$ on $\mathbf{z}_x$:&lt;/p&gt;

\[\mathbf{w}_{OLS} = \mathbb{E}[\mathbf{z}_x\mathbf{z}_x^\top]^{-1}\mathbb{E}[\mathbf{z}_x z_y] = \Sigma_{xx}^{-1}\rho.\]

&lt;p&gt;The clean name is: &lt;strong&gt;OLS on probit-transformed ranks&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;After computing $\hat z_y$, I map back with $\hat u_y=\Phi(\hat z_y)$. This is the conditional median of $u_y$ under the Gaussian copula (the exact conditional mean is $\Phi(m/\sqrt{1+s^2})$, with $m=\rho^\top\Sigma_{xx}^{-1}z_x=\hat z_y$ and $s^2=1-\rho^\top\Sigma_{xx}^{-1}\rho$, but this distinction does not affect rank evaluation, since both quantities are monotone functions of the same conditional Gaussian location; it matters only if the output is interpreted as a calibrated conditional rank).&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/spf-part2/fig5_gls_pipeline.png&quot; alt=&quot;Outcome-forecast Gaussian copula pipeline&quot; style=&quot;width:100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The key object is $\Sigma_{xx}^{-1}$: it downweights redundant signals. Suppose two forecasts are almost identical and a third forecast is independent. If all three are equally predictive of the target, $\Sigma_{xx}^{-1}$ gives the two redundant forecasts roughly half weight each, while the independent forecast keeps its full weight. Equal-weighting misses this distinction.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/spf-part2/fig1_deduplication.png&quot; alt=&quot;Deduplication from the inverse signal correlation matrix&quot; style=&quot;width:100%&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;vine-copulas-for-outcome-forecast-dependence&quot;&gt;Vine copulas for outcome-forecast dependence&lt;/h3&gt;

&lt;p&gt;The Gaussian copula is restrictive: dependence is symmetric and linear in probit space. A vine copula replaces this with a product of bivariate pair copulas. With a C-vine rooted at the target,&lt;/p&gt;

\[p(u_y, u_1,\ldots,u_D) \approx p(u_y)\prod_{k=1}^D c_k(u_y,u_k).\]

&lt;p&gt;The conditional mean becomes&lt;/p&gt;

\[\mathbb{E}[u_y \mid u_1,\ldots,u_D]
=
\frac{\int_0^1 u \prod_k c_k(u,u_k)\,du}
{\int_0^1 \prod_k c_k(u,u_k)\,du}.\]

&lt;p&gt;&lt;img src=&quot;/assets/spf-part2/fig3_vine_structure.png&quot; alt=&quot;Target-rooted C-vine structure&quot; style=&quot;width:100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This one-dimensional integral can be evaluated by Gauss-Legendre quadrature. Each pair copula can be Gaussian, Student-t, Gumbel, Clayton, Frank, or a rotated version, selected by BIC. Here, a rotated version means a reflection of an asymmetric copula, useful for opposite-tail or negative dependence patterns.&lt;/p&gt;

&lt;p&gt;Non-Gaussian pair copulas can help when a target-forecast relationship is not well described by a Gaussian copula. The figure below fixes Kendall $\tau$ at 0.5 for several bivariate copula families. They have the same overall rank association, but they transform the same signal rank into different expected outcome ranks, especially in the tails. A vine uses these pair copulas as building blocks inside a multivariate dependence model. The dotted diagonal is only an identity benchmark, $E[u_y\mid u_s]=u_s$: it maps a signal rank directly to the same outcome rank.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/spf-part2/fig2_conditional_means.png&quot; alt=&quot;Conditional mean shapes for different copula families&quot; style=&quot;width:100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;But the vine used here is deliberately simplified. A full vine over $(u_y,u_1,\ldots,u_D)$ would also model the dependence among the forecasts themselves, including conditional relationships such as forecast 1 versus forecast 2 after accounting for the target. That is more complete, but it requires many more pair-copulas and much more data.&lt;/p&gt;

&lt;p&gt;The truncated target-rooted vine keeps only the target-signal links $c_k(u_y,u_k)$. In plain language, it asks: “how does each forecast relate to the realised outcome?” and then multiplies those pieces together. That multiplication quietly assumes that, once the realised outcome is known, the forecast signals are independent of each other. This is often false for SPF lead-time forecasts. If the nowcast and the one-quarter-ahead forecast both reflect the same public macro release, the truncated vine can count that same evidence twice. The Gaussian inverse $\Sigma_{xx}^{-1}$ corrects for redundancy directly; this truncated vine does not. This is not a limitation of vines in general: a fuller vine could add conditional signal-signal pair copulas and model that redundancy. The cost is statistical, because those extra pair copulas consume data. The trade-off here is therefore specific to the truncated approximation: it is attractive for nonlinear target-signal shapes when the signals themselves are not too redundant; otherwise the Gaussian copula’s analytical inter-signal correction is often more reliable in small macro samples.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;approach-2-forecast-error-dependence&quot;&gt;Approach 2: forecast-error dependence&lt;/h2&gt;

&lt;p&gt;The second approach models errors directly. Write&lt;/p&gt;

\[X_k = Y + E_k.\]

&lt;p&gt;If the forecast-error vector is Gaussian and centred,&lt;/p&gt;

\[E = (E_1,\ldots,E_D)^\top \sim \mathcal{N}(0,\Sigma_E),\]

&lt;p&gt;then, for a candidate value $y$, the implied error vector is&lt;/p&gt;

\[e(y) = x - y\mathbf{1}.\]

&lt;p&gt;The log likelihood is, up to constants,&lt;/p&gt;

\[-\frac12 (x-y\mathbf{1})^\top \Sigma_E^{-1}(x-y\mathbf{1}).\]

&lt;p&gt;Maximising this over $y$ gives&lt;/p&gt;

\[\hat y
=
\frac{\mathbf{1}^\top \Sigma_E^{-1}x}
{\mathbf{1}^\top \Sigma_E^{-1}\mathbf{1}}.\]

&lt;p&gt;This is the precision-weighted forecast combination.&lt;/p&gt;

&lt;p&gt;Why call it &lt;strong&gt;Error GLS&lt;/strong&gt;? GLS stands for &lt;strong&gt;generalized least squares&lt;/strong&gt;. The analogy refers specifically to the inverse covariance of forecast errors. This is different from the outcome-side Gaussian copula above: there, $\Sigma_{xx}^{-1}$ is the inverse of the signal covariance matrix in probit-rank space. Here, $\Sigma_E^{-1}$ is the inverse of the forecast error covariance matrix in level space. Both inverses change the geometry of the combination problem so that redundant or noisy directions count less.&lt;/p&gt;

&lt;p&gt;The covariance matrix is not the residual covariance from a regression of $y$ on $x$. It is the covariance of the forecasters’ errors with each other:&lt;/p&gt;

\[\Sigma_E = \operatorname{Cov}(E_1,\ldots,E_D).\]

&lt;p&gt;So Error GLS means: estimate how the forecasts err together, then combine the observed forecasts with weights implied by $\Sigma_E^{-1}$. If two forecasts usually make the same mistake, their shared error mode receives less weight. If one forecast has low error variance after accounting for the others, it receives more weight.&lt;/p&gt;

&lt;p&gt;This is the approach that most deserves the GLS analogy because it is explicitly using the inverse covariance matrix of forecast errors. The zero-mean assumption is only for the clean derivation. In practice, one should either de-bias the forecast errors on the training sample or include an estimated mean error vector $\mu_E$; otherwise the method may combine forecasts precisely around the wrong centre.&lt;/p&gt;

&lt;p&gt;It is also useful to compare the two inverse matrices that have appeared:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Method&lt;/th&gt;
      &lt;th&gt;Inverse matrix&lt;/th&gt;
      &lt;th&gt;Space&lt;/th&gt;
      &lt;th&gt;What gets discounted?&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Gaussian outcome copula&lt;/td&gt;
      &lt;td&gt;$\Sigma_{xx}^{-1}$&lt;/td&gt;
      &lt;td&gt;probit-transformed forecast ranks&lt;/td&gt;
      &lt;td&gt;redundant signals&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Error GLS&lt;/td&gt;
      &lt;td&gt;$\Sigma_E^{-1}$&lt;/td&gt;
      &lt;td&gt;forecast errors in level space&lt;/td&gt;
      &lt;td&gt;redundant error modes&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The formulas look similar because both use a precision matrix, but they answer different probability questions. The outcome-side approach asks for the likely rank of $Y$ given the forecast ranks. The error-side approach asks which candidate $y$ makes the implied forecast errors most plausible.&lt;/p&gt;

&lt;h3 id=&quot;the-true-copula-error-generalisation&quot;&gt;The true copula-error generalisation&lt;/h3&gt;

&lt;p&gt;The Gaussian error model can be generalised with a copula. Let each error have marginal CDF $F_k$ and density $f_k$. Then&lt;/p&gt;

\[f_E(e_1,\ldots,e_D)
=
c(F_1(e_1),\ldots,F_D(e_D))\prod_k f_k(e_k).\]

&lt;p&gt;For each candidate $y$, compute implied errors&lt;/p&gt;

\[e_k(y)=x_k-y.\]

&lt;p&gt;Then choose&lt;/p&gt;

\[\hat y
=
\arg\max_y
\left[
\log c(F_1(e_1(y)),\ldots,F_D(e_D(y)))
+
\sum_k \log f_k(e_k(y))
\right].\]

&lt;p&gt;This is the direct copula version of the “most plausible errors” idea. I estimate the marginal error distributions with KDE, transform candidate errors to error ranks, and fit either a Gaussian copula or a vine copula to those transformed errors. Prediction then becomes a one-dimensional optimisation over candidate $y$ values: choose the value whose implied transformed error vector has the highest fitted copula likelihood. In the experiments I use a robust grid search rather than a gradient method, because the KDE-plus-copula likelihood can be irregular in small samples.&lt;/p&gt;

&lt;p&gt;This method is conceptually appealing, but it is more fragile than the closed-form Gaussian formula. It requires good marginal error estimates, enough data to fit the copula, and a stable optimisation for every prediction.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;synthetic-checks&quot;&gt;Synthetic checks&lt;/h2&gt;

&lt;p&gt;The synthetic studies below check whether the methods behave as theory says they should. For the outcome-side approach, &lt;strong&gt;Case A&lt;/strong&gt; is a synthetic data-generating process with correlated Gaussian signals, where redundancy correction should help; &lt;strong&gt;Case B&lt;/strong&gt; is a synthetic data-generating process with tail-dependent signals, where a vine has a real nonlinear dependence pattern to learn. For the error-side approach, I use one synthetic design with Gaussian correlated forecast errors and one with curved forecast-error dependence.&lt;/p&gt;

&lt;p&gt;For the cross-sectional synthetic experiments, I report &lt;strong&gt;ICIR&lt;/strong&gt;, the information coefficient ratio: the mean rank correlation between prediction and realised outcome, divided by its time-series standard deviation. The synthetic setup generates $T$ periods, each with $N$ cross-sectional observations; the information coefficient (IC) is the Spearman rank correlation between predicted and realised outcomes within each period. ICIR is then the mean IC divided by its standard deviation across the $T$ periods. Higher ICIR means the method is not only predictive on average, but predictably predictive through time.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/spf-part2/fig7_two_track_results.png&quot; alt=&quot;Synthetic and SPF evidence for the two-approach framework&quot; style=&quot;width:100%&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;outcome-side-approach-when-gaussian-helps-and-when-vine-helps&quot;&gt;Outcome-side approach: when Gaussian helps and when vine helps&lt;/h3&gt;

&lt;p&gt;In the outcome-forecast synthetic study, Case A has correlated Gaussian signals. The Gaussian copula edges out equal-weight because $\Sigma_{xx}^{-1}$ deflates redundant signal clusters:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Method&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Case A ICIR&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Equal-weight&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;9.1&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Gaussian copula&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;9.2&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Vine copula&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8.8&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Case B has independent signals with non-Gaussian target-signal dependence: Gumbel upper-tail, survival Gumbel lower-tail, Student-t heavy tails, and Gaussian. The vine recovers the pair-copula families and wins:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Method&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Case B ICIR&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Equal-weight&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;97.5&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Gaussian copula&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;124.4&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Vine copula&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;129.1&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The detailed synthetic comparison is shown below.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/spf-part2/fig4_synthetic.png&quot; alt=&quot;Synthetic comparison where Gaussian and vine each win in their own regime&quot; style=&quot;width:100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The synthetic example illustrates the intended role of the vine: it can improve on the Gaussian copula when the target-signal dependence is genuinely asymmetric, tail-dependent, or otherwise non-elliptical. That extra flexibility is useful only if the sample contains enough stable dependence signal to estimate it reliably. The empirical question is whether the SPF panel provides that much information.&lt;/p&gt;

&lt;h3 id=&quot;error-side-approach-when-gls-wins-and-when-vine-wins&quot;&gt;Error-side approach: when GLS wins and when vine wins&lt;/h3&gt;

&lt;p&gt;In the error-dependence study, the Gaussian correlated-error case behaves as expected:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Method&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Spearman&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;RMSE&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Equal-weight&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.853&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.609&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Inverse MSE&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.888&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.513&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Outcome Gaussian rank&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.921&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.398&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Error GLS&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;0.928&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.402&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Gaussian error-copula&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.925&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;0.391&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Vine error-copula&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.893&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.510&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The RMSE for Outcome Gaussian rank is computed after mapping its predicted rank back through the empirical training distribution of the realised outcome. In this Gaussian-error design, the error covariance is the right summary of the error distribution. Error GLS therefore gives the best rank correlation, while the Gaussian error-copula gives the best level RMSE. The vine error-copula is more flexible, but that flexibility is unnecessary here and hurts out-of-sample performance.&lt;/p&gt;

&lt;p&gt;But we can also construct a nonlinear error geometry where a covariance matrix is the wrong summary. Let a latent error factor $a$ drive&lt;/p&gt;

\[E_1 \approx a, \qquad E_2 \approx a^2 - 1, \qquad E_3 \approx -(a^2 - 1).\]

&lt;p&gt;The dependence is curved, not elliptical.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/spf-part2/fig8_nonlinear_errors.png&quot; alt=&quot;Nonlinear forecast-error dependence where a vine error-copula helps&quot; style=&quot;width:100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In that case the vine error-copula wins:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Method&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Spearman&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;RMSE&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Equal-weight&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.972&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.248&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Inverse MSE&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.959&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.307&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Error GLS&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.995&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.089&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Outcome Gaussian rank&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.989&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.157&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Gaussian error-copula&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.979&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.198&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Vine error-copula&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;0.995&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;0.079&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The RMSE for Outcome Gaussian rank is again computed after empirical rank-to-level calibration. It beats the Gaussian error-copula here because it directly models the target rank $Y \mid X_1,\ldots,X_D$, while the Gaussian error-copula is an indirect error-likelihood model and is misspecified for this curved error distribution. Error GLS also remains strong: although the dependence is nonlinear, $E_2$ and $E_3$ nearly cancel each other, so the covariance matrix still captures a powerful linear variance-reduction effect. The vine error-copula wins by using the remaining nonlinear error geometry that covariance compresses into an ellipse.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;a-humbling-spf-fixed-split-check&quot;&gt;A humbling SPF fixed-split check&lt;/h2&gt;

&lt;p&gt;Synthetic data is useful because the data-generating process is known. The SPF panel is a harder test: the signal-to-noise ratio, the dependence structure, and the stability of the relationships are all uncertain.&lt;/p&gt;

&lt;p&gt;Before the full rolling experiment of Part 3, I ran a simple fixed split on the SPF panel: train through 2010, test after 2010, requiring all five lead-time forecasts to be present. Each method is fitted separately by macro variable so that GDP growth, inflation, unemployment, housing, and industrial production are not forced onto one common scale. Rank/probit transforms, error KDEs, and covariance matrices are estimated on the training sample only. For evaluation, realised values and predictions are first converted to ranks within each macro variable; those within-variable ranks are then stacked, and one Spearman correlation is computed on the stacked rank data.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Method&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Spearman on stacked within-variable ranks&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Outcome Gaussian rank&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;&lt;strong&gt;0.511&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Error GLS&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.478&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Inverse MSE&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.436&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Equal-weight&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.406&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Gaussian error-copula&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.322&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Vine error-copula&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.296&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;This first real-data check is humbling. The KDE plus copula-error likelihood underperforms here, which is consistent with a method that is too flexible for the available macro sample and for the stability of the train-test relationship. The outcome Gaussian rank model estimates one main object: a signal correlation matrix fitted to rank-transformed data. The error-copula approach estimates several objects in sequence: a KDE for each error marginal, then a multivariate copula fitted on the transformed error ranks. With only a few decades of quarterly observations, this two-stage estimation problem can add more variance than useful structure. Error GLS is less expressive, but it is also much lighter: it collapses the error dependence into a single parametric covariance matrix, which is why it holds up better in this check.&lt;/p&gt;

&lt;p&gt;This is a useful caution for macroeconomic and financial forecasting: a flexible model can win in a synthetic design where its assumptions are true, but lose in real samples unless it is strongly regularised.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;what-part-3-tests&quot;&gt;What Part 3 tests&lt;/h2&gt;

&lt;p&gt;Part 3 compares these method families on a walk-forward SPF horserace:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Family&lt;/th&gt;
      &lt;th&gt;Method&lt;/th&gt;
      &lt;th&gt;What it tests&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Baselines&lt;/td&gt;
      &lt;td&gt;Persistence, Lead 0, equal-weight, trimmed mean, inverse MSE&lt;/td&gt;
      &lt;td&gt;How far simple benchmarks go&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Outcome-side approach&lt;/td&gt;
      &lt;td&gt;OLS on ranks, Gaussian copula on probit ranks, vine outcome copula&lt;/td&gt;
      &lt;td&gt;Whether modelling target-forecast dependence helps&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Error-side approach&lt;/td&gt;
      &lt;td&gt;Error GLS, shrunk error GLS, Gaussian/vine error-copula&lt;/td&gt;
      &lt;td&gt;Whether modelling forecast-error dependence helps&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Part 3 will use a walk-forward evaluation with an expanding training window: the test date moves forward one forecast date at a time, and each fitted method is refitted using only the history available at that date. This is closer to actual forecast use than the fixed split above. It will also compare initial-release and latest-revised targets, and trace rolling out-of-sample performance through time. The named-forecaster experiment will remain separate, because same-horizon forecasters with similar skill are a different problem from cross-horizon signals with a structural lead-time hierarchy.&lt;/p&gt;

&lt;p&gt;The key distinction is between two probability questions:&lt;/p&gt;

\[\mathbb{E}[Y \mid X_1,\ldots,X_D]\]

&lt;p&gt;versus&lt;/p&gt;

\[\arg\max_y f_E(X_1-y,\ldots,X_D-y).\]

&lt;p&gt;The first models the outcome conditional on the forecasts. The second models the joint forecast errors implied by a candidate outcome.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;references-and-further-reading&quot;&gt;References and further reading&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Bates, J. M. and Granger, C. W. J. (1969), &lt;a href=&quot;https://www.jstor.org/stable/3008764&quot;&gt;“The Combination of Forecasts”&lt;/a&gt;, &lt;em&gt;Operational Research Quarterly&lt;/em&gt;.&lt;/li&gt;
  &lt;li&gt;Granger, C. W. J. and Ramanathan, R. (1984), &lt;a href=&quot;https://doi.org/10.1002/for.3980030207&quot;&gt;“Improved Methods of Combining Forecasts”&lt;/a&gt;, &lt;em&gt;Journal of Forecasting&lt;/em&gt;.&lt;/li&gt;
  &lt;li&gt;Genre, V., Kenny, G., Meyler, A. and Timmermann, A. (2013), &lt;a href=&quot;https://doi.org/10.1016/j.ijforecast.2012.06.004&quot;&gt;“Combining Expert Forecasts: Can Anything Beat the Simple Average?”&lt;/a&gt;, &lt;em&gt;International Journal of Forecasting&lt;/em&gt;.&lt;/li&gt;
  &lt;li&gt;Sklar, A. (1959), “Fonctions de repartition a n dimensions et leurs marges,” &lt;em&gt;Publications de l’Institut de Statistique de l’Universite de Paris&lt;/em&gt;.&lt;/li&gt;
  &lt;li&gt;Bedford, T. and Cooke, R. M. (2002), &lt;a href=&quot;https://doi.org/10.1214/aos/1031689016&quot;&gt;“Vines: A New Graphical Model for Dependent Random Variables”&lt;/a&gt;, &lt;em&gt;Annals of Statistics&lt;/em&gt;.&lt;/li&gt;
  &lt;li&gt;Aas, K., Czado, C., Frigessi, A. and Bakken, H. (2009), &lt;a href=&quot;https://doi.org/10.1016/j.insmatheco.2007.02.001&quot;&gt;“Pair-Copula Constructions of Multiple Dependence”&lt;/a&gt;, &lt;em&gt;Insurance: Mathematics and Economics&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Wed, 08 Jul 2026 00:00:00 +0000</pubDate>
        <link>https://www.marti.ai/forecasting/2026/07/08/spf-part2-copulas.html</link>
        <guid isPermaLink="true">https://www.marti.ai/forecasting/2026/07/08/spf-part2-copulas.html</guid>
        
        
        <category>forecasting</category>
        
      </item>
    
      <item>
        <title>Combining Professional Forecasters with Copulas (Part 1): The Survey of Professional Forecasters</title>
        <description>&lt;p&gt;&lt;em&gt;This is the first post in a three-part series. Part 1 introduces the Survey of Professional Forecasters and provides a thorough exploratory analysis of the dataset. &lt;a href=&quot;/forecasting/2026/07/08/spf-part2-copulas.html&quot;&gt;Part 2&lt;/a&gt; develops the copula framework and validates it on synthetic data. &lt;a href=&quot;/forecasting/2026/07/12/spf-part3-horserace.html&quot;&gt;Part 3&lt;/a&gt; runs the walk-forward empirical horserace on official SPF evaluation targets.&lt;/em&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;why-forecast-combination-matters&quot;&gt;Why forecast combination matters&lt;/h2&gt;

&lt;p&gt;You have several forecasters. Each one issues quarterly predictions for an economic variable, say the unemployment rate two quarters from now. None of them is reliably the best. They agree with each other more than they disagree. How should you combine them into a single estimate that is better than any individual forecaster and, ideally, better than simply averaging all of them?&lt;/p&gt;

&lt;p&gt;This question has occupied economists since Bates and Granger’s 1969 paper introduced the combination framework. It has a subtlety that is easy to miss: the naive answer (“optimally weight them”) often fails in practice. The optimal weights, estimated from data, carry enough estimation noise that a simple equal-weight average frequently beats them out-of-sample. This empirical regularity is called the &lt;strong&gt;forecast combination puzzle&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Over this three-part series we will use a copula-based combination method to probe when and why the puzzle appears and disappears. The dataset is the &lt;strong&gt;Survey of Professional Forecasters&lt;/strong&gt; (SPF): 58 years of quarterly macroeconomic predictions, freely available from the Federal Reserve Bank of Philadelphia. This post is entirely about understanding that dataset before fitting any model.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;the-survey-of-professional-forecasters-a-brief-history&quot;&gt;The Survey of Professional Forecasters: a brief history&lt;/h2&gt;

&lt;p&gt;The SPF was launched in 1968, making it one of the oldest continuously-run macroeconomic forecast surveys in the world. It was originally co-sponsored by the American Statistical Association (ASA) and the National Bureau of Economic Research (NBER). In 1990, the Federal Reserve Bank of Philadelphia took over administration and has run the survey ever since without interruption.&lt;/p&gt;

&lt;p&gt;The survey is conducted quarterly, near the middle of each quarter, before the Bureau of Economic Analysis releases its advance GDP estimate. Participants are professional economists at banks, investment firms, research institutions, and universities. Participation is voluntary and anonymous: each respondent is identified by a numeric ID that appears consistently across surveys but is never linked to a name or institution in the public data release.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why central banks pay attention.&lt;/strong&gt; The SPF is a primary external cross-check for the Federal Reserve’s own internal Greenbook projections. In the period before the Greenbook became public, the SPF was one of the few sources of professional near-term forecasts that the Fed could compare itself against. Today, the Fed’s Monetary Policy Report cites SPF long-run inflation expectations as a measure of inflation anchoring. The European Central Bank and the Bank of England run structurally similar surveys (the ECB SPF and the Bank of England’s Monetary Policy Committee surveys), partly inspired by the U.S. SPF.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why the academic literature uses it.&lt;/strong&gt; The combination of individual-level microdata, long history, and multiple variables makes the SPF unusually rich for econometric research. Key papers that use it include:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Ang, Bekaert, and Wei (2007): showed that the SPF consensus outperforms a wide range of model-based inflation forecasts, including Phillips-curve, term-structure, and time-series models.&lt;/li&gt;
  &lt;li&gt;Coibion and Gorodnichenko (2015): used the individual-level microdata to document &lt;em&gt;information rigidity&lt;/em&gt;, i.e., professional forecasters underreact to publicly available data in a way consistent with sticky information models.&lt;/li&gt;
  &lt;li&gt;Genre, Kenny, Meyler, and Timmermann (2013): studied whether any combination method beats the simple average for same-horizon SPF forecasts and found the puzzle alive and well.&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;the-dataset-variables-horizons-and-structure&quot;&gt;The dataset: variables, horizons, and structure&lt;/h2&gt;

&lt;p&gt;The SPF collects predictions for a set of U.S. macroeconomic variables at five horizons each quarter: the &lt;em&gt;nowcast&lt;/em&gt; (the current quarter, which may be partially observed), and four-quarters-ahead. The eight variables used in this series are described below.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;real-gdp-growth-rgdp&quot;&gt;Real GDP growth (RGDP)&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What it measures.&lt;/strong&gt; Real Gross Domestic Product is the total market value of all goods and services produced in the United States in a given quarter, adjusted for inflation using chain-weighted price indices with a base year of 2017. It is the broadest single measure of economic activity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How it is collected.&lt;/strong&gt; The Bureau of Economic Analysis (BEA) releases three successive vintages each quarter: the &lt;em&gt;advance estimate&lt;/em&gt; (about four weeks after quarter-end), the &lt;em&gt;second estimate&lt;/em&gt; (about eight weeks), and the &lt;em&gt;third estimate&lt;/em&gt; (about twelve weeks). SPF forecasters submit responses near the middle of the quarter, so the advance estimate for the just-completed quarter is not yet available; forecasters are largely working from monthly indicators (employment, retail sales, industrial production).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Units in SPF.&lt;/strong&gt; Forecasters report in billions of chained 2017 dollars at a seasonally adjusted annual rate. We convert to quarter-on-quarter growth rates (%) using the ratio of consecutive horizon values from the same respondent’s row.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it matters.&lt;/strong&gt; Real GDP growth is the headline indicator for business cycle expansions and recessions, the variable the Federal Open Market Committee implicitly or explicitly targets through the dual mandate, and the reference series for most macroeconomic models. Predicting it correctly is notoriously difficult: GDP growth is close to a random walk over quarterly horizons once trend growth is removed.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;gdp-price-deflator-pgdp&quot;&gt;GDP price deflator (PGDP)&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What it measures.&lt;/strong&gt; The GDP price deflator (also called the GDP implicit price deflator) is the ratio of nominal GDP to real GDP; it covers the prices of all goods and services included in GDP, including investment, government spending, and net exports. It is therefore broader than the CPI, which covers only household consumption.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How it is collected.&lt;/strong&gt; Published by the BEA alongside GDP releases. Subject to the same vintage structure as RGDP.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Units in SPF.&lt;/strong&gt; Forecasters report index levels (2017 = 100). We convert to quarter-on-quarter growth rates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it matters.&lt;/strong&gt; The GDP deflator is the broadest measure of domestic price pressure. The Federal Reserve’s preferred inflation gauge is the PCE deflator (Personal Consumption Expenditures), which is closely related but covers a slightly different basket. Academic forecasting studies often use PGDP because its history in the SPF is longer than the PCE series.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;nominal-gdp-ngdp&quot;&gt;Nominal GDP (NGDP)&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What it measures.&lt;/strong&gt; Nominal GDP is GDP measured at current market prices, without any inflation adjustment. By accounting identity, NGDP growth equals real GDP growth plus the GDP deflator inflation rate. It is therefore the sum of the two previous variables.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Units in SPF.&lt;/strong&gt; Billions of current (nominal) dollars at a seasonally adjusted annual rate, converted to quarter-on-quarter growth rates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it matters.&lt;/strong&gt; Nominal GDP targeting was proposed as an alternative monetary policy framework (McCallum 1987, Sumner 2014): the idea is that a central bank targeting a stable NGDP growth path would automatically accommodate supply shocks without generating unnecessary recessions. The variable thus has a direct policy relevance beyond its role as a bookkeeping identity.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;industrial-production-indprod&quot;&gt;Industrial production (INDPROD)&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What it measures.&lt;/strong&gt; The Federal Reserve’s Industrial Production index tracks the real output of the manufacturing, mining, and electric and gas utilities sectors. It covers roughly one fifth of the U.S. economy but is more cyclically sensitive than GDP because it excludes the service sector, which is less volatile.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How it is collected.&lt;/strong&gt; Produced by the Federal Reserve Board and released monthly, giving forecasters more within-quarter information than for GDP.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Units in SPF.&lt;/strong&gt; Index levels (2017 = 100), converted to quarter-on-quarter growth rates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it matters.&lt;/strong&gt; Because industrial production is available monthly, it serves as a key input to GDP nowcasting models. The Chicago Fed National Activity Index and the Philadelphia Fed’s ADS index both weight industrial production heavily. Its higher frequency makes it more predictable at short horizons from within-quarter data, but it is more volatile than GDP at longer horizons.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;housing-starts-housing&quot;&gt;Housing starts (HOUSING)&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What it measures.&lt;/strong&gt; Housing starts counts the number of new privately owned residential units on which construction has begun in a given month. The SPF variable is a quarterly aggregate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How it is collected.&lt;/strong&gt; Published monthly by the U.S. Census Bureau and the Department of Housing and Urban Development, available with only a short lag.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Units in SPF.&lt;/strong&gt; Thousands of units at a seasonally adjusted annual rate, converted to quarter-on-quarter growth rates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it matters.&lt;/strong&gt; Housing starts is one of the most reliable leading indicators of the business cycle: residential investment typically peaks well before recessions and troughs early in recoveries. The series is highly sensitive to mortgage rates, which means it reflects Federal Reserve policy with a lag of six to eighteen months. As a result it is watched closely by financial market participants. However, it is also highly volatile and subject to weather effects, making medium-term forecasting particularly hard.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;corporate-profits-cprof&quot;&gt;Corporate profits (CPROF)&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What it measures.&lt;/strong&gt; The BEA’s after-tax corporate profits series measures the operating surplus earned by domestic corporations, adjusted for inventory valuation and capital consumption. It is a quarterly flow variable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How it is collected.&lt;/strong&gt; Published by the BEA as part of the National Income and Product Accounts (NIPA), with substantial revision risk: the data is subject to benchmark revisions that can be large and retrospective.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Units in SPF.&lt;/strong&gt; Billions of current dollars, converted to quarter-on-quarter growth rates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it matters.&lt;/strong&gt; Corporate profits are a leading indicator of future investment and hiring decisions: firms that earn more tend to invest more. They are also directly relevant to equity valuation (equity prices are discounted future profits), and they are an important input to fiscal projections because corporate tax revenues track profits with a short lag. Despite their economic importance, corporate profits are one of the hardest SPF variables to forecast, partly because of their volatility and partly because of data revision uncertainty.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;unemployment-rate-unemp&quot;&gt;Unemployment rate (UNEMP)&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What it measures.&lt;/strong&gt; The unemployment rate is the share of the civilian labour force that is without a job, actively seeking work, and available to work. It is the most widely followed labour market indicator.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How it is collected.&lt;/strong&gt; The Bureau of Labor Statistics (BLS) computes the rate from the monthly Current Population Survey (CPS), a household survey of approximately 60,000 households. It is released on the first Friday of the following month and is not subject to large revisions (unlike GDP).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Units in SPF.&lt;/strong&gt; Percentage of the labour force, reported directly as a level (not a growth rate). This is important: because unemployment is a rate, it is already stationary and mean-reverting, and forecasters submit it as a level rather than a change.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it matters.&lt;/strong&gt; Unemployment is one of the two variables in the Federal Reserve’s dual mandate (maximum employment and price stability). It is also a key input to wage dynamics and therefore to inflation (the Phillips curve links unemployment gaps to inflation). Its serial persistence is extremely high: the first-order autocorrelation of quarterly unemployment is above 0.97 over the full SPF sample. This means that even a naive “next quarter will look like this quarter” forecast achieves Spearman rank correlation above 0.95 with the realised outcome, a benchmark that combination methods must beat.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;cpi-inflation-cpi&quot;&gt;CPI inflation (CPI)&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What it measures.&lt;/strong&gt; The Consumer Price Index for All Urban Consumers (CPI-U) measures the average change over time in the prices paid by urban consumers for a representative basket of goods and services. The basket includes food, energy, housing, medical care, transportation, and recreation, weighted by expenditure shares from the Consumer Expenditure Survey.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How it is collected.&lt;/strong&gt; Each month, BLS field agents physically record prices for roughly 80,000 items across approximately 23,000 retail outlets, service providers, and rental units (grocery stores, hospitals, landlords, gas stations, etc.) in 75 urban areas. Items are organised into a fixed consumption basket whose weights come from the Consumer Expenditure Survey, which tracks what households actually spend. Housing costs, the single largest component, are measured via owners’ equivalent rent, estimated by surveying renters about what their units would fetch on the open market. The BLS releases the resulting index monthly, typically in the second or third week of the following month. Unlike GDP, CPI is not subject to major revisions after initial release; only seasonal adjustment factors are updated annually, and those changes are modest.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Units in SPF.&lt;/strong&gt; The SPF asks for the percentage change in the CPI over the relevant forecast horizon, expressed at an annual rate. This is one of the rate variables reported directly rather than as a level.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it matters.&lt;/strong&gt; CPI is the most visible inflation measure for households, wage negotiators, and indexed contracts (Social Security benefits, TIPS coupons, many labour agreements are CPI-indexed). The Fed targets a 2% rate of PCE inflation, which historically runs about 0.3-0.5 percentage points below CPI, but the public and markets watch CPI closely. The unpredictability of CPI beyond very short horizons (the nowcast captures quarter-to-quarter momentum, but by h=2 the correlation with realised values drops to around 0.32 for the consensus and near zero for individual forecasters) reflects genuine macroeconomic uncertainty: inflation depends on energy prices, supply chains, and expectations, none of which are easily projected two quarters out.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;A compact summary:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Code&lt;/th&gt;
      &lt;th&gt;What is forecasted&lt;/th&gt;
      &lt;th&gt;Units&lt;/th&gt;
      &lt;th&gt;Level or rate&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;RGDP&lt;/td&gt;
      &lt;td&gt;Real GDP&lt;/td&gt;
      &lt;td&gt;q/q growth %&lt;/td&gt;
      &lt;td&gt;Level → growth&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;PGDP&lt;/td&gt;
      &lt;td&gt;GDP price deflator&lt;/td&gt;
      &lt;td&gt;q/q growth %&lt;/td&gt;
      &lt;td&gt;Level → growth&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;NGDP&lt;/td&gt;
      &lt;td&gt;Nominal GDP&lt;/td&gt;
      &lt;td&gt;q/q growth %&lt;/td&gt;
      &lt;td&gt;Level → growth&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;INDPROD&lt;/td&gt;
      &lt;td&gt;Industrial production index&lt;/td&gt;
      &lt;td&gt;q/q growth %&lt;/td&gt;
      &lt;td&gt;Level → growth&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;HOUSING&lt;/td&gt;
      &lt;td&gt;Housing starts&lt;/td&gt;
      &lt;td&gt;q/q growth %&lt;/td&gt;
      &lt;td&gt;Level → growth&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;CPROF&lt;/td&gt;
      &lt;td&gt;Corporate profits&lt;/td&gt;
      &lt;td&gt;q/q growth %&lt;/td&gt;
      &lt;td&gt;Level → growth&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;UNEMP&lt;/td&gt;
      &lt;td&gt;Unemployment rate&lt;/td&gt;
      &lt;td&gt;% of labour force&lt;/td&gt;
      &lt;td&gt;Rate (direct)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;CPI&lt;/td&gt;
      &lt;td&gt;CPI-U inflation&lt;/td&gt;
      &lt;td&gt;% annual rate&lt;/td&gt;
      &lt;td&gt;Rate (direct)&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Level variables are reported by forecasters as quarterly index levels; we convert to quarter-on-quarter growth rates using the ratio of consecutive horizon columns. Rate variables are reported directly as percentages and require no transformation.&lt;/p&gt;

&lt;p&gt;The full microdata file is publicly available at no charge from the Philadelphia Fed:&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pandas&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Download once from Philadelphia Fed:
# https://www.philadelphiafed.org/surveys-and-data/real-time-data-research/individual-forecasts
# Then read with calamine engine (openpyxl fails on this file's date types)
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;xl&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ExcelFile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;spfmicrodata.xlsx&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;engine&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;calamine&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xl&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sheet_names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# ['NGDP', 'PGDP', 'CPROF', 'UNEMP', 'EMP', 'INDPROD', 'HOUSING',
#  'TBILL', 'BOND', 'BAABOND', 'TBOND', 'RGDP']
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Each sheet has the structure:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;YEAR  QUARTER  ID   RGDP1  RGDP2  RGDP3  RGDP4  RGDP5  RGDP6  ...
1968  4        1    713.9  720.1  730.2  ...
1968  4        2    713.9  735.0  748.0  ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The column convention is: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;{VAR}1&lt;/code&gt; is the previous quarter’s level (provided as a common anchor), &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;{VAR}2&lt;/code&gt; is the nowcast (h=0), &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;{VAR}3&lt;/code&gt; is h=1, through &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;{VAR}6&lt;/code&gt; which is h=4.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Building realised values.&lt;/strong&gt; We reconstruct realised outcomes from the survey data itself: for target quarter $t$, the realised value is the median of the panel’s h=0 (nowcast) column in the survey for quarter $t+1$. By the time the next survey is conducted, the BEA advance estimate is already public, so the following quarter’s nowcast is effectively a read on the just-completed quarter. This is a standard real-time proxy used in the forecast evaluation literature (Croushore and Stark 2001). It is important to acknowledge that this is not the same as the final revised BEA estimate and may differ materially for periods with large revisions, notably around recessions and 2020-2021.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;qadd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;q&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Advance (y, q) by k quarters.&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;idx&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;q&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;idx&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;//&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;idx&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# For a level variable like RGDP:
# realised growth for quarter t = median(RGDP2) in survey t+1
# where RGDP2 is the h=0 (nowcast) column
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;actuals&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{}&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;for &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;q&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;grp&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;groupby&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;YEAR&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;QUARTER&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;median_nowcast&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;grp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;RGDP2&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;notna&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;median_nowcast&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;ty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tq&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;qadd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;q&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;        &lt;span class=&quot;c1&quot;&gt;# this nowcast refers to the prior quarter
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;actuals&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;median_nowcast&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Convert levels to growth rates
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;realized_growth&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{}&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;for &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;q&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;level&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;sorted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;actuals&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;items&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;ty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tq&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;qadd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;q&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;if &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actuals&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;realized_growth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;q&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;level&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;actuals&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;eda-1-panel-size-and-forecaster-turnover&quot;&gt;EDA 1: panel size and forecaster turnover&lt;/h2&gt;

&lt;p&gt;The first thing to understand about the SPF is how the panel has evolved over 58 years.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/spf-part1/fig1_panel_size.png&quot; alt=&quot;Panel size over time&quot; style=&quot;width:100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The panel grew rapidly in the 1970s, contracted in the late 1980s, then stabilised after the Philadelphia Fed took over administration in 1990. Since 1990, the RGDP panel has consistently attracted 30-50 respondents per quarter, with a brief contraction during the 2008-2009 financial crisis and a more sustained one after 2020 as some long-tenured participants retired.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The turnover problem.&lt;/strong&gt; Of the 463 unique forecaster IDs in the RGDP file, most are active for a short stretch:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/spf-part1/fig2_tenure.png&quot; alt=&quot;Forecaster tenure distribution&quot; style=&quot;width:100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The median forecaster submits RGDP predictions for only about 9 quarters. The 90th percentile is around 54 quarters (13.5 years). Even the most persistent forecaster in the RGDP panel appears in only 126 of 231 surveys (54%). This has an important modelling consequence: a balanced panel of named forecasters spanning the full 58-year history is not feasible. We address this in two ways in the later posts: by using the panel consensus (median) across all active respondents at each horizon, and by running a named-forecaster experiment restricted to the sub-period where at least three of the most persistent respondents are simultaneously active.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Load RGDP sheet
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;read_excel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xl&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sheet_name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;RGDP&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;engine&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;calamine&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Count quarters per forecaster
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tenure&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;groupby&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;YEAR&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Unique IDs: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;nunique&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Median tenure (quarters): &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tenure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;90th percentile: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tenure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;quantile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Max (most persistent): &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tenure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Fraction of total 231 quarters: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tenure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;231&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# Unique IDs: 463
# Median tenure (quarters): 9
# 90th percentile: 54
# Max (most persistent): 126
# Fraction of total 231 quarters: 54.5%
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;eda-2-how-predictable-are-these-variables&quot;&gt;EDA 2: how predictable are these variables?&lt;/h2&gt;

&lt;p&gt;Before thinking about combination, the most basic question is whether professional forecasters have any skill at all, and how that skill varies across variables and horizons.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/spf-part1/fig3_skill_decay.png&quot; alt=&quot;Skill decay by variable and horizon&quot; style=&quot;width:100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The pattern is striking and variable-specific:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Unemployment rate&lt;/strong&gt; is the most forecastable variable at every horizon. Even four quarters ahead, the consensus has a Spearman rank correlation with the realised rate above 0.30. The nowcast correlation exceeds 0.99. This reflects the strong serial persistence of unemployment: the level this quarter predicts next quarter’s level with very high accuracy.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;CPI inflation&lt;/strong&gt; forecast skill decays quickly. The nowcast correlation is around 0.60 (the BLS releases CPI for the first month of the quarter before the survey date, giving forecasters a partial read on current-quarter inflation), but by h=2 the consensus correlation drops to around 0.32, and individual forecaster skill is near zero. The consensus still extracts a weak common signal, but individual precision is essentially gone.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Real GDP growth&lt;/strong&gt; is difficult to forecast even one quarter ahead. The nowcast correlation (around 0.55) reflects the within-quarter monthly indicators already available at survey time (payrolls, retail sales, industrial production) rather than the BEA advance GDP estimate, which is not yet published when forecasters submit; the one-quarter-ahead forecast already struggles to beat persistence.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The fact that predictability varies so much across variables is important for the combination design: any method that pools across variables must account for this heterogeneity.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;scipy.stats&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;spearmanr&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;consensus_skill_by_horizon&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;panel_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;realized_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Compute Spearman ρ between consensus forecast and realised, for each horizon.&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;rhos&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;col&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;h&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;   &lt;span class=&quot;c1&quot;&gt;# h=0 -&amp;gt; col 2, h=4 -&amp;gt; col 6
&lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;col&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;panel_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;columns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;rhos&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nan&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;continue&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;# Panel consensus = median across all respondents in each survey quarter
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;consensus&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;panel_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;groupby&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;YEAR&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;QUARTER&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;col&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;median&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;reset_index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;# Advance survey date to the target quarter
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;consensus&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;target_y&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;consensus&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;apply&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;lambda&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;qadd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;YEAR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;QUARTER&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;axis&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;consensus&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;target_q&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;consensus&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;apply&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;lambda&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;qadd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;YEAR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;QUARTER&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;axis&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;merged&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;consensus&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;merge&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;realized_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;target_y&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;target_q&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;dropna&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;rhos&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;spearmanr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;merged&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;col&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;merged&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;realized&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;statistic&lt;/span&gt;
                    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;merged&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nan&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rhos&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;eda-3-individual-forecaster-skill-and-its-distribution&quot;&gt;EDA 3: individual forecaster skill and its distribution&lt;/h2&gt;

&lt;p&gt;The consensus masks a wide distribution of individual skill. How different are the best and worst forecasters in the panel?&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/spf-part1/fig4_individual_skill.png&quot; alt=&quot;Individual skill distribution&quot; style=&quot;width:100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The two extremes of the dataset are illustrated clearly:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;UNEMP at h=0 (nowcast):&lt;/strong&gt; almost every individual forecaster has a Spearman correlation above 0.90 with the realised rate. The median is 0.98. There is essentially no skill heterogeneity: anyone who submits a reasonable nowcast for unemployment gets the ranking right almost perfectly. Averaging these forecasters is trivially close to optimal.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;CPI at h=2:&lt;/strong&gt; the distribution of individual correlations is centred close to zero, with a wide spread. Some forecasters have positive correlation, some have negative correlation. The median is around 0.09. This is the canonical “hard to forecast” regime: even the best-performing panelists are barely better than noise, and combining noise does not produce signal.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The intermediate cases (UNEMP h=2 and CPI h=0) are where the combination question is most interesting.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;individual_rhos&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;horizon&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;panel_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;realized_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;min_quarters&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Distribution of per-forecaster Spearman ρ with the realised outcome.&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;col&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;horizon&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;rows&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;row&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;panel_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;iterrows&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;sy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sq&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;YEAR&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]),&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;QUARTER&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;ty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tq&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;qadd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;horizon&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;notna&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;col&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]):&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;rows&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;target_y&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;target_q&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                         &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]),&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;forecast&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;col&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]})&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;df_fc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DataFrame&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rows&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;merge&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;realized_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;target_y&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;target_q&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;rhos&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;iid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;grp&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_fc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;groupby&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;grp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;min_quarters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;rhos&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;spearmanr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;grp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;forecast&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;grp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;realized&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;statistic&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rhos&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;eda-4-is-individual-skill-persistent&quot;&gt;EDA 4: is individual skill persistent?&lt;/h2&gt;

&lt;p&gt;If some forecasters are systematically better than others, a combination method that upweights them should outperform equal-weighting. But is there persistent skill?&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/spf-part1/fig6_skill_persistence.png&quot; alt=&quot;Skill persistence&quot; style=&quot;width:100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;For unemployment, skill is strikingly persistent: a forecaster who performs well at h=1 also performs well at h=2. The Spearman correlation between a forecaster’s skill rank at h=1 and their skill rank at h=2 is very high. This makes intuitive sense: forecasters who understand the persistence structure of unemployment do well at all horizons.&lt;/p&gt;

&lt;p&gt;For real GDP growth, the picture looks superficially similar (skill persistence ρ = 0.84, nearly as high as unemployment’s 0.87), but the distribution of skill is fundamentally different: many RGDP forecasters have near-zero or negative Spearman correlations with the realised outcome at both horizons, so the panel is centred near zero rather than near one. What the persistence coefficient tells us is that whatever skill or bias a forecaster has, it is durable across horizons; it does not tell us that skill levels are high. This aligns with the broader finding in the forecasting literature that RGDP growth is close to a martingale over quarterly intervals: most forecasters have little genuine skill, and those who do are consistently skilled, while those with systematic biases remain biased.&lt;/p&gt;

&lt;p&gt;The existence of persistent skill for unemployment suggests that combination methods which exploit skill differentials could add value, at least in principle. Whether they do in practice depends on how reliably those differentials can be estimated from finite data.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;eda-5-the-cross-horizon-redundancy-structure&quot;&gt;EDA 5: the cross-horizon redundancy structure&lt;/h2&gt;

&lt;p&gt;When we combine forecasts at different lead times (e.g., the nowcast alongside 1-, 2-, 3-, and 4-quarter-ahead consensus forecasts), the signals are not independent. How correlated are they?&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/spf-part1/fig5_crosshorizon_corr.png&quot; alt=&quot;Cross-horizon correlation heatmap&quot; style=&quot;width:100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The correlation between consecutive horizons is very high: the nowcast and 1-quarter-ahead consensus correlate at 0.87; the 3Q and 4Q-ahead forecasts correlate at 0.91. Even the least-correlated pair, nowcast and 4Q-ahead, has a Spearman correlation of 0.75. This redundancy structure has a direct implication for combination: a simple average of the five lead-time forecasts dilutes the most informative one (the nowcast) with four highly redundant, less accurate versions. An optimal method should recognise this and concentrate weight on the most informative signal.&lt;/p&gt;

&lt;p&gt;The redundancy is not accidental. Forecasters form their views about the current quarter first, then extrapolate to future quarters using a model that is largely anchored to the current forecast. A forecaster’s 4Q-ahead view of GDP growth is typically little more than their nowcast adjusted for mean reversion.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Compute cross-horizon Spearman correlation matrix (pooled across all 8 variables)
# Using the prebuilt panel wide format: one row per (var, target_y, target_q)
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df_wide&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;read_parquet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;spf_panel_wide.parquet&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;reset_index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;lead_cols&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;lead0&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;lead1&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;lead2&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;lead3&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;lead4&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;corr_matrix&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_wide&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lead_cols&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;dropna&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;corr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;method&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;spearman&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;corr_matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;round&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;#         lead0  lead1  lead2  lead3  lead4
# lead0    1.00   0.87   0.80   0.76   0.75
# lead1    0.87   1.00   0.90   0.85   0.83
# lead2    0.80   0.90   1.00   0.90   0.87
# lead3    0.76   0.85   0.90   1.00   0.91
# lead4    0.75   0.83   0.87   0.91   1.00
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;eda-6-how-predictable-is-each-variable-at-h2&quot;&gt;EDA 6: how predictable is each variable at h=2?&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;/assets/spf-part1/fig7_predictability.png&quot; alt=&quot;Variable predictability at h=2&quot; style=&quot;width:100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The gap between the most and least predictable variables at a two-quarter horizon is enormous. Unemployment (consensus Spearman correlation 0.91 with realised) is roughly three times more predictable than CPI (0.32) and ten times more predictable than corporate profits (0.09), which is the least forecastable variable in the panel. This heterogeneity means that any pooled analysis across variables must be interpreted carefully: pooling improves statistical efficiency but conflates very different underlying environments.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;eda-7-realised-values-and-regime-shifts&quot;&gt;EDA 7: realised values and regime shifts&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;/assets/spf-part1/fig8_realized_series.png&quot; alt=&quot;Realised value time series&quot; style=&quot;width:100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The 58-year sample covers six distinct macroeconomic regimes:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;1968-1979 (Great Inflation):&lt;/strong&gt; unemployment rises and CPI climbs to double digits.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;1980-1983 (Volcker disinflation):&lt;/strong&gt; deliberate tight monetary policy drives CPI from 13% to 3% at the cost of a deep recession and peak unemployment of 10.8%.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;1984-2007 (Great Moderation):&lt;/strong&gt; low volatility in both inflation and output growth, long expansions.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;2008-2009 (Global Financial Crisis):&lt;/strong&gt; unemployment spikes from 4.4% to 10%.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;2010-2019 (post-GFC recovery):&lt;/strong&gt; slow recovery, below-target inflation throughout.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;2020-2026 (COVID and aftermath):&lt;/strong&gt; unemployment briefly hit 14.7% in April 2020, then fell sharply; CPI surged to 9% in 2022, the highest in 40 years, before gradually retreating.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This regime diversity is important for evaluating any combination method out-of-sample: a model trained on Great Moderation data may perform very differently during the inflation surge of 2021-2022. We will trace this explicitly in Part 3.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;eda-8-forecaster-disagreement-over-time&quot;&gt;EDA 8: forecaster disagreement over time&lt;/h2&gt;

&lt;p&gt;Do professional forecasters agree more or less during economic stress?&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/spf-part1/fig9_disagreement.png&quot; alt=&quot;Forecaster disagreement over time&quot; style=&quot;width:100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Disagreement (cross-sectional standard deviation of 2Q-ahead UNEMP forecasts) was low and stable for most of the survey’s history, including during the Great Inflation and the Volcker recession. It shows a small visible spike at the Global Financial Crisis and then an enormous spike at COVID, by far the largest in the 58-year sample. The COVID spike is consistent with the unprecedented uncertainty about the trajectory of the labour market: no historical analogue existed for a pandemic-induced shutdown followed by an equally sharp reopening. The absence of elevated disagreement during the 1970s-1980s recessions is itself informative: unemployment is persistent enough that even during those turbulent episodes, forecasters converged on similar near-term paths.&lt;/p&gt;

&lt;p&gt;This pattern has a direct implication for combination: during periods of high disagreement, the cross-sectional distribution of forecasts carries more information (some forecasters may have genuinely different information sets or models), making it potentially more valuable to weight them unequally. During periods of low disagreement, equal-weight is nearly optimal by symmetry.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;what-the-eda-tells-us&quot;&gt;What the EDA tells us&lt;/h2&gt;

&lt;p&gt;Before fitting any model, the data already answers several questions:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. The combination problem is not trivial.&lt;/strong&gt; Individual forecasters vary enormously in skill, depending on the variable and horizon. UNEMP nowcasters are essentially all equally skilled; CPI medium-term forecasters are all essentially noise. The interesting combination problem lives in the middle: variables and horizons where some skill exists, some heterogeneity exists, and some redundancy across signals must be managed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. The cross-horizon structure is the main design lever.&lt;/strong&gt; The five lead-time forecasts of the same variable are a natural set of signals: they are all targeting the same outcome, they have a structural skill hierarchy (nowcast is always best), and they are highly correlated with each other. This creates the exact redundancy that a well-designed combination method should exploit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Panel turnover limits named-forecaster experiments.&lt;/strong&gt; The 58-year span is too long for a balanced panel of named forecasters. Any long-run analysis must use the consensus. For experiments on the combination puzzle (same-horizon, named-forecaster combinations), we are limited to smaller panels where a few high-coverage individual forecasters overlap for the same variable, horizon, and target quarter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Regime diversity is substantial.&lt;/strong&gt; A combination method that works during the Great Moderation may fail during an inflation surge. Part 3 checks whether the main rankings remain stable through time using rolling out-of-sample performance summaries.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;what-comes-next&quot;&gt;What comes next&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;/forecasting/2026/07/08/spf-part2-copulas.html&quot;&gt;Part 2&lt;/a&gt; builds the mathematical framework. We separate two approaches: modelling the joint dependence of outcomes and forecasts, and modelling the joint dependence of forecast errors. The Gaussian outcome-forecast copula reduces to OLS / best linear prediction on probit ranks; the Gaussian error model gives the more classical GLS-style precision-weighted combination. We also introduce vine copulas for both approaches and use synthetic data to show when their extra flexibility helps.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/forecasting/2026/07/12/spf-part3-horserace.html&quot;&gt;Part 3&lt;/a&gt; puts the resulting method families on the SPF data: simple baselines (persistence, Lead 0, equal-weight, trimmed mean, inverse MSE), outcome-forecast methods (OLS/rank regression, Gaussian copula, vine copula), and error-dependence methods (error GLS, shrinkage variants, and error-copula diagnostics). It reports the walk-forward horserace, revision-sensitivity checks, rolling out-of-sample performance, and named-forecaster case studies.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;em&gt;Data: &lt;a href=&quot;https://www.philadelphiafed.org/surveys-and-data/real-time-data-research/individual-forecasts&quot;&gt;SPF Individual Forecasts, Federal Reserve Bank of Philadelphia&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
</description>
        <pubDate>Sat, 04 Jul 2026 00:00:00 +0000</pubDate>
        <link>https://www.marti.ai/forecasting/2026/07/04/spf-part1-eda.html</link>
        <guid isPermaLink="true">https://www.marti.ai/forecasting/2026/07/04/spf-part1-eda.html</guid>
        
        
        <category>forecasting</category>
        
      </item>
    
      <item>
        <title>Who Competes with Whom? Mapping Hong Kong's Financial Competitor Network from Labour Market Data</title>
        <description>&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/hk-competitor-network/cross_type_flow_heatmap.png&quot; alt=&quot;Cross-type flow matrix between firm types&quot; /&gt;
&lt;/p&gt;

&lt;h1 id=&quot;who-competes-with-whom-mapping-hong-kongs-financial-competitor-network-from-labour-market-data&quot;&gt;Who Competes with Whom? Mapping Hong Kong’s Financial Competitor Network from Labour Market Data&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;When Citadel loses a portfolio manager to Point72, both firms understand the competitive stakes. The SFC register records when the licence at Citadel was cancelled and when a new one at Point72 was activated. The gap between them is a legal mechanism (the non-compete clause) but also a data signal. For moves between rival hedge funds, 13% of professionals wait more than a year before their next licence activates. This post is about what that signal, aggregated across thousands of transitions over 20 years, reveals about competitive structure in Hong Kong’s financial industry.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;tl;dr&lt;/strong&gt; Using 20 years of regulatory data from Hong Kong’s Securities and Futures Commission (SFC), we construct a firm-firm competitor network for approximately 5,000 financial companies, without relying on self-reported disclosures or analyst judgment. The key insight: when employees move between firms, they leave a behavioural trace of competitive relationships. But not all moves are equal. A move from Goldman Sachs to a hedge fund is career progression; a move from Citadel to Point72 is genuine rivalry. We identify 315 hedge funds, trace 918 person-transitions between them, and map a competitor network of 2,387 firms with 14 distinct communities.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;context-the-problem-with-competitor-data&quot;&gt;Context: The problem with competitor data&lt;/h3&gt;

&lt;p&gt;Commercially available competitor datasets are either self-reported (a company says who it thinks competes with it) or constructed by analysts based on SIC codes and business descriptions. Both approaches have well-known limitations: self-reported data reflects strategic disclosure choices rather than ground truth, SIC codes are coarse proxies for actual business overlap, and private firms (which make up the vast majority of Hong Kong’s financial industry) are largely invisible to both methods.&lt;/p&gt;

&lt;p&gt;This project started from a simple observation: Hong Kong’s Securities and Futures Commission publishes a complete, public register of every licensed financial professional since 2003, including name, firm, regulated activity types, and the exact dates their licence was active. If you know when a person was at Firm A and when they joined Firm B, you have a behavioural signal of competition that would be invisible otherwise. Firms compete for the same talent precisely because they do the same thing.&lt;/p&gt;

&lt;p&gt;This builds directly on two prior papers: &lt;a href=&quot;https://arxiv.org/pdf/2410.07970&quot;&gt;Mapping Hong Kong’s Financial Ecosystem&lt;/a&gt; (which used the same register to study the network structure of licensed professionals and firms) and &lt;a href=&quot;https://arxiv.org/abs/2509.08001&quot;&gt;Turnover Contagion in HK Financial Labour Markets&lt;/a&gt;.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;data-519860-licence-records-20-years-5000-firms&quot;&gt;Data: 519,860 licence records, 20 years, 5,000 firms&lt;/h3&gt;

&lt;p&gt;The SFC register contains &lt;strong&gt;519,860 licence records&lt;/strong&gt; spanning 2003–2024, covering &lt;strong&gt;121,883 unique persons&lt;/strong&gt; and &lt;strong&gt;4,979 distinct firms&lt;/strong&gt;. Each record specifies the regulated activity type (RA1 through RA10):&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;RA&lt;/th&gt;
      &lt;th&gt;Description&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;RA1&lt;/td&gt;
      &lt;td&gt;Dealing in Securities&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;RA2&lt;/td&gt;
      &lt;td&gt;Dealing in Futures Contracts&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;RA4&lt;/td&gt;
      &lt;td&gt;Advising on Securities&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;RA6&lt;/td&gt;
      &lt;td&gt;Advising on Corporate Finance&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;RA9&lt;/td&gt;
      &lt;td&gt;Asset Management&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;RA10&lt;/td&gt;
      &lt;td&gt;Providing Credit Ratings&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Large financial groups typically appear as multiple distinct legal entities in the register: Goldman Sachs (Asia) L.L.C., Goldman Sachs Futures Co. Ltd., and Goldman Sachs Private Wealth Management Ltd. are three separate SFC registrants, but treated as a single competitive entity in our analysis. We consolidate these into &lt;strong&gt;4,576 parent entities&lt;/strong&gt; using Claude Haiku to identify ultimate parent relationships, followed by two targeted merge passes based on inspection of the highest-similarity pairs. All analysis from this point forward operates at the parent-entity level.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;methodology-three-signals-one-score&quot;&gt;Methodology: Three signals, one score&lt;/h3&gt;

&lt;p&gt;We construct the competition score between every pair of parent entities as a weighted combination of three signals. Each captures a fundamentally different dimension of competition and they are not interchangeable.&lt;/p&gt;

\[C[i,j] = 10 \times \left( \frac{1}{3} \cdot \tilde{J}[i,j] + \frac{1}{3} \cdot \tilde{F}[i,j] + \frac{1}{3} \cdot \tilde{E}[i,j] \right)\]

&lt;hr /&gt;

&lt;p&gt;&lt;strong&gt;Signal 1 — Activity Overlap (Jaccard): &lt;em&gt;potential&lt;/em&gt; competition&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For each parent entity, we compute a binary vector over the 10 regulated activity types. The Jaccard similarity between two firms measures the overlap of their regulatory footprints:&lt;/p&gt;

\[J[i,j] = \frac{|A_i \cap A_j|}{|A_i \cup A_j|}\]

&lt;p&gt;Two firms that both hold RA1, RA4, and RA9 score J=1.0. This is a &lt;em&gt;structural&lt;/em&gt; signal: do these firms operate on the same regulatory fields? It has full coverage (computable for all 8.3M pairs) and is stable over time. Its main limitation is coarseness: a Chinese retail broker and a global investment bank both hold RA1, but they serve entirely different clients.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;strong&gt;Signal 2 — Normalised Employee Flow: &lt;em&gt;revealed&lt;/em&gt; competition&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For each person, we detect &lt;em&gt;sequential transitions&lt;/em&gt;: a tenure at Firm A ending within a window of a tenure at Firm B starting. We aggregate and normalise by firm size:&lt;/p&gt;

\[F[i,j] = \frac{\text{flow}_{i \to j} + \text{flow}_{j \to i}}{\sqrt{n_i \cdot n_j}}\]

&lt;p&gt;This is a &lt;em&gt;behavioural&lt;/em&gt; signal: do firms actually compete for the same people? It is observable from the public register regardless of whether either firm chooses to disclose competitive relationships.&lt;/p&gt;

&lt;p&gt;The key methodological choice is the transition window. We use &lt;strong&gt;730 days (2 years)&lt;/strong&gt; as the cap, which ensures that moves constrained by 12–24 month non-competes are not lost. A 180-day window (the standard in labour mobility studies) would miss nearly 40% of IB→HF transitions and 28% of HF→HF transitions that occur in the 6–24 month gap range. Using 730 days adds 39% more observed transitions overall compared to 180 days.&lt;/p&gt;

&lt;p&gt;Despite its informational value, flow covers only approximately &lt;strong&gt;1% of all pairs&lt;/strong&gt;. The vast majority of the network topology derives from Jaccard and embedding. Flow is most valuable for identifying and ranking the most competitive specific relationships, not for defining the network boundary.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;strong&gt;Signal 3 — Embedding Cosine Similarity: &lt;em&gt;semantic&lt;/em&gt; competition&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We generate a short description of each firm using Claude, embed all 4,576 descriptions with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;all-mpnet-base-v2&lt;/code&gt; (768-dimensional SBERT), and compute pairwise cosine similarity. This &lt;em&gt;semantic&lt;/em&gt; signal adds value for firms whose regulatory footprints differ but whose business is clearly similar: two quant funds that may hold different RA combinations but describe themselves in near-identical terms.&lt;/p&gt;

&lt;hr /&gt;

&lt;h4 id=&quot;what-each-signal-can-and-cannot-see&quot;&gt;What each signal can and cannot see&lt;/h4&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt; &lt;/th&gt;
      &lt;th&gt;Jaccard (structural)&lt;/th&gt;
      &lt;th&gt;Flow (revealed)&lt;/th&gt;
      &lt;th&gt;Embedding (semantic)&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Coverage&lt;/td&gt;
      &lt;td&gt;All pairs&lt;/td&gt;
      &lt;td&gt;~1% of pairs&lt;/td&gt;
      &lt;td&gt;All pairs&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;What it captures&lt;/td&gt;
      &lt;td&gt;Regulatory overlap&lt;/td&gt;
      &lt;td&gt;Actual talent competition&lt;/td&gt;
      &lt;td&gt;Descriptive similarity&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Blind spots&lt;/td&gt;
      &lt;td&gt;Ignores strategy, client base, geography&lt;/td&gt;
      &lt;td&gt;Sparse; finite window misses very long career breaks&lt;/td&gt;
      &lt;td&gt;Depends on LLM description quality&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Best use&lt;/td&gt;
      &lt;td&gt;Broad network topology, community detection&lt;/td&gt;
      &lt;td&gt;Ranking competitive intensity; validating specific relationships&lt;/td&gt;
      &lt;td&gt;Niche discrimination within broad activity types&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;A regression on 4,000 LLM-scored firm pairs confirms that the signals are complementary rather than redundant. SHAP feature importance:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Feature&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;SHAP contribution&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Jaccard similarity&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.760&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Same firm type&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.365&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Embedding similarity&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.344&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Flow (normalised)&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.014&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The low SHAP for flow reflects that it is &lt;em&gt;independent&lt;/em&gt; of what the LLM uses to judge competition: it measures revealed behaviour that is invisible to any structural analysis. Equal weights are an arbitrary design choice. Jaccard dominates the LLM-based regression, but flow and embedding each provide orthogonal signal that would be lost under SHAP-proportional weighting.&lt;/p&gt;

&lt;p&gt;A few concrete examples of signal alignment and divergence:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Pair&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Score&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Raw flow&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Norm flow&lt;/th&gt;
      &lt;th&gt;Reading&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Goldman Sachs / Morgan Stanley&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5.74&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;151&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.020&lt;/td&gt;
      &lt;td&gt;Both signals align: canonical IB peers&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;UBS / Credit Suisse&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5.42&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;179&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.045&lt;/td&gt;
      &lt;td&gt;Both signals align: full-service bank peers&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Penjing Asset Management / Sigma Capital&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.16&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;18&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.455&lt;/td&gt;
      &lt;td&gt;Highest normalised flow in the dataset: two small AM firms with intense bilateral exchange relative to size&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;CMB International / CMBC International&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;6.39&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;0.000&lt;/td&gt;
      &lt;td&gt;Two distinct Chinese bank-affiliated IB arms with near-identical activity profiles; genuine competitors, zero observed talent crossing&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;network-structure-14-communities-modularity-0622&quot;&gt;Network structure: 14 communities, modularity 0.622&lt;/h3&gt;

&lt;p&gt;Applying a minimum firm size of 10 persons and competition score threshold τ=4, the network has &lt;strong&gt;2,387 nodes&lt;/strong&gt; and &lt;strong&gt;317,850 edges&lt;/strong&gt;. Louvain community detection (modularity=0.622) finds &lt;strong&gt;14 communities&lt;/strong&gt;:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Community&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Size&lt;/th&gt;
      &lt;th&gt;Representative members&lt;/th&gt;
      &lt;th&gt;Interpretation&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;0&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;706&lt;/td&gt;
      &lt;td&gt;Goldman Sachs, Morgan Stanley, UBS, BofI Securities&lt;/td&gt;
      &lt;td&gt;Full-service investment banks and their execution arms&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;412&lt;/td&gt;
      &lt;td&gt;HSBC, Bank of China, ICBC, Orient Securities&lt;/td&gt;
      &lt;td&gt;Bank-affiliated commercial banks and their securities arms&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;391&lt;/td&gt;
      &lt;td&gt;Phillip Securities, KGI, Guangdeng Futures&lt;/td&gt;
      &lt;td&gt;Retail broker-dealers and futures intermediaries&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;256&lt;/td&gt;
      &lt;td&gt;Point72, Citadel, Balyasny, Millennium, BFAM&lt;/td&gt;
      &lt;td&gt;Hedge funds&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;4&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;208&lt;/td&gt;
      &lt;td&gt;Zhongtai International, ICBC International Securities, CCB International&lt;/td&gt;
      &lt;td&gt;China-affiliated mid-tier investment banks&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;122&lt;/td&gt;
      &lt;td&gt;Phillip Capital, Haitong International Futures, BofI Securities (formerly Merrill Lynch)&lt;/td&gt;
      &lt;td&gt;Futures-heavy broker-dealers&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;102&lt;/td&gt;
      &lt;td&gt;CPPIB, Computershare, smaller retail brokers&lt;/td&gt;
      &lt;td&gt;Smaller retail and custody-focused firms&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;60&lt;/td&gt;
      &lt;td&gt;Ping An, PricewaterhouseCoopers, Lego Corporate Finance&lt;/td&gt;
      &lt;td&gt;Insurance, audit, and corporate advisory&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;8&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;53&lt;/td&gt;
      &lt;td&gt;Zhongtai International Capital, RHB Capital, Fortune Financial Capital&lt;/td&gt;
      &lt;td&gt;Mid-tier regional banks and boutique IBs&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;9&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;34&lt;/td&gt;
      &lt;td&gt;FTL Wealth Management, Thornton Global, Wisdom Wealth&lt;/td&gt;
      &lt;td&gt;Independent wealth managers and IFAs&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;10&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;28&lt;/td&gt;
      &lt;td&gt;CES Forex, Emperor International Exchange, Rakuten Securities&lt;/td&gt;
      &lt;td&gt;Forex and retail FX platforms&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;11&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8&lt;/td&gt;
      &lt;td&gt;S&amp;amp;P Global Ratings, Moody’s, Fitch&lt;/td&gt;
      &lt;td&gt;Credit rating agencies&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;12&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;5&lt;/td&gt;
      &lt;td&gt;Liquidnet, OSL Digital Securities, Hash Blockchain&lt;/td&gt;
      &lt;td&gt;Crypto and digital assets&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;13&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
      &lt;td&gt;Celestial Finance, Lei Shing Hong Finance&lt;/td&gt;
      &lt;td&gt;Residual micro-entities&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/hk-competitor-network/network_top_hubs.png&quot; alt=&quot;Top 25 hubs by degree and weighted degree&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;The modularity of 0.622 is high: communities are tightly internally connected and sparsely interconnected. Three global network properties are worth noting:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Density = 0.127&lt;/strong&gt;: 12.7% of all possible firm pairs exceed the competition threshold τ=4, relatively dense for an industry competitor network.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Clustering coefficient = 0.825&lt;/strong&gt;: if Firm A competes with B, and B competes with C, A almost certainly competes with C. Competition in financial services is highly transitive, as activity overlap propagates.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Betweenness centrality&lt;/strong&gt;: dominated by broker-dealers and mid-tier Chinese-affiliated firms, not the global investment banks. This is counterintuitive but structurally sensible: global IBs are so densely interconnected within their own community that they rarely serve as bridges. Local broker-dealers, with licences spanning retail, futures, and asset management, sit at the boundary between communities and act as connective tissue across the network.&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;historical-fingerprints-ma-collapses-and-market-exits&quot;&gt;Historical fingerprints: M&amp;amp;A, collapses, and market exits&lt;/h3&gt;

&lt;p&gt;The SFC register records every major institutional event that reshuffled Hong Kong’s financial workforce over two decades. Mergers, acquisitions, collapses, and strategic retreats all leave a characteristic signature: a concentrated burst of same-direction transitions within a narrow window.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Year&lt;/th&gt;
      &lt;th&gt;From&lt;/th&gt;
      &lt;th&gt;To&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Persons&lt;/th&gt;
      &lt;th&gt;Event&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;2008&lt;/td&gt;
      &lt;td&gt;Lehman Brothers&lt;/td&gt;
      &lt;td&gt;Nomura&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;423&lt;/td&gt;
      &lt;td&gt;Nomura acquisition of Lehman’s Asia-Pacific business&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2010&lt;/td&gt;
      &lt;td&gt;Merrill Lynch&lt;/td&gt;
      &lt;td&gt;BofI Securities&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;217&lt;/td&gt;
      &lt;td&gt;Bank of America / Merrill Lynch integration and HK rebrand&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2017&lt;/td&gt;
      &lt;td&gt;Tung Shing Securities + Futures&lt;/td&gt;
      &lt;td&gt;SinoPac Securities&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;155&lt;/td&gt;
      &lt;td&gt;SinoPac acquisition of Tung Shing’s HK brokerage&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2005&lt;/td&gt;
      &lt;td&gt;Prudential Assurance&lt;/td&gt;
      &lt;td&gt;BOC International&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;148&lt;/td&gt;
      &lt;td&gt;Prudential restructured its HK securities operations&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2023&lt;/td&gt;
      &lt;td&gt;Credit Suisse&lt;/td&gt;
      &lt;td&gt;UBS&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;45&lt;/td&gt;
      &lt;td&gt;UBS emergency rescue acquisition (March 2023)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2012&lt;/td&gt;
      &lt;td&gt;Royal Bank of Scotland&lt;/td&gt;
      &lt;td&gt;China Galaxy Securities&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;39&lt;/td&gt;
      &lt;td&gt;RBS exit from Asia, sold to Chinese state-owned buyer&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2012&lt;/td&gt;
      &lt;td&gt;Crédit Agricole&lt;/td&gt;
      &lt;td&gt;China Galaxy Securities&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;26&lt;/td&gt;
      &lt;td&gt;Crédit Agricole’s HK business absorbed by China Galaxy&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2008&lt;/td&gt;
      &lt;td&gt;Lehman Brothers&lt;/td&gt;
      &lt;td&gt;Neuberger Berman&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;19&lt;/td&gt;
      &lt;td&gt;Neuberger Berman (Lehman’s AM arm) carved out independently&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The 2008 Lehman event is the most dramatic in the dataset: 423 of 470 total Lehman to Nomura transitions occurred within the calendar year of the collapse. The 2012 entries reflect a structural shift, as RBS and Crédit Agricole both withdrew from Hong Kong and were absorbed by the same Chinese state-owned buyer, reflecting the broader retreat of Western banks from Asia operations in that period.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;the-hedge-fund-ecosystem&quot;&gt;The Hedge Fund Ecosystem&lt;/h3&gt;

&lt;h4 id=&quot;scale-7616-professionals-62-of-the-register&quot;&gt;Scale: 7,616 professionals, 6.2% of the register&lt;/h4&gt;

&lt;p&gt;Across the full 20-year register, &lt;strong&gt;7,616 persons&lt;/strong&gt; (6.2% of 121,883 total) held at least one licence at a hedge fund. The HF workforce has grown &lt;strong&gt;14-fold&lt;/strong&gt; since 2003 (182 to 2,543 active professionals by end of 2023):&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/hk-competitor-network/hf_workforce_growth.png&quot; alt=&quot;Active HF professionals registered with SFC by year&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;Growth was rapid through the 2000s (quadrupling 2003–2008), resilient through the GFC, and plateaued in 2022–2023. The plateau reflects several converging pressures: the prolonged China equity bear market from late 2021 onwards, regulatory actions affecting offshore China-focused funds, the unwind of leveraged macro China positions, and rising interest rates redirecting global LP capital away from Asia-focused alternatives. Note: 2024 is excluded as a partial year.&lt;/p&gt;

&lt;h4 id=&quot;identifying-315-hedge-funds&quot;&gt;Identifying 315 hedge funds&lt;/h4&gt;

&lt;p&gt;The SFC has no “hedge fund” licence category. A fund running a long/short equity book and a Vanguard ETF product both hold RA9 (Asset Management). We classify all 1,113 firms in the asset manager / other / PE / wealth management categories using &lt;strong&gt;Claude Sonnet&lt;/strong&gt;, with only firm name, Chinese name, and regulated activity types as input.&lt;/p&gt;

&lt;p&gt;The result: &lt;strong&gt;315 hedge funds&lt;/strong&gt; identified. A second pass classifies each by primary strategy:&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/hk-competitor-network/hf_strategy_distribution.png&quot; alt=&quot;HF strategy distribution by count and headcount&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;Long/short equity dominates by count (183 funds), reflecting Hong Kong’s role as the primary hub for Asia and China-focused equity strategies. Multi-strategy platforms are fewer (14 funds) but disproportionately large: Millennium (372), Point72 (295), and Citadel (259) are the three largest by registered professionals.&lt;/p&gt;

&lt;h4 id=&quot;survival-244-active-69-closed-median-lifespan-105-years&quot;&gt;Survival: 244 active, 69 closed, median lifespan 10.5 years&lt;/h4&gt;

&lt;p&gt;Of the 315 HFs, &lt;strong&gt;244 remain active&lt;/strong&gt; and &lt;strong&gt;69 have closed&lt;/strong&gt;. The median lifespan of closed funds is &lt;strong&gt;10.5 years&lt;/strong&gt;: these are not failed startups but mature funds that ran their course. Closure rates are highest for 2006–2007 cohorts (44–60%), likely GFC casualties.&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/hk-competitor-network/hf_survival.png&quot; alt=&quot;HF cohort survival and lifespan distribution&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;Among recent closures: Adamas Asset Management (2023, 10 years), Snow Lake Capital (2023, 11 years), Myriad Asset Management (2022, 11 years), and Azentus Capital Management (9 years).&lt;/p&gt;

&lt;h4 id=&quot;goldman-sachs-as-training-ground&quot;&gt;Goldman Sachs as training ground&lt;/h4&gt;

&lt;p&gt;Investment banks export talent to hedge funds at a &lt;strong&gt;3.32× ratio&lt;/strong&gt; relative to the reverse (1,271 IB to HF vs 383 HF to IB). This is career progression, not competition. Goldman Sachs sends &lt;strong&gt;185 persons&lt;/strong&gt; to hedge funds over the sample, the single largest feeder in the dataset, followed by Credit Suisse (158, combining all group entities), Morgan Stanley (127), Citigroup (77), JPMorgan (66), and UBS (64).&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/hk-competitor-network/hf_feeder_types.png&quot; alt=&quot;Feeder firm types into hedge funds&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;Investment banks lead with 30.4% of all HF inflows, followed by HF-to-HF moves (22.0%, covered in the next section), asset managers (21.1%), and broker-dealers (17.8%). The figure above shows only non-HF feeders; HF-to-HF transitions are analysed separately below.&lt;/p&gt;

&lt;p&gt;The broker-dealer channel (17.8%, 745 persons) deserves attention. Broker-dealer professionals (equity sales traders, research analysts, derivatives structurers) move to hedge funds as execution talent: people who know how to work markets, manage relationships with prime brokerage desks, and execute strategies efficiently. These transitions tend to be faster, with a median non-compete gap of 79 days, shorter than IB to HF moves at 96 days.&lt;/p&gt;

&lt;h4 id=&quot;hf-to-hf-competition-the-inner-circle&quot;&gt;HF-to-HF competition: the inner circle&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;918 persons&lt;/strong&gt; transitioned between HF pairs over the 20-year sample (730-day window). The top undirected pairs:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Firm A&lt;/th&gt;
      &lt;th&gt;Firm B&lt;/th&gt;
      &lt;th&gt;Persons&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Adamas Asset Management&lt;/td&gt;
      &lt;td&gt;Gen2 Partners&lt;/td&gt;
      &lt;td&gt;15&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Millennium Capital Management&lt;/td&gt;
      &lt;td&gt;Segantii Capital Management&lt;/td&gt;
      &lt;td&gt;13&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Gentleman Capital&lt;/td&gt;
      &lt;td&gt;Goldhorse Capital&lt;/td&gt;
      &lt;td&gt;13&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Millennium Capital Management&lt;/td&gt;
      &lt;td&gt;Polymer Capital&lt;/td&gt;
      &lt;td&gt;12&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Millennium Capital Management&lt;/td&gt;
      &lt;td&gt;Point72&lt;/td&gt;
      &lt;td&gt;12&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Balyasny&lt;/td&gt;
      &lt;td&gt;Point72&lt;/td&gt;
      &lt;td&gt;11&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Dymon Asia&lt;/td&gt;
      &lt;td&gt;Millennium Capital Management&lt;/td&gt;
      &lt;td&gt;11&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Balyasny&lt;/td&gt;
      &lt;td&gt;Millennium Capital Management&lt;/td&gt;
      &lt;td&gt;10&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The most active competitive cluster is the &lt;strong&gt;Balyasny–Millennium–Point72 triangle&lt;/strong&gt;, the highest-weight triplet in the dataset. Millennium appears in more top bilateral flow pairs than any other fund, reflecting its model as a multi-PM platform with high hiring and attrition across the ecosystem.&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/hk-competitor-network/hf_network_viz.png&quot; alt=&quot;HF competitor subgraph — talent flows between hedge funds&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;The network reveals two distinct competitive topologies. The global multi-strategy platforms (Millennium, Balyasny, Point72, ExodusPoint, Schonfeld) form a &lt;strong&gt;dense triangle core&lt;/strong&gt;: they compete for the same PM talent pool, and the competition is mutual. The HK-homegrown funds (Gen2, Adamas, Gentleman, Goldhorse) show &lt;strong&gt;intense bilateral competition without triangular clustering&lt;/strong&gt;, concentrated within strategy niches. Segantii is a hub-without-triangles: bilateral flows with 21 different funds spanning global multi-strats, macro, credit, and event-driven, consistent with an event-driven strategy whose talent pool overlaps many adjacent strategies.&lt;/p&gt;

&lt;h4 id=&quot;talent-magnets-and-exporters&quot;&gt;Talent magnets and exporters&lt;/h4&gt;

&lt;p&gt;Net flow (inbound minus outbound HF→HF transitions) reveals a prestige hierarchy:&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/hk-competitor-network/hf_net_flow_directionality.png&quot; alt=&quot;Net HF-to-HF talent flow: magnets vs exporters&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;The strongest &lt;strong&gt;net importers&lt;/strong&gt; are Millennium (+30), Polymer Capital (+18), Adamas (+15), Gentleman Capital (+13), and Dymon Asia (+13). Millennium’s dominance is striking: with 91 inbound and 61 outbound HF to HF moves, it is the platform of choice for experienced hedge fund professionals across strategies.&lt;/p&gt;

&lt;p&gt;The largest &lt;strong&gt;net exporters&lt;/strong&gt; are Sculptor Capital (−15), Goldhorse (−13), LIM Advisors (−13), Azentus (−11), and Point72 (−10). Several closed funds appear here, consistent with net outflow as a leading indicator of institutional stress. Point72 as a net exporter is notable: its single largest outflow destination is Millennium (10 persons), followed by Balyasny (6) and Schonfeld (4). PMs whose capital is reallocated typically move to another multi-strategy platform rather than exiting the industry. Point72 functions as a training and filtering ground within the multi-strat ecosystem.&lt;/p&gt;

&lt;h4 id=&quot;tenure-the-whole-industry-is-high-turnover&quot;&gt;Tenure: the whole industry is high-turnover&lt;/h4&gt;

&lt;p&gt;A common assumption is that hedge fund tenures are uniquely short and volatile. The data does not support this:&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/hk-competitor-network/tenure_by_firm_type.png&quot; alt=&quot;Tenure duration by firm type&quot; /&gt;
&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Firm type&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Median tenure&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;&amp;lt;1 year&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;&amp;lt;2 years&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Hedge Fund&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.9 years&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;29%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;52%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Investment Bank&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.0 years&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;28%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;51%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Asset Manager&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2.0 years&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;29%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;50%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Broker-Dealer&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1.8 years&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;33%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;54%&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Median tenures are nearly identical across all firm types. The entire Hong Kong financial industry is a high-turnover labour market.&lt;/p&gt;

&lt;p&gt;Two caveats on interpretation. First, SFC records are at the legal entity level: a professional who spends eight years at Goldman Sachs may appear as two or three separate tenures across different Goldman Sachs entities, compressing apparent tenure. Second, SFC-registered roles are disproportionately front-office and senior (portfolio managers, traders, analysts, relationship managers), roles with structurally higher turnover than back-office functions.&lt;/p&gt;

&lt;h4 id=&quot;the-gap-between-roles-where-non-competes-show-up&quot;&gt;The gap between roles: where non-competes show up&lt;/h4&gt;

&lt;p&gt;When a professional leaves one firm and joins another, the gap between their last licence deactivation and next licence activation reflects the nature of the move.&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/hk-competitor-network/gap_by_move_type.png&quot; alt=&quot;Gap between roles by transition type&quot; /&gt;
&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Transition&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;Median gap&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;&amp;gt;180 days&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt;&amp;gt;1 year&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;IB to IB&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;62 days&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;22.3%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;13.8%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;BD to HF&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;79 days&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;27.1%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;16.2%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;IB to HF&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;96 days&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;33.5%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;19.7%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;HF to HF&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;100 days&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;31.7%&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;13.1%&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;(Positive gaps only, transitions capped at 3 years.)&lt;/p&gt;

&lt;p&gt;The medians are broadly similar across transition types, ranging from 62 to 100 days. The fraction waiting more than a year varies more: IB to HF stands at 19.7%, compared to 13.1% for HF to HF. Whether this reflects more aggressive IB non-compete enforcement on buy-side departures, or other factors such as more senior roles being involved in IB to HF moves, is difficult to disentangle from this data alone.&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/hk-competitor-network/ib_hf_gap_by_seniority.png&quot; alt=&quot;IB to HF gap by seniority tier&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;Breaking down IB to HF transitions by SFC experience at departure does not show a simple seniority gradient. The &amp;gt;1 year fraction is 24.5% for the least experienced tier and 21.7% for the most experienced, with mid-career professionals (3–6 years SFC experience) showing the shortest gaps at 18.3%. This is consistent with the SFC experience measure being a lower bound: international hires with prior careers outside Hong Kong appear junior by this metric even when they are in fact senior. Given this ambiguity, the seniority breakdown should be read with caution.&lt;/p&gt;

&lt;p&gt;HF to HF moves (100 days median) show a lower long-gap fraction (13.1%) than IB to HF. This partly reflects that a share of HF to HF transitions occur when a fund closes, circumstances where the former employer has no competitive interests to enforce.&lt;/p&gt;

&lt;h4 id=&quot;career-trajectories-how-much-experience-before-the-hf&quot;&gt;Career trajectories: how much experience before the HF?&lt;/h4&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/hk-competitor-network/hf_experience_at_entry.png&quot; alt=&quot;Experience at HF entry by previous firm type&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;For the &lt;strong&gt;7,616 persons&lt;/strong&gt; who ever joined a hedge fund, &lt;strong&gt;48.8% have no prior SFC record&lt;/strong&gt;. This reflects several situations: fresh graduates recruited directly by funds, foreign hires whose prior careers were in other jurisdictions, and professionals coming from roles in Hong Kong that do not require SFC registration (quantitative researchers, for instance, are often not registered unless they hold a portfolio management role). Among those who came from other registered firms, median prior SFC experience ranges from 4.7 years (private equity) to 6.2 years (insurance), with IB professionals joining after approximately 4.9 years. All figures are lower bounds; the pre-2008 cohort is systematically undercounted.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;validation&quot;&gt;Validation&lt;/h3&gt;

&lt;p&gt;Four consistency tests confirm the network captures meaningful competition:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Skill-specificity&lt;/strong&gt;: employees moving between competitor pairs carry significantly more similar regulated activity licences (actType Jaccard 0.62 vs 0.50; Mann-Whitney p≈0).&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/hk-competitor-network/validation_skill_specificity.png&quot; alt=&quot;Skill specificity validation&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Flow intensity&lt;/strong&gt;: competitor pairs have 1.4× higher normalised flow than non-competitor pairs (p≈10⁻²⁴). The signal is real but modest, with only approximately 1% of pairs having any observed flow.&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/hk-competitor-network/validation_flow_intensity.png&quot; alt=&quot;Flow intensity validation&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Firm-type consistency&lt;/strong&gt;: 52.9% of competitor pairs are the same firm type, vs. a 26.9% random baseline (χ²=109,254, p≈0).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Tenure signature&lt;/strong&gt;: competitor-pair movers have longer pre-move tenure (701 vs 631 days median; p≈0), reflecting that movers to direct competitors tend to be more senior, and senior departures attract more scrutiny and longer notice periods.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;limitations&quot;&gt;Limitations&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Career start lower bound&lt;/strong&gt;: The register starts in 2003. Experience estimates are significantly downward-biased for professionals already in the industry by then.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;730-day window&lt;/strong&gt;: Chosen to capture non-compete-constrained flows. True multi-year career breaks are rare at the senior level and should not be counted anyway, so this window is a pragmatic rather than conservative choice.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;HF classification at the small end&lt;/strong&gt;: Some of the 315 HFs, particularly those with generic names and few registered professionals, may not be genuine hedge funds.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Embedded HF units&lt;/strong&gt;: Strategies such as equity stat-arb units within large AM groups cannot be separated at the parent-entity level.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Absence of major quant funds&lt;/strong&gt;: Several globally prominent quantitative funds (e.g. Squarepoint Capital) have no SFC-licensed entity in Hong Kong, possibly operating through Singapore. The quant segment is likely the most incomplete.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Team hires and spinoffs&lt;/strong&gt;: Both Qube Research &amp;amp; Technologies (QRT) and Y-Intercept originated from Credit Suisse’s SMG group. QRT had 12 direct CS to QRT moves in 2018 alone. Y-Intercept shows only 4 direct CS to YI moves in the register; its founding team may have come from Credit Suisse offices outside Hong Kong, which would leave no HK SFC record.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Selective registration&lt;/strong&gt;: Quantitative researchers may or may not be SFC-registered. Some firms reportedly de-register research staff precisely because licence records are public and signal headcount changes to competitors.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Static analysis&lt;/strong&gt;: All results use the full 2003–2024 window. Year-by-year tracking of how competitive relationships form and dissolve is the natural extension.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;Twenty years of regulatory data from Hong Kong’s SFC reveals a rich competitor network that no commercial data provider currently constructs. Labour mobility is a behavioural signal of competition, but the signal must be read carefully. Not every move is a defection.&lt;/p&gt;

&lt;p&gt;Key findings:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;The HK financial competitor network has 14 communities (modularity=0.622) with clear alignment to firm type; betweenness centrality is dominated by broker-dealers, not global IBs&lt;/li&gt;
  &lt;li&gt;Investment banks are training grounds, not competitors: Goldman Sachs sends 185 persons to hedge funds over 20 years, the most of any single institution, followed by Credit Suisse (158) and Morgan Stanley (127)&lt;/li&gt;
  &lt;li&gt;315 hedge funds identified (244 active, 69 closed); Millennium appears in more top bilateral flow pairs than any other fund, defining the competitive core of the multi-strategy ecosystem&lt;/li&gt;
  &lt;li&gt;IB to HF transitions show the highest fraction of moves exceeding one year (19.7%), with plausible explanations including non-compete enforcement on senior buy-side departures and the seniority profile of these moves; HF to HF stands at 13.1%&lt;/li&gt;
  &lt;li&gt;48.8% of HF entrants have no prior SFC record, reflecting direct recruitment from graduate programmes, overseas hires, and professionals coming from roles not requiring SFC registration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The methodology is fully reproducible from the SFC public register. A prepared extract of the register is available as a public dataset on &lt;a href=&quot;https://www.kaggle.com/datasets/gautiermarti/hk-sfc-register&quot;&gt;Kaggle&lt;/a&gt;. The academic paper is in preparation.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;em&gt;This work builds on &lt;a href=&quot;https://arxiv.org/pdf/2410.07970&quot;&gt;Mapping Hong Kong’s Financial Ecosystem&lt;/a&gt; and &lt;a href=&quot;https://arxiv.org/abs/2509.08001&quot;&gt;Turnover Contagion in HK Financial Labour Markets&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;em&gt;This is an academic research project conducted in collaboration with &lt;strong&gt;Abdulla Al Ketbi&lt;/strong&gt;, in the context of his PhD research on complex networks, explainable AI, and complexity science. The results presented here are preliminary and will be incorporated into his PhD manuscript and associated publications. This post does not constitute investment advice and has no connection to any employer or commercial entity.&lt;/em&gt;&lt;/p&gt;
</description>
        <pubDate>Wed, 01 Apr 2026 00:00:00 +0000</pubDate>
        <link>https://www.marti.ai/finance/2026/04/01/hk-competitor-network.html</link>
        <guid isPermaLink="true">https://www.marti.ai/finance/2026/04/01/hk-competitor-network.html</guid>
        
        
        <category>finance</category>
        
      </item>
    
      <item>
        <title>EMNLP 2025 in Suzhou</title>
        <description>&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/emnlp-2025/emnlp_suzhou_2025.png&quot; alt=&quot;EMNLP 2025 in Suzhou&quot; /&gt;
&lt;/p&gt;

&lt;h1 id=&quot;emnlp-2025-in-suzhou&quot;&gt;EMNLP 2025 in Suzhou&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; The research discussed in this post is entirely unrelated to my professional responsibilities. The work described here reflects independent academic activity that I pursue out of personal interest in modern machine learning research. All papers referenced below have been officially approved for publication and contain no proprietary or confidential information from my current employer. The material presented should not be interpreted as investment advice, financial analysis, or as having any applicability to my employer’s activities. Its relevance is strictly limited to the advancement of empirical methods and scientific understanding in machine learning.&lt;/p&gt;

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

&lt;p&gt;This year at EMNLP 2025 in Suzhou, my colleague Khaled Al Nuaimi and I attended the conference so that Khaled could present his paper on &lt;a href=&quot;https://www.youtube.com/watch?v=TuNhAZdWjrw&quot;&gt;Evasive Answers in Financial Q&amp;amp;A&lt;/a&gt;, and also to explore current R&amp;amp;D trends in empirical NLP.&lt;/p&gt;

&lt;p&gt;While walking through the poster sessions, we saw a dozen of papers closely related with our recent contributions and joint research program with Khalifa University, where I co-supervise the PhD work of my colleagues:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.linkedin.com/in/abdulla-alketbi/&quot;&gt;Abdulla Al Ketbi&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.linkedin.com/in/khaled-alnuaimi-cfa-2187b7148/&quot;&gt;Khaled Al Nuaimi&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.linkedin.com/in/saeed-almarri/&quot;&gt;Saeed Al Marri&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.linkedin.com/in/hamdan-al-ahbabi-6b6a1abb/&quot;&gt;Hamdan Al Ahbabi&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Across these doctoral projects, we are building a coherent, multi-layer research program at the intersection of:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Complex networks &amp;amp; complexity science&lt;/strong&gt;
(financial labour networks, institutional networks, contagion processes)&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Feature importance &amp;amp; explainable AI&lt;/strong&gt;
(alignment between model predictions and explanations in LLMs &amp;amp; Graphs (Networks) ML models)&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Multimodality: audio + text&lt;/strong&gt;
(tone, prosody, evasiveness, spoken Q&amp;amp;A behaviour)&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Financial Q&amp;amp;A and behavioural analytics&lt;/strong&gt;
(linguistic deception, psychological discourse strategies, managerial behaviour)&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Agent-based modelling (ABM) with explainable agents&lt;/strong&gt;
(replacing zero-intelligence coin-flipping agents with more realistic, behaviourally grounded AI agents)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At EMNLP 2025, we encountered many papers that map surprisingly well onto this agenda, in some cases reinforcing our assumptions, in others providing tools or methodologies we can directly adopt.&lt;/p&gt;

&lt;p&gt;Below is a curated summary of the key papers we saw and how they connect to our ongoing work.&lt;/p&gt;

&lt;h3 id=&quot;relevant-to-us-emnlp-2025-papers&quot;&gt;Relevant (to us) EMNLP 2025 Papers&lt;/h3&gt;

&lt;h4 id=&quot;zero-shot-extraction-of-stock-relationship-graphs-with-llms-zhou-et-al-finnlp-2025&quot;&gt;Zero-Shot Extraction of Stock Relationship Graphs with LLMs (Zhou et al., FinNLP 2025)&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://aclanthology.org/2025.finnlp-2.2.pdf&quot;&gt;paper&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/emnlp-2025/zero_shot_extraction_of_stock_relationship_graphs_with_llms.jpg&quot; alt=&quot;Zero-Shot Extraction of Stock Relationships&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What the paper does:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Uses LLMs as zero-shot knowledge bases to extract rich, typed company–company relations (supplier, competitor, JV partner, investor…).&lt;/li&gt;
  &lt;li&gt;Builds multi-relational stock-market graphs from LLM outputs.&lt;/li&gt;
  &lt;li&gt;Trains GNNs (RGCN, RGAT) for stock return ranking, outperforming GICS/Wikidata graphs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Connections to our research:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This work aligns most closely with Abdulla’s line of research.
Beyond reconstructing networks of past co-employment directly from SFC data, we could extend the financial ecosystem by using LLMs to infer missing inter-institution relationships. For example: competition, parent–subsidiary structures, shared ownership, or other strategic ties.&lt;/p&gt;

&lt;p&gt;Adding these extra edges would enrich Abdulla’s labour-contagion models by capturing sub-industry exposure, competitive pressures, organizational linkages, and cross-firm risk propagation. In short, it gives us a more complete picture of how information, shocks, or turnover might spread across the ecosystem.&lt;/p&gt;

&lt;p&gt;From the perspective of our agent-based modelling (ABM) vision, a multi-relational LLM-inferred graph provides a richer structural layer for agents to operate on. Employee-agents could factor in market competition or firm relations when deciding whether to move to a new opportunity, while firm-agents could incorporate similar relational cues when adjusting headcount or assessing talent flows. This creates a more behaviourally realistic and environmentally aware agent society than classic zero-intelligence ABMs.&lt;/p&gt;

&lt;h4 id=&quot;towards-holistic-evaluation-of-large-audio-language-models-a-comprehensive-survey-chih-kai-yang-et-al&quot;&gt;Towards Holistic Evaluation of Large Audio-Language Models: A Comprehensive Survey (Chih-Kai Yang et al.)&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://aclanthology.org/2025.emnlp-main.514.pdf&quot;&gt;paper&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/emnlp-2025/evaluation_of_large_audio_language_models.jpg&quot; alt=&quot;Towards Holistic Evaluation of Large Audio-Language Models&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What the paper does:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A taxonomy for evaluating audio-language models (LALMs), organized along four axes:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Auditory awareness &amp;amp; processing&lt;/li&gt;
  &lt;li&gt;Knowledge &amp;amp; reasoning&lt;/li&gt;
  &lt;li&gt;Dialogue-oriented ability&lt;/li&gt;
  &lt;li&gt;Fairness, safety &amp;amp; trustworthiness&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It also highlights several gaps in current audio-NLP practice:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;No clean separation between content and paralinguistic cues&lt;/li&gt;
  &lt;li&gt;Weak robustness evaluation (noise, speaker variation, accents)&lt;/li&gt;
  &lt;li&gt;Limited cultural/linguistic diversity in benchmarks&lt;/li&gt;
  &lt;li&gt;Limited evaluation of dialogue quality and response appropriateness&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Connections to our research:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hamdan’s first research contribution: Residual Speech Embeddings&lt;/p&gt;

&lt;p&gt;A natural question is: What differentiates LLMs from LALMs?
In principle, LALMs should integrate auditory information in addition to text: capturing tone, speaker traits, emotional signals, and other paralinguistic cues that are lost in transcripts.&lt;/p&gt;

&lt;p&gt;However, the survey highlights a consistent limitation: current LALMs exhibit very limited auditory awareness. They often fail to detect speaker changes, emotional shifts, or mismatches between lexical content and paralinguistic delivery. In practice, their behaviour is much closer to text-only LLMs than to genuine audio-language models.&lt;/p&gt;

&lt;p&gt;These observations align closely with what we have seen empirically.
This is precisely the motivation for Hamdan’s work on Residual Speech Embeddings, where we demonstrate that self-supervised speech models tend to over-emphasize lexical information at the expense of paralinguistic cues.&lt;/p&gt;

&lt;p&gt;Our approach explicitly removes the lexical component from the speech embedding space, leaving a representation that captures tone and other non-textual characteristics. Empirically, we show that this improves performance on tone-classification tasks, confirming that isolating the paralinguistic signal is beneficial.&lt;/p&gt;

&lt;p&gt;For reference:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2502.19387&quot;&gt;paper&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://marti.ai/ml/2025/02/02/disentangling-speech-embeddings.html&quot;&gt;blog 1&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://marti.ai/ml/2025/02/16/tone-classification-from-speech-embeddings.html&quot;&gt;blog 2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This EMNLP paper essentially validates the direction of our work: the field currently lacks benchmarks that disentangle content from paralinguistic cues, and residual speech embeddings provide a practical step toward filling that gap.&lt;/p&gt;

&lt;p&gt;It is also worth noting that Hamdan’s work naturally connects to Khaled’s research on financial Q&amp;amp;A. One of Khaled’s recent contributions focuses on detecting evasive answers in earnings calls and FOMC press conferences, based purely on the textual transcripts. A logical next step is to extend this analysis to the audio recordings themselves.&lt;/p&gt;

&lt;p&gt;Working directly from audio opens new questions that transcripts cannot capture:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Are there identifiable paralinguistic cues associated with evasive answers?&lt;/li&gt;
  &lt;li&gt;Do these cues vary depending on the type of evasive tactic employed?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hamdan’s residual embeddings provide exactly the kind of representation needed to explore these audio dimensions of evasiveness in a controlled and interpretable way.&lt;/p&gt;

&lt;p&gt;From a broader perspective, this line of work also hints at a longer-term, more speculative direction for our agent-based modelling (ABM) research. If we can reliably disentangle and quantify paralinguistic cues, it becomes conceivable—though certainly not immediate—to develop speech-enabled agents whose behaviour is influenced by vocal signals such as stress, confidence, or hesitation. While this is not a short-term objective, it illustrates how multimodal modelling could eventually lead to more realistic simulations of financial decision-making dynamics.&lt;/p&gt;

&lt;h4 id=&quot;the-medium-is-not-the-message-deconfounding-document-embeddings-via-linear-concept-erasure-fan-et-al&quot;&gt;The Medium Is Not the Message: Deconfounding Document Embeddings via Linear Concept Erasure (Fan et al.)&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://aclanthology.org/2025.emnlp-main.1634.pdf&quot;&gt;paper&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/emnlp-2025/medium_is_not_the_message.jpg&quot; alt=&quot;The Medium Is Not the Message: Deconfounding Document Embeddings via Linear Concept Erasure&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What the paper does:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Embedding-based similarity metrics between text sequences can be influenced not just by the content dimensions we most care about, but can also be biased by spurious attributes like the text’s source or language. These document confounders cause problems for many applications, but especially those that need to pool texts from different corpora.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To mitigate this, the authors introduce Linear Concept Erasure (LCE), a linear projection method that identifies the subspace corresponding to these confounders and removes it, while preserving the semantic core of the representation. Their main findings are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;cross-corpus clustering and retrieval improve after removing the confounder subspace;&lt;/li&gt;
  &lt;li&gt;downstream semantic tasks remain essentially unchanged, which is the expected outcome (semantics are preserved, and only nuisance variation is removed);&lt;/li&gt;
  &lt;li&gt;the method is simple and computationally light.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In practice, this is a form of representation surgery: identify the part of the embedding space capturing the unwanted factor, project it out, and keep the rest.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connections to our research:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This paper reinforces an intuition that also underpins Hamdan’s work on Residual Speech Embeddings: To clean the representation space by removing unwanted components.&lt;/p&gt;

&lt;p&gt;There is a clear structural similarity between the two approaches:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Residual speech embeddings remove the linear component of speech that can be predicted from text, isolating paralinguistic information;&lt;/li&gt;
  &lt;li&gt;LCE removes the linear component of text embeddings that corresponds to medium/domain/style, isolating semantic information.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In both cases, the idea is the same:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Identify a linear subspace corresponding to an unwanted factor, remove it, and work with the cleaned embedding.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We used the term residual embedding simply by analogy with “residual returns” in quantitative finance, where regression residuals are often used to remove unwanted exposures. LCE formalizes a closely related idea on the text side, but using discriminative subspace estimation rather than cross-modal regression.&lt;/p&gt;

&lt;p&gt;This opens several possibilities relevant to our research program:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;removing speaker identity or channel artifacts from audio embeddings;&lt;/li&gt;
  &lt;li&gt;removing demographic confounders in textual or multimodal representations (cf. &lt;a href=&quot;https://arxiv.org/pdf/2409.11491v1&quot;&gt;our name-based demographics study&lt;/a&gt;);&lt;/li&gt;
  &lt;li&gt;isolating emotional or deceptive cues in financial Q&amp;amp;A;&lt;/li&gt;
  &lt;li&gt;making embeddings cross-corpus comparable by suppressing stylistic and format-specific variation across sources like broker reports, earnings calls, and regulatory filings.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Overall, LCE provides an elegant confirmation that linear subspace removal, the core idea behind Hamdan’s residual embeddings, is a powerful and general approach for disentangling competing factors in representation spaces.&lt;/p&gt;

&lt;p&gt;Finally, This echoes an intuition I had years ago when doing &lt;a href=&quot;https://marti.ai/ml/2021/11/14/top2vec-10k-business.html&quot;&gt;topic modelling on business descriptions&lt;/a&gt;: the dominant axis of variation was almost always the industry sector, which is obvious but not very informative. Removing that first dimension (for example by residualizing to &lt;a href=&quot;https://marti.ai/quant/2021/08/13/gnn-sector-embedding.html&quot;&gt;sector embeddings&lt;/a&gt;) may be necessary to reveal more interesting structure.&lt;/p&gt;

&lt;h4 id=&quot;cafga-customizing-feature-attributions-to-explain-language-models-boyle-et-al&quot;&gt;CafGa: Customizing Feature Attributions to Explain Language Models (Boyle et al.)&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://aclanthology.org/2025.emnlp-demos.32.pdf&quot;&gt;paper&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/emnlp-2025/feature_attributions_for_llms.jpg&quot; alt=&quot;Feature Attributions for Large Language Models&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What the paper does:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;CaFGa proposes an attribution framework that lets users control the granularity of explanations for LLM decisions. Instead of relying on token-level heatmaps, typically noisy, unstable, and expensive, CaFGa groups text into interpretable segments (sentences, clauses, rhetorical units) and computes attributions at this coarser, more meaningful level.&lt;/p&gt;

&lt;p&gt;A key component is the use of perturbation–fidelity curves to assess whether the explanation is faithful to the model’s actual decision process. The idea is simple: remove or mask the high-attribution segments and measure how the prediction changes. Faithful explanations yield steep fidelity curves; unfaithful ones remain flat.&lt;/p&gt;

&lt;p&gt;The authors show that coarse-grained explanations tend to be more stable, more readable, and more faithful to model behavior than traditional word-level attributions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connections to our research:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Although Saeed’s credit-risk classifier operates on tabular features rather than text, CaFGa suggests a direct methodological analogue: Group features into semantic blocks (employment, income, liabilities, credit history) and compute block-level attributions. Perturbation–fidelity curves would then allow us to test whether the explanation aligns with the model’s true decision boundary. This complements our ongoing work on explanation alignment, where we repeatedly observe that LLM-generated natural-language explanations diverge from the model’s actual reasoning. CaFGa provides a principled way to quantify this divergence.&lt;/p&gt;

&lt;p&gt;The paper is also highly relevant to Khaled’s work on evasive answers in financial Q&amp;amp;A. CEO (and CFO/COO) responses in earnings calls naturally decompose into meaningful discourse segments: direct answers, hedges, topic shifts, credibility boosters, vague qualifiers, and so on. CaFGa’s segment-level attribution framework fits this structure almost perfectly. It would allow us to quantify which parts of an answer contribute most to the model’s evasiveness prediction, and whether those attributions are faithful. This could naturally lead to a follow-up study on &lt;em&gt;segment-level explanations for evasive answer detection&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Beyond academic value, such a tool would be practically useful for financial analysts during live Q&amp;amp;A sessions or one-to-one calls with management. Highlighting the segments most responsible for an “evasive” classification, together with an indication of &lt;em&gt;in which direction&lt;/em&gt; the answer is evasive (topic shift, hedging, excessive reassurance, lack of specificity), could help analysts decide when to push further, and on which aspect of the response to follow up.&lt;/p&gt;

&lt;h4 id=&quot;llms-dont-know-their-own-decision-boundaries-the-unreliability-of-self-generated-counterfactual-explanations-mayne-et-al&quot;&gt;LLMs Don’t Know Their Own Decision Boundaries: The Unreliability of Self-Generated Counterfactual Explanations (Mayne et al.)&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://aclanthology.org/2025.emnlp-main.1231.pdf&quot;&gt;paper&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/emnlp-2025/llms_dont_know_their_own_decision_boundaries.jpg&quot; alt=&quot;LLMs Don't Know Their Own Decision Boundaries&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What the paper does:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This paper investigates whether LLMs understand their own decision boundaries when used as classifiers. The authors evaluate a simple but revealing setup: small tabular datasets (2–4 features) are converted into natural-language profiles, and the LLM is asked to (i) make a prediction and then (ii) provide a self-generated counterfactual explanation (SCE): &lt;em&gt;“What is the smallest change to this profile that would flip your decision?”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Crucially, authors can enumerate the full input space, so they know exactly where the decision boundary lies.&lt;/p&gt;

&lt;p&gt;They evaluate two properties:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Validity: Does the counterfactual actually flip the model’s prediction?&lt;/li&gt;
  &lt;li&gt;Minimality: Is the suggested change close to the true decision boundary?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The core findings:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;When asked for any counterfactual, LLMs often produce valid but highly non-minimal edits (overshooting the boundary).&lt;/li&gt;
  &lt;li&gt;When asked for the smallest change, LLMs produce minimal-looking edits that frequently fail to flip the prediction.&lt;/li&gt;
  &lt;li&gt;No current model (including GPT-4.1, o3, Claude Sonnet 3.7) achieves both validity and minimality at the same time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In practice: LLMs generate counterfactuals that sound correct but fail to match the true decision boundary.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connections to our research:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This paper directly reinforces the findings from Saeed’s paper on credit-risk explanation alignment, where we show that LLM-generated explanations for credit decisions often diverge from the factors that actually drive the model’s classification. That work focused on feature-importance misalignment; this paper adds a complementary phenomenon: boundary-awareness misalignment.&lt;/p&gt;

&lt;p&gt;Together these papers paint a consistent picture:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;LLMs struggle to articulate why they made a decision (feature attributions).&lt;/li&gt;
  &lt;li&gt;LLMs also struggle to articulate how to change the decision (counterfactuals).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The methodology in this poster offers a clean way to test this in our credit-risk setting:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Use the same borrower profiles and prompt templates from Saeed’s work.&lt;/li&gt;
  &lt;li&gt;Ask the LLM to predict default vs. non-default.&lt;/li&gt;
  &lt;li&gt;Request a self-generated counterfactual: “What is the minimal change that would flip your decision?”&lt;/li&gt;
  &lt;li&gt;Parse the edited profile back to tabular form.&lt;/li&gt;
  &lt;li&gt;Re-query the model and measure validity + minimality.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Can we replicate this research in our setting?&lt;/p&gt;

&lt;p&gt;While a direct replication of their protocol in the credit domain is rather straightforward, the more interesting direction for us is constructive: Can we help LLMs generate counterfactuals that are both valid and minimal?&lt;/p&gt;

&lt;p&gt;This suggests a methodological extension: Adapting classical ML counterfactual engines (e.g., &lt;a href=&quot;https://interpret.ml/DiCE/&quot;&gt;DiCE&lt;/a&gt;) on LightGBM) to identify truly minimal edits… This could lead to a more ambitious follow-up paper: “Teaching (Credit) LLMs Their Own Decision Boundaries” where the goal is not only to expose the misalignment but to improve boundary-awareness using hybrid ML–LLM pipelines (tentatively).&lt;/p&gt;

&lt;h3 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;This quick wrap-up covers only a handful of the papers we came across, but they were among the most directly connected to the research lines pursued by the PhD students I’m co-supervising. Each of them sharpens or extends the work we’ve already been doing, whether on representations, audio–text multimodality, explainability, or financial Q&amp;amp;A behaviour.&lt;/p&gt;

&lt;p&gt;I’m writing this just a few hours before boarding my flight to NeurIPS (San Diego). With a bit of luck, I’ll come back with another batch of papers that are equally interesting and aligned with our research program.&lt;/p&gt;
</description>
        <pubDate>Sun, 30 Nov 2025 00:00:00 +0000</pubDate>
        <link>https://www.marti.ai/ml/2025/11/30/emnlp-2025-suzhou.html</link>
        <guid isPermaLink="true">https://www.marti.ai/ml/2025/11/30/emnlp-2025-suzhou.html</guid>
        
        
        <category>ML</category>
        
      </item>
    
      <item>
        <title>Serious, Sassy, or Sad? Teaching Machines to Read the Room (From Speech Embeddings)</title>
        <description>&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/tone-classification/workflow_audio_resid.png&quot; alt=&quot;Classification in Tones of Audio Speech&quot; /&gt;
&lt;/p&gt;

&lt;h1 id=&quot;serious-sassy-or-sad-teaching-machines-to-read-the-room-from-speech-embeddings&quot;&gt;Serious, Sassy, or Sad? Teaching Machines to Read the Room (From Speech Embeddings)&lt;/h1&gt;

&lt;p&gt;📌 &lt;em&gt;A politician says ‘We are fully in control of the situation’ — but their voice is trembling. Would you trust the words or the tone? Can AI detect when speech and vocal tone don’t match?&lt;/em&gt;&lt;/p&gt;

&lt;h2 id=&quot;table-of-contents&quot;&gt;Table of Contents&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#introduction&quot;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#the-experiment&quot;&gt;The experiment&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#our-key-question&quot;&gt;Research question&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#tl-dr-summary&quot;&gt;tl;dr&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#loading-the-embeddings&quot;&gt;Loading the Embeddings&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#understanding-the-embeddings&quot;&gt;Understanding the Embeddings&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#text-embeddings&quot;&gt;Text Embeddings&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#audio-embeddings&quot;&gt;Audio Embeddings&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#residual-embeddings&quot;&gt;Residual Embeddings&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#implications&quot;&gt;Implications&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#validating-the-findings-with-supervised-classification&quot;&gt;Validating the Findings with Supervised Classification&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#short-vs-long-sentences&quot;&gt;Short vs. Long Sentences&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#key-takeaways&quot;&gt;🔍 Key Takeaways&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#discrepancy-index--a-future-research-direction&quot;&gt;Discrepancy Index – A Future Research Direction&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;N.B.&lt;/strong&gt; This blog post serves as a pedagogical introduction to the core concepts and methodologies explored in Hamdan Al Ahbabi’s PhD research as part of his doctoral studies at Khalifa University, under my co-supervision. It is entirely non-work-related and should not be interpreted as such. Instead, its purpose is to support and complement future presentations at academic conferences.&lt;/p&gt;

&lt;h2 id=&quot;introduction-&quot;&gt;Introduction &lt;a id=&quot;introduction&quot;&gt;&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;In our previous blog post, &lt;a href=&quot;https://marti.ai/ml/2025/02/02/disentangling-speech-embeddings.html&quot;&gt;Disentangling Speech Embeddings&lt;/a&gt;, we introduced a simple yet effective method for removing linguistic content (&lt;em&gt;what is being said&lt;/em&gt;) from speech embeddings. Concretely, we trained a linear model to predict raw speech embeddings from the corresponding text embeddings and used the residuals (differences) as a proxy for non-linguistic vocal features.
We demonstrated that the resulting “residual” embeddings retained enough vocal cue information to cluster sentences by speaker identity rather than semantic content — suggesting that these embeddings preserve vocal tone and style independently of the words spoken.&lt;/p&gt;

&lt;p&gt;Now, we take this idea one step further. This time, we explore whether these residual embeddings can help classify how something is said—focusing on vocal tone and speaking style.&lt;/p&gt;

&lt;h2 id=&quot;the-experiment-&quot;&gt;The experiment &lt;a id=&quot;the-experiment&quot;&gt;&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;We use a single speaker (a female, US English voice - Natalie from &lt;a href=&quot;https://murf.ai/&quot;&gt;murf.ai&lt;/a&gt;) and have her deliver different sentences across a variety of &lt;strong&gt;tones and styles&lt;/strong&gt;. The sentences range from &lt;strong&gt;neutral business jargon&lt;/strong&gt; to &lt;strong&gt;casual, sentiment-laden&lt;/strong&gt; phrases (both positive and negative). The 12 distinct tones/styles tested include: Sorrowful, Inspirational, Terrified, Furious, Newscast Casual, Conversational, Angry, Sad, Meditative, Newscast Formal, Narration, and Promo.&lt;/p&gt;

&lt;h2 id=&quot;research-question-&quot;&gt;Research question &lt;a id=&quot;our-key-question&quot;&gt;&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;👉 Is it easier to classify speech into one of these 12 tones/styles using the original wav2vec2 audio embeddings, or does the “residual” version (where content has been removed) provide a cleaner signal for tone classification?&lt;/p&gt;

&lt;h2 id=&quot;tldr-&quot;&gt;tl;dr &lt;a id=&quot;tl-dr-summary&quot;&gt;&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;✅ Both linear and non-linear models perform better using the residual embeddings than the raw audio ones, where the actual spoken content appears to confuse the model.&lt;/p&gt;

&lt;p&gt;✅ Linear and non-linear classifiers perform similarly, suggesting that the relevant information (tone/style) is well-captured in a way that can be extracted with simple linear methods.&lt;/p&gt;

&lt;p&gt;✅ Shorter sentences provide fewer vocal cues, making tone classification harder. Residual embeddings help the most in these cases by removing content interference.&lt;/p&gt;

&lt;p&gt;✅ With longer sentences, tone information is naturally stronger, reducing the need for content filtering—though residual embeddings still offer a slight edge.&lt;/p&gt;

&lt;p&gt;✅ This supports the idea that removing linguistic content enhances models’ ability to focus on &lt;strong&gt;paralinguistic features&lt;/strong&gt; (tone, style, speaker characteristics).&lt;/p&gt;

&lt;h2 id=&quot;loading-the-embeddings-&quot;&gt;Loading the Embeddings &lt;a id=&quot;loading-the-embeddings&quot;&gt;&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;Let’s start by loading the data (sentences and embeddings).&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;os&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pandas&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;matplotlib.pyplot&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;seaborn&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sns&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sklearn.linear_model&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Ridge&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;LogisticRegression&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sklearn.ensemble&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;RandomForestClassifier&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sklearn.metrics&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;accuracy_score&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f1_score&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;roc_auc_score&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;confusion_matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sklearn.model_selection&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;train_test_split&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sklearn.decomposition&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;PCA&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sklearn.manifold&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TSNE&lt;/span&gt;


&lt;span class=&quot;n&quot;&gt;styles&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Sorrowful&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Inspirational&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Terrified&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Furious&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Newscast Casual&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Conversational&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Angry&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Sad&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Meditative&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Newscast Formal&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Narration&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Promo&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;


&lt;span class=&quot;n&quot;&gt;sentences&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;read_parquet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;earnings_calls_sentences.parquet&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;positive_sentences&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;read_parquet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;positive_sentences.parquet&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;negative_sentences&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;read_parquet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;negative_sentences.parquet&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nf&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sentences&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sample&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;positive_sentences&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sample&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;negative_sentences&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sample&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div&gt;
&lt;style scoped=&quot;&quot;&gt;
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
&lt;/style&gt;
&lt;table border=&quot;1&quot; class=&quot;dataframe&quot;&gt;
  &lt;thead&gt;
    &lt;tr style=&quot;text-align: right;&quot;&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;sentence&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;th&gt;5&lt;/th&gt;
      &lt;td&gt;For the next 100 years to come, we will contin...&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;36&lt;/th&gt;
      &lt;td&gt;It's not just that we recruit the best or that...&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;13&lt;/th&gt;
      &lt;td&gt;You see the overseas sales ratio of the in-hou...&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;46&lt;/th&gt;
      &lt;td&gt;Compared to the IOCs over the last five years,...&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;31&lt;/th&gt;
      &lt;td&gt;Not just profitable growth for ExxonMobil, but...&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;div&gt;
&lt;style scoped=&quot;&quot;&gt;
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
&lt;/style&gt;
&lt;table border=&quot;1&quot; class=&quot;dataframe&quot;&gt;
  &lt;thead&gt;
    &lt;tr style=&quot;text-align: right;&quot;&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;sentence&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;th&gt;25&lt;/th&gt;
      &lt;td&gt;The resilience and optimism you maintain in th...&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;3&lt;/th&gt;
      &lt;td&gt;That meal was incredibly delicious.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;10&lt;/th&gt;
      &lt;td&gt;Your kindness and generosity are truly inspiring.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;18&lt;/th&gt;
      &lt;td&gt;Everything is going so well—I feel incredibly ...&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;4&lt;/th&gt;
      &lt;td&gt;I'm so proud of you for achieving your goal!&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;div&gt;
&lt;style scoped=&quot;&quot;&gt;
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
&lt;/style&gt;
&lt;table border=&quot;1&quot; class=&quot;dataframe&quot;&gt;
  &lt;thead&gt;
    &lt;tr style=&quot;text-align: right;&quot;&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;sentence&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;th&gt;15&lt;/th&gt;
      &lt;td&gt;I couldn't be more frustrated with how things ...&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;8&lt;/th&gt;
      &lt;td&gt;You are the most unreliable person I've ever met.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;37&lt;/th&gt;
      &lt;td&gt;It is disheartening to see that despite having...&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;5&lt;/th&gt;
      &lt;td&gt;You always find a way to make things worse.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;1&lt;/th&gt;
      &lt;td&gt;I absolutely hate dealing with this kind of si...&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;read_parquet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;wav2vec2_audio_embeddings.parquet&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;df_text_emb&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;read_parquet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;dataframe_text_embeddings.parquet&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Convert DataFrames to NumPy arrays
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_text_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# shape: (n_samples, 1536)
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;   &lt;span class=&quot;c1&quot;&gt;# shape: (n_samples, 768)
&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Text embeddings shape:&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Audio embeddings shape:&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Text embeddings shape: (1584, 1536)
Audio embeddings shape: (1584, 768)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Train Ridge regression model
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;train_ridge_regression&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;model&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Ridge&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;fit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;train_ridge_regression&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Compute residual embeddings
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Y_pred&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;predict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;E&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Y_pred&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;df_residual_emb&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DataFrame&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;df_residual_emb&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div&gt;
&lt;style scoped=&quot;&quot;&gt;
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
&lt;/style&gt;
&lt;table border=&quot;1&quot; class=&quot;dataframe&quot;&gt;
  &lt;thead&gt;
    &lt;tr style=&quot;text-align: right;&quot;&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;0&lt;/th&gt;
      &lt;th&gt;1&lt;/th&gt;
      &lt;th&gt;2&lt;/th&gt;
      &lt;th&gt;3&lt;/th&gt;
      &lt;th&gt;4&lt;/th&gt;
      &lt;th&gt;5&lt;/th&gt;
      &lt;th&gt;6&lt;/th&gt;
      &lt;th&gt;7&lt;/th&gt;
      &lt;th&gt;8&lt;/th&gt;
      &lt;th&gt;9&lt;/th&gt;
      &lt;th&gt;...&lt;/th&gt;
      &lt;th&gt;758&lt;/th&gt;
      &lt;th&gt;759&lt;/th&gt;
      &lt;th&gt;760&lt;/th&gt;
      &lt;th&gt;761&lt;/th&gt;
      &lt;th&gt;762&lt;/th&gt;
      &lt;th&gt;763&lt;/th&gt;
      &lt;th&gt;764&lt;/th&gt;
      &lt;th&gt;765&lt;/th&gt;
      &lt;th&gt;766&lt;/th&gt;
      &lt;th&gt;767&lt;/th&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;sent_speaker&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;th&gt;embeddings_downloaded_audio_00_Angry.npy&lt;/th&gt;
      &lt;td&gt;0.000547&lt;/td&gt;
      &lt;td&gt;-0.005123&lt;/td&gt;
      &lt;td&gt;0.033253&lt;/td&gt;
      &lt;td&gt;-0.038299&lt;/td&gt;
      &lt;td&gt;0.013721&lt;/td&gt;
      &lt;td&gt;-0.038447&lt;/td&gt;
      &lt;td&gt;0.007130&lt;/td&gt;
      &lt;td&gt;0.023777&lt;/td&gt;
      &lt;td&gt;0.000756&lt;/td&gt;
      &lt;td&gt;-0.018350&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;-0.011541&lt;/td&gt;
      &lt;td&gt;-0.012827&lt;/td&gt;
      &lt;td&gt;0.026055&lt;/td&gt;
      &lt;td&gt;-0.032220&lt;/td&gt;
      &lt;td&gt;-0.038547&lt;/td&gt;
      &lt;td&gt;0.006204&lt;/td&gt;
      &lt;td&gt;-0.010762&lt;/td&gt;
      &lt;td&gt;0.002884&lt;/td&gt;
      &lt;td&gt;-0.038804&lt;/td&gt;
      &lt;td&gt;0.044158&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;embeddings_downloaded_audio_00_Conversational.npy&lt;/th&gt;
      &lt;td&gt;-0.012998&lt;/td&gt;
      &lt;td&gt;0.003234&lt;/td&gt;
      &lt;td&gt;0.010352&lt;/td&gt;
      &lt;td&gt;-0.004429&lt;/td&gt;
      &lt;td&gt;0.019514&lt;/td&gt;
      &lt;td&gt;-0.000994&lt;/td&gt;
      &lt;td&gt;0.014857&lt;/td&gt;
      &lt;td&gt;0.005752&lt;/td&gt;
      &lt;td&gt;-0.004121&lt;/td&gt;
      &lt;td&gt;-0.029278&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;-0.032924&lt;/td&gt;
      &lt;td&gt;0.002646&lt;/td&gt;
      &lt;td&gt;0.021952&lt;/td&gt;
      &lt;td&gt;0.001924&lt;/td&gt;
      &lt;td&gt;-0.037578&lt;/td&gt;
      &lt;td&gt;-0.013107&lt;/td&gt;
      &lt;td&gt;-0.020910&lt;/td&gt;
      &lt;td&gt;-0.005894&lt;/td&gt;
      &lt;td&gt;0.017660&lt;/td&gt;
      &lt;td&gt;-0.035358&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;embeddings_downloaded_audio_00_Furious.npy&lt;/th&gt;
      &lt;td&gt;-0.066253&lt;/td&gt;
      &lt;td&gt;0.015863&lt;/td&gt;
      &lt;td&gt;-0.018699&lt;/td&gt;
      &lt;td&gt;0.040799&lt;/td&gt;
      &lt;td&gt;-0.021040&lt;/td&gt;
      &lt;td&gt;0.018685&lt;/td&gt;
      &lt;td&gt;0.038205&lt;/td&gt;
      &lt;td&gt;-0.000754&lt;/td&gt;
      &lt;td&gt;0.012815&lt;/td&gt;
      &lt;td&gt;-0.008809&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;0.003965&lt;/td&gt;
      &lt;td&gt;0.008530&lt;/td&gt;
      &lt;td&gt;0.002404&lt;/td&gt;
      &lt;td&gt;-0.032704&lt;/td&gt;
      &lt;td&gt;0.055339&lt;/td&gt;
      &lt;td&gt;-0.023414&lt;/td&gt;
      &lt;td&gt;-0.019636&lt;/td&gt;
      &lt;td&gt;0.023885&lt;/td&gt;
      &lt;td&gt;-0.000745&lt;/td&gt;
      &lt;td&gt;-0.023359&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;embeddings_downloaded_audio_00_Inspirational.npy&lt;/th&gt;
      &lt;td&gt;-0.002424&lt;/td&gt;
      &lt;td&gt;-0.028308&lt;/td&gt;
      &lt;td&gt;0.000459&lt;/td&gt;
      &lt;td&gt;0.002153&lt;/td&gt;
      &lt;td&gt;-0.007286&lt;/td&gt;
      &lt;td&gt;0.022152&lt;/td&gt;
      &lt;td&gt;-0.025893&lt;/td&gt;
      &lt;td&gt;-0.025777&lt;/td&gt;
      &lt;td&gt;-0.058059&lt;/td&gt;
      &lt;td&gt;-0.007379&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;0.016637&lt;/td&gt;
      &lt;td&gt;-0.011735&lt;/td&gt;
      &lt;td&gt;0.017605&lt;/td&gt;
      &lt;td&gt;0.017890&lt;/td&gt;
      &lt;td&gt;0.033506&lt;/td&gt;
      &lt;td&gt;0.005326&lt;/td&gt;
      &lt;td&gt;-0.003464&lt;/td&gt;
      &lt;td&gt;-0.004350&lt;/td&gt;
      &lt;td&gt;-0.007208&lt;/td&gt;
      &lt;td&gt;0.026986&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;embeddings_downloaded_audio_00_Meditative.npy&lt;/th&gt;
      &lt;td&gt;0.001378&lt;/td&gt;
      &lt;td&gt;-0.011582&lt;/td&gt;
      &lt;td&gt;0.036844&lt;/td&gt;
      &lt;td&gt;-0.042164&lt;/td&gt;
      &lt;td&gt;-0.036087&lt;/td&gt;
      &lt;td&gt;0.010559&lt;/td&gt;
      &lt;td&gt;-0.005657&lt;/td&gt;
      &lt;td&gt;0.025860&lt;/td&gt;
      &lt;td&gt;-0.070218&lt;/td&gt;
      &lt;td&gt;0.003857&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;0.046636&lt;/td&gt;
      &lt;td&gt;0.004565&lt;/td&gt;
      &lt;td&gt;0.011343&lt;/td&gt;
      &lt;td&gt;-0.003232&lt;/td&gt;
      &lt;td&gt;-0.006497&lt;/td&gt;
      &lt;td&gt;-0.026536&lt;/td&gt;
      &lt;td&gt;0.002865&lt;/td&gt;
      &lt;td&gt;-0.012032&lt;/td&gt;
      &lt;td&gt;-0.005313&lt;/td&gt;
      &lt;td&gt;0.042849&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;...&lt;/th&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;embeddings_positive_text_downloaded_audio_39_Newscast Formal.npy&lt;/th&gt;
      &lt;td&gt;-0.010689&lt;/td&gt;
      &lt;td&gt;-0.001865&lt;/td&gt;
      &lt;td&gt;-0.040611&lt;/td&gt;
      &lt;td&gt;0.009453&lt;/td&gt;
      &lt;td&gt;0.047540&lt;/td&gt;
      &lt;td&gt;-0.027685&lt;/td&gt;
      &lt;td&gt;0.015540&lt;/td&gt;
      &lt;td&gt;0.012837&lt;/td&gt;
      &lt;td&gt;0.010790&lt;/td&gt;
      &lt;td&gt;0.011269&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;-0.015807&lt;/td&gt;
      &lt;td&gt;-0.010005&lt;/td&gt;
      &lt;td&gt;-0.005689&lt;/td&gt;
      &lt;td&gt;-0.000988&lt;/td&gt;
      &lt;td&gt;-0.033687&lt;/td&gt;
      &lt;td&gt;0.001929&lt;/td&gt;
      &lt;td&gt;0.008778&lt;/td&gt;
      &lt;td&gt;-0.015480&lt;/td&gt;
      &lt;td&gt;-0.008912&lt;/td&gt;
      &lt;td&gt;-0.012508&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;embeddings_positive_text_downloaded_audio_39_Promo.npy&lt;/th&gt;
      &lt;td&gt;-0.035135&lt;/td&gt;
      &lt;td&gt;0.026699&lt;/td&gt;
      &lt;td&gt;-0.025716&lt;/td&gt;
      &lt;td&gt;-0.008928&lt;/td&gt;
      &lt;td&gt;0.055495&lt;/td&gt;
      &lt;td&gt;0.066652&lt;/td&gt;
      &lt;td&gt;0.038595&lt;/td&gt;
      &lt;td&gt;-0.007269&lt;/td&gt;
      &lt;td&gt;-0.032083&lt;/td&gt;
      &lt;td&gt;-0.002548&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;0.044913&lt;/td&gt;
      &lt;td&gt;0.003458&lt;/td&gt;
      &lt;td&gt;0.005861&lt;/td&gt;
      &lt;td&gt;-0.050246&lt;/td&gt;
      &lt;td&gt;0.004993&lt;/td&gt;
      &lt;td&gt;0.000369&lt;/td&gt;
      &lt;td&gt;0.010904&lt;/td&gt;
      &lt;td&gt;-0.010641&lt;/td&gt;
      &lt;td&gt;-0.021717&lt;/td&gt;
      &lt;td&gt;-0.054168&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;embeddings_positive_text_downloaded_audio_39_Sad.npy&lt;/th&gt;
      &lt;td&gt;0.019876&lt;/td&gt;
      &lt;td&gt;0.014143&lt;/td&gt;
      &lt;td&gt;-0.087296&lt;/td&gt;
      &lt;td&gt;0.017254&lt;/td&gt;
      &lt;td&gt;0.075202&lt;/td&gt;
      &lt;td&gt;-0.049448&lt;/td&gt;
      &lt;td&gt;-0.006937&lt;/td&gt;
      &lt;td&gt;-0.039578&lt;/td&gt;
      &lt;td&gt;0.067603&lt;/td&gt;
      &lt;td&gt;-0.001711&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;-0.036482&lt;/td&gt;
      &lt;td&gt;-0.010577&lt;/td&gt;
      &lt;td&gt;-0.000425&lt;/td&gt;
      &lt;td&gt;0.051968&lt;/td&gt;
      &lt;td&gt;-0.067635&lt;/td&gt;
      &lt;td&gt;0.016389&lt;/td&gt;
      &lt;td&gt;-0.007544&lt;/td&gt;
      &lt;td&gt;-0.042562&lt;/td&gt;
      &lt;td&gt;0.022262&lt;/td&gt;
      &lt;td&gt;-0.001306&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;embeddings_positive_text_downloaded_audio_39_Sorrowful.npy&lt;/th&gt;
      &lt;td&gt;0.021177&lt;/td&gt;
      &lt;td&gt;-0.034878&lt;/td&gt;
      &lt;td&gt;-0.025202&lt;/td&gt;
      &lt;td&gt;0.025799&lt;/td&gt;
      &lt;td&gt;-0.004771&lt;/td&gt;
      &lt;td&gt;-0.026035&lt;/td&gt;
      &lt;td&gt;-0.018924&lt;/td&gt;
      &lt;td&gt;-0.022863&lt;/td&gt;
      &lt;td&gt;0.038629&lt;/td&gt;
      &lt;td&gt;-0.001309&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;-0.024871&lt;/td&gt;
      &lt;td&gt;0.010005&lt;/td&gt;
      &lt;td&gt;0.003231&lt;/td&gt;
      &lt;td&gt;0.040676&lt;/td&gt;
      &lt;td&gt;0.012732&lt;/td&gt;
      &lt;td&gt;-0.019660&lt;/td&gt;
      &lt;td&gt;0.016285&lt;/td&gt;
      &lt;td&gt;-0.011352&lt;/td&gt;
      &lt;td&gt;0.044231&lt;/td&gt;
      &lt;td&gt;0.067834&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;embeddings_positive_text_downloaded_audio_39_Terrified.npy&lt;/th&gt;
      &lt;td&gt;0.019007&lt;/td&gt;
      &lt;td&gt;-0.010457&lt;/td&gt;
      &lt;td&gt;0.005947&lt;/td&gt;
      &lt;td&gt;0.026304&lt;/td&gt;
      &lt;td&gt;-0.048532&lt;/td&gt;
      &lt;td&gt;0.004886&lt;/td&gt;
      &lt;td&gt;-0.005772&lt;/td&gt;
      &lt;td&gt;-0.014250&lt;/td&gt;
      &lt;td&gt;0.044395&lt;/td&gt;
      &lt;td&gt;0.002009&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;0.006794&lt;/td&gt;
      &lt;td&gt;0.008677&lt;/td&gt;
      &lt;td&gt;0.002136&lt;/td&gt;
      &lt;td&gt;0.020690&lt;/td&gt;
      &lt;td&gt;0.000381&lt;/td&gt;
      &lt;td&gt;-0.016183&lt;/td&gt;
      &lt;td&gt;0.008968&lt;/td&gt;
      &lt;td&gt;0.016245&lt;/td&gt;
      &lt;td&gt;0.035921&lt;/td&gt;
      &lt;td&gt;0.059694&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;1584 rows × 768 columns&lt;/p&gt;
&lt;/div&gt;

&lt;h2 id=&quot;understanding-the-embeddings-&quot;&gt;Understanding the Embeddings &lt;a id=&quot;understanding-the-embeddings&quot;&gt;&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;To begin, we visualize the embeddings by projecting them into a 2D space using standard dimensionality reduction techniques like PCA and t-SNE. This allows us to explore whether any clear structure emerges in these representations.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_text_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_residual_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Extract labels: assuming styles are encoded in filenames
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;labels&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Series&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;.npy&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
                    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;plot_pca_tsne&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;labels&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;title_prefix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;
    Apply PCA and t-SNE to reduce dimensions and visualize embeddings.
    &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;# Convert labels to categorical numeric values
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;label_values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label_mapping&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;factorize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;labels&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;# Apply PCA
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;pca&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;PCA&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n_components&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;X_pca&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pca&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;fit_transform&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;# Apply t-SNE
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;tsne&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;TSNE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n_components&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;perplexity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_state&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;X_tsne&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tsne&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;fit_transform&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;fig&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;axes&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;subplots&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;# PCA Plot
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;scatter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;axes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;scatter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;X_pca&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[:,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_pca&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[:,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label_values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cmap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;tab20&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;axes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;set_title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;title_prefix&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; - PCA Projection&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;axes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;set_xlabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;PC1&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;axes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;set_ylabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;PC2&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;# t-SNE Plot
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;scatter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;axes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;scatter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;X_tsne&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[:,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_tsne&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[:,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label_values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cmap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;tab20&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;axes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;set_title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;title_prefix&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; - t-SNE Projection&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;axes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;set_xlabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;t-SNE Dim 1&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;axes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;set_ylabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;t-SNE Dim 2&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;# Add legend for the unique labels
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;legend_labels&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;enumerate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label_mapping&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)}&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;handles&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;scatter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;legend_elements&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;labels_list&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;legend_labels&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;handles&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))]&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;axes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;legend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;handles&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;labels_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                   &lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;best&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fontsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;small&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Styles&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;


    
&lt;span class=&quot;c1&quot;&gt;# Run PCA &amp;amp; t-SNE for Text Embeddings
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;content_labels&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Series&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;business&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;52&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;negative&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;40&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;positive&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;40&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;plot_pca_tsne&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;content_labels&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Text Embeddings&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Run PCA &amp;amp; t-SNE for Audio Embeddings
&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;plot_pca_tsne&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;labels&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Audio Embeddings&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Run PCA &amp;amp; t-SNE for Residual Embeddings
&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;plot_pca_tsne&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;labels&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Residual Embeddings&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/tone-classification/output_9_0.png&quot; alt=&quot;Text Embeddings 2D Projections&quot; /&gt;
&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/tone-classification/output_9_1.png&quot; alt=&quot;Audio Embeddings 2D Projections&quot; /&gt;
&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/tone-classification/output_9_2.png&quot; alt=&quot;Residual Embeddings 2D Projections&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;These visualizations confirm that residual embeddings provide clearer clustering by tone, reinforcing their usefulness in capturing vocal style.&lt;/p&gt;

&lt;p&gt;In more details:&lt;/p&gt;

&lt;h3 id=&quot;text-embeddings-&quot;&gt;Text Embeddings &lt;a id=&quot;text-embeddings&quot;&gt;&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;The first row displays the text embeddings projected onto a two-dimensional space using PCA (left) and t-SNE (right). Since these embeddings represent only the textual content and not the way sentences are spoken, the different tone/style labels do not appear distinct in the PCA projection. Instead, we only observe clusters corresponding to:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Business-related sentences (52 samples)&lt;/li&gt;
  &lt;li&gt;Positive sentiment sentences (40 samples)&lt;/li&gt;
  &lt;li&gt;Negative sentiment sentences (40 samples)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This indicates that text embeddings primarily encode content (and sentiment).&lt;/p&gt;

&lt;h3 id=&quot;audio-embeddings-&quot;&gt;Audio Embeddings &lt;a id=&quot;audio-embeddings&quot;&gt;&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;For the raw audio embeddings, the PCA projection (center-left) does not exhibit clear structure. While a handful of outliers are present, the majority of the data points are densely packed without clear separation. This suggests that in their raw form, audio embeddings mix linguistic content and vocal tone/style, making them difficult to disentangle.&lt;/p&gt;

&lt;p&gt;However, when applying t-SNE (center-right), we start to observe some degree of clustering by tone/style. Notably:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The “Promo” (grey) and “Furious” (orange) styles form noticeable clusters.&lt;/li&gt;
  &lt;li&gt;Other styles remain partially mixed, indicating that raw audio embeddings do encode tone information but not in a way that is easily separable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These findings reinforce the idea that raw speech embeddings contain a blend of both linguistic and speaker-specific information, making it challenging to extract tone/style characteristics directly.&lt;/p&gt;

&lt;h3 id=&quot;residual-embeddings-&quot;&gt;Residual Embeddings &lt;a id=&quot;residual-embeddings&quot;&gt;&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;The residual embeddings, which remove linguistic content using the elementary method presented in &lt;a href=&quot;https://marti.ai/ml/2025/02/02/disentangling-speech-embeddings.html&quot;&gt;Disentangling Speech Embeddings&lt;/a&gt;, exhibit a much stronger clustering structure:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;PCA projection (bottom-left) shows better-defined clusters (e.g., blue, orange, brown, grey) compared to raw audio embeddings, although the separation is not perfect.&lt;/li&gt;
  &lt;li&gt;t-SNE projection (bottom-right) reveals a remarkably clear separation of the 12 tones/styles. Unlike raw audio embeddings, the residual embeddings distinctly group sentences by how they are spoken rather than what is being said.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This result strongly suggests that &lt;strong&gt;removing linguistic content leaves behind a representation that is highly predictive of tone and style&lt;/strong&gt;. In other words:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Text embeddings capture only the content of speech (&lt;em&gt;what is being said&lt;/em&gt;).&lt;/li&gt;
  &lt;li&gt;Residual embeddings predominantly encode vocal tone/style (&lt;em&gt;how it is being said&lt;/em&gt;).&lt;/li&gt;
  &lt;li&gt;Raw audio embeddings contain a mixture of both, making classification more difficult.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;implications-&quot;&gt;Implications &lt;a id=&quot;implications&quot;&gt;&lt;/a&gt;&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;If the goal is tone/style classification, residual embeddings should be used instead of raw audio embeddings.&lt;/li&gt;
  &lt;li&gt;Residual embeddings cluster strongly by style, meaning even simple models (e.g., logistic regression) should be able to classify tone effectively.&lt;/li&gt;
  &lt;li&gt;This experiment confirms that an elementary linear disentanglement technique successfully separates tone and linguistic content in speech embeddings.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;validating-the-findings-with-supervised-classification-&quot;&gt;Validating the Findings with Supervised Classification &lt;a id=&quot;validating-the-findings-with-supervised-classification&quot;&gt;&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;So far, our unsupervised analysis has shown that residual embeddings exhibit clearer clustering by tone/style compared to raw audio embeddings. But how well does this separation translate to practical classification performance?&lt;/p&gt;

&lt;p&gt;To test this, we move to a supervised classification approach:&lt;/p&gt;

&lt;p&gt;🔹 &lt;strong&gt;Objective:&lt;/strong&gt; Train a classifier to predict tone/style from speech embeddings and compare performance across different representations (audio vs. residual).&lt;/p&gt;

&lt;p&gt;🔹 &lt;strong&gt;Hypothesis:&lt;/strong&gt; If residual embeddings truly capture tone/style better than raw audio embeddings, a simple classifier should achieve higher accuracy on residuals than on raw audio embeddings.&lt;/p&gt;

&lt;p&gt;🔹 &lt;strong&gt;Experiment:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Train a logistic regression model and a random forest classifier on both raw audio and residual embeddings.&lt;/li&gt;
  &lt;li&gt;Compare accuracy, F1-score, and AUC-ROC across models and representations.&lt;/li&gt;
  &lt;li&gt;Evaluate whether removing linguistic content improves the model’s ability to focus on tone and style.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s dive into the code and results:&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Function to train, evaluate, and return results
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;model_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Trains a model, evaluates performance, and returns metrics.&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;X_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_test&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;train_test_split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;test_size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_state&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    
    &lt;span class=&quot;c1&quot;&gt;# Train model
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;fit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    
    &lt;span class=&quot;c1&quot;&gt;# Predict
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;y_pred&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;predict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;y_proba&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;predict_proba&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;hasattr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;predict_proba&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    
    &lt;span class=&quot;c1&quot;&gt;# Compute Metrics
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;acc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;accuracy_score&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_pred&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;f1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;f1_score&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_pred&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;average&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;weighted&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;roc_auc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;nf&quot;&gt;roc_auc_score&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_proba&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;multi_class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;ovr&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_proba&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;y_pred&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;predict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;conf_matrix&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;confusion_matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_pred&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Model&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;model_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Accuracy&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;F1 Score&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;AUC-ROC&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;roc_auc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Confusion Matrix&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;conf_matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;


&lt;span class=&quot;c1&quot;&gt;# Function to display confusion matrix
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;plot_confusion_matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;conf_matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Plots a confusion matrix with heatmap.&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;figure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;sns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;heatmap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;conf_matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;annot&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cmap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Blues&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;xlabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Predicted Label&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ylabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;True Label&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Prepare data for classification tasks
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;prepare_classification_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_residual_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_text_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;use_case&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;business&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;use_case&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;business&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;contains&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;positive&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;contains&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;negative&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;use_case&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;sentimental_text&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;contains&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;positive&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;contains&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;negative&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;use_case&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;short_text&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;mask&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;extract&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;_(\d+)_&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;astype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;between&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;19&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;mask&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;contains&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;positive&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
             &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;contains&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;negative&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;mask&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;tolist&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;use_case&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;long_text&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;mask&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;extract&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;_(\d+)_&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;astype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;between&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;39&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;mask&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;contains&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;positive&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
             &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;contains&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;negative&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;mask&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;tolist&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;       
    
    &lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;.npy&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
               &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    
    &lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_residual_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;y_resid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;.npy&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
               &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    
    &lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_text_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;y_text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt;
    
    &lt;span class=&quot;nf&quot;&gt;return &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;prepare_classification_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_residual_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_text_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;use_case&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;business&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;


&lt;span class=&quot;c1&quot;&gt;# Convert labels to numerical format
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unique_labels&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;sorted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;label_mapping&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;idx&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;idx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;enumerate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unique_labels&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label_mapping&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;y_resid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label_mapping&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;y_text&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label_mapping&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Convert DataFrames to numpy arrays
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_numpy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_numpy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_numpy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Define models
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;log_reg&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;LogisticRegression&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;max_iter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_state&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;random_forest&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;RandomForestClassifier&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n_estimators&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_state&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Evaluate models
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;log_reg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Logistic Regression (X_text)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;log_reg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Logistic Regression (X_audio)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;log_reg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Logistic Regression (X_resid)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_forest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Random Forest (X_text)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_forest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Random Forest (X_audio)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_forest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Random Forest (X_resid)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Convert results to DataFrame
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;results_df&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DataFrame&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;drop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;columns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Confusion Matrix&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;

&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Classification Results:&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;results_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Classification Results:
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div&gt;
&lt;style scoped=&quot;&quot;&gt;
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
&lt;/style&gt;
&lt;table border=&quot;1&quot; class=&quot;dataframe&quot;&gt;
  &lt;thead&gt;
    &lt;tr style=&quot;text-align: right;&quot;&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;Model&lt;/th&gt;
      &lt;th&gt;Accuracy&lt;/th&gt;
      &lt;th&gt;F1 Score&lt;/th&gt;
      &lt;th&gt;AUC-ROC&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;th&gt;0&lt;/th&gt;
      &lt;td&gt;Logistic Regression (X_text)&lt;/td&gt;
      &lt;td&gt;0.000&lt;/td&gt;
      &lt;td&gt;0.000000&lt;/td&gt;
      &lt;td&gt;0.096726&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;1&lt;/th&gt;
      &lt;td&gt;Logistic Regression (X_audio)&lt;/td&gt;
      &lt;td&gt;0.888&lt;/td&gt;
      &lt;td&gt;0.889941&lt;/td&gt;
      &lt;td&gt;0.990831&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;2&lt;/th&gt;
      &lt;td&gt;Logistic Regression (X_resid)&lt;/td&gt;
      &lt;td&gt;0.944&lt;/td&gt;
      &lt;td&gt;0.944745&lt;/td&gt;
      &lt;td&gt;0.997317&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;3&lt;/th&gt;
      &lt;td&gt;Random Forest (X_text)&lt;/td&gt;
      &lt;td&gt;0.000&lt;/td&gt;
      &lt;td&gt;0.000000&lt;/td&gt;
      &lt;td&gt;0.095351&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;4&lt;/th&gt;
      &lt;td&gt;Random Forest (X_audio)&lt;/td&gt;
      &lt;td&gt;0.800&lt;/td&gt;
      &lt;td&gt;0.797580&lt;/td&gt;
      &lt;td&gt;0.972571&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;5&lt;/th&gt;
      &lt;td&gt;Random Forest (X_resid)&lt;/td&gt;
      &lt;td&gt;0.920&lt;/td&gt;
      &lt;td&gt;0.919786&lt;/td&gt;
      &lt;td&gt;0.996321&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;As anticipated, text embeddings do not capture tone or style information, as they solely encode linguistic content. We included them in the experiment as a control to validate this assumption, and the results confirm that tone cannot be recovered from text embeddings alone. This is clearly reflected in the classification performance shown in the bar plot below:&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Plot classification results
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;figure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;set_index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Model&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;plot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kind&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;bar&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Classification Performance Comparison&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fontsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ylabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Score&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fontsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;xticks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rotation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;45&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fontsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;yticks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fontsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;legend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;lower right&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fontsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;grid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;linestyle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;linewidth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/tone-classification/output_16_1.png&quot; alt=&quot;Classification Performance Comparison between Models and Embeddings&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Remark:&lt;/strong&gt; Even with simple models like logistic regression, residual embeddings achieved over 94% accuracy. This suggests that tone information is not only well-preserved but also highly predictable once linguistic content is removed. In contrast, raw audio embeddings performed worse, likely because they mix content with tone.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;prepare_classification_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_residual_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_text_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;use_case&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;sentimental_text&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;


&lt;span class=&quot;c1&quot;&gt;# Convert labels to numerical format
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unique_labels&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;sorted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;label_mapping&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;idx&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;idx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;enumerate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unique_labels&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label_mapping&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;y_resid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label_mapping&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;y_text&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label_mapping&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Convert DataFrames to numpy arrays
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_numpy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_numpy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_numpy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Define models
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;log_reg&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;LogisticRegression&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;max_iter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_state&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;random_forest&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;RandomForestClassifier&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n_estimators&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_state&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Evaluate models
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;log_reg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Logistic Regression (X_text)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;log_reg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Logistic Regression (X_audio)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;log_reg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Logistic Regression (X_resid)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_forest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Random Forest (X_text)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_forest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Random Forest (X_audio)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_forest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Random Forest (X_resid)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;


&lt;span class=&quot;c1&quot;&gt;# Convert results to DataFrame
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;results_df&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DataFrame&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;drop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;columns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Confusion Matrix&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;

&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Classification Results:&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;results_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Classification Results:
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div&gt;
&lt;style scoped=&quot;&quot;&gt;
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
&lt;/style&gt;
&lt;table border=&quot;1&quot; class=&quot;dataframe&quot;&gt;
  &lt;thead&gt;
    &lt;tr style=&quot;text-align: right;&quot;&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;Model&lt;/th&gt;
      &lt;th&gt;Accuracy&lt;/th&gt;
      &lt;th&gt;F1 Score&lt;/th&gt;
      &lt;th&gt;AUC-ROC&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;th&gt;0&lt;/th&gt;
      &lt;td&gt;Logistic Regression (X_text)&lt;/td&gt;
      &lt;td&gt;0.000000&lt;/td&gt;
      &lt;td&gt;0.000000&lt;/td&gt;
      &lt;td&gt;0.120661&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;1&lt;/th&gt;
      &lt;td&gt;Logistic Regression (X_audio)&lt;/td&gt;
      &lt;td&gt;0.875000&lt;/td&gt;
      &lt;td&gt;0.873449&lt;/td&gt;
      &lt;td&gt;0.978296&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;2&lt;/th&gt;
      &lt;td&gt;Logistic Regression (X_resid)&lt;/td&gt;
      &lt;td&gt;0.880208&lt;/td&gt;
      &lt;td&gt;0.878072&lt;/td&gt;
      &lt;td&gt;0.986610&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;3&lt;/th&gt;
      &lt;td&gt;Random Forest (X_text)&lt;/td&gt;
      &lt;td&gt;0.000000&lt;/td&gt;
      &lt;td&gt;0.000000&lt;/td&gt;
      &lt;td&gt;0.097720&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;4&lt;/th&gt;
      &lt;td&gt;Random Forest (X_audio)&lt;/td&gt;
      &lt;td&gt;0.687500&lt;/td&gt;
      &lt;td&gt;0.682460&lt;/td&gt;
      &lt;td&gt;0.943511&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;5&lt;/th&gt;
      &lt;td&gt;Random Forest (X_resid)&lt;/td&gt;
      &lt;td&gt;0.848958&lt;/td&gt;
      &lt;td&gt;0.846386&lt;/td&gt;
      &lt;td&gt;0.975307&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;Logistic Regression performs surprisingly well on raw audio embeddings, likely because some tone information is already linearly separable, as suggested by the earlier 2D projections. However, Random Forests show a much stronger improvement with residual embeddings, benefiting from the removal of linguistic content. By eliminating this noise, residual embeddings provide a cleaner representation of paralinguistic features, making them more suitable for decision-tree-based learning.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Plot classification results
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;figure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;set_index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Model&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;plot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kind&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;bar&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Classification Performance Comparison&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fontsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ylabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Score&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fontsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;xticks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rotation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;45&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fontsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;yticks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fontsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;legend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;lower right&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fontsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;grid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;linestyle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;linewidth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/tone-classification/output_20_1.png&quot; alt=&quot;Classification Performance Comparison between Models and Embeddings&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Before expanding the dataset with longer sentences, we initially ran this experiment using only 20 short positive and 20 short negative sentences. In that setup, logistic regression on raw audio embeddings achieved 0.71 accuracy, while residual embeddings improved performance to 0.82. This suggests that for shorter sentences, where vocal cues are more limited or entangled with linguistic content, residual embeddings provide a clearer benefit. By stripping away the linguistic information, they make it easier for the model to focus on paralinguistic features, leading to a more pronounced lift in classification accuracy.&lt;/p&gt;

&lt;p&gt;This motivated us to examine whether longer, more expressive sentences improve classification performance overall and to assess whether the advantage of residual embeddings over raw audio embeddings diminishes as more vocal cues become available.&lt;/p&gt;

&lt;h2 id=&quot;short-vs-long-sentences-&quot;&gt;Short vs. Long Sentences &lt;a id=&quot;short-vs-long-sentences&quot;&gt;&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;To explore this, we compare model performance on short versus long sentences, starting with the short sentence case.&lt;/p&gt;

&lt;h3 id=&quot;the-short-sentences-case&quot;&gt;The short sentences case:&lt;/h3&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;prepare_classification_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_residual_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_text_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;use_case&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;short_text&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;


&lt;span class=&quot;c1&quot;&gt;# Convert labels to numerical format
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unique_labels&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;sorted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;label_mapping&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;idx&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;idx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;enumerate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unique_labels&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label_mapping&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;y_resid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label_mapping&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;y_text&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label_mapping&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Convert DataFrames to numpy arrays
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_numpy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_numpy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_numpy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Define models
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;log_reg&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;LogisticRegression&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;max_iter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_state&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;random_forest&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;RandomForestClassifier&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n_estimators&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_state&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Evaluate models
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;log_reg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Logistic Regression (X_text)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;log_reg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Logistic Regression (X_audio)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;log_reg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Logistic Regression (X_resid)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_forest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Random Forest (X_text)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_forest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Random Forest (X_audio)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_forest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Random Forest (X_resid)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;


&lt;span class=&quot;c1&quot;&gt;# Convert results to DataFrame
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;results_df&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DataFrame&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;drop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;columns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Confusion Matrix&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;

&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Classification Results:&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;results_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Plot classification results
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;figure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;set_index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Model&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;plot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kind&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;bar&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Classification Performance Comparison&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fontsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ylabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Score&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fontsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;xticks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rotation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;45&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fontsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;yticks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fontsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;legend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;lower right&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fontsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;grid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;linestyle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;linewidth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Classification Results:
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div&gt;
&lt;style scoped=&quot;&quot;&gt;
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
&lt;/style&gt;
&lt;table border=&quot;1&quot; class=&quot;dataframe&quot;&gt;
  &lt;thead&gt;
    &lt;tr style=&quot;text-align: right;&quot;&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;Model&lt;/th&gt;
      &lt;th&gt;Accuracy&lt;/th&gt;
      &lt;th&gt;F1 Score&lt;/th&gt;
      &lt;th&gt;AUC-ROC&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;th&gt;0&lt;/th&gt;
      &lt;td&gt;Logistic Regression (X_text)&lt;/td&gt;
      &lt;td&gt;0.000000&lt;/td&gt;
      &lt;td&gt;0.000000&lt;/td&gt;
      &lt;td&gt;0.121146&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;1&lt;/th&gt;
      &lt;td&gt;Logistic Regression (X_audio)&lt;/td&gt;
      &lt;td&gt;0.708333&lt;/td&gt;
      &lt;td&gt;0.700649&lt;/td&gt;
      &lt;td&gt;0.936023&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;2&lt;/th&gt;
      &lt;td&gt;Logistic Regression (X_resid)&lt;/td&gt;
      &lt;td&gt;0.822917&lt;/td&gt;
      &lt;td&gt;0.817159&lt;/td&gt;
      &lt;td&gt;0.978280&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;3&lt;/th&gt;
      &lt;td&gt;Random Forest (X_text)&lt;/td&gt;
      &lt;td&gt;0.000000&lt;/td&gt;
      &lt;td&gt;0.000000&lt;/td&gt;
      &lt;td&gt;0.093249&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;4&lt;/th&gt;
      &lt;td&gt;Random Forest (X_audio)&lt;/td&gt;
      &lt;td&gt;0.552083&lt;/td&gt;
      &lt;td&gt;0.533623&lt;/td&gt;
      &lt;td&gt;0.847435&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;5&lt;/th&gt;
      &lt;td&gt;Random Forest (X_resid)&lt;/td&gt;
      &lt;td&gt;0.697917&lt;/td&gt;
      &lt;td&gt;0.685180&lt;/td&gt;
      &lt;td&gt;0.947323&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/tone-classification/output_23_3.png&quot; alt=&quot;Classification Performance Comparison between Models and Embeddings&quot; /&gt;
&lt;/p&gt;

&lt;h3 id=&quot;the-long-sentences-case&quot;&gt;The long sentences case:&lt;/h3&gt;

&lt;p&gt;We now turn to longer sentences, where more vocal cues are naturally present.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;prepare_classification_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_residual_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_text_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;use_case&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;long_text&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;


&lt;span class=&quot;c1&quot;&gt;# Convert labels to numerical format
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unique_labels&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;sorted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;label_mapping&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;idx&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;idx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;enumerate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unique_labels&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label_mapping&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;y_resid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label_mapping&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;y_text&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label_mapping&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Convert DataFrames to numpy arrays
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_numpy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_numpy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_numpy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Define models
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;log_reg&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;LogisticRegression&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;max_iter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_state&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;random_forest&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;RandomForestClassifier&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n_estimators&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_state&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Evaluate models
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;log_reg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Logistic Regression (X_text)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;log_reg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Logistic Regression (X_audio)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;log_reg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Logistic Regression (X_resid)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_forest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Random Forest (X_text)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_forest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Random Forest (X_audio)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;evaluate_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_forest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Random Forest (X_resid)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;


&lt;span class=&quot;c1&quot;&gt;# Convert results to DataFrame
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;results_df&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DataFrame&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;drop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;columns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Confusion Matrix&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;

&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Classification Results:&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;results_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Plot classification results
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;figure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;results_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;set_index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Model&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;plot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kind&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;bar&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Classification Performance Comparison&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fontsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ylabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Score&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fontsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;xticks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rotation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;45&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fontsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;yticks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fontsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;legend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;lower right&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fontsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;grid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;linestyle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;linewidth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Classification Results:
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div&gt;
&lt;style scoped=&quot;&quot;&gt;
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
&lt;/style&gt;
&lt;table border=&quot;1&quot; class=&quot;dataframe&quot;&gt;
  &lt;thead&gt;
    &lt;tr style=&quot;text-align: right;&quot;&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;Model&lt;/th&gt;
      &lt;th&gt;Accuracy&lt;/th&gt;
      &lt;th&gt;F1 Score&lt;/th&gt;
      &lt;th&gt;AUC-ROC&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;th&gt;0&lt;/th&gt;
      &lt;td&gt;Logistic Regression (X_text)&lt;/td&gt;
      &lt;td&gt;0.000000&lt;/td&gt;
      &lt;td&gt;0.000000&lt;/td&gt;
      &lt;td&gt;0.110647&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;1&lt;/th&gt;
      &lt;td&gt;Logistic Regression (X_audio)&lt;/td&gt;
      &lt;td&gt;0.979167&lt;/td&gt;
      &lt;td&gt;0.979601&lt;/td&gt;
      &lt;td&gt;0.996384&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;2&lt;/th&gt;
      &lt;td&gt;Logistic Regression (X_resid)&lt;/td&gt;
      &lt;td&gt;0.989583&lt;/td&gt;
      &lt;td&gt;0.989279&lt;/td&gt;
      &lt;td&gt;0.999267&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;3&lt;/th&gt;
      &lt;td&gt;Random Forest (X_text)&lt;/td&gt;
      &lt;td&gt;0.000000&lt;/td&gt;
      &lt;td&gt;0.000000&lt;/td&gt;
      &lt;td&gt;0.097023&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;4&lt;/th&gt;
      &lt;td&gt;Random Forest (X_audio)&lt;/td&gt;
      &lt;td&gt;0.895833&lt;/td&gt;
      &lt;td&gt;0.904243&lt;/td&gt;
      &lt;td&gt;0.989440&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;5&lt;/th&gt;
      &lt;td&gt;Random Forest (X_resid)&lt;/td&gt;
      &lt;td&gt;0.989583&lt;/td&gt;
      &lt;td&gt;0.989279&lt;/td&gt;
      &lt;td&gt;0.999817&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/tone-classification/output_25_3.png&quot; alt=&quot;Classification Performance Comparison between Models and Embeddings&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;This last experiment highlights an important distinction:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Short sentences&lt;/strong&gt; provide fewer vocal cues, making it harder for models to distinguish tone from linguistic content. In raw audio embeddings, tone information is often entangled with what is being said, making classification more difficult. This is where &lt;strong&gt;residual embeddings provide a significant advantage&lt;/strong&gt;, as they strip away content-related noise and preserve only vocal tone and style.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Long sentences&lt;/strong&gt;, on the other hand, naturally contain &lt;strong&gt;more vocal evidence of tone&lt;/strong&gt;, making classification easier across all models—even when using raw audio embeddings. With longer utterances, the additional speech data allows tone to emerge more distinctly, reducing the need for content filtering. Consequently, while residual embeddings still perform best, the gap between raw and residual embeddings becomes less pronounced.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In summary, &lt;strong&gt;residual embeddings are most beneficial when tone cues are sparse or ambiguous&lt;/strong&gt;, such as in short speech segments. When ample vocal evidence is available (as in longer utterances), models can more easily capture tone directly from raw embeddings, making content removal less critical.&lt;/p&gt;

&lt;h2 id=&quot;-key-takeaways-&quot;&gt;🔍 Key Takeaways &lt;a id=&quot;key-takeaways&quot;&gt;&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;✅ &lt;strong&gt;Residual embeddings cluster clearly by tone&lt;/strong&gt;, unlike raw audio embeddings, making them a more effective representation of vocal style.&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Removing linguistic content enhances classification accuracy&lt;/strong&gt;, particularly in cases where tone is subtle or mixed with content.&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Even simple models perform well on residual embeddings&lt;/strong&gt;, proving that the extracted paralinguistic features are well-structured and easy to classify.&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Residual embeddings are especially beneficial for short sentences&lt;/strong&gt;, where tone cues are limited and harder to separate from content in raw audio embeddings.&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;With longer sentences, tone information becomes more pronounced in raw audio embeddings&lt;/strong&gt;, naturally improving classification performance across the board and reducing the gap between raw and residual embeddings.&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Residual embeddings provide the greatest advantage when tone evidence is sparse or ambiguous&lt;/strong&gt;, reinforcing their usefulness in analyzing brief speech segments or detecting subtle vocal cues.&lt;/p&gt;

&lt;h2 id=&quot;discrepancy-index--a-future-research-direction-&quot;&gt;Discrepancy Index – A Future Research Direction &lt;a id=&quot;discrepancy-index--a-future-research-direction&quot;&gt;&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;So far, we’ve demonstrated that residual embeddings are more effective at capturing tone and style, while text embeddings reflect semantic content. But what happens when textual sentiment and vocal tone don’t align?&lt;/p&gt;

&lt;p&gt;This opens up an exciting research question: Could we quantify such discrepancies to detect sarcasm, persuasion, or even deception?&lt;/p&gt;

&lt;h4 id=&quot;-the-idea&quot;&gt;💡 The idea:&lt;/h4&gt;

&lt;p&gt;We propose a Discrepancy Index, a metric to measure mismatches between text sentiment (&lt;em&gt;what is said&lt;/em&gt;) and vocal tone (&lt;em&gt;how it is said&lt;/em&gt;).&lt;/p&gt;

&lt;h4 id=&quot;-potential-applications&quot;&gt;🔹 Potential applications:&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;📢 &lt;strong&gt;Sarcasm detection&lt;/strong&gt; → Positive words, but an angry tone? That’s likely sarcasm.&lt;/li&gt;
  &lt;li&gt;🕵️‍♂️ &lt;strong&gt;Deception &amp;amp; hesitation analysis&lt;/strong&gt; → A positive tone but hesitant, uncertain speech? Possible deception or reluctance.&lt;/li&gt;
  &lt;li&gt;🎭 &lt;strong&gt;Politeness &amp;amp; persuasion&lt;/strong&gt; → Negative wording, but spoken warmly? Maybe softening bad news.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;-next-steps-for-exploration&quot;&gt;🔬 Next steps for exploration:&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;Train a model to classify &lt;strong&gt;text sentiment&lt;/strong&gt; (positive/negative).&lt;/li&gt;
  &lt;li&gt;Train another model to classify &lt;strong&gt;vocal tone&lt;/strong&gt; from residual embeddings.&lt;/li&gt;
  &lt;li&gt;Compute a Discrepancy Score: When sentiment and tone contradict, is it meaningful?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We hypothesize that by detecting mismatches between vocal tone and textual sentiment, we can build AI models that detect sarcasm, deception, and persuasion more effectively.&lt;/p&gt;

&lt;p&gt;For instance, in customer service, a polite “We’re happy to help” in a frustrated tone might signal dissatisfaction. In earnings calls, a neutral financial update with a hesitant tone might indicate hidden concerns.&lt;/p&gt;

&lt;p&gt;These findings reinforce that AI can learn not just &lt;em&gt;what&lt;/em&gt; we say, but &lt;em&gt;how&lt;/em&gt; we say it. By exploring the Discrepancy Index for sarcasm, persuasion, and deception, we take another step toward teaching machines to ‘read the room’.&lt;/p&gt;
</description>
        <pubDate>Sun, 16 Feb 2025 00:00:00 +0000</pubDate>
        <link>https://www.marti.ai/ml/2025/02/16/tone-classification-from-speech-embeddings.html</link>
        <guid isPermaLink="true">https://www.marti.ai/ml/2025/02/16/tone-classification-from-speech-embeddings.html</guid>
        
        
        <category>ML</category>
        
      </item>
    
      <item>
        <title>Disentangling Speech Embeddings: Removing Text Content from Audio Embeddings with Regression</title>
        <description>&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/disentangling-speech-embeddings/metaphor_audio_embeddings.jpg&quot; alt=&quot;Disentangling Speech Embeddings&quot; /&gt;
&lt;/p&gt;

&lt;h1 id=&quot;disentangling-speech-embeddings-removing-text-content-from-audio-embeddings-with-regression&quot;&gt;Disentangling Speech Embeddings: Removing Text Content from Audio Embeddings with Regression&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;tl;dr:&lt;/strong&gt; Speech embeddings encode both text content and audio-specific features (e.g., speaker identity, prosody). This blog explores how to disentangle these components by using Ridge regression to remove text content, leaving residual embeddings that focus on speaker-specific characteristics. We analyze these residual embeddings, and find that the residuals effectively isolate audio features.&lt;/p&gt;

&lt;h2 id=&quot;table-of-contents&quot;&gt;Table of Contents&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;#introduction&quot;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#data-preparation&quot;&gt;Data Preparation&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#loading-embeddings&quot;&gt;Loading Audio and Text Embeddings&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#experimental-setup&quot;&gt;Experimental Setup&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#dataframes&quot;&gt;Building DataFrames&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#residualizing&quot;&gt;Residualizing Audio Embeddings via Regression&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#regression-problem&quot;&gt;Setting Up the Regression Problem&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#fitting-model&quot;&gt;Fitting a Ridge Regression Model&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#computing-residuals&quot;&gt;Computing Residuals&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#similarity-analysis&quot;&gt;Analyzing Embedding Similarities&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#pairwise-cosine&quot;&gt;Pairwise Similarity with Cosine Similarity for Each Voice&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#same-voice-similarity&quot;&gt;Same-Voice Similarity: Audio vs. Residual&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#different-voice-similarity&quot;&gt;Different-Voice Similarity: Audio vs. Residual&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#avg-similarity&quot;&gt;Average Similarity Across Voices&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#discussion&quot;&gt;Discussion and Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;1-introduction-&quot;&gt;1. Introduction &lt;a name=&quot;introduction&quot;&gt;&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;Over the past few years, advances in deep learning—especially using transformer architectures and self-supervised learning—have revolutionized audio and speech processing. Modern models produce rich speech embeddings that encapsulate various aspects of the signal: background noise, speaker identity, prosody, and even the semantic content (i.e., what is being said).&lt;/p&gt;

&lt;p&gt;However, if you plan to use these embeddings for downstream tasks, an important question arises: &lt;strong&gt;What exactly is contained in these embeddings?&lt;/strong&gt; Are they dominated by the text content, or do they also capture pure audio characteristics? In this blog post, we walk through a notebook that tackles this question by “regressing out” the text content from the audio embeddings. We then analyze both the original and residual embeddings to see how the similarity patterns change, and whether we have isolated the speaker/audio-specific features.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;N.B.&lt;/strong&gt; This blog post serves as a pedagogical introduction to the core concepts and methodologies explored in Hamdan Al Ahbabi’s PhD research as part of his doctoral studies at Khalifa University, under my co-supervision. It is entirely non-work-related and should not be interpreted as such. Instead, its purpose is to support and complement future presentations at academic conferences.&lt;/p&gt;

&lt;h3 id=&quot;background-concepts&quot;&gt;Background Concepts&lt;/h3&gt;

&lt;p&gt;Before we dive into the analysis, let’s briefly define a few key concepts:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Embeddings:&lt;/strong&gt; High-dimensional numerical representations of text or audio data, capturing semantic or speaker-specific information.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Cosine Similarity:&lt;/strong&gt; A measure of similarity between two vectors, calculated as the cosine of the angle between them. It ranges from -1 (opposite) to 1 (identical).&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Ridge Regression:&lt;/strong&gt; A linear regression model with an L2 regularization term that prevents overfitting by penalizing large coefficients.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With these definitions in mind, let’s move on to the data preparation.&lt;/p&gt;

&lt;h2 id=&quot;2-data-preparation-&quot;&gt;2. Data Preparation &lt;a name=&quot;data-preparation&quot;&gt;&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;We first load and preprocess our data. In our case, we have:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Text embeddings&lt;/strong&gt; (shape 1536) stored in a Parquet file.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Audio embeddings&lt;/strong&gt; (shape 768) stored as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.npy&lt;/code&gt; files for each sentence and voice.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;21-loading-audio-and-text-embeddings-&quot;&gt;2.1 Loading Audio and Text Embeddings &lt;a name=&quot;loading-embeddings&quot;&gt;&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;We start by importing our libraries and reading in the embeddings.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pandas&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;matplotlib.pyplot&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sklearn.linear_model&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Ridge&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sklearn.metrics.pairwise&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cosine_similarity&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Define a list of voice labels used in the recordings.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;voices&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;alloy&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;ash&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;coral&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;fable&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;onyx&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;nova&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;sage&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;shimmer&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Load text embeddings and sentence metadata.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text_emb&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;read_parquet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;text_embeddings.parquet&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;sentences&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;read_parquet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;earnings_calls_sentences.parquet&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Process audio embeddings: compute a single (mean-pooled) vector per recording.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;audio_embeddings&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;idx&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sentences&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;voice&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;voices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;embedding&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;audio_embeddings/speech_&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;idx&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;/speech_&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;voice&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;.npy&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;# Mean pool over the time axis; adjust indexing as needed.
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;single_embedding&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;embedding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;mean&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;axis&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;tolist&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;audio_embeddings&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;idx&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;voice&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;single_embedding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;22-experimental-setup-&quot;&gt;2.2 Experimental Setup &lt;a name=&quot;experimental-setup&quot;&gt;&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Our experiments start with a dataset of 52 unique sentences, each spoken by 9 different voices (e.g., “alloy,” “ash,” “coral”). This results in a total of 468 audio recordings, with each sentence-voice pair represented by:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Text embeddings&lt;/strong&gt; (dimensionality: 1536) encoding the semantic content of the sentence.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Audio embeddings&lt;/strong&gt; (dimensionality: 768) capturing both speaker-specific characteristics and the spoken content.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This setup allows us to explore how embeddings encode information across voices and sentences and how residualizing affects these representations.&lt;/p&gt;

&lt;h3 id=&quot;23-building-dataframes-&quot;&gt;2.3 Building DataFrames &lt;a name=&quot;dataframes&quot;&gt;&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Next, we construct DataFrames for the audio embeddings. For each sentence (indexed by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;idx&lt;/code&gt;) and for each voice, we load the corresponding &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.npy&lt;/code&gt; file, compute the mean over time frames, and store the result. We then repeat the text embedding for each voice (since each sentence’s text is paired with multiple voices).&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Create a DataFrame with audio embeddings and set the index.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DataFrame&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;audio_embeddings&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;set_index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;sent_speaker&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Expand the text embeddings to match the number of audio samples.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;exp_text_emb&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;idx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;row&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;text_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;iterrows&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;voices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;exp_text_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;tolist&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;df_text_emb&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DataFrame&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;exp_text_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df_text_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div&gt;
&lt;style scoped=&quot;&quot;&gt;
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
&lt;/style&gt;
&lt;table border=&quot;1&quot; class=&quot;dataframe&quot;&gt;
  &lt;thead&gt;
    &lt;tr style=&quot;text-align: right;&quot;&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;1&lt;/th&gt;
      &lt;th&gt;2&lt;/th&gt;
      &lt;th&gt;3&lt;/th&gt;
      &lt;th&gt;4&lt;/th&gt;
      &lt;th&gt;5&lt;/th&gt;
      &lt;th&gt;6&lt;/th&gt;
      &lt;th&gt;7&lt;/th&gt;
      &lt;th&gt;8&lt;/th&gt;
      &lt;th&gt;9&lt;/th&gt;
      &lt;th&gt;10&lt;/th&gt;
      &lt;th&gt;...&lt;/th&gt;
      &lt;th&gt;759&lt;/th&gt;
      &lt;th&gt;760&lt;/th&gt;
      &lt;th&gt;761&lt;/th&gt;
      &lt;th&gt;762&lt;/th&gt;
      &lt;th&gt;763&lt;/th&gt;
      &lt;th&gt;764&lt;/th&gt;
      &lt;th&gt;765&lt;/th&gt;
      &lt;th&gt;766&lt;/th&gt;
      &lt;th&gt;767&lt;/th&gt;
      &lt;th&gt;768&lt;/th&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;sent_speaker&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;th&gt;0_alloy&lt;/th&gt;
      &lt;td&gt;-0.181595&lt;/td&gt;
      &lt;td&gt;0.044399&lt;/td&gt;
      &lt;td&gt;0.336770&lt;/td&gt;
      &lt;td&gt;0.053689&lt;/td&gt;
      &lt;td&gt;0.187663&lt;/td&gt;
      &lt;td&gt;-0.230498&lt;/td&gt;
      &lt;td&gt;0.022786&lt;/td&gt;
      &lt;td&gt;-0.104681&lt;/td&gt;
      &lt;td&gt;-0.193501&lt;/td&gt;
      &lt;td&gt;-0.176574&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;-0.056888&lt;/td&gt;
      &lt;td&gt;0.203571&lt;/td&gt;
      &lt;td&gt;0.096349&lt;/td&gt;
      &lt;td&gt;0.057072&lt;/td&gt;
      &lt;td&gt;-0.296644&lt;/td&gt;
      &lt;td&gt;-0.061813&lt;/td&gt;
      &lt;td&gt;-0.190370&lt;/td&gt;
      &lt;td&gt;0.177688&lt;/td&gt;
      &lt;td&gt;0.354035&lt;/td&gt;
      &lt;td&gt;-0.282887&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;0_ash&lt;/th&gt;
      &lt;td&gt;-0.136084&lt;/td&gt;
      &lt;td&gt;-0.002757&lt;/td&gt;
      &lt;td&gt;0.295544&lt;/td&gt;
      &lt;td&gt;0.086532&lt;/td&gt;
      &lt;td&gt;0.232084&lt;/td&gt;
      &lt;td&gt;-0.240367&lt;/td&gt;
      &lt;td&gt;0.033949&lt;/td&gt;
      &lt;td&gt;-0.110311&lt;/td&gt;
      &lt;td&gt;-0.150221&lt;/td&gt;
      &lt;td&gt;-0.166532&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;-0.029989&lt;/td&gt;
      &lt;td&gt;0.178773&lt;/td&gt;
      &lt;td&gt;0.108225&lt;/td&gt;
      &lt;td&gt;0.074687&lt;/td&gt;
      &lt;td&gt;-0.370774&lt;/td&gt;
      &lt;td&gt;-0.072837&lt;/td&gt;
      &lt;td&gt;-0.204104&lt;/td&gt;
      &lt;td&gt;0.226053&lt;/td&gt;
      &lt;td&gt;0.343412&lt;/td&gt;
      &lt;td&gt;-0.251210&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;0_coral&lt;/th&gt;
      &lt;td&gt;-0.158940&lt;/td&gt;
      &lt;td&gt;0.009858&lt;/td&gt;
      &lt;td&gt;0.358308&lt;/td&gt;
      &lt;td&gt;0.066840&lt;/td&gt;
      &lt;td&gt;0.209457&lt;/td&gt;
      &lt;td&gt;-0.220230&lt;/td&gt;
      &lt;td&gt;-0.010542&lt;/td&gt;
      &lt;td&gt;-0.112051&lt;/td&gt;
      &lt;td&gt;-0.242541&lt;/td&gt;
      &lt;td&gt;-0.176694&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;-0.013010&lt;/td&gt;
      &lt;td&gt;0.216197&lt;/td&gt;
      &lt;td&gt;0.078014&lt;/td&gt;
      &lt;td&gt;0.045757&lt;/td&gt;
      &lt;td&gt;-0.367586&lt;/td&gt;
      &lt;td&gt;-0.057285&lt;/td&gt;
      &lt;td&gt;-0.206471&lt;/td&gt;
      &lt;td&gt;0.237917&lt;/td&gt;
      &lt;td&gt;0.285875&lt;/td&gt;
      &lt;td&gt;-0.227131&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;0_echo&lt;/th&gt;
      &lt;td&gt;-0.147727&lt;/td&gt;
      &lt;td&gt;0.021007&lt;/td&gt;
      &lt;td&gt;0.367160&lt;/td&gt;
      &lt;td&gt;0.052192&lt;/td&gt;
      &lt;td&gt;0.219705&lt;/td&gt;
      &lt;td&gt;-0.233183&lt;/td&gt;
      &lt;td&gt;0.013074&lt;/td&gt;
      &lt;td&gt;-0.109856&lt;/td&gt;
      &lt;td&gt;-0.230388&lt;/td&gt;
      &lt;td&gt;-0.161419&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;-0.016526&lt;/td&gt;
      &lt;td&gt;0.195764&lt;/td&gt;
      &lt;td&gt;0.098858&lt;/td&gt;
      &lt;td&gt;0.127696&lt;/td&gt;
      &lt;td&gt;-0.308343&lt;/td&gt;
      &lt;td&gt;-0.074408&lt;/td&gt;
      &lt;td&gt;-0.170866&lt;/td&gt;
      &lt;td&gt;0.212565&lt;/td&gt;
      &lt;td&gt;0.339611&lt;/td&gt;
      &lt;td&gt;-0.250214&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;0_fable&lt;/th&gt;
      &lt;td&gt;-0.173835&lt;/td&gt;
      &lt;td&gt;0.020789&lt;/td&gt;
      &lt;td&gt;0.361774&lt;/td&gt;
      &lt;td&gt;0.049154&lt;/td&gt;
      &lt;td&gt;0.180092&lt;/td&gt;
      &lt;td&gt;-0.222793&lt;/td&gt;
      &lt;td&gt;-0.007481&lt;/td&gt;
      &lt;td&gt;-0.098986&lt;/td&gt;
      &lt;td&gt;-0.209910&lt;/td&gt;
      &lt;td&gt;-0.172046&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;-0.087433&lt;/td&gt;
      &lt;td&gt;0.161901&lt;/td&gt;
      &lt;td&gt;0.106060&lt;/td&gt;
      &lt;td&gt;0.113969&lt;/td&gt;
      &lt;td&gt;-0.340039&lt;/td&gt;
      &lt;td&gt;-0.061142&lt;/td&gt;
      &lt;td&gt;-0.185088&lt;/td&gt;
      &lt;td&gt;0.235554&lt;/td&gt;
      &lt;td&gt;0.332321&lt;/td&gt;
      &lt;td&gt;-0.299397&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;5 rows × 768 columns&lt;/p&gt;
&lt;/div&gt;

&lt;div&gt;
&lt;style scoped=&quot;&quot;&gt;
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
&lt;/style&gt;
&lt;table border=&quot;1&quot; class=&quot;dataframe&quot;&gt;
  &lt;thead&gt;
    &lt;tr style=&quot;text-align: right;&quot;&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;0&lt;/th&gt;
      &lt;th&gt;1&lt;/th&gt;
      &lt;th&gt;2&lt;/th&gt;
      &lt;th&gt;3&lt;/th&gt;
      &lt;th&gt;4&lt;/th&gt;
      &lt;th&gt;5&lt;/th&gt;
      &lt;th&gt;6&lt;/th&gt;
      &lt;th&gt;7&lt;/th&gt;
      &lt;th&gt;8&lt;/th&gt;
      &lt;th&gt;9&lt;/th&gt;
      &lt;th&gt;...&lt;/th&gt;
      &lt;th&gt;1526&lt;/th&gt;
      &lt;th&gt;1527&lt;/th&gt;
      &lt;th&gt;1528&lt;/th&gt;
      &lt;th&gt;1529&lt;/th&gt;
      &lt;th&gt;1530&lt;/th&gt;
      &lt;th&gt;1531&lt;/th&gt;
      &lt;th&gt;1532&lt;/th&gt;
      &lt;th&gt;1533&lt;/th&gt;
      &lt;th&gt;1534&lt;/th&gt;
      &lt;th&gt;1535&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;th&gt;0&lt;/th&gt;
      &lt;td&gt;-0.017998&lt;/td&gt;
      &lt;td&gt;-0.02158&lt;/td&gt;
      &lt;td&gt;-0.007001&lt;/td&gt;
      &lt;td&gt;-0.015076&lt;/td&gt;
      &lt;td&gt;0.008172&lt;/td&gt;
      &lt;td&gt;-0.005641&lt;/td&gt;
      &lt;td&gt;-0.010977&lt;/td&gt;
      &lt;td&gt;-0.005072&lt;/td&gt;
      &lt;td&gt;-0.01783&lt;/td&gt;
      &lt;td&gt;-0.018438&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;0.004975&lt;/td&gt;
      &lt;td&gt;-0.005728&lt;/td&gt;
      &lt;td&gt;0.050969&lt;/td&gt;
      &lt;td&gt;0.001896&lt;/td&gt;
      &lt;td&gt;0.001191&lt;/td&gt;
      &lt;td&gt;-0.01849&lt;/td&gt;
      &lt;td&gt;-0.005182&lt;/td&gt;
      &lt;td&gt;-0.005217&lt;/td&gt;
      &lt;td&gt;-0.001707&lt;/td&gt;
      &lt;td&gt;-0.011934&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;1&lt;/th&gt;
      &lt;td&gt;-0.017998&lt;/td&gt;
      &lt;td&gt;-0.02158&lt;/td&gt;
      &lt;td&gt;-0.007001&lt;/td&gt;
      &lt;td&gt;-0.015076&lt;/td&gt;
      &lt;td&gt;0.008172&lt;/td&gt;
      &lt;td&gt;-0.005641&lt;/td&gt;
      &lt;td&gt;-0.010977&lt;/td&gt;
      &lt;td&gt;-0.005072&lt;/td&gt;
      &lt;td&gt;-0.01783&lt;/td&gt;
      &lt;td&gt;-0.018438&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;0.004975&lt;/td&gt;
      &lt;td&gt;-0.005728&lt;/td&gt;
      &lt;td&gt;0.050969&lt;/td&gt;
      &lt;td&gt;0.001896&lt;/td&gt;
      &lt;td&gt;0.001191&lt;/td&gt;
      &lt;td&gt;-0.01849&lt;/td&gt;
      &lt;td&gt;-0.005182&lt;/td&gt;
      &lt;td&gt;-0.005217&lt;/td&gt;
      &lt;td&gt;-0.001707&lt;/td&gt;
      &lt;td&gt;-0.011934&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;2&lt;/th&gt;
      &lt;td&gt;-0.017998&lt;/td&gt;
      &lt;td&gt;-0.02158&lt;/td&gt;
      &lt;td&gt;-0.007001&lt;/td&gt;
      &lt;td&gt;-0.015076&lt;/td&gt;
      &lt;td&gt;0.008172&lt;/td&gt;
      &lt;td&gt;-0.005641&lt;/td&gt;
      &lt;td&gt;-0.010977&lt;/td&gt;
      &lt;td&gt;-0.005072&lt;/td&gt;
      &lt;td&gt;-0.01783&lt;/td&gt;
      &lt;td&gt;-0.018438&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;0.004975&lt;/td&gt;
      &lt;td&gt;-0.005728&lt;/td&gt;
      &lt;td&gt;0.050969&lt;/td&gt;
      &lt;td&gt;0.001896&lt;/td&gt;
      &lt;td&gt;0.001191&lt;/td&gt;
      &lt;td&gt;-0.01849&lt;/td&gt;
      &lt;td&gt;-0.005182&lt;/td&gt;
      &lt;td&gt;-0.005217&lt;/td&gt;
      &lt;td&gt;-0.001707&lt;/td&gt;
      &lt;td&gt;-0.011934&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;3&lt;/th&gt;
      &lt;td&gt;-0.017998&lt;/td&gt;
      &lt;td&gt;-0.02158&lt;/td&gt;
      &lt;td&gt;-0.007001&lt;/td&gt;
      &lt;td&gt;-0.015076&lt;/td&gt;
      &lt;td&gt;0.008172&lt;/td&gt;
      &lt;td&gt;-0.005641&lt;/td&gt;
      &lt;td&gt;-0.010977&lt;/td&gt;
      &lt;td&gt;-0.005072&lt;/td&gt;
      &lt;td&gt;-0.01783&lt;/td&gt;
      &lt;td&gt;-0.018438&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;0.004975&lt;/td&gt;
      &lt;td&gt;-0.005728&lt;/td&gt;
      &lt;td&gt;0.050969&lt;/td&gt;
      &lt;td&gt;0.001896&lt;/td&gt;
      &lt;td&gt;0.001191&lt;/td&gt;
      &lt;td&gt;-0.01849&lt;/td&gt;
      &lt;td&gt;-0.005182&lt;/td&gt;
      &lt;td&gt;-0.005217&lt;/td&gt;
      &lt;td&gt;-0.001707&lt;/td&gt;
      &lt;td&gt;-0.011934&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;4&lt;/th&gt;
      &lt;td&gt;-0.017998&lt;/td&gt;
      &lt;td&gt;-0.02158&lt;/td&gt;
      &lt;td&gt;-0.007001&lt;/td&gt;
      &lt;td&gt;-0.015076&lt;/td&gt;
      &lt;td&gt;0.008172&lt;/td&gt;
      &lt;td&gt;-0.005641&lt;/td&gt;
      &lt;td&gt;-0.010977&lt;/td&gt;
      &lt;td&gt;-0.005072&lt;/td&gt;
      &lt;td&gt;-0.01783&lt;/td&gt;
      &lt;td&gt;-0.018438&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;0.004975&lt;/td&gt;
      &lt;td&gt;-0.005728&lt;/td&gt;
      &lt;td&gt;0.050969&lt;/td&gt;
      &lt;td&gt;0.001896&lt;/td&gt;
      &lt;td&gt;0.001191&lt;/td&gt;
      &lt;td&gt;-0.01849&lt;/td&gt;
      &lt;td&gt;-0.005182&lt;/td&gt;
      &lt;td&gt;-0.005217&lt;/td&gt;
      &lt;td&gt;-0.001707&lt;/td&gt;
      &lt;td&gt;-0.011934&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;5 rows × 1536 columns&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;Now we have two DataFrames:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;df_text_emb&lt;/code&gt; of shape (n_samples, 1536), and&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;df_audio_emb&lt;/code&gt; of shape (n_samples, 768), where &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;n_samples&lt;/code&gt; equals the number of sentences multiplied by the number of voices.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;3-residualizing-audio-embeddings-via-regression-&quot;&gt;3. Residualizing Audio Embeddings via Regression &lt;a name=&quot;residualizing&quot;&gt;&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;The key idea is to remove the text content from the audio embeddings. We assume that each audio embedding $ \mathbf{y} $ can be approximated as a linear function of the text embedding $ \mathbf{x} $:&lt;/p&gt;

\[\mathbf{y} = W \mathbf{x} + \mathbf{e}\]

&lt;p&gt;where $W$ is the weight matrix and $ \mathbf{e} $ is the residual representing audio-specific information. We use Ridge regression to learn $W$.&lt;/p&gt;

&lt;h3 id=&quot;31-setting-up-the-regression-problem-&quot;&gt;3.1 Setting Up the Regression Problem &lt;a name=&quot;regression-problem&quot;&gt;&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;We convert our DataFrames into NumPy arrays and check their shapes.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Convert DataFrames to NumPy arrays.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_text_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# shape: (n_samples, 1536)
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;   &lt;span class=&quot;c1&quot;&gt;# shape: (n_samples, 768)
&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Text embeddings shape:&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Audio embeddings shape:&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Text embeddings shape: (468, 1536)
Audio embeddings shape: (468, 768)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;32-fitting-a-ridge-regression-model-&quot;&gt;3.2 Fitting a Ridge Regression Model &lt;a name=&quot;fitting-model&quot;&gt;&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;We now fit a Ridge regression model (with a chosen regularization strength) that maps text embeddings to audio embeddings.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Use the entire dataset for training for simplicity.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Y_train&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Y&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;X_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Y_test&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Y&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Fit the Ridge regression model.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1.0&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# Regularization strength; you may adjust this.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Ridge&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;fit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Y_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;style&gt;#sk-container-id-2 {
  /* Definition of color scheme common for light and dark mode */
  --sklearn-color-text: #000;
  --sklearn-color-text-muted: #666;
  --sklearn-color-line: gray;
  /* Definition of color scheme for unfitted estimators */
  --sklearn-color-unfitted-level-0: #fff5e6;
  --sklearn-color-unfitted-level-1: #f6e4d2;
  --sklearn-color-unfitted-level-2: #ffe0b3;
  --sklearn-color-unfitted-level-3: chocolate;
  /* Definition of color scheme for fitted estimators */
  --sklearn-color-fitted-level-0: #f0f8ff;
  --sklearn-color-fitted-level-1: #d4ebff;
  --sklearn-color-fitted-level-2: #b3dbfd;
  --sklearn-color-fitted-level-3: cornflowerblue;

  /* Specific color for light theme */
  --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));
  --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, white)));
  --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));
  --sklearn-color-icon: #696969;

  @media (prefers-color-scheme: dark) {
    /* Redefinition of color scheme for dark theme */
    --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));
    --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, #111)));
    --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));
    --sklearn-color-icon: #878787;
  }
}

#sk-container-id-2 {
  color: var(--sklearn-color-text);
}

#sk-container-id-2 pre {
  padding: 0;
}

#sk-container-id-2 input.sk-hidden--visually {
  border: 0;
  clip: rect(1px 1px 1px 1px);
  clip: rect(1px, 1px, 1px, 1px);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}

#sk-container-id-2 div.sk-dashed-wrapped {
  border: 1px dashed var(--sklearn-color-line);
  margin: 0 0.4em 0.5em 0.4em;
  box-sizing: border-box;
  padding-bottom: 0.4em;
  background-color: var(--sklearn-color-background);
}

#sk-container-id-2 div.sk-container {
  /* jupyter's `normalize.less` sets `[hidden] { display: none; }`
     but bootstrap.min.css set `[hidden] { display: none !important; }`
     so we also need the `!important` here to be able to override the
     default hidden behavior on the sphinx rendered scikit-learn.org.
     See: https://github.com/scikit-learn/scikit-learn/issues/21755 */
  display: inline-block !important;
  position: relative;
}

#sk-container-id-2 div.sk-text-repr-fallback {
  display: none;
}

div.sk-parallel-item,
div.sk-serial,
div.sk-item {
  /* draw centered vertical line to link estimators */
  background-image: linear-gradient(var(--sklearn-color-text-on-default-background), var(--sklearn-color-text-on-default-background));
  background-size: 2px 100%;
  background-repeat: no-repeat;
  background-position: center center;
}

/* Parallel-specific style estimator block */

#sk-container-id-2 div.sk-parallel-item::after {
  content: &quot;&quot;;
  width: 100%;
  border-bottom: 2px solid var(--sklearn-color-text-on-default-background);
  flex-grow: 1;
}

#sk-container-id-2 div.sk-parallel {
  display: flex;
  align-items: stretch;
  justify-content: center;
  background-color: var(--sklearn-color-background);
  position: relative;
}

#sk-container-id-2 div.sk-parallel-item {
  display: flex;
  flex-direction: column;
}

#sk-container-id-2 div.sk-parallel-item:first-child::after {
  align-self: flex-end;
  width: 50%;
}

#sk-container-id-2 div.sk-parallel-item:last-child::after {
  align-self: flex-start;
  width: 50%;
}

#sk-container-id-2 div.sk-parallel-item:only-child::after {
  width: 0;
}

/* Serial-specific style estimator block */

#sk-container-id-2 div.sk-serial {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: var(--sklearn-color-background);
  padding-right: 1em;
  padding-left: 1em;
}


/* Toggleable style: style used for estimator/Pipeline/ColumnTransformer box that is
clickable and can be expanded/collapsed.
- Pipeline and ColumnTransformer use this feature and define the default style
- Estimators will overwrite some part of the style using the `sk-estimator` class
*/

/* Pipeline and ColumnTransformer style (default) */

#sk-container-id-2 div.sk-toggleable {
  /* Default theme specific background. It is overwritten whether we have a
  specific estimator or a Pipeline/ColumnTransformer */
  background-color: var(--sklearn-color-background);
}

/* Toggleable label */
#sk-container-id-2 label.sk-toggleable__label {
  cursor: pointer;
  display: flex;
  width: 100%;
  margin-bottom: 0;
  padding: 0.5em;
  box-sizing: border-box;
  text-align: center;
  align-items: start;
  justify-content: space-between;
  gap: 0.5em;
}

#sk-container-id-2 label.sk-toggleable__label .caption {
  font-size: 0.6rem;
  font-weight: lighter;
  color: var(--sklearn-color-text-muted);
}

#sk-container-id-2 label.sk-toggleable__label-arrow:before {
  /* Arrow on the left of the label */
  content: &quot;▸&quot;;
  float: left;
  margin-right: 0.25em;
  color: var(--sklearn-color-icon);
}

#sk-container-id-2 label.sk-toggleable__label-arrow:hover:before {
  color: var(--sklearn-color-text);
}

/* Toggleable content - dropdown */

#sk-container-id-2 div.sk-toggleable__content {
  max-height: 0;
  max-width: 0;
  overflow: hidden;
  text-align: left;
  /* unfitted */
  background-color: var(--sklearn-color-unfitted-level-0);
}

#sk-container-id-2 div.sk-toggleable__content.fitted {
  /* fitted */
  background-color: var(--sklearn-color-fitted-level-0);
}

#sk-container-id-2 div.sk-toggleable__content pre {
  margin: 0.2em;
  border-radius: 0.25em;
  color: var(--sklearn-color-text);
  /* unfitted */
  background-color: var(--sklearn-color-unfitted-level-0);
}

#sk-container-id-2 div.sk-toggleable__content.fitted pre {
  /* unfitted */
  background-color: var(--sklearn-color-fitted-level-0);
}

#sk-container-id-2 input.sk-toggleable__control:checked~div.sk-toggleable__content {
  /* Expand drop-down */
  max-height: 200px;
  max-width: 100%;
  overflow: auto;
}

#sk-container-id-2 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {
  content: &quot;▾&quot;;
}

/* Pipeline/ColumnTransformer-specific style */

#sk-container-id-2 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {
  color: var(--sklearn-color-text);
  background-color: var(--sklearn-color-unfitted-level-2);
}

#sk-container-id-2 div.sk-label.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {
  background-color: var(--sklearn-color-fitted-level-2);
}

/* Estimator-specific style */

/* Colorize estimator box */
#sk-container-id-2 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {
  /* unfitted */
  background-color: var(--sklearn-color-unfitted-level-2);
}

#sk-container-id-2 div.sk-estimator.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {
  /* fitted */
  background-color: var(--sklearn-color-fitted-level-2);
}

#sk-container-id-2 div.sk-label label.sk-toggleable__label,
#sk-container-id-2 div.sk-label label {
  /* The background is the default theme color */
  color: var(--sklearn-color-text-on-default-background);
}

/* On hover, darken the color of the background */
#sk-container-id-2 div.sk-label:hover label.sk-toggleable__label {
  color: var(--sklearn-color-text);
  background-color: var(--sklearn-color-unfitted-level-2);
}

/* Label box, darken color on hover, fitted */
#sk-container-id-2 div.sk-label.fitted:hover label.sk-toggleable__label.fitted {
  color: var(--sklearn-color-text);
  background-color: var(--sklearn-color-fitted-level-2);
}

/* Estimator label */

#sk-container-id-2 div.sk-label label {
  font-family: monospace;
  font-weight: bold;
  display: inline-block;
  line-height: 1.2em;
}

#sk-container-id-2 div.sk-label-container {
  text-align: center;
}

/* Estimator-specific */
#sk-container-id-2 div.sk-estimator {
  font-family: monospace;
  border: 1px dotted var(--sklearn-color-border-box);
  border-radius: 0.25em;
  box-sizing: border-box;
  margin-bottom: 0.5em;
  /* unfitted */
  background-color: var(--sklearn-color-unfitted-level-0);
}

#sk-container-id-2 div.sk-estimator.fitted {
  /* fitted */
  background-color: var(--sklearn-color-fitted-level-0);
}

/* on hover */
#sk-container-id-2 div.sk-estimator:hover {
  /* unfitted */
  background-color: var(--sklearn-color-unfitted-level-2);
}

#sk-container-id-2 div.sk-estimator.fitted:hover {
  /* fitted */
  background-color: var(--sklearn-color-fitted-level-2);
}

/* Specification for estimator info (e.g. &quot;i&quot; and &quot;?&quot;) */

/* Common style for &quot;i&quot; and &quot;?&quot; */

.sk-estimator-doc-link,
a:link.sk-estimator-doc-link,
a:visited.sk-estimator-doc-link {
  float: right;
  font-size: smaller;
  line-height: 1em;
  font-family: monospace;
  background-color: var(--sklearn-color-background);
  border-radius: 1em;
  height: 1em;
  width: 1em;
  text-decoration: none !important;
  margin-left: 0.5em;
  text-align: center;
  /* unfitted */
  border: var(--sklearn-color-unfitted-level-1) 1pt solid;
  color: var(--sklearn-color-unfitted-level-1);
}

.sk-estimator-doc-link.fitted,
a:link.sk-estimator-doc-link.fitted,
a:visited.sk-estimator-doc-link.fitted {
  /* fitted */
  border: var(--sklearn-color-fitted-level-1) 1pt solid;
  color: var(--sklearn-color-fitted-level-1);
}

/* On hover */
div.sk-estimator:hover .sk-estimator-doc-link:hover,
.sk-estimator-doc-link:hover,
div.sk-label-container:hover .sk-estimator-doc-link:hover,
.sk-estimator-doc-link:hover {
  /* unfitted */
  background-color: var(--sklearn-color-unfitted-level-3);
  color: var(--sklearn-color-background);
  text-decoration: none;
}

div.sk-estimator.fitted:hover .sk-estimator-doc-link.fitted:hover,
.sk-estimator-doc-link.fitted:hover,
div.sk-label-container:hover .sk-estimator-doc-link.fitted:hover,
.sk-estimator-doc-link.fitted:hover {
  /* fitted */
  background-color: var(--sklearn-color-fitted-level-3);
  color: var(--sklearn-color-background);
  text-decoration: none;
}

/* Span, style for the box shown on hovering the info icon */
.sk-estimator-doc-link span {
  display: none;
  z-index: 9999;
  position: relative;
  font-weight: normal;
  right: .2ex;
  padding: .5ex;
  margin: .5ex;
  width: min-content;
  min-width: 20ex;
  max-width: 50ex;
  color: var(--sklearn-color-text);
  box-shadow: 2pt 2pt 4pt #999;
  /* unfitted */
  background: var(--sklearn-color-unfitted-level-0);
  border: .5pt solid var(--sklearn-color-unfitted-level-3);
}

.sk-estimator-doc-link.fitted span {
  /* fitted */
  background: var(--sklearn-color-fitted-level-0);
  border: var(--sklearn-color-fitted-level-3);
}

.sk-estimator-doc-link:hover span {
  display: block;
}

/* &quot;?&quot;-specific style due to the `&lt;a&gt;` HTML tag */

#sk-container-id-2 a.estimator_doc_link {
  float: right;
  font-size: 1rem;
  line-height: 1em;
  font-family: monospace;
  background-color: var(--sklearn-color-background);
  border-radius: 1rem;
  height: 1rem;
  width: 1rem;
  text-decoration: none;
  /* unfitted */
  color: var(--sklearn-color-unfitted-level-1);
  border: var(--sklearn-color-unfitted-level-1) 1pt solid;
}

#sk-container-id-2 a.estimator_doc_link.fitted {
  /* fitted */
  border: var(--sklearn-color-fitted-level-1) 1pt solid;
  color: var(--sklearn-color-fitted-level-1);
}

/* On hover */
#sk-container-id-2 a.estimator_doc_link:hover {
  /* unfitted */
  background-color: var(--sklearn-color-unfitted-level-3);
  color: var(--sklearn-color-background);
  text-decoration: none;
}

#sk-container-id-2 a.estimator_doc_link.fitted:hover {
  /* fitted */
  background-color: var(--sklearn-color-fitted-level-3);
}
&lt;/style&gt;
&lt;div id=&quot;sk-container-id-2&quot; class=&quot;sk-top-container&quot;&gt;&lt;div class=&quot;sk-text-repr-fallback&quot;&gt;&lt;pre&gt;Ridge()&lt;/pre&gt;&lt;b&gt;In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. &lt;br /&gt;On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;sk-container&quot; hidden=&quot;&quot;&gt;&lt;div class=&quot;sk-item&quot;&gt;&lt;div class=&quot;sk-estimator fitted sk-toggleable&quot;&gt;&lt;input class=&quot;sk-toggleable__control sk-hidden--visually&quot; id=&quot;sk-estimator-id-2&quot; type=&quot;checkbox&quot; checked=&quot;&quot; /&gt;&lt;label for=&quot;sk-estimator-id-2&quot; class=&quot;sk-toggleable__label fitted sk-toggleable__label-arrow&quot;&gt;&lt;div&gt;&lt;div&gt;Ridge&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;a class=&quot;sk-estimator-doc-link fitted&quot; rel=&quot;noreferrer&quot; target=&quot;_blank&quot; href=&quot;https://scikit-learn.org/1.6/modules/generated/sklearn.linear_model.Ridge.html&quot;&gt;?&lt;span&gt;Documentation for Ridge&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;sk-estimator-doc-link fitted&quot;&gt;i&lt;span&gt;Fitted&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/label&gt;&lt;div class=&quot;sk-toggleable__content fitted&quot;&gt;&lt;pre&gt;Ridge()&lt;/pre&gt;&lt;/div&gt; &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;33-computing-residuals-&quot;&gt;3.3 Computing Residuals &lt;a name=&quot;computing-residuals&quot;&gt;&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;After fitting the model, we compute the predicted audio embeddings and then the residuals:&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Predict audio embeddings from text embeddings.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Y_pred&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;predict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Compute the residual: actual audio embedding minus predicted embedding.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;E&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Y_pred&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Shape of the residual embeddings:&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Optional: evaluate the model performance.
&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sklearn.metrics&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mean_squared_error&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;mse&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;mean_squared_error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Y_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;predict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Test MSE:&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Create a DataFrame for the residual embeddings.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;residual_emb&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DataFrame&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;residual_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Shape of the residual embeddings: (468, 768)
Test MSE: 0.0011371899030286064
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div&gt;
&lt;style scoped=&quot;&quot;&gt;
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
&lt;/style&gt;
&lt;table border=&quot;1&quot; class=&quot;dataframe&quot;&gt;
  &lt;thead&gt;
    &lt;tr style=&quot;text-align: right;&quot;&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;0&lt;/th&gt;
      &lt;th&gt;1&lt;/th&gt;
      &lt;th&gt;2&lt;/th&gt;
      &lt;th&gt;3&lt;/th&gt;
      &lt;th&gt;4&lt;/th&gt;
      &lt;th&gt;5&lt;/th&gt;
      &lt;th&gt;6&lt;/th&gt;
      &lt;th&gt;7&lt;/th&gt;
      &lt;th&gt;8&lt;/th&gt;
      &lt;th&gt;9&lt;/th&gt;
      &lt;th&gt;...&lt;/th&gt;
      &lt;th&gt;758&lt;/th&gt;
      &lt;th&gt;759&lt;/th&gt;
      &lt;th&gt;760&lt;/th&gt;
      &lt;th&gt;761&lt;/th&gt;
      &lt;th&gt;762&lt;/th&gt;
      &lt;th&gt;763&lt;/th&gt;
      &lt;th&gt;764&lt;/th&gt;
      &lt;th&gt;765&lt;/th&gt;
      &lt;th&gt;766&lt;/th&gt;
      &lt;th&gt;767&lt;/th&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;sent_speaker&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;th&gt;0_alloy&lt;/th&gt;
      &lt;td&gt;-0.052219&lt;/td&gt;
      &lt;td&gt;0.008099&lt;/td&gt;
      &lt;td&gt;0.030596&lt;/td&gt;
      &lt;td&gt;-0.024522&lt;/td&gt;
      &lt;td&gt;-0.031399&lt;/td&gt;
      &lt;td&gt;-0.003683&lt;/td&gt;
      &lt;td&gt;0.003598&lt;/td&gt;
      &lt;td&gt;0.029022&lt;/td&gt;
      &lt;td&gt;0.005255&lt;/td&gt;
      &lt;td&gt;-0.011372&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;-0.027316&lt;/td&gt;
      &lt;td&gt;0.008942&lt;/td&gt;
      &lt;td&gt;0.010294&lt;/td&gt;
      &lt;td&gt;-0.032126&lt;/td&gt;
      &lt;td&gt;0.044079&lt;/td&gt;
      &lt;td&gt;-0.000491&lt;/td&gt;
      &lt;td&gt;-0.006691&lt;/td&gt;
      &lt;td&gt;-0.039610&lt;/td&gt;
      &lt;td&gt;0.013437&lt;/td&gt;
      &lt;td&gt;-0.027009&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;0_ash&lt;/th&gt;
      &lt;td&gt;-0.006709&lt;/td&gt;
      &lt;td&gt;-0.039057&lt;/td&gt;
      &lt;td&gt;-0.010630&lt;/td&gt;
      &lt;td&gt;0.008322&lt;/td&gt;
      &lt;td&gt;0.013022&lt;/td&gt;
      &lt;td&gt;-0.013552&lt;/td&gt;
      &lt;td&gt;0.014761&lt;/td&gt;
      &lt;td&gt;0.023392&lt;/td&gt;
      &lt;td&gt;0.048536&lt;/td&gt;
      &lt;td&gt;-0.001330&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;-0.000417&lt;/td&gt;
      &lt;td&gt;-0.015856&lt;/td&gt;
      &lt;td&gt;0.022170&lt;/td&gt;
      &lt;td&gt;-0.014510&lt;/td&gt;
      &lt;td&gt;-0.030051&lt;/td&gt;
      &lt;td&gt;-0.011516&lt;/td&gt;
      &lt;td&gt;-0.020425&lt;/td&gt;
      &lt;td&gt;0.008755&lt;/td&gt;
      &lt;td&gt;0.002814&lt;/td&gt;
      &lt;td&gt;0.004668&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;0_coral&lt;/th&gt;
      &lt;td&gt;-0.029564&lt;/td&gt;
      &lt;td&gt;-0.026442&lt;/td&gt;
      &lt;td&gt;0.052134&lt;/td&gt;
      &lt;td&gt;-0.011371&lt;/td&gt;
      &lt;td&gt;-0.009605&lt;/td&gt;
      &lt;td&gt;0.006586&lt;/td&gt;
      &lt;td&gt;-0.029729&lt;/td&gt;
      &lt;td&gt;0.021652&lt;/td&gt;
      &lt;td&gt;-0.043785&lt;/td&gt;
      &lt;td&gt;-0.011492&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;0.016562&lt;/td&gt;
      &lt;td&gt;0.021568&lt;/td&gt;
      &lt;td&gt;-0.008041&lt;/td&gt;
      &lt;td&gt;-0.043440&lt;/td&gt;
      &lt;td&gt;-0.026863&lt;/td&gt;
      &lt;td&gt;0.004037&lt;/td&gt;
      &lt;td&gt;-0.022792&lt;/td&gt;
      &lt;td&gt;0.020619&lt;/td&gt;
      &lt;td&gt;-0.054723&lt;/td&gt;
      &lt;td&gt;0.028747&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;0_echo&lt;/th&gt;
      &lt;td&gt;-0.018352&lt;/td&gt;
      &lt;td&gt;-0.015293&lt;/td&gt;
      &lt;td&gt;0.060987&lt;/td&gt;
      &lt;td&gt;-0.026018&lt;/td&gt;
      &lt;td&gt;0.000643&lt;/td&gt;
      &lt;td&gt;-0.006368&lt;/td&gt;
      &lt;td&gt;-0.006114&lt;/td&gt;
      &lt;td&gt;0.023847&lt;/td&gt;
      &lt;td&gt;-0.031632&lt;/td&gt;
      &lt;td&gt;0.003783&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;0.013046&lt;/td&gt;
      &lt;td&gt;0.001135&lt;/td&gt;
      &lt;td&gt;0.012803&lt;/td&gt;
      &lt;td&gt;0.038499&lt;/td&gt;
      &lt;td&gt;0.032380&lt;/td&gt;
      &lt;td&gt;-0.013086&lt;/td&gt;
      &lt;td&gt;0.012812&lt;/td&gt;
      &lt;td&gt;-0.004733&lt;/td&gt;
      &lt;td&gt;-0.000987&lt;/td&gt;
      &lt;td&gt;0.005664&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;0_fable&lt;/th&gt;
      &lt;td&gt;-0.044460&lt;/td&gt;
      &lt;td&gt;-0.015510&lt;/td&gt;
      &lt;td&gt;0.055601&lt;/td&gt;
      &lt;td&gt;-0.029056&lt;/td&gt;
      &lt;td&gt;-0.038970&lt;/td&gt;
      &lt;td&gt;0.004022&lt;/td&gt;
      &lt;td&gt;-0.026668&lt;/td&gt;
      &lt;td&gt;0.034717&lt;/td&gt;
      &lt;td&gt;-0.011154&lt;/td&gt;
      &lt;td&gt;-0.006844&lt;/td&gt;
      &lt;td&gt;...&lt;/td&gt;
      &lt;td&gt;-0.057861&lt;/td&gt;
      &lt;td&gt;-0.032728&lt;/td&gt;
      &lt;td&gt;0.020005&lt;/td&gt;
      &lt;td&gt;0.024772&lt;/td&gt;
      &lt;td&gt;0.000684&lt;/td&gt;
      &lt;td&gt;0.000180&lt;/td&gt;
      &lt;td&gt;-0.001409&lt;/td&gt;
      &lt;td&gt;0.018257&lt;/td&gt;
      &lt;td&gt;-0.008277&lt;/td&gt;
      &lt;td&gt;-0.043519&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;5 rows × 768 columns&lt;/p&gt;
&lt;/div&gt;

&lt;h2 id=&quot;4-analyzing-embedding-similarities-&quot;&gt;4. Analyzing Embedding Similarities &lt;a name=&quot;similarity-analysis&quot;&gt;&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;To understand the impact of residualizing audio embeddings, we analyze how similarity patterns change before and after regressing out the text content. Specifically, we compute pairwise similarity matrices for both the original audio embeddings and the residual embeddings. We then compare these similarity matrices by examining their coefficient distributions, visualizing their structures, and summarizing them using average similarity scores across voices. This allows us to assess whether the residual embeddings effectively isolate speaker-specific features.&lt;/p&gt;

&lt;h3 id=&quot;41-pairwise-similarity-with-cosine-similarity-for-each-voice-&quot;&gt;4.1 Pairwise Similarity with Cosine Similarity for Each Voice &lt;a name=&quot;pairwise-cosine&quot;&gt;&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;We first compute pairwise cosine similarity among the residual embeddings and visualize the distribution of similarity values for each voice using histograms.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Compute cosine similarity on the residual embeddings.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sim&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;cosine_similarity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;residual_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;df_sim&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DataFrame&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sim&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;residual_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;columns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;residual_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Plot histograms of the upper-triangle similarity values for each voice.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;figure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1.0&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# starting alpha for histogram transparency
&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;voice&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;voices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;# Select sample indices that contain the current voice.
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;sample&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_sim&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;voice&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;mat&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_sim&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sample&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sample&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    
    &lt;span class=&quot;c1&quot;&gt;# Mask lower-triangle and diagonal values.
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;mask&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;triu&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ones&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dtype&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;upper_tri_values&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;where&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mask&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nan&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;flatten&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    
    &lt;span class=&quot;c1&quot;&gt;# Filter out NaN values.
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;upper_tri_values&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;upper_tri_values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;isnan&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;upper_tri_values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;
    
    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;hist&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;upper_tri_values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bins&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;voice&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.10&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;legend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Histogram of Residual Embedding Similarities by Voice&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;xlabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Cosine Similarity&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ylabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Frequency&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/disentangling-speech-embeddings/output_15_0.png&quot; alt=&quot;Disentangling Speech Embeddings&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;The histogram above displays the cosine similarity distributions of residual embeddings for each voice after regressing out the text content. Each colored distribution represents a specific voice (e.g., “alloy,” “ash,” “coral”), with the x-axis showing the cosine similarity values and the y-axis indicating the frequency of these values.&lt;/p&gt;

&lt;p&gt;Key Observations:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Distinct Voice Distributions:&lt;/strong&gt; The residual embeddings show noticeable differences in cosine similarity distributions for each voice, highlighting that voice-specific characteristics are preserved after text content is removed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cosine Similarity Range:&lt;/strong&gt; Unlike the original audio embeddings, where cosine similarity values are tightly clustered due to shared text content, the residual embeddings exhibit a wider range of similarity values (from negative values to moderately high positives, up to ~0.8). This indicates reduced influence from shared text content.&lt;/p&gt;

&lt;p&gt;To further illustrate the impact of residualization, we compare the similarity patterns of residual embeddings with those of the original audio embeddings. The next histogram visualizes the cosine similarity distributions of the original audio embeddings for each voice, offering a baseline to evaluate how much the shared text content influences these embeddings.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Compute cosine similarity on the audio embeddings.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sim&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;cosine_similarity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;df_sim&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DataFrame&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sim&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;columns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Plot histograms of the upper-triangle similarity values for each voice.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;figure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1.0&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# starting alpha for histogram transparency
&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;voice&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;voices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;# Select sample indices that contain the current voice.
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;sample&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_sim&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;voice&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;mat&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_sim&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sample&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sample&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    
    &lt;span class=&quot;c1&quot;&gt;# Mask lower-triangle and diagonal values.
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;mask&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;triu&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ones&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dtype&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;upper_tri_values&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;where&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mask&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nan&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;flatten&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    
    &lt;span class=&quot;c1&quot;&gt;# Filter out NaN values.
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;upper_tri_values&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;upper_tri_values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;isnan&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;upper_tri_values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;
    
    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;hist&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;upper_tri_values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bins&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;voice&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.10&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;legend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Histogram of Audio Embedding Similarities by Voice&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;xlabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Cosine Similarity&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ylabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Frequency&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/disentangling-speech-embeddings/output_18_0.png&quot; alt=&quot;Disentangling Speech Embeddings&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;The histogram above displays the cosine similarity distributions for the original audio embeddings across different voices. Each colored distribution represents a specific voice (e.g., “alloy,” “ash,” “coral”), with the x-axis showing cosine similarity values and the y-axis indicating their frequency.&lt;/p&gt;

&lt;p&gt;Key Observations:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Overlapping Voice Distributions:&lt;/strong&gt; The similarity distributions for different voices overlap significantly, demonstrating that shared text content dominates the original audio embeddings.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;High Similarity Concentration:&lt;/strong&gt; The cosine similarity values for the original audio embeddings are tightly clustered in a high range, predominantly between 0.88 and 0.99, highlighting the strong influence of the text content.&lt;/p&gt;

&lt;p&gt;Unlike the residual embeddings, the original audio embeddings exhibit a narrow spread of similarity values, indicating that speaker-specific features are less prominent in the original embeddings.&lt;/p&gt;

&lt;h3 id=&quot;42-same-voice-similarity-audio-vs-residual-&quot;&gt;4.2 Same-Voice Similarity: Audio vs. Residual &lt;a name=&quot;same-voice-similarity&quot;&gt;&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;In this section, we compare the cosine similarity patterns for recordings of the same voice (e.g., “alloy” vs. “alloy”) using both the original audio embeddings and the residual embeddings. The pairwise similarity matrices and histograms illustrate distinct differences between the two representations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Original Audio Embeddings (Same Voice)&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Compute similarity for the same voice on audio embeddings.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;voice_1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;alloy&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;voice_2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;alloy&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# Same voice comparison.
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;sample_1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;voice_1&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;sample_2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;voice_2&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;pairwise_sim_same_audio&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;cosine_similarity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sample_1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sample_2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;figure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;pcolormesh&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pairwise_sim_same_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cmap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;viridis&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Pairwise Similarity: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;alloy&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; vs. &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;alloy&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; (Audio Embeddings)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;colorbar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;figure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;hist&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pairwise_sim_same_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;flatten&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bins&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Histogram: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;alloy&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; vs. &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;alloy&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; (Audio Embeddings)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;xlabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Cosine Similarity&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ylabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Frequency&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Series&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pairwise_sim_same_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;flatten&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/disentangling-speech-embeddings/output_21_0.png&quot; alt=&quot;Disentangling Speech Embeddings&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;The similarity matrix for the original audio embeddings shows consistently high values, with most cosine similarity scores tightly clustered around 0.98. This is reflected in the histogram, where the majority of values fall between 0.95 and 1.0.&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/disentangling-speech-embeddings/output_21_1.png&quot; alt=&quot;Disentangling Speech Embeddings&quot; /&gt;
&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;count    2704.000000
mean        0.978689
std         0.013633
min         0.903744
25%         0.972316
50%         0.982532
75%         0.988346
max         1.000000
dtype: float64
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Residual Embeddings (Same Voice)&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Compute similarity for the same voice on residual embeddings.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sample_1_resid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;residual_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;voice_1&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;sample_2_resid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;residual_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;voice_2&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;pairwise_sim_same_resid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;cosine_similarity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;residual_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sample_1_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;residual_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sample_2_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;figure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;pcolormesh&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pairwise_sim_same_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cmap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;viridis&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Pairwise Similarity: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;alloy&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; vs. &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;alloy&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; (Residual Embeddings)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;colorbar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;figure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;hist&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pairwise_sim_same_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;flatten&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bins&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Histogram: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;alloy&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; vs. &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;alloy&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; (Residual Embeddings)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;xlabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Cosine Similarity&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ylabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Frequency&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Series&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pairwise_sim_same_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;flatten&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/disentangling-speech-embeddings/output_23_0.png&quot; alt=&quot;Disentangling Speech Embeddings&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;In contrast, the similarity matrix for the residual embeddings reveals a broader range of cosine similarity values, spanning from approximately -0.2 to 1.0. The histogram demonstrates more variability, with similarity values distributed more evenly across the range.&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/disentangling-speech-embeddings/output_23_1.png&quot; alt=&quot;Disentangling Speech Embeddings&quot; /&gt;
&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;count    2704.000000
mean        0.460229
std         0.187644
min        -0.210560
25%         0.338727
50%         0.468087
75%         0.593228
max         1.000000
dtype: float64
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;43-different-voice-similarity-audio-vs-residual-&quot;&gt;4.3 Different-Voice Similarity: Audio vs. Residual &lt;a name=&quot;different-voice-similarity&quot;&gt;&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;In this section, we analyze the similarity patterns for recordings of different voices (e.g., “alloy” vs. “coral”) using both the original audio embeddings and the residual embeddings.&lt;/p&gt;

&lt;p&gt;The results provide insights into how shared text content and speaker-specific features influence embedding similarity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Original Audio Embeddings (Different Voices)&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Compute similarity for different voices on audio embeddings.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;voice_1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;alloy&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;voice_2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;coral&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# different voice comparison.
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;sample_1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;voice_1&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;sample_2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;voice_2&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;pairwise_sim_same_audio&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;cosine_similarity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sample_1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sample_2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;figure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;pcolormesh&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pairwise_sim_same_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cmap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;viridis&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Pairwise Similarity: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;alloy&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; vs. &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;coral&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; (Audio Embeddings)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;colorbar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;figure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;hist&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pairwise_sim_same_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;flatten&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bins&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Histogram: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;alloy&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; vs. &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;coral&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; (Audio Embeddings)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;xlabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Cosine Similarity&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ylabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Frequency&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Series&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pairwise_sim_same_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;flatten&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/disentangling-speech-embeddings/output_25_0.png&quot; alt=&quot;Disentangling Speech Embeddings&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;The similarity matrix and histogram for the original audio embeddings show that even for different voices, cosine similarity values remain high, with most scores clustering between 0.96 and 0.98. This indicates that shared text content dominates the embeddings, overwhelming the differences between voices. The high similarity values reflect a lack of discrimination between different speakers when text content is present.&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/disentangling-speech-embeddings/output_25_1.png&quot; alt=&quot;Disentangling Speech Embeddings&quot; /&gt;
&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;count    2704.000000
mean        0.968115
std         0.015492
min         0.885379
25%         0.962617
50%         0.972892
75%         0.978895
max         0.988612
dtype: float64
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Residual Embeddings (Different Voices)&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Compute similarity for different voices on residual embeddings.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sample_1_resid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;residual_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;voice_1&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;sample_2_resid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;residual_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;voice_2&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;pairwise_sim_same_resid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;cosine_similarity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;residual_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sample_1_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;residual_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sample_2_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;figure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;pcolormesh&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pairwise_sim_same_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cmap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;viridis&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Pairwise Similarity: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;alloy&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; vs. &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;coral&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; (Residual Embeddings)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;colorbar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;figure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;hist&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pairwise_sim_same_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;flatten&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bins&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Histogram: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;alloy&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; vs. &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;coral&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; (Residual Embeddings)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;xlabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Cosine Similarity&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ylabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Frequency&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Series&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pairwise_sim_same_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;flatten&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/disentangling-speech-embeddings/output_26_0.png&quot; alt=&quot;Disentangling Speech Embeddings&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;In stark contrast, the similarity matrix and histogram for the residual embeddings demonstrate a near-complete absence of similarity between different voices. The distribution of cosine similarity values spans a much wider range, centering around -0.15 with values as low as -0.5. This confirms that the residual embeddings have successfully removed the shared text content, leaving behind voice-specific characteristics. Since the embeddings now focus solely on speaker-related features, the similarity between different voices naturally drops.&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/disentangling-speech-embeddings/output_26_1.png&quot; alt=&quot;Disentangling Speech Embeddings&quot; /&gt;
&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;count    2704.000000
mean       -0.148577
std         0.139143
min        -0.516812
25%        -0.244333
50%        -0.161543
75%        -0.065892
max         0.443491
dtype: float64
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The last histogram is particularly compelling, as it illustrates the impact of residualization by showing the near-complete absence of similarity between embeddings from different voices.&lt;/p&gt;

&lt;h3 id=&quot;44-average-similarity-across-voices-&quot;&gt;4.4 Average Similarity Across Voices &lt;a name=&quot;avg-similarity&quot;&gt;&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Finally, in this section, we compute the average pairwise cosine similarity between all combinations of voices for both the original and residual embeddings. This provides a broader summary of the effects observed in Sections 4.2 and 4.3 by generalizing the analysis to all voice pairs. Instead of examining the entire distribution of similarities, we condense the information into average values for each voice combination.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;plot_heatmap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sim_matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;xtick_labels&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;figure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;pcolormesh&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sim_matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cmap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;viridis&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;colorbar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;tick_positions&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;arange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sim_matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;xticks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tick_positions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;xtick_labels&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rotation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;90&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;yticks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tick_positions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;xtick_labels&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;compute_avg_similarity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;voices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;voices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;avg_sim&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;zeros&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v1&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;enumerate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;voices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v2&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;enumerate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;voices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;sample_1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v1&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;sample_2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v2&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;elem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;sim_vals&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;cosine_similarity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sample_1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sample_2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;avg_sim&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;nanmean&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sim_vals&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;flatten&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;avg_sim&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Average similarity on audio embeddings.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sim_audio&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;compute_avg_similarity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df_audio_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;voices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;plot_heatmap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sim_audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
             &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Average Similarity Between Voices (Audio Embeddings)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
             &lt;span class=&quot;n&quot;&gt;voices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Average similarity on residual embeddings.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sim_resid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;compute_avg_similarity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;residual_emb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;voices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;plot_heatmap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sim_resid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
             &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Average Similarity Between Voices (Residual Embeddings)&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
             &lt;span class=&quot;n&quot;&gt;voices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Original Audio Embeddings&lt;/strong&gt;&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/disentangling-speech-embeddings/output_28_0.png&quot; alt=&quot;Disentangling Speech Embeddings&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;The heatmap of average pairwise similarities for the original audio embeddings reveals uniformly high similarity values across all voice pairs, with most values exceeding 0.96. This aligns with the earlier observations that text content dominates the original embeddings. The lack of variability in the heatmap suggests that the original embeddings do not effectively distinguish between voices, as the textual content contributes significantly to the similarity scores.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Residual Embeddings&lt;/strong&gt;&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/disentangling-speech-embeddings/output_28_1.png&quot; alt=&quot;Disentangling Speech Embeddings&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;In contrast, the heatmap for the residual embeddings shows low or negative similarity values for different voice pairs, illustrating the success of residualization in removing text content. For the same voice combinations (diagonal elements of the heatmap), the values are noticeably higher, reflecting the preservation of speaker-specific features. The strong contrast between diagonal and off-diagonal values demonstrates that the residual embeddings capture meaningful differences between voices while retaining consistency within the same voice.&lt;/p&gt;

&lt;h2 id=&quot;5-discussion-and-conclusion-&quot;&gt;5. Discussion and Conclusion &lt;a name=&quot;discussion&quot;&gt;&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;Our analysis shows that the original audio embeddings exhibit high similarity across different voices, likely due to the dominating influence of text content (since all voices speak the same sentence). After applying Ridge regression to regress out the text component, the residual embeddings show:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;High within-voice similarity:&lt;/strong&gt; The residual still captures speaker-specific characteristics.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Low between-voice similarity:&lt;/strong&gt; The shared text content is largely removed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this blog, we demonstrated how regression can effectively isolate speaker-specific features in audio embeddings by removing shared text content. However, we did not analyze in depth what characteristics remain in the residual embeddings. Do they capture pitch, tone, prosody, timbre, speaking rate, vocal intensity, or background noise? These are open questions worth further exploration.
In future posts, we aim to explore these residual features in greater detail, shedding light on the nuances of what these embeddings truly represent and how they can be applied to more specialized audio analysis tasks.&lt;/p&gt;
</description>
        <pubDate>Sun, 02 Feb 2025 00:00:00 +0000</pubDate>
        <link>https://www.marti.ai/ml/2025/02/02/disentangling-speech-embeddings.html</link>
        <guid isPermaLink="true">https://www.marti.ai/ml/2025/02/02/disentangling-speech-embeddings.html</guid>
        
        
        <category>ML</category>
        
      </item>
    
      <item>
        <title>Personal Reflections on NeurIPS 2024</title>
        <description>&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/neurips-2024/neurips_2024_header.jpg&quot; alt=&quot;NeurIPS 2024&quot; /&gt;
&lt;/p&gt;

&lt;h1 id=&quot;personal-reflections-on-neurips-2024&quot;&gt;Personal Reflections on NeurIPS 2024&lt;/h1&gt;

&lt;h3 id=&quot;introduction&quot;&gt;Introduction&lt;/h3&gt;

&lt;p&gt;I attended NeurIPS 2024 in Vancouver with a few colleagues (Patrik, Kelvin, Lars, and Mathieu), despite the tempting weather and numerous events happening in Abu Dhabi during the winter season; Got a bad cold on the way back.
This blog is an attempt to crystallize some of my personal takeaways from the conference, along with potential leads for further exploration. Naturally, it won’t be exhaustive, as I couldn’t attend every session and had other responsibilities to manage during the event. That said, I feel I gained a solid understanding of what had been happening in the fast-paced world of (academic) AI and ML over the past year.&lt;/p&gt;

&lt;p&gt;NeurIPS (Neural Information Processing Systems), established in 1987, is one of the most prestigious conferences in artificial intelligence (AI) and machine learning (ML). Over the decades, it has grown into a global hub for researchers, practitioners, and industry leaders to share pioneering work, exchange ideas, and explore cutting-edge advancements. In 2024, NeurIPS reached a historic milestone with nearly 16,000 registrations, cementing its status as the largest academic conference in the field.&lt;/p&gt;

&lt;p&gt;Beyond its peer-reviewed papers (talks, posters) and workshops, the event features a dynamic ecosystem of activities, including industry-sponsored events and an expansive sponsor expo (&lt;a href=&quot;https://nips.cc/Conferences/2024/Sponsors&quot;&gt;NeurIPS 2024 sponsors&lt;/a&gt;). This expo serves as a talent magnet, with companies—ranging from deep tech innovators to hedge funds and proprietary trading firms—eagerly recruiting PhD graduates and top researchers whose work is showcased at the conference. NeurIPS not only shapes the trajectory of AI research but also bridges academia and industry, fueling advancements across technology and finance.&lt;/p&gt;

&lt;h3 id=&quot;key-highlights-from-the-conference&quot;&gt;Key Highlights from the Conference&lt;/h3&gt;

&lt;p&gt;I like to visualize papers on a map to navigate the main themes and find the ones I’m interested in, or even to grasp the broader trends of a conference. For example, I’ve done this for &lt;a href=&quot;https://marti.ai/ml/2024/06/22/icml-2024-abstracts-selection.html&quot;&gt;ICML 2024&lt;/a&gt;. However, this time, some others have already done a great job capturing the main topics of NeurIPS 2024, so no point duplicating their efforts. Here are two interactive websites that do it well:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://jalammar.github.io/assets/neurips_2024.html&quot;&gt;A visualization of NeurIPS 2024 topics by Jay Alammar&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/neurips-2024/neurips_papers_map.jpg&quot; alt=&quot;NeurIPS 2024 Papers Map&quot; /&gt;
        NeurIPS 2024 Papers Map
&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://neurips2024.vizhub.ai&quot;&gt;Official NeurIPS visualization&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/neurips-2024/neurips_alt_map.jpg&quot; alt=&quot;NeurIPS 2024 Papers Map&quot; /&gt;
        NeurIPS 2024 Papers Map - Official
&lt;/p&gt;

&lt;p&gt;I somewhat prefer the ‘non-official’ version: I find it more convenient to navigate the papers by similarity.&lt;/p&gt;

&lt;p&gt;Another interesting angle is the specialization by economic/geographic regions, which you can explore in this &lt;a href=&quot;https://aiworld.eu/embed/sankey&quot;&gt;Sankey diagram&lt;/a&gt;.&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/neurips-2024/neurips_authors_sankey.jpg&quot; alt=&quot;NeurIPS 2024 Geographies-to-Topics Sankey&quot; /&gt;
        Geographies-to-Topics Sankey
&lt;/p&gt;

&lt;p&gt;The conference is clearly dominated by China and the USA, which together account for about three-quarters of the papers. It’s unclear what methodology the Sankey uses—whether it attributes papers based on the authors’ university affiliations (likely) or tries to infer their nationalities from names (less likely). This is something I’ve explored before using LLMs to infer demographics from names—if you’re curious, I’ve written about it in &lt;a href=&quot;https://marti.ai/ai/2024/11/17/what-in-a-name.html&quot;&gt;this blog&lt;/a&gt;. Many papers from US universities are authored by Chinese researchers (or ABCs), highlighting China’s strong influence in AI research.&lt;/p&gt;

&lt;p&gt;The specialization by region is also revealing. China stands out in Computer Vision and NLP and has a proportional strength in Graph Neural Networks.
China’s dominance in Computer Vision suggests ongoing investments in this field, likely driven by applications in surveillance and autonomous systems.
It’s notable that China is on par with the USA in RL &amp;amp; Robotics, but relatively weaker in “Explainable AI.” In contrast, the USA appears well-diversified across all sub-fields. Europe, while contributing fewer papers, shows a relatively stronger focus on “Explainable AI” and “Ethics &amp;amp; Safety.”&lt;/p&gt;

&lt;p&gt;What’s missing? A good visualization illustrating the evolution of topics over time. I remember 10 years ago, it was all about supervised ML, structured predictions, dealing with missing and noisy labels, and active learning. Can we trace the transition from this focus on efficient labeling to the current zero-shot and few-shot paradigms? What caused some topics to fade away completely—were they trivialized by newer approaches? And do these newer paradigms fully subsume the older problems, or is it a case where they solve only certain aspects while the community shifts focus due to trends and “mode effects”?&lt;/p&gt;

&lt;p&gt;Maybe I’ll take this up as a weekend project at some point—not super practical, but it would be fun to visualize how the field has evolved over the past 10–15 years just out of curiosity.&lt;/p&gt;

&lt;p&gt;NeurIPS 2024 revealed some clear directions in AI/ML research. Multimodality continues to be a major focus, with researchers exploring how to integrate text, audio, video, and other modalities more effectively. Efficiency in LLMs is another prominent theme, whether through compression techniques, new architectures, or advances in inference. The role of reinforcement learning is also evolving—often intertwined with LLMs—to improve fine-tuning and enable more interactive applications. These trends highlight the ongoing balance between theoretical advancements and practical applications in the field.&lt;/p&gt;

&lt;p&gt;Building on these broader trends, below are some of my personal takeaways and areas I found particularly interesting at NeurIPS 2024.&lt;/p&gt;

&lt;h3 id=&quot;personal-takeaways&quot;&gt;Personal Takeaways&lt;/h3&gt;

&lt;p&gt;Staying up-to-date in the field is a lot of work—it moves incredibly fast. It’s impossible to keep track of all the research, especially since a lot of it will turn out to be less relevant, follow wrong paths, or quickly get subsumed by superior models and approaches. Many ideas presented today will be discarded in the coming years as they are beaten by better solutions. Still, it’s a valuable exercise to try to understand and predict which pieces of work will be influential for the future of the field. I should probably commit to a fixed list for each conference—it’s too easy to ‘back trade’ and claim “I knew it!” after the fact. Feels a bit like stock picking, doesn’t it?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LLMs&lt;/strong&gt; were, unsurprisingly, a major focus of the conference, often tying into more classic areas of ML. For instance, there were several papers exploring LLMs in combination with &lt;strong&gt;Reinforcement Learning (RL)&lt;/strong&gt;. If you look at the thematic map (below), you can see how LLMs subdivide into various sub-categories and connect with other branches of ML, such as &lt;strong&gt;privacy/security/adversarial attacks&lt;/strong&gt;, &lt;strong&gt;multimodality&lt;/strong&gt;, and alternative learning paradigms. One particularly interesting area is the investigation of using &lt;strong&gt;Transformers for state-space models&lt;/strong&gt;, traditionally dominated by methods like Kalman filters.&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/neurips-2024/neurips_map_llms_to_others.jpg&quot; alt=&quot;NeurIPS 2024 Papers Map - Focus on LLMs&quot; /&gt;
        NeurIPS 2024 Papers Map - Focus on LLMs
&lt;/p&gt;

&lt;p&gt;There were also lots of papers on applying LLMs to tackle mathematical and algorithmic problems, as well as in coding/programming tasks, like &lt;strong&gt;code generation&lt;/strong&gt; and &lt;strong&gt;programming assistants&lt;/strong&gt;. The industry is already seeing widespread adoption here—think Microsoft’s GitHub Copilot. The papers in this space seem to focus on pushing beyond the current capabilities or identifying and addressing corner cases that need more attention.&lt;/p&gt;

&lt;p&gt;Another standout topic was &lt;strong&gt;LLM Compression Techniques&lt;/strong&gt;, which focus on reducing the size, computational requirements, and memory footprint of large models while preserving as much of their performance as possible. The implications are obvious—lower costs, easier deployment in low-resource environments (like edge devices), and improved energy efficiency, which aligns with broader goals of sustainability. This area is crucial given how resource-hungry LLMs can be (GPUs/TPUs don’t come cheap, and energy costs are a concern for large-scale adoption). The emphasis on this topic shows the growing demand for solutions that make LLMs more accessible and environmentally sustainable.&lt;/p&gt;

&lt;p&gt;Interestingly, the focus on efficient inference was reflected in the presence of several companies showcasing fast inference hardware, like &lt;strong&gt;Cerebras&lt;/strong&gt;, &lt;strong&gt;D-Matrix&lt;/strong&gt;, and &lt;strong&gt;SambaNova&lt;/strong&gt;. Surprisingly, &lt;strong&gt;Groq&lt;/strong&gt; wasn’t there—or at least I didn’t spot them.&lt;/p&gt;

&lt;p&gt;NeurIPS isn’t typically the go-to conference for deep dives into knowledge graphs (KGs), but there were still some interesting contributions, particularly in how LLMs and KGs interact. For example, papers like &lt;a href=&quot;https://arxiv.org/pdf/2405.16412&quot;&gt;KG-FIT: Knowledge Graph Fine-Tuning Upon Open-World Knowledge&lt;/a&gt; explore how LLMs can integrate with KGs, enriching their ability to reason over structured and unstructured data.&lt;/p&gt;

&lt;p&gt;LLMs themselves can be thought of as &lt;strong&gt;fuzzy lookup tables&lt;/strong&gt; or &lt;strong&gt;compressed knowledge bases&lt;/strong&gt;, as they inherently store and compress vast amounts of the world knowledge they’re exposed to during training (cf. Hochreiter’s slide below). However, their “fuzziness” makes them less precise than KGs when it comes to exact reasoning, which is why the two technologies often complement each other.&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/neurips-2024/neurips_llm_like_database.jpg&quot; alt=&quot;LLMs are like databases&quot; /&gt;
        LLMs are like databases - Sepp Hochreiter
&lt;/p&gt;

&lt;p&gt;Another promising direction is the use of LLMs to build, maintain, and enhance ontologies or KGs—tasks that have traditionally been labor-intensive and require substantial manual effort. LLMs can help automate ontology learning, as seen in &lt;a href=&quot;https://arxiv.org/pdf/2410.23584&quot;&gt;End-to-End Ontology Learning with Large Language Models&lt;/a&gt;, or assist with challenges like entity alignment despite noisy data (&lt;a href=&quot;https://arxiv.org/pdf/2405.16806&quot;&gt;Entity Alignment with Noisy Annotations from Large Language Models&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;The synergy between KGs and LLMs is notable because it bridges the precision of symbolic representations with the adaptability and generalization of neural models. Whether fine-tuning LLMs on KGs, using LLMs to extract and structure knowledge, or leveraging KGs to ground LLMs for better factual accuracy, this interplay is likely to grow into a critical subfield of AI research.&lt;/p&gt;

&lt;p&gt;Another relatively significant chunk of papers at the conference focused on the theme of &lt;strong&gt;transformers for state space models (SSMs)&lt;/strong&gt;. The potential applications are broad, spanning &lt;strong&gt;time-series forecasting, control systems&lt;/strong&gt; (e.g., dynamic modeling for robots or autonomous vehicles), and &lt;strong&gt;signal processing&lt;/strong&gt;. This stream of research aims to merge the strengths of traditional SSMs, which excel at handling latent states and noise in dynamical systems, with transformers, known for their ability to model long-range dependencies and complex, non-linear relationships.&lt;/p&gt;

&lt;p&gt;The idea is intriguing—by blending these paradigms, researchers hope to create models that are both expressive and interpretable, leveraging the strengths of both approaches. While transformers have revolutionized sequence modeling, they face challenges like high resource demands and limited interpretability, which this hybrid approach could potentially address.&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/neurips-2024/neurips_transformers_ssm.jpg&quot; alt=&quot;Transformers for state space models&quot; /&gt;
        Transformers for state space models 
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mamba: A New Competitor to Transformers?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One particularly interesting development in this space is the emergence of &lt;strong&gt;Mamba&lt;/strong&gt;, a relatively recent architecture introduced on December 1, 2023. Despite its youth, Mamba already has more than two dozen papers accepted at NeurIPS 2024 leveraging the architecture, suggesting it’s gaining traction rapidly. Could Mamba-like models represent the next trend in sequence modeling? It’s too early to tell, but the pace of adoption at this year’s NeurIPS hints at strong interest.&lt;/p&gt;

&lt;p&gt;Mamba is positioned as an &lt;strong&gt;alternative to transformers&lt;/strong&gt;, specifically designed to improve efficiency and interpretability for tasks where sequence modeling intersects with dynamical systems. This architecture seeks to address some of the computational and scalability challenges of transformers while retaining their ability to handle complex dependencies.&lt;/p&gt;

&lt;p&gt;While I’m not deeply familiar with this literature yet, it’s clear that Mamba and transformer-SSM hybrids are generating a lot of excitement. There seems to be real potential here, not just for theoretical advancements but for practical applications in areas like economic and financial time-series forecasting or autonomous systems. I should probably find the time to catch up on this literature, as it feels like a promising development. Will Mamba-like models carve out a niche alongside or even rival transformers?&lt;/p&gt;

&lt;p&gt;I’ve bookmarked a handful of papers that caught my attention and seem relevant for understanding Mamba and its applications. I might read them later… These include:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2408.15237&quot;&gt;The Mamba in the Llama: Distilling and Accelerating Hybrid Models&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2406.07592&quot;&gt;MambaLRP: Explaining Selective State Space Sequence Models&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2405.17394&quot;&gt;The Expressive Capacity of State Space Models: A Formal Language Perspective&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;LLM-based agents are an exciting and rapidly growing trend in research, with significant promise for industrial applications. These agents leverage the capabilities of large language models to perform complex, autonomous tasks across various domains. The flexibility and generalization capabilities of LLMs make them a strong candidate for automating workflows, enabling better decision-making, and even simulating human-like collaboration. Below are some key themes and papers on this topic that stood out:&lt;/p&gt;

&lt;p&gt;LLMs as Urban Agents:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2402.14744&quot;&gt;Large Language Models as Urban Residents: An LLM Agent Framework for Personal Mobility Generation&lt;/a&gt;:
This paper explores LLM-based agents in the context of urban mobility, treating them as “virtual residents” to generate and simulate personal mobility patterns. These applications hold potential for urban planning, traffic management, and optimizing public transport systems. While similar use cases have been studied in agent-based modeling literature, they often rely on simpler, non-LLM-based agents. The novelty here lies in incorporating LLM-based agents into the modeling process, enabling more sophisticated and adaptable simulations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Coding and Bug-Fixing Agents&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2406.12952&quot;&gt;SWT-Bench: Testing and Validating Real-World Bug-Fixes with Code Agents&lt;/a&gt;:
Investigates the use of LLM-based agents for testing and validating software bug fixes, providing insights into how autonomous agents can improve software reliability.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2403.17927&quot;&gt;MAGIS: LLM-Based Multi-Agent Framework for GitHub Issue ReSolution&lt;/a&gt;:
MAGIS introduces a team of four specialized agents: a Manager, Repository Custodian, Developer, and Quality Assurance Engineer, each tailored for different aspects of software evolution. This multi-agent setup demonstrates how LLMs can coordinate complex, collaborative workflows in software development.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Data Science and Workflow Automation&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2407.10956&quot;&gt;Spider2-V: How Far Are Multimodal Agents From Automating Data Science and Engineering Workflows?&lt;/a&gt;:
This paper provides a sobering look at the limitations of current multimodal agents, particularly in automating data science workflows. According to the authors, these agents still struggle with GUI interactions, highlighting the challenges of translating high-level language capabilities into precise, context-sensitive actions.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2411.14497&quot;&gt;Star-Agents: Automatic Data Optimization with LLM Agents for Instruction Tuning&lt;/a&gt;:
Focuses on optimizing data for instruction tuning through LLM-based agents, demonstrating their utility in automating large-scale data preprocessing and curation tasks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Multi-Agent Environments&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://arxiv.org/pdf/2411.03865&quot;&gt;AdaSociety: An Adaptive Environment with Social Structures for Multi-Agent Decision-Making&lt;/a&gt;:
Explores the design of adaptive environments where multiple LLM-based agents interact with social structures to solve decision-making problems. The emphasis on social dynamics and collaboration adds a layer of complexity, mimicking real-world team interactions.&lt;/p&gt;

&lt;p&gt;Financial Decision-Making&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://arxiv.org/pdf/2407.06567&quot;&gt;FinCon: A Synthesized LLM Multi-Agent System with Conceptual Verbal Reinforcement for Enhanced Financial Decision Making&lt;/a&gt;:
FinCon employs a hierarchical structure with Manager and Analyst agents collaborating through natural language interactions. The system generalizes across financial tasks, including single-stock trading and portfolio management, showcasing the potential of LLM-based agents in quantitative finance.&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/neurips-2024/neurips_fincon.jpg&quot; alt=&quot;Manager and Analyst agents - Automating the pod model?&quot; /&gt;
        Manager and Analyst agents - Automating the pod model?
&lt;/p&gt;

&lt;p&gt;Before LLM-based agents took center stage, the main “agents” discussed at ML conferences were those built on &lt;strong&gt;Reinforcement Learning (RL)&lt;/strong&gt;. As can be seen on the conference papers map, these two sub-fields are increasingly intertwined. Many RL agents now incorporate LLMs either as a core component or as part of their input pipeline. LLMs provide these agents with enhanced natural language understanding, which allows them to process unstructured or complex instructions, interact with users more naturally, and even reason in ways that traditional RL agents struggle with.&lt;/p&gt;

&lt;p&gt;Interestingly, this interaction works in both directions. RL is not just a consumer of LLM capabilities—it’s also a tool for improving or aligning LLMs. Techniques like &lt;strong&gt;Reinforcement Learning from Human Feedback (RLHF)&lt;/strong&gt; have been key to fine-tuning LLMs for tasks that require alignment with human values or preferences, such as making conversational agents more polite or factual.&lt;/p&gt;

&lt;p&gt;The multimodal large language model (LLM) space is a growing area of research, evident from a distinct cluster of papers in the NeurIPS papers map. These models sit at the intersection of traditional LLMs (text-based) and systems designed for &lt;strong&gt;text-to-image and text-to-video generation&lt;/strong&gt;. Among the various approaches, researchers are focusing on both speed improvements and expanding multimodal capabilities, including &lt;strong&gt;audio, visual, and temporal understanding&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Some papers tackle &lt;strong&gt;audio-visual learning&lt;/strong&gt;, addressing how to combine spoken language with visual cues for tasks like captioning, transcription, and video understanding. There is also interest in audio-only tasks, though these remain a niche area within NeurIPS, as ICASSP (International Conference on Acoustics, Speech, and Signal Processing) is the more dedicated venue for such research.&lt;/p&gt;

&lt;p&gt;Video-based LLMs (VLMs) are emerging as a focal point. These models aim to integrate textual descriptions with video inputs to build temporal understanding. However, this remains a challenge due to the complexity of aligning text with dynamic, multi-frame video content. Temporal coherence—understanding events in sequence—is an area where significant progress is needed.&lt;/p&gt;

&lt;p&gt;Generating videos remains one of the hardest tasks in multimodal modeling. Many systems struggle to respect common physics, such as gravity or object permanence, leading to outputs that break realism. Despite these flaws, improvements in video-language models (VLMs) signal progress, and this area remains an active focus of the AI/ML community.&lt;/p&gt;

&lt;p&gt;Modeling text, audio, and video together remains a complex task due to the differences in data structure, scale, and temporal characteristics of these modalities. While progress is being made, truly unified multimodal models are still at an early stage. Advancements in architecture design, pretraining strategies, and computational efficiency will likely be needed to handle these challenges effectively.&lt;/p&gt;

&lt;p&gt;Multimodal data remains an underutilized source of knowledge. Current LLMs are thought to have covered much of the publicly available text-based data, and future improvements in AI understanding may depend on incorporating other modalities:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Audio&lt;/strong&gt;: Podcasts and expert discussions capture nuanced information and perspectives not commonly available in written form.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Video&lt;/strong&gt;: Videos contain knowledge about the physical world, including motion, spatial relationships, and common-sense physics, which text-based models cannot fully grasp.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If models like VLMs improve their ability to integrate and analyze these modalities, they could lead to better internal representations and broader applications in areas like robotics, education, and healthcare.&lt;/p&gt;

&lt;p&gt;While multimodal LLMs are growing, diffusion models remain a prominent area of research, particularly in image generation. These models dominate this domain due to their ability to generate high-quality, high-resolution images.&lt;/p&gt;

&lt;p&gt;A notable trend is the rise of Diffusion Transformers, which combine diffusion processes with the attention-based capabilities of transformers. These models are proving to be highly effective for generating detailed, structured images. However, new challengers like Diffusion Mamba are emerging, potentially offering a more efficient alternative to the transformer-based architecture.&lt;/p&gt;

&lt;p&gt;Despite the ongoing dominance of diffusion models in image generation, GPT-like autoregressive (AR) models are now surpassing diffusion transformers in certain settings. Notably, the paper &lt;a href=&quot;https://arxiv.org/abs/2404.02905&quot;&gt;Visual Autoregressive Modeling: Scalable Image Generation via Next-Scale Prediction&lt;/a&gt; received the NeurIPS Best Paper Award for its groundbreaking work. This research highlights how AR models can achieve state-of-the-art results in image generation by leveraging scalability and precision in next-pixel or next-scale predictions.&lt;/p&gt;

&lt;p&gt;It has been a while—probably about five years—since I last followed the developments in Graph Neural Networks (GNNs), and NeurIPS 2024 gave me a useful update on how the field has evolved. GNNs are no longer confined to traditional message-passing paradigms; instead, the field has diversified into new architectures, scalability methods, and integration with other models like LLMs.&lt;/p&gt;

&lt;p&gt;As a quick refresher, GNNs aim to predict various properties or relationships in graphs, tackling tasks like node classification, link prediction, graph classification, graph regression, dynamic graph prediction, and even graph generation. Graphs—or networks, as they’re often called in social sciences—are everywhere in science and industry, with applications ranging from fraud detection and drug discovery to marketing and social network analysis.&lt;/p&gt;

&lt;p&gt;One interesting direction is the development of “universal” GNNs—models designed to generalize across different types of graphs and tasks. This feels a bit like the “GPT moment” in NLP, where the goal is to create a general-purpose model. Papers like &lt;a href=&quot;https://arxiv.org/pdf/2406.05346&quot;&gt;ProG: A Graph Prompt Learning Benchmark&lt;/a&gt; and &lt;a href=&quot;https://arxiv.org/pdf/2410.23855&quot;&gt;RAGraph: A General Retrieval-Augmented Graph Learning Framework&lt;/a&gt; explore this idea. That said, the concept still seems far from realization. Graph data can vary a lot—from molecular graphs to social networks—so building a one-size-fits-all solution is a tough challenge.&lt;/p&gt;

&lt;p&gt;To dig deeper, I bookmarked a few more papers that caught my attention during the conference. These papers span foundational tasks, interpretability, and novel methods in GNNs:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Foundational Tasks:&lt;/strong&gt; &lt;a href=&quot;https://arxiv.org/pdf/2402.08583&quot;&gt;Mixture of Link Predictors on Graphs&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;GNNs and LLMs:&lt;/strong&gt; &lt;a href=&quot;https://www.arxiv.org/pdf/2408.14512&quot;&gt;LLMs as Zero-shot Graph Learners: Alignment of GNN Representations with LLM Token Embeddings&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Interpretability:&lt;/strong&gt; &lt;a href=&quot;https://arxiv.org/pdf/2406.01317&quot;&gt;The Intelligible and Effective Graph Neural Additive Networks&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And, finally, a potentially useful trick for the practitioner: &lt;a href=&quot;https://arxiv.org/pdf/2405.17311&quot;&gt;Probabilistic Graph Rewiring via Virtual Nodes&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Overall, there is about five years of research to catch up on. It will be interesting to see whether graphs or time-series models will achieve their “universal” moment first—if such a thing is even possible for either field.&lt;/p&gt;

&lt;p&gt;GNNs and causality appear close in the NeurIPS 2024 papers map, as both fields rely heavily on graphs—directed acyclic graphs (DAGs) in the case of causality.
GNNs focus on modeling complex relationships and interactions in networks, often with a prediction angle, whereas causality shifts the focus to uncovering and quantifying cause-and-effect relationships, leaning more towards explanation.&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/neurips-2024/gnn_and_causality.jpg&quot; alt=&quot;GNNs and Causal AI&quot; /&gt;
        GNNs and Causal AI
&lt;/p&gt;

&lt;p&gt;Within the causality cluster, there’s a clear split: Causal Discovery and Representation is positioned closer to GNNs, while Causal Inference and Experimental Design sits further away. This reflects the focus of each area—causal discovery often involves graph-based methods to uncover relationships, while causal inference is more about estimating effects once a causal structure is known.&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/neurips-2024/neurips_discovery_vs_inference.jpg&quot; alt=&quot;Causal Discovery vs. Causal Inference - NeuRIPS 2024 Tutorial&quot; /&gt;
            Causal Discovery vs. Causal Inference - NeuRIPS 2024 Tutorial
&lt;/p&gt;

&lt;p&gt;Causal discovery tries to answer the question, “What causes what?” It works on identifying relationships between variables, often using observational data, and aims to represent these as a DAG or similar graphical structure. Causal inference, on the other hand, answers, “How much does X affect Y?” It focuses on quantifying effects under interventions and testing the robustness of those conclusions. Together, they form a complementary loop: discovery generates hypotheses about causality, and inference tests and refines them.&lt;/p&gt;

&lt;p&gt;While I don’t actively use causal discovery methods in my work, I’ve picked up some high-level insights from colleagues who specialize in this area. For domains where interventions are difficult or impossible, causal discovery becomes the primary focus. However, finding robust results in practice is incredibly challenging. It would be useful to see a systematic review ranking the applications of causal discovery methods from “easy” to “hard/not yet applicable”. I don’t have the bandwidth to experiment widely, but clarifying where the field stands in terms of practical applications would be helpful.&lt;/p&gt;

&lt;p&gt;Causal discovery is an exciting area because of its potential to improve both interpretability and robustness in AI systems. Its applications span a wide range of fields, from healthcare to economics. A few papers and tools in this space caught my attention:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2307.16405&quot;&gt;Causal-learn: Causal Discovery in Python&lt;/a&gt;: A Python library designed to make causal discovery more accessible.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2303.04209&quot;&gt;Causal Dependence Plots&lt;/a&gt;: This approach visualizes how an outcome depends on changes in a predictor, along with the subsequent causal changes in other predictors.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2402.09891&quot;&gt;Do causal predictors generalize better to new domains?&lt;/a&gt;
Predictors using all available features, regardless of causality, have better in-domain and out-of-domain accuracy than predictors using causal features (!).&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/abs/2402.03941&quot;&gt;Discovery of the Hidden World with Large Language Models&lt;/a&gt;
A paper showing how LLMs and causal discovery methods can complement each other in factor proposals.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://openreview.net/pdf?id=xZKXGvLB0c&quot;&gt;Causal vs. Anticausal merging of predictors&lt;/a&gt;
Authors show that if we observe all bivariate distributions, the CMAXENT solution reduces to a logistic regression in the causal direction and Linear Discriminant Analysis (LDA) in the anticausal direction.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Overall, while the theoretical tools in causal discovery are advancing, applying them effectively in real-world scenarios seems to remain a big challenge. It’s an area worth watching.&lt;/p&gt;

&lt;p&gt;Moving from causality to another application-driven area, healthcare stood out as a distinct cluster on the NeurIPS 2024 map, positioned between ‘Large Language Models’ and ‘Multimodal Large Language Models,’ with 14 papers focused on LLM applications in medicine.&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/neurips-2024/neurips_healthcare.jpg&quot; alt=&quot;AI for Healthcare&quot; /&gt;
        AI for Healthcare
&lt;/p&gt;

&lt;p&gt;Healthcare has long been a major user of applied causality, particularly through RCTs (randomized controlled trials) and causal inference methods. What’s new in these NeurIPS contributions is the focus on leveraging LLMs and introducing novel benchmarks. These papers primarily explore how LLMs can assist in medical tasks while starting to touch on some notion of causality—especially in understanding and reasoning about the decisions made by these models in high-stakes environments like medicine.&lt;/p&gt;

&lt;p&gt;Interestingly, this highlights a potential convergence: while healthcare has historically used causality to ensure robust and interpretable outcomes, the next step may involve integrating causality into LLMs themselves. This is an active area of research, and it was even explored in a NeurIPS 2024 tutorial (picture below).&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/neurips-2024/neurips_causality_llms.jpg&quot; alt=&quot;LLMs and Causality - NeuRIPS 2024 Tutorial&quot; /&gt;
            LLMs and Causality - NeuRIPS 2024 Tutorial
&lt;/p&gt;

&lt;p&gt;While I don’t work in this area (data science for healthcare), it’s of interest to &lt;a href=&quot;https://www.adialab.ae&quot;&gt;ADIA Lab&lt;/a&gt;—an independent laboratory dedicated to data and computational sciences. Exploring these works could inspire research collaborations or yield practical insights.&lt;/p&gt;

&lt;p&gt;What makes this collection particularly interesting is its focus on practical constraints and high-stakes decision-making, hallmarks of the medical field. Strict data privacy regulations, the need for interpretable models, and the severe consequences of errors set a high bar for performance. These challenges force researchers to design rigorous benchmarks and address real-world usability, offering valuable lessons for other domains where decisions carry material consequences.&lt;/p&gt;

&lt;p&gt;Across these papers, several common themes emerge: improving the interpretability and reliability of LLMs, designing benchmarks tailored to medical tasks, and addressing safety, bias, and real-world usability. Here’s a brief overview of the contributions:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2409.17508&quot;&gt;Uni-Med: A Unified Medical Generalist Foundation Model For Multi-Task Learning Via Connector-MoE&lt;/a&gt; A multi-task model integrating six medical tasks, from question answering to image classification.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2405.19266&quot;&gt;PediatricsGPT: Large Language Models as Chinese Medical Assistants for Pediatric Applications&lt;/a&gt; The first pediatric-specific LLM for Chinese medical applications.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2404.15155&quot;&gt;MDAgents: An Adaptive Collaboration of LLMs for Medical Decision-Making&lt;/a&gt; A multi-agent framework for collaborative decision-making, excelling in multi-modal reasoning tasks.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2406.00922&quot;&gt;MediQ: Question-Asking LLMs and a Benchmark for Reliable Interactive Clinical Reasoning&lt;/a&gt; A system designed for question-asking to improve reliability in clinical reasoning.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://openreview.net/pdf?id=Dgy5WVgPd2&quot;&gt;Instruction Tuning Large Language Models to Understand Electronic Health Records&lt;/a&gt; Focuses on improving LLM performance in answering EHR-related patient queries.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2408.01933&quot;&gt;DiReCT: Diagnostic Reasoning for Clinical Notes via Large Language Models&lt;/a&gt; A dataset for evaluating diagnostic reasoning and interpretability compared to human doctors.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://openreview.net/pdf?id=zDaD8zv8tG&quot;&gt;A teacher-teacher framework for clinical language representation learning&lt;/a&gt; A framework for aligning pre-existing models to better represent clinical notes.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://openreview.net/pdf?id=XXaIoJyYs7&quot;&gt;MedJourney: Benchmark and Evaluation of Large Language Models over Patient Clinical Journey&lt;/a&gt; A benchmark covering four stages of a patient’s clinical journey, with tasks across 12 datasets.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2406.12036&quot;&gt;MEDCALC-BENCH: Evaluating Large Language Models for Medical Calculations&lt;/a&gt; Focused on evaluating LLMs’ ability to perform medical calculations, highlighting their current limitations in clinical settings.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2402.16040&quot;&gt;EHRNoteQA: An LLM Benchmark for Real-World Clinical Practice Using Discharge Summaries&lt;/a&gt; A benchmark built on discharge summaries, evaluating LLM performance in answering patient-specific questions.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2406.16341&quot;&gt;EHRCon: Dataset for Checking Consistency between Unstructured Notes and Structured Tables in Electronic Health Records&lt;/a&gt; A framework for verifying consistency in EHRs.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2403.03744v4&quot;&gt;MedSafetyBench: Evaluating and Improving the Medical Safety of Large Language Models&lt;/a&gt; A benchmark dataset measuring medical safety in LLMs, emphasizing fine-tuning for improved performance.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.arxiv.org/pdf/2411.05521&quot;&gt;SM3-Text-to-Query: Synthetic Multi-Model Medical Text-to-Query Benchmark&lt;/a&gt; A benchmark of diverse natural language queries for medical tasks.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2405.05506&quot;&gt;Cross-Care: Assessing the Healthcare Implications of Pre-training Data on Language Model Bias&lt;/a&gt; Highlights biases in LLMs’ disease prevalence representation across demographics.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These papers demonstrate the ongoing efforts to create safe, interpretable, and practical AI systems for healthcare. Even for those outside the domain, the rigor and high standards required for medical applications can serve as a model for developing AI in other critical areas.&lt;/p&gt;

&lt;p&gt;Climate science is another area of focus for ADIA Lab, which has a natural interest in understanding long-term environmental trends and their impacts.&lt;/p&gt;

&lt;p&gt;What’s the difference between climate and weather? In simple terms, weather describes the short-term atmospheric conditions in a specific place—think hours to days. Climate, on the other hand, is the average of weather conditions over a much longer period, typically decades or centuries. While weather forecasts tell you if it will rain tomorrow, climate models help predict long-term changes like global warming or shifts in precipitation patterns.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Climate&lt;/strong&gt; papers:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2401.14657&quot;&gt;Validating Climate Models with Spherical Convolutional Wasserstein Distance&lt;/a&gt; Introduces a method to measure differences between climate models and reanalysis data, ensuring better model validation.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2402.00712&quot;&gt;ChaosBench: A Multi-Channel, Physics-Based Benchmark for Subseasonal-to-Seasonal Climate Prediction&lt;/a&gt; Proposes a benchmark to extend predictability from weeks to months, filling a crucial gap in climate forecasting.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2406.14798&quot;&gt;Probabilistic Emulation of a Global Climate Model with Spherical DYffusion&lt;/a&gt; Explores whether the success of data-driven methods in weather forecasting can extend to the complexities of climate modeling.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Weather&lt;/strong&gt; papers:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2405.20348&quot;&gt;Personalized Adapter for Large Meteorology Model on Devices: Towards Weather Foundation Models&lt;/a&gt; Introduces LM-WEATHER, a model outperforming state-of-the-art results across tasks like forecasting and imputation.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2405.13796&quot;&gt;Generalizing Weather Forecast to Fine-grained Temporal Scales via Physics-AI Hybrid Modeling&lt;/a&gt; Combines physics for large-scale weather patterns with AI for adaptive corrections, achieving state-of-the-art performance at multiple timescales.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2406.04759&quot;&gt;Probabilistic Weather Forecasting with Hierarchical Graph Neural Networks&lt;/a&gt; Combines latent-variable modeling with graph-based forecasting for more flexible and reliable probabilistic weather predictions.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2312.03876&quot;&gt;Scaling transformer neural networks for skillful and reliable medium-range weather forecasting&lt;/a&gt; A transformer-based model delivering state-of-the-art performance, especially beyond 7-day forecasts, while using significantly less training data and compute.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These papers highlight the growing integration of physics-informed AI and advanced deep learning methods in tackling the challenges of both weather and climate prediction.&lt;/p&gt;

&lt;p&gt;There were several other topics at NeurIPS 2024 that I didn’t dive into, such as molecular and quantum computing, autonomous driving, and low-level optimization techniques for ML models. While these areas are undoubtedly interesting and important, they are a bit far from my current interests and expertise.&lt;/p&gt;

&lt;h3 id=&quot;whats-next&quot;&gt;What’s next?&lt;/h3&gt;

&lt;p&gt;Looking back at NeurIPS 2024, there are plenty of ideas to dig into and explore further. Here’s what I plan to focus on next:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Reach out to some of the authors of papers that caught my attention and invite them to present their work at the &lt;a href=&quot;https://www.meetup.com/adml-abu-dhabi-machine-learning/&quot;&gt;Abu Dhabi Machine Learning Meetups&lt;/a&gt; (or the Hong Kong ones for HK-based researchers). These sessions are a great way to learn directly from the researchers and get a better understanding of their work in a more pedagogical setting.&lt;/li&gt;
  &lt;li&gt;Try out a couple of GitHub repos associated with papers I bookmarked. If anything interesting comes out of playing with the implementations—whether insights or practical tweaks—I’ll blog about it. Not necessarily aiming for something groundbreaking, but more as a way to deepen my understanding.&lt;/li&gt;
  &lt;li&gt;Work through the stack of papers I’ve bookmarked from the conference. I’m particularly interested in topics like multimodal LLMs, Diffusion Transformers, and the Mamba architecture—these seem like promising directions worth exploring further.&lt;/li&gt;
  &lt;li&gt;Start keeping tabs on the emerging themes and discussions as they develop toward ICML 2025. It’s always better to go into a conference with a clear idea of what to prioritize.&lt;/li&gt;
  &lt;li&gt;Spend a bit more time understanding areas I’m less familiar with, like video-language models or the integration of text, audio, and video. These seem like foundational challenges, and it’s probably the next big frontier in AI.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Plenty to keep busy with. These conferences always leave me with a mix of curiosity and a bit of FOMO—there’s so much happening that you can’t possibly cover it all…&lt;/p&gt;

&lt;p&gt;&lt;em&gt;For those in Abu Dhabi (or Hong Kong), consider joining one of our upcoming Machine Learning Meetups. We’ll be discussing some of these trends in more depth, and it’s a great chance to learn from each other.&lt;/em&gt;&lt;/p&gt;

&lt;h3 id=&quot;wrapping-up&quot;&gt;Wrapping up&lt;/h3&gt;

&lt;p&gt;NeurIPS 2024 brought a wide range of progress in AI/ML, from foundational work on multimodal models to practical applications in agents and generative systems. As always, it’s impossible to cover everything, but the conference gave me a good sense of where the field is heading and plenty of ideas to dig into. It’ll be interesting to see how these trends develop over the next year.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Are there any under-the-radar papers or trends I missed? Let me know!&lt;/strong&gt;&lt;/p&gt;
</description>
        <pubDate>Tue, 31 Dec 2024 00:00:00 +0000</pubDate>
        <link>https://www.marti.ai/ml/2024/12/31/neurips-2024-takeaways.html</link>
        <guid isPermaLink="true">https://www.marti.ai/ml/2024/12/31/neurips-2024-takeaways.html</guid>
        
        
        <category>ML</category>
        
      </item>
    
      <item>
        <title>What’s in a Name? AI Meets the Sociology of Naming</title>
        <description>&lt;p style=&quot;text-align: center;&quot;&gt;

&lt;div style=&quot;text-align: center;&quot;&gt;
    &lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/MDHwF0yeZNM&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;/p&gt;

&lt;h1 id=&quot;whats-in-a-name-ai-meets-the-sociology-of-naming&quot;&gt;What’s in a Name? AI Meets the Sociology of Naming&lt;/h1&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;

&lt;div style=&quot;display: flex; align-items: center; justify-content: center;&quot;&gt;
    &lt;img src=&quot;/assets/socio-onomastics/waldhari.png&quot; alt=&quot;Waldhari - Ruler of the army&quot; style=&quot;height: 200px; margin-right: 10px;&quot; /&gt;
    &lt;img src=&quot;/assets/socio-onomastics/Number_of_Gautier_born_per_year.png&quot; alt=&quot;Number of Gautier born in France per year&quot; style=&quot;height: 200px;&quot; /&gt;
&lt;/div&gt;

&lt;/p&gt;

&lt;h3 id=&quot;introduction-context-of-this-blog&quot;&gt;Introduction: Context of this blog&lt;/h3&gt;

&lt;p&gt;My first encounter with this topic occurred while working on clustering financial time series to identify relative value opportunities in credit default swaps and develop alternative risk models. Around the same time, I was exploring open data sources and came across yearly datasets released by INSEE, which detailed the number of first names given to people born each year in France. These datasets allowed for the reconstruction of time series over the past century, enabling analyses such as measuring correlations between first names, clustering based on attribution patterns, and identifying similarities and trends.&lt;/p&gt;

&lt;p&gt;This became an excellent use case for testing the flexibility of the &lt;a href=&quot;https://www.datagrapple.com&quot;&gt;DataGrapple&lt;/a&gt; platform, a tool designed to visualize CDS spread time series and hierarchical clustering from my research. Collaborating with Philippe Donnat and his team at the time, we integrated the first-name time series and hierarchical clusters into the platform, showcasing its visualization capabilities. Alongside this technical work, I developed an interest in the sociological aspects of naming and purchased Baptiste Coulmont’s book, which delves into the sociology of first names in France.&lt;/p&gt;

&lt;p&gt;Fast forward 10 years, I encountered a tangentially related problem while working with my colleagues Abdulla and Khaled, who are pursuing PhDs in Data Science. As part of their research, they explored a dataset containing names (of both individuals and companies) but with few other accompanying features. Recognizing that names often encapsulate rich information about the entity they represent (see the field of &lt;a href=&quot;https://en.wikipedia.org/wiki/Onomastics&quot;&gt;onomastics&lt;/a&gt;), we explored the idea of using Large Language Models (LLMs) to extract characteristics from names and enrich the original dataset.&lt;/p&gt;

&lt;p&gt;Although the research is still in its early stages, Abdulla and Khaled have already summarized some of their findings in two preprints:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/abs/2409.11491&quot;&gt;Enriching Datasets with Demographics through Large Language Models: What’s in a Name?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2410.07970&quot;&gt;Mapping Hong Kong’s Financial Ecosystem: A Network Analysis of the SFC’s Licensed Professionals and Institutions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Interestingly, these same tools have the potential to advance historical research, particularly in fields like prosopography, where patterns across groups of individuals—such as their names, origins, and societal roles—reveal broader historical dynamics. To better appreciate the possibilities for combining AI with such research, it’s worth delving into the historical development of socio-onomastics, a discipline that has long sought to understand the cultural and social significance of names.&lt;/p&gt;

&lt;h3 id=&quot;introduction-brief-history-of-socio-onomastics&quot;&gt;Introduction: Brief history of socio-onomastics&lt;/h3&gt;

&lt;p&gt;The sociology of first names and surnames is not a new subject. Studies on the topic date back as early as 1681, such as the &lt;em&gt;Traité de l’origine des noms et des surnoms&lt;/em&gt; (apparently available on &lt;a href=&quot;https://www.amazon.fr/Traite-LOrigine-Surnoms-Gilles-Andre-Roque/dp/112004555X&quot;&gt;Amazon&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;This field, known as socio-onomastics, emerged as a sub-discipline of sociology in the late 1970s.&lt;/p&gt;

&lt;p&gt;In France, sociologist Baptiste Coulmont has studied this topic for over two decades. He authored &lt;em&gt;Sociologie des prénoms&lt;/em&gt; (2011, with a third edition published in 2022) and hosts a &lt;a href=&quot;https://coulmont.com/bac/results.php&quot;&gt;website illustrating the relationship between first names and results on the French national exam&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In France, a person’s full name (first name + last name) can reveal a surprising amount of information, such as gender, year of birth, social status, and even geographic origin—often pinpointing the region and sometimes even the specific village. This phenomenon is particularly pronounced in France, which boasts more than &lt;a href=&quot;https://www.eupedia.com/europe/european_family_names.shtml&quot;&gt;900,000 different surnames&lt;/a&gt;). However, similar patterns can be observed to varying degrees in other parts of the world.&lt;/p&gt;

&lt;h3 id=&quot;key-takeaways-from-socio-onomastics-research&quot;&gt;Key takeaways from socio-onomastics research&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Cultural Influence:&lt;/strong&gt; Media, religion, and globalization shape naming trends.
    &lt;ul&gt;
      &lt;li&gt;“Kevin” in France became popular in the 1990s due to American pop culture, including actors like Kevin Costner.&lt;/li&gt;
      &lt;li&gt;“Chloé” gained traction in part due to its association with the French luxury fashion brand.&lt;/li&gt;
      &lt;li&gt;“Marie” remained dominant in earlier centuries because of its connection to the Virgin Mary and Catholic traditions.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Social Stratification:&lt;/strong&gt; Certain names are linked to class or community perceptions.
    &lt;ul&gt;
      &lt;li&gt;“Éléonore” or “Hugo” are often associated with upper-class or more academically inclined families in France.&lt;/li&gt;
      &lt;li&gt;“Jordan” or “Dylan” are sometimes linked to working-class families, reflecting aspirational naming trends inspired by celebrities or sports figures.&lt;/li&gt;
      &lt;li&gt;“Kevin” became stigmatized over time in France, being stereotypically linked to lower social classes.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Regional Identity:&lt;/strong&gt; Names can pinpoint geographic and cultural origins.
    &lt;ul&gt;
      &lt;li&gt;“Jean-Baptiste” is more common in rural, Catholic regions of France, reflecting traditional values.&lt;/li&gt;
      &lt;li&gt;In Brittany, names like “Gwenaël” or “Maël” are tied to Celtic heritage and local identity.&lt;/li&gt;
      &lt;li&gt;Surnames like “Le Goff”: This name is prevalent in Brittany, a region in western France, and reflects the area’s Celtic linguistic heritage.&lt;/li&gt;
      &lt;li&gt;Surnames like “Barthez”: Common in Occitan-speaking regions such as southern France, particularly in Languedoc.&lt;/li&gt;
      &lt;li&gt;Surnames like “Noël”: Frequently found in northeastern France, particularly in Lorraine, where it often reflects historical Catholic traditions associated with Christmas.&lt;/li&gt;
      &lt;li&gt;Surnames like “Dubois”: While common across France, it historically originates from regions with significant woodland areas, such as Normandy or Picardy, as it means “of the woods.”&lt;/li&gt;
      &lt;li&gt;Surnames like “Schmitt”: This surname is common in Alsace and reflects the region’s Germanic influence, as Alsace has historically shifted between French and German control. “Schmitt” is derived from the German word Schmied, meaning “smith.”&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Generational Shifts:&lt;/strong&gt; Popularity cycles reflect evolving societal values.
    &lt;ul&gt;
      &lt;li&gt;“Jacques,” once a staple name for boys in older generations, has largely fallen out of favor in modern France.&lt;/li&gt;
      &lt;li&gt;“Emma” surged in the 2000s as a modern, elegant alternative to older names like “Marie.”&lt;/li&gt;
      &lt;li&gt;Names like “Théo” and “Léo” are increasingly popular among younger parents, reflecting contemporary naming preferences.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Ethnic Identity:&lt;/strong&gt; Names often preserve cultural roots within diverse societies.
    &lt;ul&gt;
      &lt;li&gt;“Mohamed” remains a popular choice among families of North African origin in France, reflecting cultural and religious ties.&lt;/li&gt;
      &lt;li&gt;“Giuseppe” or “Enzo” among Italian immigrant communities highlights the retention of cultural heritage.&lt;/li&gt;
      &lt;li&gt;“Wei” or “Xiao” are common names among Chinese immigrants, signaling strong ties to their linguistic and cultural origins.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;case-study-gautier&quot;&gt;Case Study: Gautier&lt;/h3&gt;

&lt;p&gt;What does ChatGPT 4o know about “Gautier”?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prompt:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;What can you tell about the first name “Gautier” in this context?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;ChatGPT 4o:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first name Gautier offers an interesting lens for socio-onomastics in the French context, as it reflects cultural, historical, and social influences:&lt;/p&gt;

&lt;h4 id=&quot;historical-and-cultural-context&quot;&gt;Historical and Cultural Context&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Origins:&lt;/strong&gt; The name Gautier is derived from the Germanic Waldhari (wald- meaning “rule” and -hari meaning “army”). It has deep medieval roots and is closely tied to the Frankish heritage in France, making it a historically noble or prestigious name.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Popularity:&lt;/strong&gt; Gautier has experienced revivals during different periods. In the 19th and early 20th centuries, it was relatively rare, often associated with historical or literary connotations, such as the poet Théophile Gautier. Its popularity increased in the late 20th century as part of a broader trend of reviving older, traditional French names.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;social-and-regional-patterns&quot;&gt;Social and Regional Patterns&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Social Class:&lt;/strong&gt; In modern times, Gautier is often associated with upper-middle-class families or parents seeking a name that blends tradition and sophistication.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Spelling Variants:&lt;/strong&gt; The choice of spelling can also reveal social nuances:
    &lt;ul&gt;
      &lt;li&gt;Gautier (traditional and French spelling) tends to appear among families with an appreciation for history or classic French culture.&lt;/li&gt;
      &lt;li&gt;Gauthier (with an “h”) is equally traditional but sometimes perceived as slightly more formal or tied to surnames that have become first names.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;regional-relevance&quot;&gt;Regional Relevance&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Geographical Association:&lt;/strong&gt; The name may be more common in regions of France with strong medieval legacies or historical ties to Frankish culture, such as the Loire Valley or Burgundy. However, it is not strongly tied to any one region, making it relatively “neutral” geographically.&lt;/p&gt;

&lt;h4 id=&quot;abstract-pattern&quot;&gt;Abstract Pattern&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Generational Shift:&lt;/strong&gt; Like many older French names, Gautier has benefited from a revival trend among parents looking for names that are both distinctive and rooted in French tradition. This reflects broader societal interest in blending heritage with modern identity.&lt;/p&gt;

&lt;p&gt;In summary, Gautier serves as a good example of a name that is culturally rich, socially nuanced, and representative of broader trends in French naming practices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prompt:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;If you were to provide an educated guess, what is the most likely year of birth of “Gautier”?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;ChatGPT 4o:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Based on naming trends in France, an educated guess for the most likely year of birth for someone named Gautier would fall in the 1990s to early 2000s. Here’s why:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Revival of Traditional Names:&lt;/strong&gt; During the late 20th century, there was a resurgence of interest in older, classic French names, including medieval and aristocratic names like Gautier. This aligns with a broader cultural trend toward reviving names with historical significance.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Distinctive yet Timeless Appeal:&lt;/strong&gt; Names like Gautier became attractive to parents who wanted something traditional yet distinctive, without being overly old-fashioned.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Peak Popularity Data:&lt;/strong&gt; While exact statistics for Gautier may not always be available, names in the same category (like Arthur or Thibault) typically saw a rise in the 1990s and early 2000s.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If we were to pick a single most likely year, 1995 would be a reasonable estimate, as this was a peak period for names of this type in France. However, it would still be commonly used throughout the decade surrounding this time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Data sourced from INSEE, showing the annual number of individuals named ‘Gautier’ born in France:&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/socio-onomastics/Number_of_Gautier_born_per_year.png&quot; alt=&quot;Number of 'Gautier' born per year in France&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prompt:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;If you were to provide an educated guess, what is the most likely average grade for “Gautier” at the French Baccalauréat (French national exam)?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;ChatGPT 4o:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Analyzing the performance of students named “Gautier” in the French Baccalauréat reveals notable trends:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;High Success Rate:&lt;/strong&gt; In 2023, 100% of candidates named “Gautier” passed the Baccalauréat.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Mentions Très Bien:&lt;/strong&gt; The name “Gautier” is among those whose bearers frequently achieve the highest honors, indicating strong academic performance.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These patterns suggest that students named “Gautier” often excel in their studies, achieving commendable results in the Baccalauréat.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Data sourced from Baptiste Coulmont’s website, illustrating performance of ‘Gautier’ vs. the national average results in the French Baccalauréat:&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/socio-onomastics/Gautier_performance_French_bac.png&quot; alt=&quot;Comparison of Gautier's performance compared to the national average at the French Baccalauréat&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;Let’s now combine the first name “Gautier” with the surname “Marti” to analyze the sociological insights a full name can reveal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prompt:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Based solely on the combination of the first name “Gautier” and the surname “Marti,” and without referencing any specific individual, what can be inferred about the person’s likely cultural background, regional origin, and other sociological aspects?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;ChatGPT 4o:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Analysis:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The name “Gautier Marti” offers insights into cultural and regional origins:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;First Name: Gautier
    &lt;ul&gt;
      &lt;li&gt;&lt;em&gt;Origin:&lt;/em&gt; “Gautier” is the French form of “Walter,” derived from the Germanic elements “wald” (rule) and “hari” (army), meaning “ruler of the army.”&lt;/li&gt;
      &lt;li&gt;&lt;em&gt;Usage:&lt;/em&gt; Predominantly used in France, “Gautier” is a masculine name with historical significance, often associated with medieval French nobility.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Surname: Marti
    &lt;ul&gt;
      &lt;li&gt;&lt;em&gt;Origin:&lt;/em&gt; “Marti” is a surname found in various cultures:
        &lt;ul&gt;
          &lt;li&gt;Catalan: Derived from the personal name “Martí,” a form of “Martin,” meaning “of Mars” or “warlike.”&lt;/li&gt;
          &lt;li&gt;Swiss German and South German: A diminutive of “Martin.”&lt;/li&gt;
          &lt;li&gt;Italian: Possibly from the medieval Greek “Martios,” meaning “March,” indicating a connection to the month.&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;em&gt;Usage:&lt;/em&gt; Common in Catalonia (Spain), parts of France, Switzerland, and Italy.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Interestingly, I briefly considered the army as a potential career path, and went through the competitive exams for officer positions in the French Air Force and the French Navy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sociological Inferences:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;em&gt;Cultural Background:&lt;/em&gt; The combination suggests a French cultural background, given the French first name “Gautier” and the presence of the surname “Marti” in southern France.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;Regional Origin:&lt;/em&gt; The surname “Marti” is prevalent in southern France, particularly in regions like Languedoc and Provence.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;Historical Context:&lt;/em&gt; The name “Gautier” has medieval French associations, while “Marti” may indicate Catalan or southern French heritage.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;“Gautier Marti” likely denotes a male individual of French nationality, possibly from southern France, with a name reflecting both medieval French and regional influences.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Overall Hypothesis:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Gautier Marti is likely a male individual of French nationality, born in the 1990s, with a mixed northern and southern French heritage. The name suggests an upper-middle-class background and possibly a family with a strong sense of cultural or historical appreciation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; ChatGPT 4o is accurate in its assessment of me, based on first name + last name only!&lt;/p&gt;

&lt;h3 id=&quot;modern-tools-and-ai-in-onomastics&quot;&gt;Modern Tools and AI in Onomastics&lt;/h3&gt;

&lt;p&gt;As demonstrated in the anecdotal “Gautier” case study, Large Language Models (LLMs) can infer a surprising amount of background information about a person based solely on their first name—and even more accurately when a last name is included. These models, trained on vast datasets, excel at identifying cultural, historical, and regional naming patterns, providing insights that were once the exclusive domain of sociological expertise.&lt;/p&gt;

&lt;p&gt;Together with Khaled and Mathieu, we aimed to provide a more comprehensive evaluation of LLMs’ capabilities, extending beyond the relatively “easy” case of French nationals. Our focus was on assessing performance across datasets with different geographic emphases: an American-focused dataset (Florida Voters Registration), a global dataset (Wikipedia People, albeit with a strong American bias), and an Asia-focused dataset (the SFC register of Hong Kong finance professionals, with a strong emphasis on Chinese names).&lt;/p&gt;

&lt;p&gt;The results are detailed in Khaled’s paper, &lt;a href=&quot;https://arxiv.org/pdf/2409.11491&quot;&gt;Enriching Datasets with Demographics through Large Language Models: What’s in a Name?&lt;/a&gt;. In summary, we found that these models are highly accurate in predicting gender, ethnicity, and nationality but face greater challenges when estimating age or date of birth. Some countries lack clear trends in naming patterns over time. For instance, in countries where first names are tied to religion, names tend to be timeless and remain in consistent use across generations. In others, like China, unisex names present difficulties in determining gender. Additionally, some Asian countries have a very limited pool of surnames—for example, South Korea, where Kim accounts for 21.5% of the population, or Vietnam, where Nguyễn is used by 39% of the population, reflecting historical practices of adopting the family names of prominent rulers.&lt;/p&gt;

&lt;p&gt;Some results of the empirical study:&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/socio-onomastics/accuracy_predicting_nationality_wikipedia_dataset.png&quot; alt=&quot;Model accuracy at predicting the correct nationality on the Wikipedia test set (166 classes)&quot; /&gt;
&lt;/p&gt;

&lt;h3 id=&quot;conclusion-names-as-windows-into-society&quot;&gt;Conclusion: Names as windows into society&lt;/h3&gt;

&lt;p&gt;This brief exploration of socio-onomastics, combined with modern tools like Large Language Models (LLMs), demonstrates how much information can be inferred from something as seemingly simple as a name. By leveraging contemporary AI tools, we can uncover patterns tied to cultural, historical, and demographic factors.&lt;/p&gt;

&lt;p&gt;While the results are promising, this work also underscores the inherent challenges and limitations of using AI for such tasks. Difficulties in handling unisex names, the timeless nature of religious naming traditions, and the prevalence of shared surnames in certain cultures highlight the complexity of this field. These challenges serve as a reminder that names are deeply intertwined with societal and historical contexts, which cannot always be fully captured by even the most advanced models.&lt;/p&gt;

&lt;p&gt;Nonetheless, the integration of LLMs into this area of research presents exciting opportunities. In contexts where breadth of analysis is prioritized over depth, LLMs provide an effective means to scale investigations across vast corpora of text. Their ability to process large datasets efficiently enables broad analyses that complement traditional approaches. This synergy could open new avenues for insights in fields such as historical research through prosopography and demographic enrichment.&lt;/p&gt;

&lt;p&gt;Ultimately, this blog represents a small step in understanding the role of names in society. While the findings suggest that names continue to offer valuable perspectives on identity and culture, we hope this work inspires further exploration at the intersection of sociology and AI research. Interestingly, this direction was not our original focus; we initially stumbled upon this topic while seeking to enrich a dataset with additional features to solve a practical prediction task.&lt;/p&gt;
</description>
        <pubDate>Sun, 17 Nov 2024 00:00:00 +0000</pubDate>
        <link>https://www.marti.ai/ai/2024/11/17/what-in-a-name.html</link>
        <guid isPermaLink="true">https://www.marti.ai/ai/2024/11/17/what-in-a-name.html</guid>
        
        
        <category>AI</category>
        
      </item>
    
      <item>
        <title>[paper] Assisting in Writing Wikipedia-like Articles From Scratch with Large Language Models</title>
        <description>&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/storm-wikipedia-articles/storm-overview.png&quot; alt=&quot;Wikipedia-like Articles by LLMs&quot; /&gt;
&lt;/p&gt;

&lt;h1 id=&quot;paper-assisting-in-writing-wikipedia-like-articles-from-scratch-with-large-language-models&quot;&gt;[paper] Assisting in Writing Wikipedia-like Articles From Scratch with Large Language Models&lt;/h1&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/stanford-oval/storm&quot;&gt;GitHub repo of the paper&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;summary-of-the-paper&quot;&gt;Summary of the paper&lt;/h3&gt;

&lt;p&gt;The paper introduces STORM, a framework designed to help large language models (LLMs) create Wikipedia-like articles from scratch by focusing on a structured pre-writing phase. STORM’s core method involves synthesizing topic outlines through a unique process of perspective-guided question asking and multi-turn simulated conversations. These steps allow the LLM to gather information from diverse viewpoints, leading to comprehensive and organized outlines. Using these outlines, STORM generates well-structured articles with improved depth, coherence, and factual accuracy. The framework outperforms traditional retrieval-augmented approaches, though challenges like source bias and verifiability remain areas for future refinement.&lt;/p&gt;

&lt;h3 id=&quot;qa-with-chatgpt-against-the-paper&quot;&gt;Q&amp;amp;A with ChatGPT against the paper&lt;/h3&gt;

&lt;p&gt;Q: What are they key elements in the paper’s method to generate a high quality article?&lt;/p&gt;

&lt;p&gt;A: The key elements of the method in the paper for generating high-quality Wikipedia-like articles involve the STORM framework, which structures the pre-writing process into several steps:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Perspective-Guided Question Asking&lt;/strong&gt;: STORM starts by identifying multiple perspectives on a topic, helping generate diverse and in-depth questions that guide research effectively.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Simulated Conversations&lt;/strong&gt;: By simulating a conversation between a topic expert and a Wikipedia writer, the model iteratively refines its understanding of the topic, asking follow-up questions to gather comprehensive information.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Outline Creation&lt;/strong&gt;: The gathered information is organized into an outline using the model’s internal knowledge and curated sources. This outline serves as a structured foundation for the article.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Section-by-Section Writing&lt;/strong&gt;: Each section of the article is generated based on the outline and relevant sources, ensuring coherence, coverage, and citation accuracy.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Q: How does STORM identify the multiple perspectives on a given topic?&lt;/p&gt;

&lt;p&gt;A: STORM identifies multiple perspectives on a given topic by first surveying related Wikipedia articles. It retrieves the tables of contents from these articles to help pinpoint diverse viewpoints relevant to the topic. These perspectives, such as those of experts or laypeople, are then used to guide the generation of varied and specific questions. This approach ensures that the model gathers a broad, nuanced understanding of the topic, allowing it to explore and integrate different facets into the final article outline​.&lt;/p&gt;

&lt;p&gt;Q: What kind of framework is used in order to simulate the conversations?&lt;/p&gt;

&lt;p&gt;A: STORM uses the DSPy framework to simulate conversations between a “Wikipedia writer” and a “topic expert.” This framework enables multi-turn, information-seeking dialogues, allowing the model to iteratively pose questions and gather responses. Each question-answer cycle builds on previous interactions, enhancing the depth and relevance of the information collected. Trusted online sources are incorporated to ground responses in verified data, supporting a reliable foundation for the final article outline and content generation​.&lt;/p&gt;

&lt;p&gt;Q: What are the weaknesses of this paper?&lt;/p&gt;

&lt;p&gt;A: Some weaknesses in the paper include:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Bias and Verifiability Issues&lt;/strong&gt;: STORM may inadvertently transfer biases from its information sources, leading to articles that sometimes lack neutrality or include unverifiable connections between facts.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Citation Limitations&lt;/strong&gt;: Though citations are used, some generated connections between information pieces are not directly verifiable, raising accuracy concerns.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Simplified Task Scope&lt;/strong&gt;: The framework primarily generates text-based articles, overlooking multimedia or structured data (like tables) typical of high-quality Wikipedia entries, which limits its realism for broader applications​.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Q: Besides the Wikipedia use case, what could be other interesting and relevant tasks that this STORM framework could tackle?&lt;/p&gt;

&lt;p&gt;A: Beyond Wikipedia, the STORM framework could be applied to other tasks requiring comprehensive research, structure, and neutrality, such as:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Educational Content Creation&lt;/strong&gt;: Developing curricula, study guides, or academic summaries where balanced perspectives are essential.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Technical Documentation&lt;/strong&gt;: Producing structured and informative guides, FAQs, or manuals for complex systems in software or engineering.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Market Analysis Reports&lt;/strong&gt;: Compiling structured business or financial reports with varied perspectives (e.g., market trends, consumer insights, regulatory impacts).&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Policy Briefs&lt;/strong&gt;: Crafting policy documents that balance diverse viewpoints, ensuring well-rounded insights for government or NGO reports.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These tasks would benefit from STORM’s capacity to integrate varied information sources, generate outlines, and maintain organized content.&lt;/p&gt;

&lt;p&gt;Q: What kind of questions would you suggest to ask against this paper to learn as much as possible from this paper?&lt;/p&gt;

&lt;p&gt;A: Here are some in-depth questions to guide your learning from the paper:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Framework Design&lt;/strong&gt;: What motivated the choice of using the DSPy framework for conversation simulation, and how does it enhance the pre-writing stage?
&lt;strong&gt;Evaluation Metrics&lt;/strong&gt;: How do the paper’s automatic and human evaluation metrics assess outline quality? What are their limitations?
&lt;strong&gt;Perspective Discovery&lt;/strong&gt;: What methods did the authors explore for identifying diverse perspectives, and could alternative approaches improve this process?
&lt;strong&gt;Bias Handling&lt;/strong&gt;: How does the framework address potential biases in information retrieval, and what solutions are suggested for future work?
&lt;strong&gt;Applications Beyond Wikipedia&lt;/strong&gt;: What specific adaptations might be necessary to apply STORM in fields like policy analysis or technical documentation?&lt;/p&gt;

&lt;p&gt;Q: What kind of experiments do the author perform with their ablation study?&lt;/p&gt;

&lt;p&gt;A: In their ablation study, the authors evaluate the impact of different components within the STORM framework on the quality of generated Wikipedia-like articles. They systematically remove or modify specific elements to assess their contributions:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Perspective-Guided Question Asking&lt;/strong&gt;: They examine the effect of generating questions from multiple perspectives versus a single perspective, analyzing how this influences the depth and breadth of the collected information.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Simulated Conversations&lt;/strong&gt;: The study assesses the role of multi-turn conversations between simulated roles (e.g., “Wikipedia writer” and “topic expert”) in enhancing the relevance and coherence of the gathered content.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Outline Generation&lt;/strong&gt;: They investigate the importance of structured outline creation prior to writing, comparing outcomes with and without this step to determine its impact on the organization and coverage of the final article.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Q: What’s the conclusion of this ablation study?&lt;/p&gt;

&lt;p&gt;A: The study concludes that each component of the STORM framework plays a vital role in producing high-quality, well-structured Wikipedia-like articles. Removing any of these elements results in a noticeable decline in the overall quality of the generated content.&lt;/p&gt;

&lt;h3 id=&quot;related-work&quot;&gt;Related work&lt;/h3&gt;

&lt;p&gt;While exploring frameworks implementing similar ideas, I came across &lt;a href=&quot;https://github.com/assafelovic/gpt-researcher&quot;&gt;GPT Researcher&lt;/a&gt; and decided to give it a try. It’s straightforward to install locally, and you can start experimenting right away using the default configuration—assuming you have API keys for OpenAI and Tavily.&lt;/p&gt;

&lt;p&gt;Setting up the experiment is as easy as this:&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/storm-wikipedia-articles/experiment-writing-report.png&quot; alt=&quot;GPT Research on Market Neutral Equities&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;Wait for 5 minutes while the Agent is doing its thing…&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/storm-wikipedia-articles/agent-thinking.png&quot; alt=&quot;Agent planning and researching&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;The results were somewhat disappointing (using only the web; not grounded in a relevant corpus). Not too surprising given the sources the Agent selected…&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;
    &lt;img src=&quot;/assets/storm-wikipedia-articles/agent-sources.png&quot; alt=&quot;Agent selected sources...&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;I’ll let you judge for yourself:&lt;/p&gt;

&lt;h4 id=&quot;agent-output&quot;&gt;Agent Output:&lt;/h4&gt;

&lt;p&gt;Building an Equity Market Neutral Strategy Using Alternative Data&lt;/p&gt;

&lt;p&gt;In the evolving landscape of quantitative finance, equity market neutral (EMN) strategies have emerged as a robust approach to achieving returns independent of market direction. These strategies, primarily employed by hedge funds, involve taking offsetting long and short positions in closely related stocks to hedge against market exposure. This approach seeks to capitalize on price discrepancies while maintaining a balanced portfolio that is theoretically immune to market volatility. The advent of alternative data has further revolutionized this domain, offering new avenues for enhancing the precision and effectiveness of EMN strategies.&lt;/p&gt;

&lt;p&gt;Equity market neutral strategies are designed to exploit differences in stock prices by maintaining an equal amount of long and short positions in stocks that share similar characteristics, such as market capitalization or sector affiliation. This strategy is particularly appealing to institutional investors seeking to outperform traditional bonds without the high risk associated with more aggressive funds. For a comprehensive understanding of EMN strategies, Investopedia provides a detailed overview of their mechanics and benefits.&lt;/p&gt;

&lt;p&gt;The integration of alternative data into EMN strategies represents a significant advancement in portfolio management. Alternative data, which includes non-traditional sources such as social media sentiment, satellite imagery, and transaction data, offers a granular view of market dynamics that traditional data sources might overlook. This data can enhance the predictive accuracy of stock price movements, thereby refining the selection of long and short positions within an EMN framework. Studies, such as those published in MDPI, have demonstrated the efficacy of using machine learning models like LSTM for stock prediction, leveraging alternative data to construct market-neutral portfolios.&lt;/p&gt;

&lt;p&gt;Moreover, the systematic application of alternative data in EMN strategies can help mitigate risks and enhance returns. By employing sophisticated algorithms and machine learning techniques, portfolio managers can dynamically adjust their positions to maintain market neutrality, even as market conditions fluctuate. This approach is supported by insights from BlackRock, which emphasizes the importance of a systematic process in capturing alpha opportunities and managing risk exposures.&lt;/p&gt;

&lt;p&gt;In conclusion, building an equity market neutral strategy using alternative data involves a nuanced understanding of both traditional financial principles and cutting-edge data analytics. As the financial markets continue to evolve, the integration of alternative data into EMN strategies will likely become an essential component for investors seeking to achieve consistent returns in an increasingly complex market environment.&lt;/p&gt;

&lt;p&gt;Understanding Equity Market Neutral Strategy&lt;/p&gt;

&lt;p&gt;Equity Market Neutral (EMN) strategies are designed to exploit pricing inefficiencies while maintaining a neutral exposure to the overall market. This report explores how to build an EMN strategy using alternative data, focusing on the integration of machine learning models, data collection techniques, and risk management practices.&lt;/p&gt;

&lt;p&gt;Leveraging Alternative Data in EMN Strategies&lt;/p&gt;

&lt;p&gt;Alternative data refers to non-traditional data sources that can provide unique insights into market trends. These include social media sentiment, satellite imagery, and web traffic data. The use of alternative data in EMN strategies can enhance the predictive power of models and uncover alpha opportunities that traditional data might miss.&lt;/p&gt;

&lt;p&gt;Data Collection and Processing&lt;/p&gt;

&lt;p&gt;The first step in incorporating alternative data into an EMN strategy is data collection and processing. Hedge funds and investment firms gather a wide array of data, including financial statements, earnings reports, and alternative unstructured data like news articles and social media sentiment (Aurum). The data is then cleaned and structured to be fed into quantitative models.&lt;/p&gt;

&lt;p&gt;Signal Generation&lt;/p&gt;

&lt;p&gt;Once the data is processed, the next step is generating trading signals. Quantitative models analyze the data to identify patterns and predict future stock movements. For instance, a model might use natural language processing (NLP) to gauge sentiment from news articles, which can then be used to predict stock price movements (Aurum). This approach allows for the creation of signals based on value, growth, price momentum, and quality.&lt;/p&gt;

&lt;p&gt;Machine Learning Models in EMN Strategies&lt;/p&gt;

&lt;p&gt;Machine learning models, particularly Long Short-Term Memory (LSTM) networks, have gained popularity in EMN strategies due to their ability to handle time series data effectively. These models can predict stock prices and returns with high accuracy, which is crucial for constructing a market-neutral portfolio (MDPI).&lt;/p&gt;

&lt;p&gt;LSTM-Based Stock Prediction&lt;/p&gt;

&lt;p&gt;LSTM networks are particularly suited for stock prediction due to their ability to capture long-term dependencies in data. By training on historical stock prices and alternative data, LSTM models can forecast future price movements, aiding in the selection of stocks for long and short positions in an EMN strategy.&lt;/p&gt;

&lt;p&gt;Portfolio Construction&lt;/p&gt;

&lt;p&gt;The construction of a market-neutral portfolio involves balancing long and short positions to achieve a beta close to zero. This is typically done by selecting an equal number of stocks for both positions, ensuring that gains from one side offset losses from the other (MDPI). The use of LSTM models in this process can enhance the robustness of the portfolio by improving stock selection accuracy.&lt;/p&gt;

&lt;p&gt;Risk Management in EMN Strategies&lt;/p&gt;

&lt;p&gt;Risk management is a critical component of EMN strategies, as it ensures that the portfolio remains market-neutral and minimizes exposure to systematic risk. This involves continuous monitoring and rebalancing of positions to maintain the desired risk profile.&lt;/p&gt;

&lt;p&gt;Hedging Techniques&lt;/p&gt;

&lt;p&gt;One of the main advantages of EMN strategies is their ability to hedge against market risk. By taking long positions in stocks expected to outperform and short positions in those expected to underperform, the strategy can mitigate the impact of market volatility (Picton Mahoney).&lt;/p&gt;

&lt;p&gt;Diversification Benefits&lt;/p&gt;

&lt;p&gt;EMN strategies offer diversification benefits by providing returns that are independent of market direction. This can be particularly valuable in periods of high market volatility, where traditional portfolios may suffer significant losses. By incorporating alternative data and machine learning models, EMN strategies can further enhance diversification by uncovering unique alpha opportunities (BlackRock).&lt;/p&gt;

&lt;p&gt;Performance Evaluation and Adjustment&lt;/p&gt;

&lt;p&gt;Evaluating the performance of an EMN strategy involves analyzing its risk-adjusted returns and ensuring that it meets the desired investment objectives. This requires regular backtesting and adjustment of models and data inputs to adapt to changing market conditions.&lt;/p&gt;

&lt;p&gt;Backtesting and Model Validation&lt;/p&gt;

&lt;p&gt;Backtesting is a crucial step in validating the effectiveness of an EMN strategy. By simulating the strategy’s performance on historical data, investors can assess its potential returns and identify any weaknesses in the model. This process also involves adjusting the model parameters and data inputs to optimize performance (CAIA).&lt;/p&gt;

&lt;p&gt;Continuous Improvement&lt;/p&gt;

&lt;p&gt;The dynamic nature of financial markets necessitates continuous improvement of EMN strategies. This involves updating models with new data, incorporating additional alternative data sources, and refining trading algorithms to maintain a competitive edge. By staying abreast of technological advancements and market trends, investors can ensure that their EMN strategies remain effective and profitable (Class Central).&lt;/p&gt;

&lt;p&gt;Integration with Traditional Investment Strategies&lt;/p&gt;

&lt;p&gt;While EMN strategies offer unique benefits, they can also complement traditional investment strategies by providing additional diversification and risk mitigation.&lt;/p&gt;

&lt;p&gt;Complementing the 60/40 Portfolio&lt;/p&gt;

&lt;p&gt;The traditional 60/40 portfolio, which allocates 60% to equities and 40% to bonds, can benefit from the inclusion of EMN strategies. By providing returns that are uncorrelated with the broader market, EMN strategies can enhance the overall risk-adjusted returns of the portfolio and reduce its vulnerability to market downturns (CAIA).&lt;/p&gt;

&lt;p&gt;Enhancing Long-Biased Portfolios&lt;/p&gt;

&lt;p&gt;EMN strategies can also complement long-biased portfolios by offering a hedge against market declines. By balancing long and short positions, these strategies can mitigate the impact of market volatility and provide a more stable return profile (Picton Mahoney).&lt;/p&gt;

&lt;p&gt;In summary, building an equity market-neutral strategy using alternative data involves integrating innovative data sources, advanced machine learning models, and robust risk management practices. By doing so, investors can create strategies that offer compelling returns and diversification benefits, even in challenging market conditions.&lt;/p&gt;

&lt;p&gt;Utilizing Alternative Data in EMN Strategy
Advanced Data Integration Techniques&lt;/p&gt;

&lt;p&gt;While previous sections have covered the basics of data collection and processing, this section delves deeper into advanced techniques for integrating alternative data into Equity Market Neutral (EMN) strategies. Unlike traditional data sources, alternative data such as satellite imagery, social media sentiment, and web traffic data require sophisticated integration methods to be effectively utilized in quantitative models.&lt;/p&gt;

&lt;p&gt;Data Fusion: This technique involves combining multiple data sources to create a comprehensive dataset that enhances the predictive power of EMN strategies. For example, integrating satellite imagery with social media sentiment can provide a more nuanced view of consumer behavior and market trends (AlphaSense).
Natural Language Processing (NLP): NLP is used to analyze unstructured text data from news articles and social media posts. By extracting sentiment and key themes, NLP can generate valuable insights that inform trading decisions. This approach is particularly useful for capturing market sentiment shifts that may not be reflected in traditional financial metrics (Aurum).
Geospatial Analysis: Utilizing geolocation data from smartphones and other devices can offer insights into foot traffic patterns and consumer behavior. This data can be particularly valuable for retail and consumer goods sectors, providing a real-time view of market dynamics (AlphaSense).
Signal Enhancement through Machine Learning&lt;/p&gt;

&lt;p&gt;While previous sections discussed LSTM-based stock prediction, this section focuses on enhancing signal generation through advanced machine learning techniques. These methods leverage alternative data to improve the accuracy and reliability of trading signals in EMN strategies.&lt;/p&gt;

&lt;p&gt;Ensemble Learning: By combining predictions from multiple machine learning models, ensemble learning can enhance the robustness of trading signals. This approach mitigates the risk of overfitting and improves the generalization of models to new data (OptimizDBA).
Feature Engineering: Advanced feature engineering techniques can extract meaningful patterns from alternative data, such as identifying correlations between social media sentiment and stock price movements. These engineered features can significantly enhance the predictive power of machine learning models (SSRN).
Deep Reinforcement Learning: This technique involves training models to make sequential decisions by interacting with a simulated market environment. By learning from past actions and outcomes, reinforcement learning models can optimize trading strategies in dynamic market conditions (Academia.edu).
Risk Management Innovations&lt;/p&gt;

&lt;p&gt;While previous sections have covered traditional hedging techniques, this section explores innovative risk management strategies that leverage alternative data to enhance EMN strategies.&lt;/p&gt;

&lt;p&gt;Dynamic Risk Assessment: By continuously monitoring alternative data sources, such as news sentiment and social media trends, investors can dynamically assess and adjust risk exposures. This proactive approach allows for timely responses to emerging risks and opportunities (BlackRock).
Volatility Prediction: Using machine learning models to predict market volatility based on alternative data can help investors better manage risk. For instance, analyzing social media sentiment can provide early warnings of potential market disruptions, allowing for preemptive risk mitigation (MDPI).
Scenario Analysis: By simulating various market scenarios using alternative data, investors can evaluate the potential impact of different risk factors on their portfolios. This approach enables more informed decision-making and enhances the resilience of EMN strategies (OptimizDBA).
Portfolio Optimization with Alternative Data&lt;/p&gt;

&lt;p&gt;While previous sections have discussed portfolio construction, this section focuses on optimizing EMN portfolios using alternative data to achieve superior risk-adjusted returns.&lt;/p&gt;

&lt;p&gt;Multi-Objective Optimization: This technique involves optimizing portfolios based on multiple criteria, such as maximizing returns while minimizing risk. By incorporating alternative data, investors can identify non-traditional factors that contribute to portfolio performance, such as consumer sentiment and environmental trends (Aurum).
Adaptive Rebalancing: Utilizing real-time alternative data allows for adaptive portfolio rebalancing, ensuring that portfolios remain aligned with current market conditions. This approach enhances the agility of EMN strategies and improves their ability to capture short-term market opportunities (Academia.edu).
Factor Analysis: By analyzing alternative data, investors can identify new factors that drive stock returns, such as brand loyalty or supply chain disruptions. Incorporating these factors into portfolio optimization models can enhance the predictive accuracy and performance of EMN strategies (SSRN).
Continuous Strategy Refinement&lt;/p&gt;

&lt;p&gt;While previous sections have emphasized the importance of continuous improvement, this section highlights specific strategies for refining EMN strategies using alternative data.&lt;/p&gt;

&lt;p&gt;Feedback Loops: Establishing feedback loops that incorporate alternative data allows for the continuous refinement of trading models. By analyzing the outcomes of past trades, investors can identify areas for improvement and adjust their strategies accordingly (OptimizDBA).
Data-Driven Insights: Leveraging alternative data for insights into market trends and consumer behavior can inform strategic adjustments to EMN strategies. This data-driven approach ensures that strategies remain relevant and effective in changing market environments (AlphaSense).
Collaborative Innovation: Collaborating with data scientists and industry experts can foster innovation and enhance the development of EMN strategies. By sharing insights and expertise, investors can leverage the full potential of alternative data to drive superior performance (Aurum).
Portfolio Construction and Risk Management in Equity Market Neutral Strategies
Factor-Based Stock Selection&lt;/p&gt;

&lt;p&gt;In equity market neutral (EMN) strategies, selecting the right stocks is crucial for achieving market neutrality and optimizing returns. Unlike traditional methods that rely heavily on historical price data, EMN strategies can benefit significantly from alternative data sources. These data sources include social media sentiment, satellite imagery, and web traffic analytics, which provide insights into market trends and company performance that are not captured by conventional financial metrics. For instance, social media sentiment analysis can reveal public perception and potential market movements before they are reflected in stock prices (CAIA).&lt;/p&gt;

&lt;p&gt;Advanced Machine Learning Techniques&lt;/p&gt;

&lt;p&gt;While LSTM models have been discussed in previous sections for stock prediction, this section focuses on other machine learning techniques that can enhance EMN strategies. Techniques such as random forests, gradient boosting machines, and support vector machines can be employed to capture complex, non-linear relationships in the data. These models can process large volumes of alternative data to identify patterns and predict stock movements more accurately. For example, random forests can be used to analyze a combination of financial ratios and alternative data to rank stocks based on their expected returns, thereby aiding in the construction of the long and short sides of the portfolio (Academia.edu).&lt;/p&gt;

&lt;p&gt;Dynamic Portfolio Rebalancing&lt;/p&gt;

&lt;p&gt;Dynamic portfolio rebalancing is a key component of risk management in EMN strategies. Unlike static rebalancing, which occurs at fixed intervals, dynamic rebalancing adjusts the portfolio in response to real-time market changes and new data inputs. This approach ensures that the portfolio remains aligned with the strategy’s objectives and market conditions. By integrating alternative data, such as real-time economic indicators and sentiment analysis, portfolio managers can make more informed decisions about when to rebalance the portfolio. This not only helps in maintaining market neutrality but also in capturing short-term market opportunities that may arise due to sudden shifts in market sentiment (MDPI).&lt;/p&gt;

&lt;p&gt;Risk Metrics Beyond Traditional Measures&lt;/p&gt;

&lt;p&gt;Traditional risk metrics like standard deviation and beta may not fully capture the risks associated with EMN strategies. Instead, advanced risk metrics such as Conditional Value-at-Risk (CVaR) and entropy pooling offer a more comprehensive view of potential risks. CVaR, for instance, measures the expected loss in the worst-case scenarios, providing a more robust assessment of tail risks. Entropy pooling, on the other hand, allows for the incorporation of subjective views and stress-testing scenarios, enabling a more nuanced risk management approach. These metrics help in identifying and mitigating risks that are not apparent through traditional measures, thereby enhancing the robustness of EMN strategies (Anton Vorobets).&lt;/p&gt;

&lt;p&gt;Incorporating Sentiment Analysis&lt;/p&gt;

&lt;p&gt;Sentiment analysis is an innovative tool for enhancing EMN strategies by providing insights into market psychology and investor behavior. By analyzing data from news articles, social media platforms, and financial reports, sentiment analysis can gauge the overall market mood and predict potential market movements. This information can be used to adjust the portfolio’s long and short positions to better align with market sentiment. For instance, a positive sentiment towards a particular sector may prompt an increase in long positions within that sector, while negative sentiment may lead to an increase in short positions. This proactive approach to portfolio management can improve the strategy’s performance and resilience in volatile markets (CAIA).&lt;/p&gt;

&lt;p&gt;Integration of ESG Factors&lt;/p&gt;

&lt;p&gt;Environmental, Social, and Governance (ESG) factors are increasingly being integrated into EMN strategies as a form of alternative data. ESG factors provide insights into a company’s sustainability practices and ethical considerations, which can influence long-term performance. By incorporating ESG data, EMN strategies can identify companies that are likely to outperform due to their strong ESG profiles. This not only enhances the strategy’s return potential but also aligns it with socially responsible investment practices. For example, companies with high ESG ratings may be favored for long positions, while those with poor ratings may be targeted for short positions, thereby aligning financial goals with ethical considerations (MDPI).&lt;/p&gt;

&lt;p&gt;Continuous Monitoring and Adjustment&lt;/p&gt;

&lt;p&gt;Continuous monitoring and adjustment are critical for maintaining the effectiveness of EMN strategies. This involves regularly reviewing the portfolio’s performance, risk exposures, and alignment with market conditions. By leveraging alternative data and advanced analytics, portfolio managers can identify emerging trends and potential risks in real-time. This enables them to make timely adjustments to the portfolio, such as reallocating assets or adjusting hedging strategies, to ensure that it remains on track to achieve its objectives. Continuous monitoring also facilitates the identification of underperforming assets, allowing for their timely replacement with better-performing alternatives (Academia.edu).&lt;/p&gt;

&lt;p&gt;By integrating these advanced techniques and data sources, equity market neutral strategies can be significantly enhanced, providing better risk-adjusted returns and resilience in diverse market conditions. This approach not only leverages the latest advancements in data analytics and machine learning but also aligns with the growing demand for sustainable and responsible investment practices.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;/p&gt;

&lt;p&gt;This research report outlines the construction of an Equity Market Neutral (EMN) strategy utilizing alternative data, emphasizing the integration of advanced machine learning models, sophisticated data collection techniques, and innovative risk management practices. The primary aim of EMN strategies is to exploit pricing inefficiencies while maintaining a neutral exposure to market movements. By leveraging alternative data sources such as social media sentiment, satellite imagery, and web traffic analytics, these strategies can enhance predictive accuracy and uncover alpha opportunities that traditional data might overlook. The report highlights the importance of data processing and signal generation, where techniques like Natural Language Processing (NLP) and geospatial analysis play crucial roles in extracting actionable insights from unstructured data.&lt;/p&gt;

&lt;p&gt;The incorporation of machine learning models, particularly Long Short-Term Memory (LSTM) networks, is pivotal in handling time series data and predicting stock movements with high precision. These models, along with other techniques like ensemble learning and deep reinforcement learning, significantly improve the robustness and reliability of trading signals. Risk management is another critical component, with dynamic risk assessment and volatility prediction using alternative data providing a proactive approach to mitigating market risks. The report also underscores the benefits of integrating Environmental, Social, and Governance (ESG) factors, which align financial objectives with ethical investment practices, thereby enhancing the strategy’s appeal to socially responsible investors.&lt;/p&gt;

&lt;p&gt;The findings suggest that the integration of alternative data and advanced analytics can significantly enhance the performance and resilience of EMN strategies, offering superior risk-adjusted returns even in volatile market conditions. The next steps involve continuous refinement of these strategies through feedback loops, data-driven insights, and collaborative innovation with data scientists and industry experts. By staying abreast of technological advancements and market trends, investors can ensure that their EMN strategies remain competitive and effective. This approach not only leverages cutting-edge data analytics but also aligns with the growing demand for sustainable and responsible investment practices, positioning EMN strategies as a valuable complement to traditional investment portfolios.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt; Fully automated generation (at least, this framework) does not seem yet on par with co-creation with a human expert, but a decent entrypoint for the layman.&lt;/p&gt;
</description>
        <pubDate>Sat, 02 Nov 2024 00:00:00 +0000</pubDate>
        <link>https://www.marti.ai/ai/2024/11/02/storm-wikipedia-articles.html</link>
        <guid isPermaLink="true">https://www.marti.ai/ai/2024/11/02/storm-wikipedia-articles.html</guid>
        
        
        <category>AI</category>
        
      </item>
    
  </channel>
</rss>
