<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jonathan Yahav on Medium]]></title>
        <description><![CDATA[Stories by Jonathan Yahav on Medium]]></description>
        <link>https://medium.com/@jhyahav?source=rss-ef72e1b40cd0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tQSSZNHTS7LzCnpOTRjkOQ.jpeg</url>
            <title>Stories by Jonathan Yahav on Medium</title>
            <link>https://medium.com/@jhyahav?source=rss-ef72e1b40cd0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 06:46:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jhyahav/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[When Optimal is the Enemy of Good: High-Budget Differential Privacy for Medical AI]]></title>
            <link>https://jhyahav.medium.com/when-optimal-is-the-enemy-of-good-high-budget-differential-privacy-for-medical-ai-9e6ff4e4a2e3?source=rss-ef72e1b40cd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e6ff4e4a2e3</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[differential-privacy]]></category>
            <category><![CDATA[medicine]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[privacy]]></category>
            <dc:creator><![CDATA[Jonathan Yahav]]></dc:creator>
            <pubDate>Wed, 05 Mar 2025 09:10:29 GMT</pubDate>
            <atom:updated>2025-03-05T09:10:29.386Z</atom:updated>
            <content:encoded><![CDATA[<h4>Can we guarantee patient privacy without sacrificing model accuracy?</h4><p><strong>Imagine you’re building your dream home.</strong> Just about everything is ready. <strong>All that’s left to do is pick out a front door.</strong> Since the neighborhood has a low crime rate, you decide you want a door with a standard lock — nothing too fancy, but probably enough to deter 99.9% of would-be burglars.</p><p><strong>Unfortunately, the local homeowners’ association (HOA) has a rule stating that all front doors in the neighborhood must be bank vault doors.</strong> Their reasoning? Bank vault doors are the only doors that have been mathematically proven to be absolutely secure. As far as they’re concerned, any front door below that standard may as well not be there at all.</p><p><strong>You’re left with three options, none of which seems particularly appealing:</strong></p><ul><li><strong>Concede defeat and have a bank vault door installed.</strong> Not only is this expensive and cumbersome, but you’ll be left with a front door that bogs you down every single time you want to open or close it. At least burglars won’t be a problem!</li><li><strong>Leave your house doorless.</strong> The HOA rule imposes requirements on any front door in the neighborhood, but it doesn’t <em>technically</em> forbid you from not installing a door at all. That would save you a lot of time and money. The downside, of course, is that it would allow anyone to come and go as they please. On top of that, the HOA could always close the loophole, taking you back to square one.</li><li><strong>Opt out entirely.</strong> Faced with such a stark dilemma (all-in on either security or practicality), you choose not to play the game at all, selling your nearly-complete house and looking for someplace else to live.</li></ul><p>This scenario is obviously completely unrealistic. In real life, <strong>everybody strives to strike an appropriate balance between security and practicality.</strong> This balance is informed by everyone’s own circumstances and risk analysis, but it universally<strong> lands somewhere between the two extremes of bank vault door and no door at all.</strong></p><p><strong>But what if instead of your dream home, you imagined a medical AI model that has the power to help doctors improve patient outcomes?</strong> Highly-sensitive training data points from patients are your valuables. The privacy protection measures you take are the front door you choose to install. Healthcare providers and the scientific community are the HOA.</p><p><strong>Suddenly, the scenario is much closer to reality. In this article, we’ll explore why that is.</strong> After understanding the problem, we’ll consider a simple but empirically effective solution proposed in the paper <a href="https://doi.org/10.1038/s42256-024-00858-y"><em>Reconciling privacy and accuracy in AI for medical imaging</em></a><em> </em>[1]. The authors propose a <strong>balanced alternative to the three bad choices laid out above, much like the real-life approach of a typical front door.</strong></p><h4>The State of Patient Privacy in Medical AI</h4><p>Over the past few years, artificial intelligence has become an ever more ubiquitous part of our day-to-day lives, proving its utility across a wide range of domains. The rising use of AI models has, however, <strong>raised questions and concerns about protecting the privacy of the data used to train them.</strong> You may remember the well-known case of ChatGPT, just months after its initial release, <a href="https://www.forbes.com/sites/siladityaray/2023/05/02/samsung-bans-chatgpt-and-other-chatbots-for-employees-after-sensitive-code-leak/">exposing proprietary code from Samsung</a> [2].</p><p>Some of the privacy risks associated with AI models are obvious. For example, if the training data used for a model isn’t stored securely enough, bad actors could find ways to access it directly. <strong>Others are more insidious, such as the risk of <em>reconstruction</em>. </strong>As the name implies, in a <a href="https://en.wikipedia.org/wiki/Reconstruction_attack">reconstruction attack</a>, a bad actor attempts to reconstruct a model’s training data without needing to gain direct access to the dataset.</p><p>Medical records are one of the most sensitive kinds of personal information there are. Although specific regulation varies by jurisdiction, patient data is generally subject to stringent safeguards, with hefty fines for inadequate protection. <strong>Beyond the letter of the law, unintentionally exposing such data could irreparably damage our ability to use specialized AI to empower medical professionals.</strong></p><p>As Ziller, Mueller, Stieger, <em>et al.</em> point out [1], <strong>fully taking advantage of medical AI requires rich datasets comprising information from actual patients.</strong> This information must be obtained with the full consent of the patient. Ethically acquiring medical data for research was challenging enough as it was before the unique challenges posed by AI came into play. But if proprietary code being exposed caused Samsung to ban the use of ChatGPT [2], what would happen if attackers managed to reconstruct MRI scans and identify the patients they belonged to? <strong>Even isolated instances of negligent protection against data reconstruction could end up being a monumental setback for medical AI as a whole.</strong></p><p>Tying this back into our front door metaphor, the HOA statute calling for bank vault doors starts to make a little bit more sense. <strong>When the cost of a single break-in could be so catastrophic for the entire neighborhood, it’s only natural to want to go to any lengths to prevent them.</strong></p><h4>Differential Privacy (DP) as a Theoretical Bank Vault Door</h4><p>Before we discuss what an appropriate balance between privacy and practicality might look like in the context of medical AI, we have to turn our attention to <strong>the inherent tradeoff between protecting an AI model’s training data and optimizing for quality of performance.</strong> This will set the stage for us to develop a basic understanding of <strong>differential privacy (DP), the theoretical gold standard of privacy protection.</strong></p><p>Although academic interest in training data privacy has increased significantly over the past four years, <strong>principles on which much of the conversation is based were pointed out by researchers well before the recent LLM boom,</strong> and even before OpenAI was founded in 2015. Though it doesn’t deal with reconstruction <em>per se</em>, <strong>the 2013 paper </strong><a href="https://doi.org/10.48550/arXiv.1306.4447"><strong><em>Hacking smart machines with smarter ones</em></strong></a><strong> [3]</strong> demonstrates a generalizable attack methodology capable of accurately <strong>inferring statistical properties of machine learning classifiers,</strong> noting:</p><blockquote>“Although ML algorithms are known and publicly released, training sets may not be reasonably ascertainable and, indeed, may be guarded as trade secrets. While much research has been performed about the privacy of the elements of training sets, […] we focus our attention on ML classifiers and on the statistical information that can be unconsciously or maliciously revealed from them. We show that it is possible to infer unexpected but useful information from ML classifiers.” <em>[3]</em></blockquote><p><strong>Theoretical data reconstruction attacks were described even earlier,</strong> in a context not directly pertaining to machine learning. The landmark 2003 paper <a href="https://crypto.stanford.edu/seclab/sem-03-04/psd.pdf"><strong><em>Revealing information while preserving privacy</em></strong></a> [4] demonstrates a <strong>polynomial-time reconstruction algorithm for statistical databases.</strong> (Such databases are intended to provide answers to questions about their data in aggregate while keeping individual data points anonymous.) The authors show that <strong>to mitigate the risk of reconstruction, a certain amount of noise needs to be introduced into the data.</strong> Needless to say, perturbing the original data in this way, while necessary for privacy, <strong>has implications for the quality of the responses to queries,</strong> i.e., the accuracy of the statistical database.</p><p>In explaining the purpose of DP in the first chapter of their book <a href="https://www.cis.upenn.edu/~aaroth/Papers/privacybook.pdf"><em>The Algorithmic Foundations of Differential Privacy</em></a><em> </em>[5], Cynthia Dwork and Aaron Roth address this tradeoff between privacy and accuracy:</p><blockquote><strong>“[T]he Fundamental Law of Information Recovery states that overly accurate answers to too many questions will destroy privacy in a spectacular way.</strong> The goal of algorithmic research on differential privacy is to postpone this inevitability as long as possible. <strong>Differential privacy addresses the paradox of learning nothing about an individual while learning useful information about a population.”</strong> <em>[5]</em></blockquote><p>The notion of <em>“learning nothing about an individual while learning useful information about a population”</em> is captured by considering two datasets that differ by a single entry (one that includes the entry and one that doesn’t). <strong>An (<em>ε</em>, <em>δ</em>)-differentially private querying mechanism is one for which the probability of a certain output being returned when querying one dataset is at most a multiplicative factor of the probability when querying the other dataset.</strong> Denoting the mechanism by <em>M</em>, the set of possible outputs by <em>S</em>, and the datasets by <em>x</em> and <em>y</em>, we formalize this as [5]:</p><blockquote><strong><em>Pr[</em>M<em>(</em>x<em>) ∈ </em>S<em>] ≤ exp(</em>ε<em>) ⋅ Pr[</em>M<em>(</em>y<em>) ∈ </em>S<em>] + </em>δ</strong></blockquote><p>Where <strong><em>ε</em></strong><em> </em>is the <em>privacy loss parameter</em> and <strong><em>δ</em></strong> is the <em>failure probability parameter</em>. <em>ε</em> quantifies how much privacy is lost as a result of a query, while a positive <em>δ</em> allows for privacy to fail altogether for a query at a certain (usually very low) probability. Note that <em>ε</em> is an exponential parameter, meaning that even slightly increasing it can cause privacy to decay significantly.</p><p><strong>An important and useful property of DP is <em>composition</em>.</strong> Notice that the definition above only applies to cases where we run a single query. The composition property helps us generalize it to cover multiple queries based on the fact that <strong>privacy loss and failure probability accumulate predictably when we compose several queries,</strong> be they based on the same mechanism or different ones. This accumulation is easily proven to be (at most) linear [5]. What this means is that, <strong>rather than considering a privacy loss parameter for one query, we may view <em>ε</em> as a <em>privacy budget</em> that can be utilized across a number of queries.</strong> For example, when taken together, one query using a (1, 0)-DP mechanism and two queries using a (0.5, 0)-DP mechanism satisfy (2, 0)-DP.</p><p><strong>The value of DP comes from the theoretical privacy guarantees it promises.</strong> Setting <em>ε</em> = 1 and <em>δ</em> = 0, for example, we find that the probability of any given output occurring when querying dataset <em>y</em> is at most exp(1) = e ≈ 2.718 times greater than that same output occurring when querying dataset <em>x</em>. Why does this matter? Because <strong>the greater the discrepancy between the probabilities of certain outputs occurring, the easier it is to determine the contribution of the individual entry by which the two datasets differ, and the easier it is to ultimately reconstruct that individual entry.</strong></p><p>In practice, designing an (<em>ε</em>, <em>δ</em>)-differentially private randomized mechanism entails the <strong>addition of random noise drawn from a distribution dependent on <em>ε</em> and <em>δ.</em> </strong>The specifics are beyond the scope of this article. Shifting our focus back to machine learning, though, we find that the idea is the same: DP for ML hinges on introducing noise into the training data, which yields robust privacy guarantees in much the same way.</p><p>Of course, this is where the tradeoff we mentioned comes into play. <strong>Adding noise to the training data comes at the cost of making learning more difficult.</strong> We could <em>absolutely </em>add enough noise to achieve <em>ε</em> = 0.01 and <em>δ</em> = 0, making the difference in output probabilities between <em>x</em> and <em>y</em> virtually nonexistent. <strong>This would be wonderful for privacy, but terrible for learning.</strong> <strong>A model trained on such a noisy dataset would perform very poorly on most tasks.</strong></p><p><strong>There is no consensus on what constitutes a “good” <em>ε</em> value, or on universal methodologies or best practices for <em>ε</em> selection [6].</strong> In many ways, <em>ε</em> embodies the privacy/accuracy tradeoff, and the “proper” value to aim for is highly context-dependent. <em>ε</em> = 1 is generally regarded as offering high privacy guarantees. Although privacy diminishes exponentially with respect to <em>ε</em>, values as high as <em>ε </em>= 32 are mentioned in literature and thought to provide moderately strong privacy guarantees [1].</p><p>The authors of <a href="https://doi.org/10.1038/s42256-024-00858-y"><em>Reconciling privacy and accuracy in AI for medical imaging</em></a><em> </em>[1] test the effects of DP on the accuracy of AI models on three real-world medical imaging datasets. They do so using various values of <em>ε</em> and comparing them to a non-private (non-DP) control. <strong>Table 1</strong> provides a partial summary of their results for <em>ε</em> = 1 and <em>ε</em> = 8:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*FgtOaBMkxtmKDjBQBa_GNA.png" /><figcaption><strong>Table 1:</strong> Comparison of AI model performance across the RadImageNet [7], HAM10000 [8], and MSD Liver [9] datasets with <em>δ = 8</em>⁻⁷⋅10 and privacy budgets of ε = 1, ε = 8, and without DP (non-private). A higher MCC/Dice score indicates higher accuracy. Although providing strong theoretical privacy guarantees in the face of a worst-case adversary, <strong>DP significantly degrades model accuracy. </strong>The negative impact on performance is especially noticeable in the latter two datasets, which are considered small datasets. Image by the author, based on image by A. Ziller, T.T. Mueller, S. Stieger, et al from Table 3 in <a href="https://doi.org/10.1038/s42256-024-00858-y"><strong><em>Reconciling privacy and accuracy in AI for medical imaging</em></strong></a><em> [1] </em>(use under<a href="https://creativecommons.org/licenses/by/4.0/"> CC-BY 4.0 license</a>).</figcaption></figure><p><strong>Even approaching the higher end of the typical <em>ε</em> values attested in literature, DP is still as cumbersome as a bank vault door for medical imaging tasks.</strong> The noise introduced into the training data is catastrophic for AI model accuracy, especially when the datasets at hand are small. Note, for example, the huge drop-off in Dice score on the MSD Liver dataset, even with the relatively high <em>ε </em>value of 8.</p><p><strong>Ziller, Mueller, Stieger, <em>et al.</em> suggest that the accuracy drawbacks of DP with typical <em>ε</em> values may contribute to the lack of widespread adoption of DP in the field of medical AI [1].</strong> Yes, wanting mathematically-provable privacy guarantees is definitely sensible, but at what cost? Leaving so much of the diagnostic power of AI models on the table in the name of privacy is not an easy choice to make.</p><p>Revisiting our dream home scenario armed with an understanding of DP, we find that the options we (seem to) have map neatly onto the three we had for our front door.</p><ul><li><strong>DP with typical values of <em>ε</em> is like installing a bank vault door:</strong> costly, but effective for privacy. As we’ll see, it’s also complete overkill in this case.</li><li><strong>Not using DP is like not installing a door at all:</strong> much easier, but risky. As mentioned above, though, DP has yet to be widely applied in medical AI [1].</li><li><strong>Passing up opportunities to use AI is like giving up and selling the house:</strong> it saves us the headache of dealing with privacy concerns weighed against incentives to maximize accuracy, but a lot of potential is lost in the process.</li></ul><p>It looks like we’re at an impasse… <strong>unless we think outside the box.</strong></p><h4>High-Budget DP: Privacy and Accuracy Aren’t an Either/Or</h4><p>In <a href="https://doi.org/10.1038/s42256-024-00858-y"><em>Reconciling privacy and accuracy in AI for medical imaging</em></a> [1], Ziller, Mueller, Stieger, <em>et al.</em> offer the medical AI equivalent of a regular front door — <strong>an approach that manages to protect privacy while giving up very little in the way of model performance.</strong> Granted, this protection is not theoretically optimal — far from it. However, as the authors show through a series of experiments, <strong>it <em>is </em>good enough to counter almost any realistic threat of reconstruction.</strong></p><p><strong>As the saying goes, “Perfect is the enemy of good.” In this case, it is the “optimal” — an insistence on arbitrarily low <em>ε</em> values — that locks us into the false dichotomy of total privacy versus total accuracy.</strong> Just as a bank vault door has its place in the real world, so does DP with <em>ε </em>≤ 32. Still, the existence of the bank vault door <strong>doesn’t mean plain old front doors don’t also have a place in the world. The same goes for <em>high-budget</em> DP.</strong></p><p>The idea behind high-budget DP is straightforward: using privacy budgets (<em>ε</em> values) that are so high that they <em>“are near-universally shunned as being meaningless”</em> [1] — <strong>budgets ranging from <em>ε = </em>10⁶ to as high as <em>ε = </em>10¹⁵.</strong> In theory, these provide such weak privacy guarantees that it seems like common sense to dismiss them as no better than not using DP at all. In practice, though, this couldn’t be further from the truth. As we will see by looking at the results from the paper, high-budget DP shows significant promise in countering realistic threats. As Ziller, Mueller, Stieger, <em>et al.</em> put it [1]:</p><blockquote>“[E]ven a ‘pinch of privacy’ has drastic effects in practical scenarios.”</blockquote><p>First, though, we need to ask ourselves what we consider to be a “realistic” threat. <strong>Any discussion of the efficacy of high-budget DP is inextricably tied to the <em>threat model</em> under which we choose to evaluate it.</strong> In this context, a threat model is simply the set of assumptions we make about what a bad actor interested in obtaining our model’s training data is able to do.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*TZRg-8DGrjSI4oqfEtFDeQ.png" /><figcaption><strong>Table 2: </strong>Comparison of threat models. For all three, we also assume that the adversary has unbounded computational ability. Image by A. Ziller, T.T. Mueller, S. Stieger, et al from Table 1 in <a href="https://doi.org/10.1038/s42256-024-00858-y"><strong><em>Reconciling privacy and accuracy in AI for medical imaging</em></strong></a><em> [1] </em>(use under<a href="https://creativecommons.org/licenses/by/4.0/"> CC-BY 4.0 license</a>).</figcaption></figure><p><strong>The paper’s findings hinge on a calibration of the assumptions to better suit real-world threats to patient privacy. </strong>The authors argue that the worst-case model, which is the one typically used for DP, is far too pessimistic. For example, it assumes that the adversary has full access to each original image while attempting to reconstruct it based on the AI model (see Table 2) [1]. This pessimism explains the discrepancy between the reported <em>“drastic effects in practical scenarios”</em> of high privacy budgets and the very weak <em>theoretical </em>privacy guarantees that they offer. We may liken it to incorrectly assessing the security threats a typical house faces, wrongly assuming they are likely to be as sophisticated and enduring as those faced by a bank.</p><p><strong>The authors therefore propose two alternative threat models,</strong> which they call the “relaxed” and “realistic” models. Under both of these, adversaries keep some core capabilities from the worst-case model: access to the AI model’s architecture and weights, the ability to manipulate its hyperparameters, and unbounded computational abilities (see Table 2). The realistic adversary is assumed to have no access to the original images and an imperfect reconstruction algorithm. <strong>Even these assumptions leave us with a rigorous threat model that may still be considered pessimistic for most real-world scenarios [1].</strong></p><p>Having established the three relevant threat models to consider, Ziller, Mueller, Stieger, <em>et al.</em> <strong>compare AI model accuracy in conjunction with the reconstruction risk under each threat model at different values of <em>ε</em>.</strong> As we saw in Table 1, this is done for three exemplary medical imaging datasets. Their full results are presented in <strong>Table 3:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n9TNsr6CdCS13x4TJ7n21A.png" /><figcaption><strong>Table 3:</strong> Comparison of AI model performance and reconstruction risk per threat model across the RadImageNet [7], HAM10000 [8], and MSD Liver [9] datasets with <em>δ = 8</em>⁻⁷⋅10 and various privacy budgets, including some as high as ε = 10⁹ and ε = 10¹². A higher MCC/Dice score indicates higher accuracy. Image by A. Ziller, T.T. Mueller, S. Stieger, et al from Table 3 in <a href="https://doi.org/10.1038/s42256-024-00858-y"><strong><em>Reconciling privacy and accuracy in AI for medical imaging</em></strong></a><em> [1] </em>(use under<a href="https://creativecommons.org/licenses/by/4.0/"> CC-BY 4.0 license</a>).</figcaption></figure><p>Unsurprisingly, high privacy budgets (exceeding <em>ε</em> = 10⁶) significantly mitigate the loss of accuracy seen with lower (stricter) privacy budgets. Across all tested datasets, <strong>models trained with high-budget DP at <em>ε</em> = 10⁹ (HAM10000, MSD Liver) or <em>ε</em> = 10¹² (RadImageNet) perform nearly as well as their non-privately trained counterparts.</strong> This is in line with our understanding of the privacy/accuracy tradeoff: the less noise introduced into the training data, the better a model can learn.</p><p><strong>What <em>is </em>surprising is the degree of empirical protection afforded by high-budget DP against reconstruction under the realistic threat model.</strong> Remarkably, the realistic reconstruction risk is assessed to be 0% for each of the aforementioned models.<strong> The high efficacy of high-budget DP </strong>in defending medical AI training images against realistic reconstruction attacks<strong> is made even clearer by looking at the results of reconstruction attempts.</strong> <strong>Figure 1</strong> below shows the five most readily reconstructed images from the MSD Liver dataset [9] using DP with high privacy budgets of ε = 10⁶, ε = 10⁹, ε = 10¹², and ε = 10¹⁵.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*HMh2TbcpT12laUs5xbiKRw.png" /><figcaption><strong>Figure 1:</strong> The five most readily reconstructed images from the MSD Liver dataset [9] using DP with high privacy budgets of ε = 10⁶, ε = 10⁹, ε = 10¹², and ε = 10¹⁵. Image by A. Ziller, T.T. Mueller, S. Stieger, et al from Figure 3 in <a href="https://doi.org/10.1038/s42256-024-00858-y"><strong><em>Reconciling privacy and accuracy in AI for medical imaging</em></strong></a><em> [1] </em>(use under<a href="https://creativecommons.org/licenses/by/4.0/"> CC-BY 4.0 license</a>).</figcaption></figure><p>Note that, at least to the naked eye, <strong>even the best reconstructions obtained when using the former two budgets are visually indistinguishable from random noise. </strong>This lends intuitive credence to the argument that<strong> budgets often deemed too high to provide any meaningful protection could be instrumental in protecting privacy without giving up accuracy when using AI for medical imaging.</strong> In contrast, the reconstructions when using ε = 10¹⁵ closely resemble the original images, showing that not all high budgets are created equal.</p><p>Based on their findings, Ziller, Mueller, Stieger, <em>et al.</em> <strong>make the case for training medical imaging AI models using (at least) high-budget DP as the norm.</strong> They note the empirical efficacy of high-budget DP in countering realistic reconstruction risks at very little cost in terms of model accuracy. <strong>The authors go so far as to claim that “<em>it seems negligent to train AI models without any form of formal privacy guarantee.</em>” [1]</strong></p><h4>Conclusion</h4><p>We started with a hypothetical scenario in which you were forced to decide between a bank vault door or no door at all for your dream home (or giving up and selling the incomplete house). After an exploration of the risks posed by inadequate privacy protection in medical AI, we looked into the <strong><em>privacy/accuracy tradeoff</em></strong> as well as the history and theory behind <strong><em>reconstruction attacks</em></strong> and<strong> <em>differential privacy (DP)</em>.</strong> We then saw how <strong>DP with common privacy budgets (<em>ε</em> values) degrades medical AI model performance</strong> and compared it to the bank vault door in our hypothetical.</p><p>Finally, we examined empirical results from the paper <a href="https://doi.org/10.1038/s42256-024-00858-y"><em>Reconciling privacy and accuracy in AI for medical imaging</em></a> to find out how <strong><em>high-budget differential privacy</em> can be used to escape the false dichotomy of bank vault door vs. no door</strong> and protect patient privacy in the real world without sacrificing model accuracy in the process.</p><p>If you enjoyed this article, please consider following me on <a href="https://www.linkedin.com/in/jhyahav/">LinkedIn</a> to keep up with future articles and projects.</p><h4>References</h4><p>[1] <strong>Ziller, A., Mueller, T.T., Stieger, S. <em>et al.</em></strong> Reconciling privacy and accuracy in AI for medical imaging. <em>Nat Mach Intell</em> <strong>6</strong>, 764–774 (2024). <a href="https://doi.org/10.1038/s42256-024-00858-y">https://doi.org/10.1038/s42256-024-00858-y</a>.</p><p>[2] <strong>Ray, S.</strong> Samsung bans ChatGPT and other chatbots for employees after sensitive code leak. <em>Forbes</em> (2023). <a href="https://www.forbes.com/sites/siladityaray/2023/05/02/samsung-bans-chatgpt-and-other-chatbots-for-employees-after-sensitive-code-leak/">https://www.forbes.com/sites/siladityaray/2023/05/02/samsung-bans-chatgpt-and-other-chatbots-for-employees-after-sensitive-code-leak/</a>.</p><p>[3] <strong>Ateniese, G., Mancini, L. V., Spognardi, A. <em>et al.</em></strong> Hacking smart machines with smarter ones: how to extract meaningful data from machine learning classifiers. <em>International Journal of Security and Networks</em> <strong>10</strong>, 137–150 (2015). <a href="https://doi.org/10.48550/arXiv.1306.4447">https://doi.org/10.48550/arXiv.1306.4447</a>.</p><p>[4] <strong>Dinur, I. &amp; Nissim, K.</strong> Revealing information while preserving privacy. <em>Proc. 22nd ACM SIGMOD-SIGACT-SIGART Symp Principles Database Syst</em> 202–210 (2003). <a href="https://doi.org/10.1145/773153.773173">https://doi.org/10.1145/773153.773173</a>.</p><p>[5] <strong>Dwork, C. &amp; Roth, A.</strong> The algorithmic foundations of differential privacy. <em>Foundations and Trends in Theoretical Computer Science</em> <strong>9</strong>, 211–407 (2014). <a href="https://doi.org/10.1561/0400000042">https://doi.org/10.1561/0400000042</a>.</p><p>[6] <strong>Dwork, C., Kohli, N. &amp; Mulligan, D.</strong> Differential privacy in practice: expose your epsilons! <em>Journal of Privacy and Confidentiality</em> <strong>9</strong> (2019). <a href="https://doi.org/10.29012/jpc.689">https://doi.org/10.29012/jpc.689</a>.</p><p>[7] <strong>Mei, X., Liu, Z., Robson, P.M. <em>et al.</em></strong> RadImageNet: an open radiologic deep learning research dataset for effective transfer learning. <em>Radiol Artif Intell</em> <strong>4.5</strong>, e210315 (2022). <a href="https://doi.org/10.1148/ryai.210315">https://doi.org/10.1148/ryai.210315</a>.</p><p>[8] <strong>Tschandl, P., Rosendahl, C. &amp; Kittler, H.</strong> The HAM10000 dataset, a large collection of multi-source dermatoscopic images of common pigmented skin lesions. <em>Sci Data</em> <strong>5</strong>, 180161 (2018). <a href="https://doi.org/10.1038/sdata.2018.161">https://doi.org/10.1038/sdata.2018.161</a>.</p><p>[9] <strong>Antonelli, M., Reinke, A., Bakas, S. <em>et al.</em></strong> The Medical Segmentation Decathlon. <em>Nat Commun</em> <strong>13</strong>, 4128 (2022). <a href="https://doi.org/10.1038/s41467-022-30695-9">https://doi.org/10.1038/s41467-022-30695-9</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e6ff4e4a2e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Statistical Learnability of Strategic Linear Classifiers: A Proof Walkthrough]]></title>
            <link>https://medium.com/data-science/statistical-learnability-of-strategic-linear-classifiers-a-proof-walkthrough-e80db99d6c4e?source=rss-ef72e1b40cd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/e80db99d6c4e</guid>
            <category><![CDATA[thoughts-and-theory]]></category>
            <category><![CDATA[classification-algorithms]]></category>
            <category><![CDATA[game-theory]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[vc-dimension]]></category>
            <dc:creator><![CDATA[Jonathan Yahav]]></dc:creator>
            <pubDate>Wed, 08 Jan 2025 17:01:43 GMT</pubDate>
            <atom:updated>2025-01-08T17:01:43.108Z</atom:updated>
            <content:encoded><![CDATA[<h4>With the help of an intricate geometric construction, we can prove that instance-wise cost functions quickly drive SVC to infinity.</h4><p>In the <a href="https://towardsdatascience.com/quantifying-the-complexity-and-learnability-of-strategic-classification-problems-fd04cbfdd4b9">previous article in this series</a>, we examined the concept of <em>strategic VC dimension</em> (SVC) and its connection to the <em>Fundamental Theorem of Strategic Learning</em>. We will make use of both of those in this article, alongside the ideas of <em>achievable labelings</em> and <em>strategic shattering coefficients</em> that we explored in the lead-up to them.</p><p><a href="https://towardsdatascience.com/quantifying-the-complexity-and-learnability-of-strategic-classification-problems-fd04cbfdd4b9">Quantifying the Complexity and Learnability of Strategic Classification Problems</a></p><p><strong>If you haven’t read the </strong><a href="https://towardsdatascience.com/extending-pac-learning-to-a-strategic-classification-setting-6c374935dde2"><strong>first article in this series</strong></a><strong> yet, I encourage you to start from there before moving on to the aforementioned article on SVC:</strong></p><p><a href="https://towardsdatascience.com/extending-pac-learning-to-a-strategic-classification-setting-6c374935dde2">Extending PAC Learning to a Strategic Classification Setting</a></p><p>With the context from the other articles in this series in place, <strong>a basic grasp of set theory and geometry will be all you’ll need to understand the theorem and its proof.</strong></p><h4>How an Instance-Wise Cost Function Affects SVC: Stating the Theorem</h4><p>As we saw, SVC can be used as a tool to estimate the expressive power of a hypothesis class within a strategic classification context. Having carefully defined SVC as a generalization of the canonical VC dimension, we understand that the two have much in common. When, though, does SVC diverge from its canonical counterpart? Can we come up with a scenario in which the strategic aspect of a classification problem significantly increases its complexity?<strong> It turns out we can, with relative ease: linear classification.</strong></p><p>Linear classification involves determining whether a data point should be positively or negatively classified based on a linear function applied to its features. Geometrically, we can imagine a linear classifier inducing a linear decision boundary in <em>d</em>-dimensional real space (ℝ<em>ᵈ </em>). Anything on one side of the boundary is positively classified, and anything on the other side is negatively classified. In one-dimensional space, the decision boundary is a threshold (<a href="https://towardsdatascience.com/quantifying-the-complexity-and-learnability-of-strategic-classification-problems-fd04cbfdd4b9#4322">as we saw in the previous article</a>). In two-dimensional space, it’s a line dividing the plane. In general, it’s a <a href="https://en.wikipedia.org/wiki/Hyperplane">hyperplane</a>.</p><p><strong>In canonical binary classification, the VC dimension of the hypothesis class comprising all linear classifiers in ℝ<em>ᵈ </em>is <em>d + 1</em></strong>, <strong>which is finite.</strong> For example, for <em>d</em> = 2 (linear classifiers in <strong>ℝ</strong>²), the VC dimension is 3. The <a href="https://www.cs.princeton.edu/courses/archive/spring16/cos511/lec17.pdf">Fundamental Theorem of Statistical Learning</a> dictates that <strong>canonical linear classification is therefore PAC learnable.⁽¹⁾</strong></p><p><strong>Intuitively, we might expect the same conclusion to hold for the strategic analog of the problem.</strong> After all, linear classifiers are some of the simplest classifiers there are, and reasoning about them can be rather natural.<strong>⁽²⁾</strong></p><p><strong>However, that simplicity goes out the window as soon as we throw <em>instance-wise</em> cost functions into the mix. As we will prove:</strong></p><blockquote><em>Given a strategic linear classification problem Sᴛʀᴀᴄ⟨</em>H<em>, </em>R<em>, </em>c<em>⟩, </em><strong><em>there exists an</em></strong><em> </em><strong><em>instance-wise cost function</em></strong><em> </em><strong>c<em>(</em>z<em>; </em>x<em>)</em></strong><em> </em><strong><em>= ℓ</em>ₓ<em>(</em>z - x<em>)</em></strong><em> </em><strong><em>such that SVC(</em>H<em>, </em>R<em>, </em>c<em>) = </em>∞.</strong></blockquote><p>In other words, using the <a href="https://towardsdatascience.com/quantifying-the-complexity-and-learnability-of-strategic-classification-problems-fd04cbfdd4b9#8540"><em>Fundamental Theorem of Strategic Learning</em></a>, we find that <strong>linear classification in a strategic setting equipped with an <em>instance-wise</em> cost function is not generally PAC learnable.</strong> Interestingly, it will not be PAC learnable even if we strip away as much complexity as we can. In this case, we will do so by <strong>focusing on strategic linear classification on the Cartesian plane ( <em>X </em>⊆ ℝ²) with the homogeneous preference class (<em>R</em> = { 1 }).</strong></p><p><strong>The more general conclusion will follow from the counterexample we will show under those simplifying conditions. </strong>If strategic linear classification is not PAC learnable in ℝ², there is no way it could be PAC learnable in any higher dimension. Likewise, every other preference class we laid out in our setup is a strict generalization of the homogeneous preference class. If we could prove PAC learnability for any of those preference classes, we would also be able to do so for the simpler case where <em>R</em> = { 1 }.</p><h4>From Labelings to Points on the Unit Circle: Proof Setup</h4><p>Based on the assumptions above, we begin by turning our attention to the special case <strong>Sᴛʀᴀᴄ⟨<em>Hₗ</em>, { 1 }, <em>c</em>⟩, </strong>with <em>Hₗ </em>being the hypothesis class comprising all linear classifiers in ℝ². We then initialize <em>n</em> two-dimensional feature vectors at the origin: ∀ <em>i</em> ≤ <em>n </em>. <em>xᵢ</em> = (0, 0). Since we’re using the homogeneous preference class, we have that ∀ <em>i</em> ≤ <em>n </em>. <em>rᵢ</em> = 1. <strong>The only difference between the data points will be in how our cost function behaves on each of them.</strong> This is where the crux of the proof lies, as we will soon see.</p><p>Before we discuss the cost function at length, though, <strong>we need to <em>geometrize </em>the </strong><a href="https://towardsdatascience.com/quantifying-the-complexity-and-learnability-of-strategic-classification-problems-fd04cbfdd4b9#4322"><strong>possible labelings</strong></a><strong> of our unlabeled data points.</strong> As we saw <a href="https://towardsdatascience.com/quantifying-the-complexity-and-learnability-of-strategic-classification-problems-fd04cbfdd4b9">last time</a>,<strong> a set of <em>n</em> unlabeled data points must have exactly 2<em>ⁿ</em> possible labelings.</strong> Representing a set of labelings (<em>n</em>-tuples) geometrically in ℝ² is relatively straightforward: we simply select an arbitrary point for each possible labeling. In particular, we will <strong>choose 2<em>ⁿ</em> such representative points</strong> <strong><em>on the unit circle</em>,</strong> <strong>each assigned to a possible labeling.</strong> While the particular coordinates of the representative points themselves are unimportant, <strong>we <em>do </em>require that each such point be unique.</strong> We also require that no two points be origin-symmetric with respect to one another.</p><p>We will <strong>denote this set of representative points by <em>S</em>.</strong> Having selected our representative points, we use them to define the <strong>origin-symmetric set <em>S’,</em></strong> i.e., <em>S’</em> = { (-<em>x</em>, -<em>y</em>) : (<em>x</em>, <em>y</em>) ∈ <em>S </em>}. Note that <em>S</em> and <em>S’ </em>are disjoint (<em>S</em> ∩ <em>S’</em> = ∅) as a consequence of how we selected the points in <em>S</em>.</p><p>For a particular <em>x</em>ᵢ, <strong>we define <em>Sᵢ </em>as the subset of S that includes only the points that represent labelings in which <em>x</em>ᵢ is positively classified. </strong>Similarly, we derive the origin-symmetric <em>Sᵢ’ </em>⊂ <em>S’</em> from <em>Sᵢ</em>. In the example below, the points above the <em>x</em>-axis are those representing labelings in which <em>x</em>ᵢ is positively classified, i.e., <em>Sᵢ</em>. Those below the <em>x</em>-axis comprise their origin-symmetric set <em>Sᵢ’</em> (with the numbering matching between symmetric pairs of points). Note that the selection of points above the <em>x</em>-axis is completely arbitrary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*-AenB5mfrqb6jxd2y6XDEA.png" /><figcaption><strong>Figure 1:</strong> An example of labeling geometrization for an arbitrary <em>x</em>ᵢ. Recall that we started by initializing all unlabeled data points as (0, 0). Points in <em>Sᵢ are numbered in black. Their origin-symmetric counterparts in Sᵢ’ are numbered in blue. </em>Image by the author, based on image by R. Sundaram, A. Vullikanti, H. Xu, F. Yao from <a href="https://arxiv.org/abs/2012.03310"><strong>PAC-Learning for Strategic Classification</strong></a> (use under<a href="https://creativecommons.org/licenses/by/4.0/"> CC-BY 4.0 license</a>).</figcaption></figure><p><strong>We proceed to construct a convex polygon <em>Gᵢ</em>, with its vertices being the points in <em>Sᵢ</em> ∪ <em>Sᵢ’</em>.</strong> The <em>Gᵢ</em> for each unlabeled data point will be key in designing an instance-wise cost function <em>c</em> with which we will always be able to achieve all possible labelings, thus showing that SVC(<em>Hₗ</em>, { 1 }, <em>c</em>) = ∞. Towards this end, the convexity of <em>Gᵢ </em>will prove critical, as will its origin symmetry (stemming from our choice of <em>Sᵢ’ </em>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*5HfGStJrf3PXZAgA9U4jVA.png" /><figcaption><strong>Figure 2: </strong>The convex, origin-symmetric polygon Gᵢ derived from <em>Sᵢ and Sᵢ’ as shown in Figure 1. </em>Image by the author, based on image by R. Sundaram, A. Vullikanti, H. Xu, F. Yao from <a href="https://arxiv.org/abs/2012.03310"><strong>PAC-Learning for Strategic Classification</strong></a> (use under<a href="https://creativecommons.org/licenses/by/4.0/"> CC-BY 4.0 license</a>).</figcaption></figure><h4>Turning Polygons into Preferences: Constructing the Cost Function</h4><p>For each of the <em>n</em> origin-initialized, unlabeled data points we started with, we now have a convex, origin-symmetric polygon that represents the labelings in which it is positively classified. <strong>Each <em>Gᵢ</em> can now be used to define the behavior of our instance-wise cost function <em>c</em> on its corresponding <em>xᵢ</em>.</strong> We will use <em>Gᵢ </em>to define a seminorm<strong>⁽³⁾</strong>:</p><blockquote><strong><em>∥ </em>y <em>∥</em>ɢᵢ = <em>inf { ε ∈ </em>ℝ⁺ <em>: </em>y<em> ∈ ε</em>Gᵢ <em>}</em></strong></blockquote><p>This definition implies that <strong>the distance between <em>xᵢ</em> and some point <em>z</em> is less than 1 if and only if <em>z </em>lies within <em>Gᵢ.</em></strong> I.e.:</p><blockquote><em>∥ </em>z - xᵢ <em>∥</em>ɢᵢ <em>&lt; 1 ⇔ </em>z <em>∈ </em>Gᵢ</blockquote><p><strong>For the rest of the proof, it is sufficient that we understand this connection between ∥ ⋅ ∥<em>ɢᵢ </em>and a point being inside <em>Gᵢ.</em></strong><em> </em>(See Footnote (3) for a discussion of why ∥ ⋅ ∥<em>ɢᵢ </em>qualifies as a seminorm and for more details about its geometric interpretation.)</p><p><strong>We thus define the instance-wise cost function <em>c</em>:</strong></p><blockquote>c<em>(</em>z<em>; </em>xᵢ<em>) = ℓ</em>ᵢ<em>(</em>z<em> - </em>xᵢ<em>)</em></blockquote><p><strong>Where:</strong></p><blockquote><em>ℓ</em>ᵢ<em>(</em>z<em> - </em>xᵢ<em>) = ∥ </em>z<em> - </em>xᵢ <em>∥</em>ɢᵢ</blockquote><p><strong>That is, for each unlabeled data point <em>xᵢ</em>, <em>c</em> behaves as ∥ ⋅ ∥<em>ɢᵢ </em>would.</strong> Note that this behavior is different for each data point. This is because we constructed a unique <em>Gᵢ </em>for every <em>xᵢ</em>, and each ∥ <strong>⋅</strong> ∥<em>ɢᵢ</em> is derived from its corresponding polygon <em>Gᵢ</em>.</p><h4>Data Point Best Response as a Result of the Cost Function</h4><p>With the instance-wise cost function <em>c</em> in place, <strong>we may turn our attention to how our data points interact with linear classifiers.</strong> Recall that we have constrained our consideration to the homogeneous preference class, meaning that <em>r</em> = 1 for all of our points. I.e., <em>xᵢ</em> stands to gain a reward of magnitude 1 for being positively classified. Given a linear classifier, <strong>each data point will thus be willing to incur any cost less than 1 to manipulate its feature vector to ensure it falls on the positive side of the decision boundary. </strong>This will guarantee it receives positive utility as a result of the manipulation.</p><p><em>c</em> is designed so that a data point with feature vector <em>xᵢ</em> has to pay ∥ <em>z</em> - <em>xᵢ</em> ∥<em>ɢᵢ</em> to change its feature vector to <em>z</em>. As we saw,<strong> </strong>as long as <em>z</em> lies inside <em>Gᵢ</em>, this cost will be less than 1.</p><p><strong>Suppose we have a decision boundary that crosses <em>Gᵢ </em></strong>(intersects it at two points) <strong>with <em>xᵢ</em> falling on its negative half-plane<em>.</em> As illustrated in Figure 3 below,</strong> this creates a sub-polygon such that for any <em>z</em> within it:</p><ul><li>The cost to move to <em>z</em> is less than 1: <em>c</em>(<em>z</em>; <em>xᵢ</em>) = ∥ <em>z</em> — <em>xᵢ</em> ∥<em>ɢᵢ </em>&lt; 1</li><li>The <a href="https://towardsdatascience.com/extending-pac-learning-to-a-strategic-classification-setting-6c374935dde2#2a1e">realized reward</a> for moving is precisely 1: 𝕀(<em>h</em>(<em>z</em>) = 1) ⋅ <em>r </em>= 1</li></ul><p>Whereby the utility for data point <em>i</em>, 𝕀(<em>h</em>(<em>z</em>) = 1) ⋅ <em>r -</em> <em>c</em>(<em>z</em>; <em>xᵢ</em>), is positive, in turn making any such <em>z</em> a better response than non-manipulation. In other words, <strong>the data point will always want to manipulate its feature vector into one that lies in this sub-polygon.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*8s638E5PYI66iPYIK6QahQ.png" /><figcaption><strong>Figure 3:</strong> An example of a linear classifier with a decision boundary that properly intersects <em>Gᵢ, with xᵢ</em> falling on its negative half-plane<em>. The resulting “Goldilocks zone” between the decision boundary and the perimeter of Gᵢ is shaded in green. Changing xᵢ to any z lying in this area confers </em><strong><em>positive utility.</em></strong><em> This is because the reward gained is 1 and the cost incurred is less than 1. </em>Image by the author, based on image by R. Sundaram, A. Vullikanti, H. Xu, F. Yao from <a href="https://arxiv.org/abs/2012.03310"><strong>PAC-Learning for Strategic Classification</strong></a> (use under<a href="https://creativecommons.org/licenses/by/4.0/"> CC-BY 4.0 license</a>).</figcaption></figure><p><strong>Conversely, given a decision boundary that does <em>not </em>cross <em>Gᵢ</em>,</strong> no such sub-polygon exists. The cost of manipulating <em>xᵢ</em> to cross the boundary will always be greater than 1, and thus not worth the reward. <strong>The data point best response will be the original feature vector, meaning it’s best to stay put.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*bqmURetZfDaHyMXN6xAVRw.png" /><figcaption><strong>Figure 4:</strong> An example of a polygon <em>Gᵢ and a </em>linear classifier with a decision boundary that <strong>does not</strong> cross <em>it</em>. Note how<strong> there are no points that are both on the positive side of the decision boundary and inside <em>Gᵢ.</em></strong><em> Equivalently, there are no vectors into which the data point could manipulate its feature vector for positive utility. </em>Image by the author, based on image by R. Sundaram, A. Vullikanti, H. Xu, F. Yao from <a href="https://arxiv.org/abs/2012.03310"><strong>PAC-Learning for Strategic Classification</strong></a> (use under<a href="https://creativecommons.org/licenses/by/4.0/"> CC-BY 4.0 license</a>).</figcaption></figure><h4>Isolating Representative Points Using Linear Classifiers</h4><p>We now understand the strategic implications of whether or not a certain decision boundary crosses <em>Gᵢ</em>. Calling to mind the role of our points on the unit circle as representatives of possible labelings, <strong>we can demonstrate the connection between labelings where a data point is positively classified and linear classifiers.</strong></p><p>Let 𝓛 be an arbitrary labeling of our <em>n</em> data points, and let <em>sₗ </em>∈ <em>S</em> be its unique representative point on the unit circle. Let <em>x</em>ᵢ be one of our unlabeled data points. We will explore the behavior of the data point with respect to a particular linear classifier, denoted <em>hₗ</em>. <strong>We require that the decision boundary induced by <em>hₗ</em> do the following:</strong></p><ol><li>Cross the unit circle.</li><li>Strictly separate <em>sₗ</em> from all other points in <em>S</em> ∪ <em>S’</em>.</li><li>Positively classify <em>sₗ</em>.</li></ol><p><strong>The structure of <em>S</em> ∪ <em>S’</em> guarantees that such an <em>hₗ</em> exists.⁽⁴⁾</strong></p><p>With <em>hₗ</em> at our disposal, we may explore how our cost function <em>c</em> interacts with <em>hₗ </em>for <em>xᵢ</em> depending on whether or not <em>x</em>ᵢ should be positively classified under 𝓛. <strong>In fact, we will prove that a data point is positively classified by <em>hₗ</em> if and only if it is positively labeled under 𝓛.</strong></p><p>Let us first consider the case in which<strong> we want <em>xᵢ</em> to be <em>positively</em> labeled (see Figure 5).</strong> Recall that we defined <em>Sᵢ </em>as “the subset of <em>S</em> that includes only the points that represent labelings in which <em>xᵢ</em> is positively classified.” We know, then, that <strong><em>sₗ</em> ∈ <em>Sᵢ</em>. </strong>In particular, <em>sₗ</em> must be one of the vertices of <em>Gᵢ</em>. The fact that <em>hₗ</em> strictly separates <em>sₗ</em> from all other points in <em>S</em> ∪ <em>S’</em> means that it is strictly separated from the other vertices of <em>Gᵢ</em>. <strong>Hence, <em>hₗ</em> must cross <em>Gᵢ, </em>incentivizing the data point to manipulate its feature vector.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*bGxEtuoR4M3jmO5jFIJFcw.png" /><figcaption><strong>Figure 5:</strong> If <em>x</em>ᵢ should be positively labeled under 𝓛<strong>,</strong> <strong><em>hₗ</em> crosses <em>Gᵢ. </em></strong><em>This incentivizes the data point to manipulate its feature vector (see </em><strong><em>Figure 3</em></strong><em>). </em>Image by R. Sundaram, A. Vullikanti, H. Xu, F. Yao from <a href="https://arxiv.org/abs/2012.03310"><strong>PAC-Learning for Strategic Classification</strong></a> (use under<a href="https://creativecommons.org/licenses/by/4.0/"> CC-BY 4.0 license</a>).</figcaption></figure><p>We proceed to examine the case in which<strong> we want <em>xᵢ</em> to be <em>negatively </em>labeled under 𝓛 (see Figure 6). </strong>As a result of how we constructed <em>Sᵢ</em>, <strong><em>sₗ</em> ∉ <em>Sᵢ</em>. </strong>Additionally, having required that the origin-symmetric <em>S’ </em>be disjoint from <em>S</em>, we know that <strong><em>sₗ</em> ∉ <em>Sᵢ’</em>.</strong> It follows that <strong><em>sₗ </em>is not a vertex of <em>Gᵢ</em></strong>. Once again, <em>hₗ</em> strictly separates <em>sₗ</em> from all other points in <em>S</em> ∪ <em>S’, </em>including all the vertices of <em>Gᵢ</em>. Because <em>Gᵢ </em>is convex, we conclude that <strong>any point in <em>Gᵢ</em> is on the opposite side of <em>hₗ</em> as <em>sₗ</em>.</strong> In other words, <strong><em>hₗ</em> does not cross <em>Gᵢ</em>.</strong> Consequently,<strong> the data point will choose to stay put</strong> rather than “overpaying” to manipulate its feature vector to cross <em>hₗ</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*Dd-lxJIRAn5vDuEpUE9saw.png" /><figcaption><strong>Figure 6:</strong> If <em>x</em>ᵢ should be positively labeled under 𝓛,<strong> <em>hₗ</em> does not cross <em>Gᵢ. </em></strong><em>This incentivizes the data point </em><strong><em>not</em></strong><em> to manipulate its feature vector (see </em><strong><em>Figure 4</em></strong><em>). </em>Image by R. Sundaram, A. Vullikanti, H. Xu, F. Yao from <a href="https://arxiv.org/abs/2012.03310"><strong>PAC-Learning for Strategic Classification</strong></a> (use under<a href="https://creativecommons.org/licenses/by/4.0/"> CC-BY 4.0 license</a>).</figcaption></figure><p><strong>In summary, our unlabeled data point <em>xᵢ</em> will engage in manipulation to cross <em>hₗ </em>if and only if 𝓛 dictates that the data point should be positively classified.</strong> In our strategic classification setting, this means that <strong><em>hₗ </em>positively classifies a data point if and only if that data point should be positively labeled according to 𝓛.</strong></p><h4>Putting It All Together: Inducing an Arbitrary Labeling</h4><p>Using what we have seen so far, we are able to demonstrate that we can achieve any labeling of our <em>n</em> data points we want. <strong>Overlaying all of our data points and their respective polygons </strong>(see Figure 7),<strong> </strong>we can see that <strong>given a labeling 𝓛, we are able to achieve it</strong> with the help of a corresponding linear classifier <em>hₗ</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GE6Ye2y0EECzktY3rNkSsw.png" /><figcaption><strong>Figure 7:</strong> Simplified visualization of overlaid data points with their corresponding cost function polygons. <strong><em>sₗ represents a labeling </em></strong>𝓛 <strong><em>in which data point i should be positively classified and data point j should be negatively classified.</em></strong><em> The unmanipulated feature vectors of the two overlap at (0, 0). However, </em><strong><em>data point i will be positively classified by hₗ </em></strong><em>because it will move to the positive side of the decision boundary induced by hₗ (since the boundary crosses Gᵢ). </em><strong><em>Data point j will stay on the negative side</em></strong><em> because the boundary does not cross Gⱼ. </em>Image by the author, based on images by R. Sundaram, A. Vullikanti, H. Xu, F. Yao from <a href="https://arxiv.org/abs/2012.03310"><strong>PAC-Learning for Strategic Classification</strong></a> (use under<a href="https://creativecommons.org/licenses/by/4.0/"> CC-BY 4.0 license</a>).</figcaption></figure><p>Any data point <em>xᵢ</em> that 𝓛 rules should be positively classified will manipulate its feature vector and move to the positive side of the decision boundary created by <em>hₗ </em>(like the case in Figure 5). At the same time, any data point <em>xⱼ</em> that should be negatively classified will not be sufficiently incentivized to manipulate its feature vector, causing it to stay on the negative side of the decision boundary. <strong>Across all <em>n</em> data points, those that will be positively classified will be <em>exactly </em>the ones that 𝓛 dictates should be positively classified. In other words, we can induce any labeling we wish.</strong></p><p>We therefore have a sample of <em>n </em>unlabeled, potentially-manipulated data points that is <strong>strategically shattered by <em>Hₗ</em>,</strong> the hypothesis class of all linear classifiers in ℝ². Based on <a href="https://towardsdatascience.com/quantifying-the-complexity-and-learnability-of-strategic-classification-problems-fd04cbfdd4b9#974a">how we defined strategic shattering coefficients</a>, we find that <strong>σ<em>ₙ</em>(<em>Hₗ, </em>{ 1 }<em>, c</em>) = 2<em>ⁿ</em>.</strong> <strong>It follows that SVC(<em>Hₗ, </em>{ 1 }<em>, c</em>) = ∞.</strong></p><h4>Conclusion</h4><p>First, <strong>we posed linear classification</strong> as a problem that is canonically PAC learnable, but <strong>not generally strategic PAC learnable.</strong> Second, we simplified our strategic classification problem by limiting our consideration to <strong>the homogeneous preference class on the Cartesian plane.</strong> Given <em>n</em> origin-initialized data points, <strong>we mapped each of their 2<em>ⁿ</em> possible labelings to a unique representative point</strong> on the unit circle. We then <strong>created a polygon for each data point </strong>using the representative points corresponding to the labelings under which it should be positively classified.</p><p>Based on those polygons, <strong>we constructed an instance-wise cost function, <em>c</em>, </strong>for which the cost of feature manipulation is less than 1 only within each polygon. Next, we showed that <strong>for any labeling </strong>𝓛<strong>, we could find a linear classifier that isolates its respective representative point.</strong> Such a classifier, paired with <em>c</em>, ensured that <strong>only the data points that are <em>supposed </em>to be positively classified according to </strong>𝓛<strong> are incentivized to manipulate their feature vectors</strong> to cross the decision boundary and end up with a positive label. Finally, we explained why that means that <strong>the SVC of the problem is infinite.</strong></p><h4>Acknowledgments</h4><p><strong>Writing this series of articles has been a wonderful journey, and I’m truly grateful to everyone who took the time to read them,</strong> especially those who reached out with feedback. This series wouldn’t have been possible without the authors of <a href="https://arxiv.org/abs/2012.03310">PAC-Learning for Strategic Classification</a>: <strong>Ravi Sundaram, Anil Vullikanti, Haifeng Xu,</strong> and<strong> Fan Yao.</strong> They set the stage beautifully for a deep dive into this fascinating meeting point between machine learning and game theory. Thank you to the <a href="https://medium.com/u/7e12c71dfa81"><strong>TDS Editors</strong></a>, particularly <a href="https://medium.com/u/e6ad8abedec9"><strong>Ben Huberman</strong></a> and <a href="https://medium.com/u/895063a310f4"><strong>Ludovic Benistant</strong></a>, for their support and for giving me such a fantastic platform to share my writing. Lastly, a huge thank you to <strong>Prof. Inbal Talgam-Cohen</strong> for sowing the seeds that grew into this series in the seminar she taught last winter.</p><p>If you enjoyed these articles, please consider following me on <a href="https://jhyahav.medium.com/">Medium</a> and <a href="https://www.linkedin.com/in/jhyahav/">LinkedIn</a> to keep up with future articles and projects.</p><h4>Footnotes</h4><p><strong>(1)</strong> See a proof of this result, as well as a great interactive explanation of linear classification, <a href="https://mlweb.loria.fr/book/en/VCdimhyperplane.html"><strong>here</strong></a><strong>.</strong> What we refer to as a “linear classifier” throughout this article is technically an <em>affine</em> classifier.</p><p><strong>(2)</strong> Indeed, the paper shows that restricting our consideration to <em>instance-invariant</em> cost functions yields a problem that <strong><em>is</em></strong><em> </em>PAC learnable, just like the in the canonical setting. For a refresher on the difference between instance-invariant and instance-wise cost functions, see <a href="https://towardsdatascience.com/extending-pac-learning-to-a-strategic-classification-setting-6c374935dde2#d9f5">the first article in this series</a>.</p><p><strong>(3) ∥ ⋅ ∥<em>ɢᵢ </em>as we defined it is the </strong><a href="https://en.wikipedia.org/wiki/Minkowski_functional"><strong><em>Minkowski functional</em></strong></a><strong> of <em>Gᵢ. </em></strong>In this context, we view <em>Gᵢ </em>as the set of points enclosed in the polygon we constructed. The Minkowski functional <strong>generalizes </strong>the notion of a seminorm. Recall that in <a href="https://towardsdatascience.com/extending-pac-learning-to-a-strategic-classification-setting-6c374935dde2#d9f5">the first article in this series</a>, <strong>we assumed our cost function is induced by seminorms.</strong> We would be remiss not to reconcile this assumption with the construction of ∥ ⋅ ∥<em>ɢᵢ.</em></p><p>Fortunately, it can be proven that <a href="https://proofwiki.org/wiki/Minkowski_Functional_of_Symmetric_Convex_Absorbing_Set_in_Real_Vector_Space_is_Seminorm">the Minkowski functional of a set <em>A</em> is a seminorm under certain conditions</a> [2]:</p><ul><li><em>A</em> is a subset of a vector space over <strong>ℝ</strong>.</li><li><em>A</em> is convex.</li><li><em>A</em> is symmetric.</li><li><em>A</em> is an absorbing set.</li></ul><p>Even more fortunately (or rather, by meticulous design),<em> </em><strong><em>Gᵢ </em>fulfills<em> </em>all of these conditions:</strong></p><ul><li><em>Gᵢ </em>is a subset of ℝ², which is a vector space over <strong>ℝ.</strong></li><li><em>Gᵢ </em>is a convex set since it is bounded by a convex polygon.</li><li><em>Gᵢ</em> is origin-symmetric.<em> </em><strong>(This is why we needed the <em>Sᵢ’</em> in the first place!)</strong></li><li><em>Gᵢ </em>is a convex subset of the topological vector space ℝ² equipped with the standard topology induced by the Euclidean norm. <em>Gᵢ </em>also contains the origin in its interior. <a href="https://proofwiki.org/wiki/Convex_Subset_of_Topological_Vector_Space_containing_Zero_Vector_in_Interior_is_Absorbing_Set">Therefore, <em>Gᵢ</em> is an absorbing set</a> [3].</li></ul><p><strong>∥ ⋅ ∥<em>ɢᵢ </em>is therefore a seminorm for all <em>i</em>, enabling us to continue the proof without violating our assumptions.</strong></p><p><strong>(4) </strong>Let <em>P</em> be the convex hull of (<em>S</em> ∪ <em>S’</em>)<em> </em>\<em> sₗ</em>. Note that <em>S</em> ∪ <em>S’</em> is finite. It can be proven that the convex hull of a finite set in ℝ² is compact [4]. As a singleton, { <em>sₗ</em> } is closed. Clearly, (<em>S</em> ∪ <em>S’</em>)<em> </em>\<em> sₗ</em> and <em>sₗ</em> are disjoint. <strong>It follows from the </strong><a href="https://en.wikipedia.org/wiki/Hyperplane_separation_theorem"><strong>hyperplane separation theorem</strong></a><strong> that there exists a hyperplane that strictly separates the two.</strong></p><p><strong>Let us also show that the linear decision boundary induced by the aforementioned hyperplane must intersect the unit circle at two points.</strong> Recall that a line may intersect a circle at exactly zero, one, or two points.</p><ul><li>Suppose for the sake of contradiction that the decision boundary and the unit circle are disjoint. Then all points in the unit circle must lie on the same side of the decision boundary, contradicting the assumption that <em>hₗ </em>separates (<em>S</em> ∪ <em>S’</em>)<em> </em>\<em> sₗ</em> from <em>sₗ.</em></li><li>Due to the fact that the separation is strict, <em>sₗ</em> may not lie on the decision boundary, whereby the latter cannot be tangent to the unit circle.</li><li>The only remaining possibility is that the decision boundary crosses the unit circle.</li></ul><p>As for ensuring <em>hₗ</em> positively classifies <em>sₗ,</em> it is completely up to us which side of the boundary we wish to classify positively.</p><h4>References</h4><p>[1] R. Sundaram, A. Vullikanti, H. Xu, F. Yao. <a href="https://arxiv.org/abs/2012.03310">PAC-Learning for Strategic Classification</a> (2021), International Conference on Machine Learning.</p><p>[2] ProofWiki contributors. <a href="https://proofwiki.org/wiki/Minkowski_Functional_of_Symmetric_Convex_Absorbing_Set_in_Real_Vector_Space_is_Seminorm">Minkowski functional of symmetric convex absorbing set in real vector space is seminorm</a>.</p><p>[3] ProofWiki contributors. <a href="https://proofwiki.org/wiki/Convex_Subset_of_Topological_Vector_Space_containing_Zero_Vector_in_Interior_is_Absorbing_Set">Convex subset of topological vector space containing zero vector in interior is absorbing set</a>.</p><p>[4] Math Stack Exchange contributors. <a href="https://math.stackexchange.com/a/749839">Is convex hull of a finite set of points in R² closed?</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e80db99d6c4e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/statistical-learnability-of-strategic-linear-classifiers-a-proof-walkthrough-e80db99d6c4e">Statistical Learnability of Strategic Linear Classifiers: A Proof Walkthrough</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quantifying the Complexity and Learnability of Strategic Classification Problems]]></title>
            <link>https://medium.com/data-science/quantifying-the-complexity-and-learnability-of-strategic-classification-problems-fd04cbfdd4b9?source=rss-ef72e1b40cd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd04cbfdd4b9</guid>
            <category><![CDATA[game-theory]]></category>
            <category><![CDATA[classification-algorithms]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[vc-dimension]]></category>
            <category><![CDATA[thoughts-and-theory]]></category>
            <dc:creator><![CDATA[Jonathan Yahav]]></dc:creator>
            <pubDate>Fri, 12 Apr 2024 19:35:33 GMT</pubDate>
            <atom:updated>2025-01-09T21:26:22.004Z</atom:updated>
            <content:encoded><![CDATA[<h4>How generalizing the notion of VC dimension to a strategic setting can help us understand whether or not a problem is learnable</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fi2bW5KpzA0ErFsBtd5BLw.jpeg" /><figcaption>Image generated by the author using DALL-E 3.</figcaption></figure><p>In <a href="https://towardsdatascience.com/extending-pac-learning-to-a-strategic-classification-setting-6c374935dde2">the first article in this series</a>, we formally defined the <strong><em>strategic classification problem</em></strong>, denoted Sᴛʀᴀᴄ⟨<em>H</em>, <em>R</em>, <em>c</em>⟩<strong><em>, </em></strong>as a generalization of canonical binary classification. We did so based on the paper <a href="https://arxiv.org/abs/2012.03310"><strong><em>PAC-Learning for Strategic Classification</em></strong></a> (Sundaram, Vullikanti, Xu, &amp; Yao, 2021). Along the way, we explored why we should care about considering the various preferences of rational agents during classification and how we can do so (subject to certain assumptions). We will rely heavily on the concepts introduced in the previous article, so I encourage you to read it if you haven’t already.</p><p><a href="https://towardsdatascience.com/extending-pac-learning-to-a-strategic-classification-setting-6c374935dde2">Extending PAC Learning to a Strategic Classification Setting</a></p><p>We’ll pick up where we left off, <strong>using the definition of Sᴛʀᴀᴄ⟨<em>H</em>, <em>R</em>, <em>c</em>⟩ as a jumping-off point for the useful concept of strategic VC dimension (SVC).</strong> Once we make sense of SVC, what I call<em> the</em> <em>Fundamental Theorem of Strategic Learning</em> will follow rather naturally.</p><p>While helpful,<strong> prior familiarity </strong>with shattering coefficients, the canonical VC dimension, and the <a href="https://www.cs.princeton.edu/courses/archive/spring16/cos511/lec17.pdf">Fundamental Theorem of Statistical Learning</a><strong> will not be necessary for you to follow along.</strong> However, there’s far more depth to each of them than I could ever hope to cover as part of this series, let alone in a single article. The curious reader is referred to <a href="https://medium.com/u/4688574fc42a">Andrew Rothman</a>’s wonderful and very thorough articles on the (canonical) shattering coefficient and VC dimension.</p><ul><li><a href="https://anr248.medium.com/statistical-learning-theory-part-5-shattering-coefficient-9fbce2bd98c2">Statistical Learning Theory Part 5: Shattering Coefficient</a></li><li><a href="https://anr248.medium.com/statistical-learning-theory-part-6-vapnik-chervonenkis-vc-dimension-47848a38b6e7">Statistical Learning Theory Part 6: Vapnik–Chervonenkis (VC) Dimension</a></li></ul><p>As we’ll see, <strong>strategic shattering coefficients and SVC are fairly natural generalizations of their canonical (i.e., non-strategic) counterparts.</strong> We will therefore begin with a brief rundown of each of those counterparts before explaining how they can be modified to work in a strategic setting.</p><h4>Counting Achievable Labelings: Canonical Shattering Coefficients</h4><p>Verbally defining shattering coefficients seems straightforward at first glance:</p><blockquote><em>Given a hypothesis class </em>H<em>,</em><strong><em> its </em>n<em>ᵗʰ shattering coefficient, denoted </em>Sₙ<em>(</em>H<em>), </em></strong><em>represents the </em><strong><em>largest number of labelings achievable by classifiers in </em>H<em> on a sample of </em>n<em> feature vectors.</em></strong></blockquote><p>But what is a “<em>labeling</em>”? And what makes it “<em>achievable</em>”? Answering those questions will help us lay some groundwork in pursuit of a more formal definition.</p><p>In the context of binary classification, a <strong>labeling </strong>of a sample of feature vectors is simply any one of the ways we can assign values from the set { -1, 1 } to those vectors. As a very simple example, consider two one-dimensional feature vectors (i.e., points on a number line), <em>x</em>₁ = 1 and <em>x</em>₂ = 2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M4CLjD0SsOGWhVbHbvnEQw.png" /><figcaption>A visualization of the four possible labelings of the sample <em>x</em>₁ = 1, <em>x</em>₂ = 2. Red points are negatively classified, blue ones are positively classified. Image by the author.</figcaption></figure><p>The possible labelings are any combination of the classification values we can assign the individual feature vectors independent of one another. We can represent each labeling as a vector, where the first and second coordinate represent the values assigned to <em>x</em>₁ and <em>x</em>₂, respectively. The set of possible labelings is thus { (-1, -1), (-1, 1), (1, -1), (1, 1) }. Note that a sample of size 2 yields 2² = 4 possible labelings — we’ll see how this generalizes to arbitrarily-sized samples soon.</p><p>We say that <strong>a labeling is <em>achievable </em>by a hypothesis class <em>H</em></strong> if there exists a classifier <em>h</em> ∈ <em>H</em> from which that labeling can result. Continuing with our simple example, suppose we are limited to classifiers of the form <em>x</em> ≥ <em>k</em>, k<em> </em>∈ ℝ, that is, one-dimensional thresholds such that anything to the right of the threshold is positively classified. The labeling (1, -1) is not achievable by this hypothesis class. <em>x</em>₂ being greater than <em>x</em>₁ implies that any threshold that classifies <em>x</em>₁ positively must do the same for <em>x</em>₂. The set of achievable labelings is therefore { (-1, -1), (-1, 1), (1, 1) }.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ii2Iq4gWYHb22y9mh5jpuA.png" /><figcaption>Examples of one-dimensional threshold classifiers that can be used to achieve all but one of the possible labelings of the sample <em>x</em>₁ = 1, <em>x</em>₂ = 2. Image by the author.</figcaption></figure><p>Having understood the basic terminology, we can start to develop some notation to formally express elements of the verbal definition with which we started.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VqexUr37XY3nsMqlycvnYw.png" /></figure><p>We stick to representing labelings as vectors as we did in our simple example, with each coordinate representing the classification value assigned to the corresponding feature vector. <strong>There are 2<em>ⁿ</em> possible labelings in total:</strong> there are two possible choices for each feature vector, and we can think of a labeling as a collection of <em>n</em> such choices, each made independently of the rest. <strong>If a hypothesis class <em>H</em> can achieve all possible labelings of a sample 𝒞<em>ₙ</em>, </strong>i.e., if the number of <em>achievable </em>labelings of 𝒞<em>ₙ</em> equals 2<em>ⁿ</em>,<strong> we say that <em>H shatters </em>𝒞<em>ₙ.</em></strong></p><p>Finally, using the notation from above, we converge on a more rigorous definition of <em>Sₙ</em>(<em>H</em>):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*usWmi70YKKgGVSK2fa72LA.png" /></figure><p>In keeping with our explanation of shattering, <strong><em>Sₙ</em>(<em>H</em>) equalling 2<em>ⁿ</em> implies that there exists a sample of size <em>n</em> that is shattered by <em>H</em>.</strong></p><h4>Estimating Hypothesis Class Expressiveness: Canonical VC Dimension</h4><p><strong>The Vapnik–Chervonenkis (VC) dimension is a way to gauge the expressive power of a hypothesis class. </strong>It’s based on the idea of shattering we just defined, and it plays an important role in helping us determine which hypothesis classes are PAC learnable and which aren’t.</p><p>Let’s begin by attempting to intuitively define the canonical VC dimension:</p><blockquote><em>Given a hypothesis class </em>H<em>, its VC dimension, denoted VCdim(</em>H<em>), is defined to be the greatest natural number </em>n<em> for which there exists a sample of size </em>n<em> that is </em><strong><em>shattered </em></strong><em>by </em>H<em>.</em></blockquote><p>Using <em>Sₙ</em>(<em>H</em>) enables us to express this much more cleanly and succinctly:</p><blockquote><em>VCdim(</em>H<em>)</em> = <em>max{ </em>n<em> ∈ ℕ : </em>Sₙ<em>(</em>H<em>) = 2</em>ⁿ<em> }</em></blockquote><p>However, this definition isn’t precise. Note that the set of numbers for which the shattering coefficient equals 2<em>ⁿ </em>may be infinite. (Consequently, it is possible that VCdim(<em>H</em>) = ∞.) If that’s the case, the set has no well-defined maximum. We address this by taking the supremum instead:</p><blockquote><strong><em>VCdim(</em>H<em>)</em> = <em>sup{ </em>n<em> ∈ ℕ : </em>Sₙ<em>(</em>H<em>) = 2</em>ⁿ<em> }</em></strong></blockquote><p>This rigorous and concise definition is the one we’ll use moving forward.</p><h4>Adding Preferences to the Mix: Strategic Shattering Coefficients</h4><p>Generalizing the canonical notions we just went over so that they work in a strategic setup is fairly straightforward. Redefining shattering coefficients in terms of the <em>data point best response</em> we defined in <a href="https://towardsdatascience.com/extending-pac-learning-to-a-strategic-classification-setting-6c374935dde2">the previous article</a> is practically all we’ll have to do.</p><blockquote><em>Given a hypothesis class </em>H, <em>a preference set </em>R<em>, and a cost function </em>c<em>,</em><strong><em> the </em>n<em>ᵗʰ shattering coefficient of Sᴛʀᴀᴄ⟨</em>H<em>, </em>R<em>, </em>c<em>⟩, denoted σ</em>ₙ<em>(</em>H, R, c<em>), </em></strong><em>represents </em><strong><em>the largest number of labelings achievable by classifiers in </em>H</strong><em> on a set of </em>n<em> potentially-manipulated feature vectors, i.e.,</em><strong><em> </em>n <em>data point best responses.</em></strong></blockquote><p>As a reminder, this is how we defined the data point best response:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*VNxGgycRJReSZ4Hf.png" /></figure><p>We can tweak the notation we used in our discussion of canonical shattering coefficients to further formalize this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*msfY5L86SYaNB4QU6mv_IQ.png" /></figure><p>The main difference is that each <em>x</em> in the sample has to have a corresponding <em>r</em>. Other than that, putting the data point best response where we had x in the canonical case works smoothly.</p><p><strong>As a quick sanity check, let’s consider what happens if <em>R</em> = { 0 }.</strong> The realized reward term 𝕀(<em>h</em>(<em>z</em>) = 1) ⋅ <em>r </em>will be 0 across all the data points. <strong>Maximizing utility thus becomes synonymous with minimizing cost</strong>. The best way to minimize the cost incurred by a data point is trivial: <strong>never manipulating its feature vector.</strong></p><p><strong>Δ(<em>x</em>, <em>r</em>; <em>h</em>) ends up always just being <em>x</em>,</strong> placing us firmly within the territory of canonical classification. <strong>It follows that σ<em>ₙ</em>(<em>H</em>, { 0 }, <em>c</em>)<em> = Sₙ</em>(<em>H</em>) for all <em>H, c</em>.</strong> This is consistent with our observation that the impartial preference class represented by <em>R</em> = { 0 } is equivalent to canonical binary classification.</p><h4>Expressiveness with Preferences: Strategic VC Dimension (SVC)</h4><p>Having defined the <em>n</em>ᵗʰ<strong><em> </em></strong>strategic shattering coefficient, <strong>we can simply swap out the <em>Sₙ</em>(<em>H</em>)<em> </em>in the canonical definition of the VC dimension for σ<em>ₙ</em>(<em>H</em>, <em>R</em>, <em>c</em>).</strong></p><blockquote><strong><em>SVC(</em>H, R, c<em>)</em> = <em>sup{ </em>n<em> ∈ ℕ : σ</em>ₙ<em>(</em>H, R, c<em>) = 2</em>ⁿ<em> }</em></strong></blockquote><p>Based on the example we considered above, we find that SVC(<em>H</em>, { 0 }, <em>c</em>) = VCdim(<em>H</em>) for any <em>H</em>, <em>c</em>. Indeed,<strong> SVC is to VCdim as the strategic shattering coefficient is to its canonical equivalent:</strong> both are elegant generalizations of non-strategic concepts.</p><h4>From SVC to Strategic PAC Learnability: The Fundamental Theorem of Strategic Learning</h4><p><strong>We can now use SVC to state the Fundamental Theorem of Strategic Learning,</strong> which relates the complexity of a strategic classification problem to its (agnostic) PAC learnability.</p><blockquote><strong><em>A strategic classification instance Sᴛʀᴀᴄ⟨</em>H<em>, </em>R<em>, </em>c<em>⟩ is agnostic PAC learnable if and only if SVC(</em>H, R, c<em>) is finite.</em></strong><em> The </em><a href="https://en.wikipedia.org/wiki/Sample_complexity"><em>sample complexity</em></a><em> for strategic agnostic PAC learning is </em><strong>m<em>(</em>δ<em>, </em>ε<em>) ≤ </em>Cε <em>⁻² ⋅</em> <em>(SVC(</em>H, R, c<em>) + log⁡(1/</em>δ<em>))</em></strong><em>, with </em>C<em> being a constant.</em></blockquote><p>We won’t elaborate too much on how this can be proven. Suffice it to say that it boils down to a clever reduction to the (well-documented) <a href="https://www.cs.princeton.edu/courses/archive/spring16/cos511/lec17.pdf">Fundamental Theorem of <em>Statistical </em>Learning</a>, which is essentially the non-strategic version of the theorem. If you’re mathematically inclined and interested in the nuts and bolts of the proof, you can find it in <a href="https://arxiv.org/pdf/2012.03310.pdf#page=12">Appendix B of the paper</a>.</p><p><strong>This theorem essentially completes our generalization of classic PAC learning to a strategic classification setting.</strong> It shows that the way we defined SVC actually doesn’t just make sense in our heads; it actually works as a generalization of VCdim where it matters most. Armed with the Fundamental Theorem, we are well-equipped to analyze strategic classification problems much as we would any old binary classification problem. In my opinion, having the ability to determine whether a strategic problem is theoretically learnable or not is pretty incredible!</p><h4>Conclusion</h4><p>We began by introducing the <strong>canonical shattering coefficient and VC dimension,</strong> which are central to PAC learning (and the<em> </em>Fundamental Theorem of Statistical Learning). Next, we leveraged the<em> data point best response </em>to <strong>generalize the aforementioned concepts so that they would work in our strategic setup.</strong> We defined the <strong>strategic VC dimension (SVC)</strong> and showed that when faced with the impartial preference class, it degenerates back into the canonical VC dimension. Finally, <strong>we demonstrated how SVC relates to strategic PAC learnability by means of the Fundamental Theorem of Strategic Learning.</strong></p><p><strong>In the final article in this series, we’ll build on the concepts I’ve introduced here to break down my favorite proof in the paper, </strong>which I think is a beautiful illustration of strategic classification and SVC in action.</p><p><a href="https://towardsdatascience.com/statistical-learnability-of-strategic-linear-classifiers-a-proof-walkthrough-e80db99d6c4e">Statistical Learnability of Strategic Linear Classifiers: A Proof Walkthrough</a></p><h3>References</h3><p>[1] R. Sundaram, A. Vullikanti, H. Xu, F. Yao. <a href="https://arxiv.org/abs/2012.03310">PAC-Learning for Strategic Classification</a> (2021), International Conference on Machine Learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd04cbfdd4b9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/quantifying-the-complexity-and-learnability-of-strategic-classification-problems-fd04cbfdd4b9">Quantifying the Complexity and Learnability of Strategic Classification Problems</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Extending PAC Learning to a Strategic Classification Setting]]></title>
            <link>https://medium.com/data-science/extending-pac-learning-to-a-strategic-classification-setting-6c374935dde2?source=rss-ef72e1b40cd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c374935dde2</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[thoughts-and-theory]]></category>
            <category><![CDATA[game-theory]]></category>
            <category><![CDATA[classification-algorithms]]></category>
            <category><![CDATA[algorithmic-game-theory]]></category>
            <dc:creator><![CDATA[Jonathan Yahav]]></dc:creator>
            <pubDate>Thu, 04 Apr 2024 17:26:15 GMT</pubDate>
            <atom:updated>2025-04-01T17:44:50.577Z</atom:updated>
            <content:encoded><![CDATA[<h4>A case study of the meeting point between game theory and fundamental concepts in machine learning</h4><p>Last semester, I took a seminar in <em>Incentives and Learning. </em>The papers we discussed throughout the course dealt with the overlap between the fields of game theory and machine learning. I had very little familiarity with formal game theory beforehand, and I thought finding out more about it through the lens of its intersection with machine learning was fascinating. By the end of this article, I hope you’ll think so, too!</p><p>The paper my group chose to present was <a href="https://arxiv.org/abs/2012.03310"><strong><em>PAC-Learning for Strategic Classification</em></strong></a><em> </em>(Sundaram, Vullikanti, Xu, &amp; Yao, 2021). It generalizes the basic machine learning notion of <a href="https://en.wikipedia.org/wiki/Probably_approximately_correct_learning">PAC learning</a> to work in a <strong>strategic </strong><a href="https://en.wikipedia.org/wiki/Binary_classification">binary classification</a> setting. The word “strategic” here signifies that the data points we want to classify aren’t just data points, but rather <strong>represent rational agents with their own individual preferences.</strong></p><p><strong>This will be a three-part series on my takeaways from the paper.</strong> <strong>In this article, I’ll lay the intuitive and formal foundations required to understand the strategic classification model and setup.</strong> In the next one, I’ll cover the concept of strategic VC dimension as a generalization of the canonical notion of <a href="https://en.wikipedia.org/wiki/Vapnik%E2%80%93Chervonenkis_dimension">VC dimension</a>. The final post will be a walkthrough of my favorite proof in the paper, which will tie together the definitions and ideas introduced in the first two.</p><p>An understanding the idea of binary classification and the basic notation used for it in the context of machine learning should be all you need to understand the articles in this series.<strong> Ultimately, the goal is to present the concepts in a way that makes them as approachable as possible, regardless of your background.</strong></p><h4>Why Strategic Classification Is Useful: Motivation</h4><p><strong>Binary classification is a cornerstone of machine learning. </strong>It was the first topic I was taught when I took an introductory course on the subject; the real-world example we examined back then was the problem of classifying emails as either <em>spam </em>or <em>not spam</em>. Other common examples include diagnosing a disease and screening resumes for a job posting.</p><p>The basic binary classification setup is intuitive and easily applicable to our day-to-day lives, and<strong> </strong>it can serve as a helpful demonstration of <strong>the ways we can leverage machine learning to solve <em>human </em>problems. </strong>But how often do we stop to consider the fact that <strong>people usually have a vested interest in the classification outcome of such problems?</strong> Spammers want their emails to make it through spam filters, not everyone wants their COVID test to come back positive, and job seekers may be willing to stretch the truth to score an interview. <strong>The data points aren’t just data points — they’re active participants in the classification process, often aiming to game the system to their own benefit.</strong></p><p>In light of this, the canonical binary classification setup seems a bit simplistic. However, the complexity of reexamining binary classification while tossing out the implicit assumption that the objects we wish to classify are uninfluenced by external stakes sounds unmanageable. <strong>The preferences that could affect the classification process come in so many different forms — how could we possibly take all of them into account?</strong></p><p><strong>It turns out that, under certain assumptions, we can.</strong> Through a clever generalization of the canonical binary classification model, the paper’s authors demonstrate the feasibility of designing computationally-tractable, gaming-resistant classification algorithms.</p><h4>From Data Points to Rational Agents: Preference Classes</h4><p>First, if we want to be as realistic as possible, we have to properly consider the wide breadth of forms that real-world preferences can take among rational agents. The paper mentions five increasingly general categories of preferences (which I’ll call <em>preference classes</em>). The names I’ll use for them are my own, but are based on the terminology used in the paper.</p><ol><li><strong>Impartial</strong>: No preferences, just like in canonical binary classification.</li><li><strong>Homogeneous:</strong> Identical preferences across all the agents involved. For example, within the set of people who are willing to fill out the paperwork necessary to apply for a tax refund, we can reasonably expect that everyone is equally motivated to get their money back (i.e., to be classified positively).</li><li><strong>Adversarial:</strong> Equally-motivated agents aim to induce the opposite of their true labels. Think of bluffing in poker — a player with a weak hand (negatively classified) wants their opponents to think they have a strong hand (positively classified), and vice versa. For the “equally-motivated” part, imagine all players bet the same amount.</li><li><strong>Generalized Adversarial:</strong> Unequally-motivated agents aim to induce the opposite of their true labels. This isn’t too different from the plain <em>Adversarial </em>case. Still, it should be easy to understand how a player with $100 on the line would be willing to go to greater lengths to deceive their opponents than a player betting $1.</li><li><strong>General Strategic:</strong> <em>“</em>Anything goes.<em>”</em> This preference class aims to encompass any set of preferences imaginable. All four of the previously mentioned preference classes are strict subsets of this one. Naturally, this class is the main focus of the paper, and most of the results demonstrated in the paper apply to it. The authors give the wonderful example of college applications, where “<em>students [who] have heterogeneous preferences over universities […] may manipulate their application materials during the admission process.</em>”</li></ol><p>How can the canonical classification setup be modified to account for such rich agent preferences? The answer is astoundingly simple. Instead of limiting our scope to (<em>x</em>, <em>y</em>) ∈ <em>X</em> × { -1, 1 }, <strong>we consider data points of the form (<em>x</em>, <em>y</em>, <em>r</em>) ∈ <em>X</em> × { -1, 1 } × <em>R</em>.</strong> A point’s <em>r</em> value represents its preference, which we can break down into two equally important components:</p><ul><li>The <strong>sign </strong>of <em>r</em> indicates <strong>whether the data point wants to be positively or negatively classified</strong> (<em>r</em> &gt; 0 or <em>r </em>&lt; 0, respectively).</li><li>The <strong>absolute value</strong> of <em>r</em> specifies<strong> how strong the data point’s preference is.</strong> For example, a data point with <em>r</em> = 10 would be much more strongly motivated to manipulate its feature vector <em>x </em>to ensure it ends up being positively classified than a data point with <em>r</em> = 1.</li></ul><p><strong>What determines the preference class we operate within is the set <em>R</em>.</strong> We can formally define each of the aforementioned preference classes in terms of <em>R</em> and see how the formal definitions align with their intuitive descriptions and examples:</p><ol><li><strong>Impartial</strong>: <em>R</em> = { 0 }. <em>(This makes it abundantly clear that the strategic setup is just a generalization of the canonical setup.)</em></li><li><strong>Homogeneous:</strong> <em>R</em> = { 1 }.</li><li><strong>Adversarial:</strong> <em>R</em> = { -1, 1 }, with the added requirement that all data points prefer to be classified as the opposite of their true labels.</li><li><strong>Generalized Adversarial:</strong> <em>R</em> ⊆ ℝ (and all data points prefer to be classified as the opposite of their true labels.)</li><li><strong>General Strategic:</strong> <em>R</em> ⊆ ℝ.</li></ol><h4>Giving Preference Magnitude Meaning: Cost Functions</h4><p>Clearly, though, <em>R</em> on its own isn’t enough to construct an entire general strategic framework. The very idea of a data point’s preference having a certain magnitude is meaningless without tying it to<strong> the cost the data point incurs in manipulating its feature vector.</strong> Otherwise, any data point with a positive <em>r</em>, no matter how small, would have no reason not to manipulate its feature vector <em>ad infinitum</em>. This is where the concept of <strong>cost functions</strong> comes into play.</p><p>Let <em>c</em>: <em>X</em> × <em>X </em>→ ℝ⁺. For simplicity, we will assume (as the paper’s authors do) that <em>c</em> is induced by <a href="https://en.wikipedia.org/wiki/Seminorm">seminorms</a>. We say that a <strong>test data point </strong>(<em>x</em>, <em>y</em>, <em>r</em>) may transform its feature vector <em>x</em> into <em>z </em>∈ <em>X</em> with <strong>cost</strong> <em>c</em>(<em>z</em>; <em>x</em>). It’s important to note in this context that the paper assumes that the training data is unmanipulated.</p><p>We can divide cost functions into two categories, with the former being a subset of the latter. An <strong>instance-invariant cost function</strong> is the same across all data points. To put it more formally:</p><blockquote><em>∃ℓ: </em>X<em> × </em>X<em> → ℝ⁺ . ∀(</em>x<em>, </em>y<em>, </em>r<em>) ∈ </em>X<em> × { -1, 1 } × </em>R<em> . ∀</em>z<em> ∈ </em>X<em> . </em>c<em>(</em>z<em>; </em>x<em>) = ℓ(</em>z<em> - </em>x<em>)</em></blockquote><p>I.e., there exists a function ℓ such that for all data points and all potential manipulated feature vectors, <em>c</em>(<em>z ; x</em>) simply takes the value of ℓ(<em>z</em> - <em>x</em>).</p><p>An <strong>instance-wise cost function</strong> may vary between data points. Formally:</p><blockquote><em>∀(</em>x<em>, </em>y<em>, </em>r<em>) ∈ </em>X<em> × { -1, 1 } × </em>R . <em>∃ℓ</em>ₓ<em>: </em>X<em> × </em>X<em> → ℝ⁺</em> .<em>∀</em>z<em> ∈ </em>X . c<em>(</em>z<em>; </em>x<em>) = ℓ</em>ₓ<em>(</em>z - x<em>)</em></blockquote><p>I.e., <strong>each data point can have its own function,</strong> ℓ<em>ₓ</em>, and <em>c</em>(<em>z; x</em>) takes the value of ℓ<em>ₓ</em>(<em>z - x</em>) for each individual data point.</p><p>As we will see in the final article in this series, while the difference between the two types of cost functions may seem subtle, <strong>instance-wise cost functions are significantly more expressive and harder to learn.</strong></p><h4>Preference Classes and Cost Functions in Action: An Example</h4><p>Let’s take a look at an example given in the paper to help hammer home the aspects of the setup we’ve covered so far.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-uB4y8BKE3mXK3_RAaLKMQ.png" /><figcaption>Image by <em>R. Sundaram, A. Vullikanti, H. Xu, F. Yao from </em><a href="https://arxiv.org/abs/2012.03310"><strong>PAC-Learning for Strategic Classification</strong></a><em> (use under</em><a href="https://creativecommons.org/licenses/by/4.0/"><em> CC-BY 4.0 license</em></a><em>).</em></figcaption></figure><p>In this example, we have a decision boundary induced by a linear binary classifier and four data points with individual preferences. <em>General strategic</em> is the only applicable preference class in this case.</p><p>The dotted perimeter around each <em>xᵢ</em> shows the manipulated feature vectors <em>z </em>to which it would cost the point exactly 1 to move. Since we assume the cost function is induced by seminorms, everything inside a perimeter has a cost of less than 1 for the corresponding data point to move to. We can easily tell that the cost function in this example varies from data point to data point, which means it is instance-wise.</p><p>As we can see, <strong>the leftmost data point (<em>x</em>₁, -1, -1) has no incentive to cross the decision boundary</strong> since it is on the negative side of the decision boundary while also having a negative preference. (<em>x</em>₄, -1, 2), however, wants to be positively classified, and since the <strong>reward for manipulating <em>x</em>₄</strong> to cross the boundary (which is 2) <strong>outweighs the cost</strong> of doing so (which is less than 1), <strong>it makes sense to go through with the manipulation.</strong> (<em>x</em>₃, 1, -2) is symmetric to (<em>x</em>₄, -1, 2), also deciding to manipulate its feature to achieve its desired classification outcome. Lastly,<strong> (<em>x</em>₂, -1, 1),</strong> the cost function of which we can see is based on <a href="https://en.wikipedia.org/wiki/Taxicab_geometry">taxicab distance</a>, <strong>opts to stay put regardless of its preference to be positively classified. </strong>This is because <strong>the cost of manipulating <em>x</em>₂ to cross the decision boundary would be greater than 1,</strong> surpassing the reward the data point would stand to gain by doing so.</p><p>Assuming the agents our data points represent are rational, <strong>we can very easily tell when a data point should manipulate its feature vector </strong>(benefits outweigh costs) and when it shouldn’t (costs outweigh benefits). <strong>The next step is to turn our intuitive understanding into something more formal.</strong></p><h4>Balancing Costs &amp; Benefits: Defining <em>Data Point Best Response</em></h4><p>This leads us to define the <strong><em>data point best response</em>:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*sVyQ1SwRgl0BJCQpWcj3Fw.png" /></figure><p>So we’re looking for the feature vector(s) <em>z</em> ∈ <em>X </em>that maximize… what exactly? <strong>Let’s break down the expression we’re aiming to maximize into more manageable parts.</strong></p><ul><li><strong><em>h</em>:</strong> A given binary classifier (<em>h</em>: <em>X </em>→ { -1, 1 }).</li><li><strong><em>c</em>(<em>z</em>; <em>x</em>):</strong> As stated above, this expresses the <strong>cost </strong>of modifying the feature vector <em>x</em> to be <em>z</em>.</li><li><strong>𝕀(<em>h</em>(<em>z</em>) = 1): </strong>Here, 𝕀(<em>p</em>) is the indicator function, returning 1 if the predicate <em>p </em>is upheld or 0 if it isn’t. The predicate <em>h</em>(<em>z</em>) = 1<strong> </strong>is true if the vector <em>z</em> under consideration is positively classified by <em>h</em>. Putting that together, we find that 𝕀(<em>h</em>(<em>z</em>) = 1) evaluates to 1 for any <em>z </em>that is positively classified. If <em>r</em> is positive, that’s good. If it’s negative, that’s bad.</li></ul><p><strong>The bottom-line is that we want to find vector(s) <em>z </em>for which </strong>𝕀(<em>h</em>(<em>z</em>) = 1) ⋅ <em>r</em>, which we can call the <strong><em>realized reward</em>, outweighs the cost of manipulating the original <em>x</em> into <em>z </em>by as much as possible.</strong> To put it in game theoretic terms, <strong>the data point best response maximizes the <em>utility </em>of its corresponding agent in the context of the binary classification under consideration.</strong></p><h4>Putting It All Together: A Formal Definition of the Strategic Classification Problem</h4><p>Finally, we’ve laid all the necessary groundwork to formally define <strong>the strategic classification problem.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XAP8S2eP9NLBwk7CcanpnA.png" /><figcaption>A diagram illustrating the formal definition of the strategic classification problem. Image by author.</figcaption></figure><p>Given a hypothesis class <em>H</em>, a preference class <em>R</em>, a cost function <em>c</em>, and a set of <em>n</em> data points drawn from a distribution <em>D</em>, we want to find a binary classifier <em>h</em>’ that minimizes the loss as defined in the diagram above. Note that the loss is simply a modification of the canonical zero-one loss, plugging in the data point best response instead of <em>h</em>(<em>x</em>).</p><h4>Conclusion</h4><p>Starting from the canonical binary classification setup, we introduced the notion of <strong><em>preference classes</em></strong>. Next, we saw how to formalize that notion using an <strong><em>r</em> value</strong> for each data point. We then saw how <strong><em>cost functions</em></strong> complement data point preferences. After that, we broke down an example before defining the key concept of <strong><em>data point best response</em></strong> based on the ideas we explored beforehand. Lastly, we used the data point best response to define the <strong><em>modified zero-one loss</em> used in the definition of the strategic classification problem.</strong></p><p><strong>Join me next time as I define and explain the strategic VC dimension, which is the natural next step from where we left off this time.</strong></p><p><a href="https://towardsdatascience.com/quantifying-the-complexity-and-learnability-of-strategic-classification-problems-fd04cbfdd4b9">Quantifying the Complexity and Learnability of Strategic Classification Problems</a></p><h4>References</h4><p>[1] R. Sundaram, A. Vullikanti, H. Xu, F. Yao. <a href="https://arxiv.org/abs/2012.03310">PAC-Learning for Strategic Classification</a> (2021), International Conference on Machine Learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c374935dde2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/extending-pac-learning-to-a-strategic-classification-setting-6c374935dde2">Extending PAC Learning to a Strategic Classification Setting</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Created Custom Displacement Maps for My Space-Themed Three.js Portfolio Site]]></title>
            <link>https://javascript.plainenglish.io/how-i-created-custom-displacement-maps-for-my-space-themed-three-js-portfolio-site-642b52700941?source=rss-ef72e1b40cd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/642b52700941</guid>
            <category><![CDATA[displacement-map]]></category>
            <category><![CDATA[threejs]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[Jonathan Yahav]]></dc:creator>
            <pubDate>Mon, 25 Mar 2024 18:24:35 GMT</pubDate>
            <atom:updated>2024-03-27T23:58:08.270Z</atom:updated>
            <content:encoded><![CDATA[<h4>I was surprised at the lack of free-to-use, premade displacement maps online. I was even more surprised at how easy it was to make my own.</h4><p><strong>While working on </strong><a href="https://jhyahav.vercel.app/"><strong>my portfolio site</strong></a><strong>, I encountered an interesting problem when it came to </strong><a href="https://en.wikipedia.org/wiki/Displacement_mapping"><strong>displacement maps</strong></a><strong>.</strong></p><p><strong>A brief explanation for the uninitiated:</strong> when working with graphics in general, and with Three.js meshes in particular, you can use a variety of types of maps to alter the properties of a mesh. The simplest of these is the color map, the pixels of which are, well… mapped onto the mesh. In the case of sphere-based geometries like those I used, you can think of the color map as a sort of wrapping paper to decorate the spherical geometry underneath.</p><p>In a nutshell, a displacement map is a grayscale image, where the brightness of each pixel determines how much the associated vertex of the geometry is (you guessed it!) displaced. There are a lot of other types of maps you can use with Three.js meshes for all sorts of purposes. <a href="https://threejs.org/docs/#api/en/materials/MeshStandardMaterial">Three’s MeshStandardMaterial documentation</a> is a great starting point to find out more if you’re interested.</p><p>After looking into my options, I decided that I really wanted to use displacement mapping for realism on the randomly-generated asteroids and on one of the planets I had made. However, unlike decent color maps, which I could find with relative ease, <strong>I was hard-pressed to find displacement maps which met my needs,</strong> let alone free-to-use options. Fortunately, with a bit of ingenuity and experimentation, I found a way to make my own.</p><p><strong>I’ll preface the details about my trick with two important disclaimers:</strong></p><p>1. <em>This approach may not work for your use case.</em> I created these displacement maps for a very particular purpose, that being to make them appear more-or-less random while preserving the fairly smooth aesthetics of rock formations. YMMV.</p><p>2. <em>This approach is probably not the most elegant one out there.</em> For those better versed in the world of 3D modelling and animations than myself and/or those willing to spend some money, there are cleaner solutions. You can create displacement maps from scratch using Photoshop. You can also create full-on 3D models with tools like <a href="https://www.blender.org/">Blender</a> instead of relying on displacement mapping in the first place. Also, while I can’t verify their quality or bang for buck, on my search for premade displacement maps, I did run across a couple of sites selling them for a pretty penny.</p><p>And with that out of the way, here’s how I quickly made my own rocky displacement maps for free and without any fancy tools:</p><p><strong>1.</strong> <strong>I used Google Lens to find free-to-use images similar to a watermarked preview I found of a paid displacement map.</strong> To be honest, I didn’t really know exactly what I was looking for at this point. I was mostly exploring what a displacement map that would work for me would look like, and starting from the preview of a paid map seemed like a decent starting point. In retrospect, it didn’t really matter all that much; the most important thing was to have a grayscale image with enough brightness variety throughout it to keep things interesting. If you’re reading this to follow my process and make your own displacement maps, <strong>you can skip this step</strong> and go with any free-to-use grayscale image, or use one of mine from below.</p><p><strong>2.</strong> <strong>I curated a couple of images that seemed like good candidates.</strong> I also carried out new Lens searches based on a few of the images I picked. The final two I ended up narrowing it down to were <a href="https://commons.wikimedia.org/wiki/File:Kasei_Valles_cataracts.jpg">a public-domain image of canyons on Mars</a> and <a href="https://news.uchicago.edu/story/salt-deposits-mars-hold-clues-sources-ancient-water">a NASA image of salt deposits, coincidentally also on Mars</a>.<br><strong>3.</strong> <strong>I cropped the images down so that they would be square and resized them to a reasonable resolution, 512x512 pixels.</strong> In general, your maps should be square, with the height/width being powers of 2. For most applications, 512x512 should be plenty, and you could probably go as low as 256x256 for a bit of a performance boost without sacrificing much in the way of detail.<br><strong>4.</strong> <strong>I mirrored one quarter of the image onto each of the others.</strong> I actually only did this for one of the displacement maps I ended up using. The reason I did this in the first place was to prevent any seams from showing up on the surface of the meshes. Theoretically, when working with maps, the colors on the left side of the image need to perfectly match those on the right side so that the line on the geometry where those edges meet doesn’t look weird. In practice, I tried skipping this step for the second map and the results were totally fine.<br><strong>5. I added uniform horizontal lines on the top and bottom of each image.</strong> The rationale here was similar to that of the previous step, except that this time, it actually did matter quite a bit. If you don’t make sure the brightness of the pixels at the top and bottom edges match up perfectly, you’ll end up with an unsightly effect at the poles of the sphere, as demonstrated in <a href="https://stackoverflow.com/questions/15876848/why-does-my-implementation-of-a-displacement-map-in-three-js-disconnect-vertices">this StackOverflow question</a>.<br>This is what the maps looked like at this point:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*qb5tCVi1P9NNkdHgvh7RTQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*ZjGQpO2M4Sjl8HC-nbxl4w.png" /></figure><p><strong>6. I blurred the images to smoothen the distortion.</strong> Although I was satisfied with the progress I had made after step 5, I still felt like the result wasn’t what I wanted. The bumps on the surface of my planet and asteroids were definitely noticeable, but way too pointy and jagged for my liking. (If you’re looking for prickly distortion, try skipping this step.) I experimented with different levels of blurring for each of my images until I reached what I felt was the Goldilocks zone. I did have to add the lines from step 5 back in after this, since they were absorbed in the process of blurring the images.</p><h4><strong>And voilà! Two nice little distortion maps:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*Ek61hpdHYqWMmcBeVIgMzw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*5UerCP7K-Zp9sGA_bTiLKw.png" /><figcaption><em>The final distortion maps</em></figcaption></figure><p>I was pleasantly surprised at how well they ended up working for exactly what I needed. Feel free to use them in your own projects if you want.</p><h4><a href="https://jhyahav.vercel.app/">Check out how the rocky planet and asteroids look on the finished site</a></h4><h4><a href="https://github.com/jhyahav/portfolio">Take a look at the project’s source code</a></h4><p><em>This article was originally published on the social blogging site I built, COACSS, on August 28th, 2022.</em></p><h3>In Plain English 🚀</h3><p><em>Thank you for being a part of the </em><a href="https://plainenglish.io/"><strong><em>In Plain English</em></strong></a><em> community! Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></li><li>Follow us: <a href="https://twitter.com/inPlainEngHQ"><strong>X</strong></a><strong> | </strong><a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a><strong> | </strong><a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong>YouTube</strong></a><strong> | </strong><a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Discord</strong></a><strong> | </strong><a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a></li><li>Visit our other platforms: <a href="https://stackademic.com/"><strong>Stackademic</strong></a><strong> | </strong><a href="https://cofeed.app/"><strong>CoFeed</strong></a><strong> | </strong><a href="https://venturemagazine.net/"><strong>Venture</strong></a><strong> | </strong><a href="https://blog.cubed.run/"><strong>Cubed</strong></a></li><li>More content at <a href="https://plainenglish.io/"><strong>PlainEnglish.io</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=642b52700941" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/how-i-created-custom-displacement-maps-for-my-space-themed-three-js-portfolio-site-642b52700941">How I Created Custom Displacement Maps for My Space-Themed Three.js Portfolio Site</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>