<?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[AnthonyDalke - Medium]]></title>
        <description><![CDATA[Learning and writing about data - Medium]]></description>
        <link>https://medium.com/anthonydalke?source=rss----7cf377b6f0e4---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>AnthonyDalke - Medium</title>
            <link>https://medium.com/anthonydalke?source=rss----7cf377b6f0e4---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 01:05:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/anthonydalke" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Oscar Piastri: Star in the Making? Part VI]]></title>
            <link>https://medium.com/anthonydalke/oscar-piastri-star-in-the-making-part-vi-624e3deb8c74?source=rss----7cf377b6f0e4---4</link>
            <guid isPermaLink="false">https://medium.com/p/624e3deb8c74</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[f1]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[formula]]></category>
            <dc:creator><![CDATA[Anthony Dalke]]></dc:creator>
            <pubDate>Wed, 23 Jul 2025 19:21:42 GMT</pubDate>
            <atom:updated>2024-12-17T23:16:02.343Z</atom:updated>
            <content:encoded><![CDATA[<h3>Analysis</h3><p><strong>Introduction</strong></p><p>Now that we’ve stepped through the <a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-c8d803d4f1f7">context</a> for this project, the <a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-430544218107">data required</a> to achieve the project objectives, how to <a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-72473e5db5ce">obtain the data</a>, how to <a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-9efaea07b18b">structure it</a>, and how to build <a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-8bb3e1aecd59">the pipeline</a> putting everything into practice, we can finally launch into the analysis. Word of caution: this matured into by far the longest and most detailed piece in this series!</p><p>Over my years in the data world, I’ve migrated to a pragmatic, results-based approach. That starts with a clearly defined end goal (or deliverable, to use a more business-friendly term) and working backward to shape a plan of attack. Here, that meant referring back to the problem statement in <a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-430544218107">part II</a> of this series:</p><blockquote>Assess how Oscar Piastri’s rookie season compared to others in recent F1 history.</blockquote><p>To make that problem statement more actionable, I translated it into two questions:</p><blockquote>How did his qualifying pace relative to his teammate compare to recent F1 rookies?</blockquote><blockquote>How about his race results relative to his teammate?</blockquote><p>You’ll notice both place an emphasis on comparative outcomes. This reflects the complex reality of Formula 1, where vast discrepancies in car pace across teams leaves inter-team comparisons as the most reliable (albeit still imperfect!) barometer for outsiders like us. Stated differently, comparisons to teammates minimize the potential confounding variables when assessing driver performance.</p><p>With that in mind, let’s delve into the specifics. I adopted a SQL-centric approach for a few reasons.</p><ol><li>I wanted to evaluate the impacts on performance and usability of moving between the normalized and denormalized data models I <a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-9efaea07b18b">designed</a>.</li><li>I like to sharpen my SQL skills whenever possible. I’ve come to fondly appreciate the deceptive simplicity of the language, where you can accomplish a lot with only a few commands, while enjoying a vast ocean of more powerful techniques should you dig deeper.</li><li>At some point, I may leverage the queries to practice with <a href="https://www.getdbt.com/product/what-is-dbt">dbt</a>.</li></ol><p><strong>Data Cleansing</strong></p><p>As with most (perhaps all) data projects, browsing through the records landed in Postgres spotlighted holes to patch. Some columns in certain tables contained nulls and inconsistencies. I aimed to tackle this in systematic fashion, running basic previews and aggregations on each table. Some might argue for a more automated approach, but I’ve always found it worthwhile to dedicate some time to manual review. At the very least, it has always helped instill a baseline degree of familiarity with the data.</p><p>This effort resulted in a series of DML (Data Manipulation Language) queries that sounded some common themes:</p><p>— Standardize team names and driver last names</p><p>— Fill in null driver id’s</p><p>— Trim unintended trailing white space from driver ID’s</p><p><strong>Query Comparison</strong></p><p>As noted in the introduction, I partly arranged the data in both a normalized and denormalized model to compare the structure and performance of the queries required for each.</p><p>In both cases, I opted to create a temporary table with pre-processed data, then leverage that pre-processed data for the analytical comparisons. Since I tend to think in a structured, deductive fashion, progressively drilling down to a desired result, this approach facilitated the clearest implementation of the logic for my analysis.</p><p>Casting aside risks to the overall length of this post, here are the denormalized temp table queries, which you can <a href="https://github.com/AnthonyDalke/f1data/tree/main/piastri/docs">find in full</a> in my project repo:</p><pre>CREATE TEMPORARY TABLE IF NOT EXISTS temp_rookie_results AS<br> WITH rookie_seasons AS (<br>     SELECT <br>         id_driver, <br>         MIN(&quot;year&quot;) AS rookie_year<br>     FROM <br>         sessions.events_denormalized<br>     WHERE<br>      id_driver NOT IN (<br>       &#39;alonso&#39;,<br>       &#39;button&#39;,<br>       &#39;coulthard&#39;,<br>       &#39;fisichella&#39;,<br>       &#39;frentzen&#39;,<br>       &#39;gene&#39;,<br>       &#39;heidfeld&#39;,<br>       &#39;montoya&#39;,<br>       &#39;panis&#39;,<br>       &#39;pizzonia&#39;,<br>       &#39;raikkonen&#39;,<br>       &#39;ralf_schumacher&#39;,<br>       &#39;sato&#39;,<br>       &#39;trulli&#39;,<br>       &#39;verstappen&#39;,<br>       &#39;webber&#39;,<br>       &#39;michael_schumacher&#39;,<br>       &#39;barrichello&#39;,<br>       &#39;villeneuve&#39;<br>      )<br>     GROUP BY <br>         id_driver<br> ), rookie_teams AS (<br>     SELECT DISTINCT<br>         e.id_driver, <br>         e.&quot;year&quot;, <br>         e.name_team<br>     FROM <br>         sessions.events_denormalized e<br>     INNER JOIN <br>         rookie_seasons r <br>     ON <br>         e.id_driver = r.id_driver <br>         AND e.&quot;year&quot; = r.rookie_year<br> ), team_rookie_season AS (<br>     SELECT DISTINCT<br>         e.*,<br>         CASE <br>             WHEN e.id_driver = rt.id_driver THEN &#39;rookie&#39;<br>             ELSE &#39;teammate&#39;<br>         END AS ind_rookie<br>     FROM <br>         sessions.events_denormalized e<br>     INNER JOIN <br>         rookie_teams rt <br>     ON <br>         e.&quot;year&quot; = rt.&quot;year&quot;<br>         AND e.name_team = rt.name_team<br> ), filtered_results AS (<br>  SELECT DISTINCT<br>   trs.*<br>     FROM <br>         team_rookie_season trs<br>     WHERE <br>         NOT EXISTS (<br>             SELECT 1<br>             FROM sessions.events_denormalized e<br>             WHERE e.&quot;year&quot; = trs.&quot;year&quot;<br>               AND e.&quot;round&quot; = trs.&quot;round&quot;<br>               AND e.&quot;session&quot; = trs.&quot;session&quot;<br>               AND e.name_team = trs.name_team <br>               AND e.&quot;position&quot; = &#39;DNF&#39;<br>         )<br>  )<br> SELECT <br>     *<br> FROM <br>     filtered_results;</pre><p>And here are the normalized temp table queries:</p><pre>CREATE TEMPORARY TABLE IF NOT EXISTS temp_rookie_results AS<br>    WITH rookie_seasons AS (<br>        SELECT <br>            r.id_driver, <br>            MIN(r.year) AS rookie_year<br>        FROM <br>            sessions.results r<br>     WHERE<br>      id_driver NOT IN (<br>       &#39;alonso&#39;,<br>       &#39;button&#39;,<br>       &#39;coulthard&#39;,<br>       &#39;fisichella&#39;,<br>       &#39;frentzen&#39;,<br>       &#39;gene&#39;,<br>       &#39;heidfeld&#39;,<br>       &#39;montoya&#39;,<br>       &#39;panis&#39;,<br>       &#39;pizzonia&#39;,<br>       &#39;raikkonen&#39;,<br>       &#39;ralf_schumacher&#39;,<br>       &#39;sato&#39;,<br>       &#39;trulli&#39;,<br>       &#39;verstappen&#39;,<br>       &#39;webber&#39;,<br>       &#39;michael_schumacher&#39;,<br>       &#39;barrichello&#39;,<br>       &#39;villeneuve&#39;<br>      )<br>        GROUP BY <br>            r.id_driver<br>    ),<br>    rookie_teams AS (<br>        SELECT DISTINCT<br>            r.id_driver, <br>            r.year, <br>            r.name_team<br>        FROM <br>            sessions.results r<br>        INNER JOIN <br>            rookie_seasons rs <br>        ON <br>            r.id_driver = rs.id_driver <br>            AND r.year = rs.rookie_year<br>    ),<br>    team_rookie_season AS (<br>        SELECT DISTINCT<br>            r.*,<br>            CASE <br>                WHEN r.id_driver = rt.id_driver THEN &#39;rookie&#39;<br>                ELSE &#39;teammate&#39;<br>            END AS ind_rookie<br>        FROM <br>            sessions.results r<br>        INNER JOIN <br>            rookie_teams rt <br>        ON <br>            r.year = rt.year<br>            AND r.name_team = rt.name_team<br>    ),<br> filtered_results AS (<br>  SELECT DISTINCT<br>   trs.*<br>        FROM <br>            team_rookie_season trs<br>        WHERE <br>            NOT EXISTS (<br>                SELECT 1<br>                FROM sessions.results r<br>                WHERE r.year = trs.year<br>                  AND r.round = trs.round<br>                  AND r.session = trs.session<br>                  AND r.name_team = trs.name_team <br>                  AND r.position = &#39;DNF&#39;<br>            )<br>    )<br>    SELECT <br>        fr.year,<br>        fr.round,<br>        c.name_circuit,<br>        c.country_circuit,<br>        fr.id_driver,<br>        d.name_driver_last,<br>        d.name_driver_first,<br>        fr.name_team,<br>        fr.session,<br>        fr.position,<br>        fr.time,<br>        fr.ind_rookie<br>    FROM <br>        filtered_results fr<br>    INNER JOIN <br>        sessions.events e ON fr.year = e.year AND fr.round = e.round<br>    INNER JOIN <br>        sessions.circuits c ON e.name_circuit = c.name_circuit<br>    INNER JOIN <br>        sessions.drivers d ON fr.id_driver = d.id_driver;</pre><p>In terms of structure, material differences didn’t emerge until the tail end. With the help of my beloved <a href="http://diffchecker.com/">diffchecker.com</a> and ignoring table aliases, on the right we can see the normalized data model required a few extra joins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9D4fglvyUraeELrcO4zXaQ.png" /><figcaption>Denormalied (L) and Normalized (R)</figcaption></figure><p>Upstream of that final step, both approaches involved multiple scans of the same table — sessions.events_denormalized for the denormalized model and sessions.results for the normalized model. For a larger-scale pipeline where this sort of analysis would occur regularly, this might argue for reconstructing the normalized model to contain tables or views storing the “intermediate” data produced by the CTE’s. This would free end users from depending on so many JOINs and CTE’s, thus improving their query performance. However, for my exploratory purposes, this didn’t become necessary.</p><p>In terms of performance, unfortunately, the small data volume (only tens of thousands) reduced any advantages between the two approaches below a level detectable to the naked eye. Fortunately, the EXPLAIN ANALYZE SQL statement afforded another, more precise perspective. Interestingly, the denormalized queries entailed greater cost but shorter planning <em>and</em> execution time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*bNp8bgIMSoGo3qcLT-cg5g.png" /><figcaption>Query plan comparison</figcaption></figure><p>This suggests Postgres may have over-estimated the demands of the denormalized plan — in other words, perhaps the volume of the data in my tables caused the denormalized queries to run faster than Postgres expected. At different volumes, the normalized queries might seize the time advantage, as the lower cost calculation would suggest.</p><p>So, to summarize, <em>for this specific use case</em>, the denormalized data model offered a slight performance advantage. From a subjective standpoint, I would add readability (shorter overall query length, with fewer JOINs) and usability (only a single table to keep in one’s mental bandwidth) to the list of the denormalized model’s advantages.</p><p>With this assessment completed, we can move on to the exciting conclusion to this project: analyzing the data!</p><p><strong>Qualifying Analysis</strong></p><p>At its essence, qualifying captures snapshots of a driver’s pace. Finishing order on track doesn’t inherently determine finishing position. In other words, just because a driver finishes their qualifying lap before their teammate doesn’t mean they’ll manage a better lap time (in fact, finishing <em>later</em> in a qualifying session generally helps, since the track “rubbers in” as cars shed fragments of their tire rubber with each lap). What ultimately matters is the lap time itself.</p><p>Furthermore, as argued above, our safest gauge of driver performance centers on inter-team comparisons. With this in mind, I arrived at two metrics for qualifying results.</p><ol><li><strong>Average final qualifying lap time relative to teammate</strong></li><li><strong>Qualifying “wins” over teammate</strong></li></ol><p>To calculate the first metric, I established a driver’s teammate’s ultimate time as the baseline for a qualifying session, then calculated the driver’s time as a percentage of it. Converted to a formula, this would look something like…</p><pre>driver_laptime / teammate_laptime * 100</pre><p>…and the smaller the result, the better. Converting to a percentage, rather than simply computing the absolute time difference between teammates eased comparisons, placing the results on a leveler (more level?) playing field. For instance, an advantage of two tenths of a second on a long lap, such as at Spa-Francorchamps in Belgium, wouldn’t look quite as impressive as the same advantage over a short lap, like at the Red Bull Ring in Austria. Note, I limited this metric to rounds where both drivers in the team made it to the same final qualifying session. For example, if only one driver made it past Q1, I excluded the round from this calculation. This ensured track conditions remained as comparable as possible.</p><p>I decided to calculate this by race weekend, then average those differences over the course of the driver’s rookie season. The per-weekend figures served the dual purpose of laying the groundwork for the second metric calculation, where I defined a “win” as either posting a quicker time in the latest session both drivers in a team shared <em>or</em> making it to a later qualifying session in a weekend.</p><p>To illustrate, if Driver A and B both made it to Q3 and respectively managed laps of 1:21:03 and 1:21:17, Driver A would notch a “win”, with a relative lap time of 99.83%. However, if in a different weekend Driver A made it to Q2, but Driver B couldn’t make it out of Q1, Driver A would also get credited with a “win”.</p><p>The metrics conferred unique benefits. As a relative figure, the average relative lap time highlighted degrees of excellence — a number of 99.5% would stand out as more impressive than, say, 99.9%. On the other hand, as an absolute metric, the win count depicted the driver’s consistency (beating a teammate over many qualifying sessions would prove more impressive than a small number of outlier individual sessions).</p><p>When it came to coding the SQL, I effectively outlined the queries by working through a progressively more granular thought process.</p><pre>→ Find the minimum season year for driver<br> - → Find the results for their team in that season by round<br> - - → Identify the latest session for each driver by round<br> - - - → Find the final lap time each driver in their latest session</pre><p>This produced the data to calculate the metrics described above.</p><p>— For average relative lap time, filter the data population to records where each driver had the same latest session, then divide the driver’s lap time by their teammate’s, and multiply by 100.</p><p>— For “wins”, write a CASE statement counting the records where a driver posted a lap time quicker than their teammate’s for the same final qualifying session <em>or</em> their latest session exceeded their teammate’s.</p><p>For reference, the queries amounted to this:</p><pre>WITH session_max_rookie AS (<br>    SELECT<br>        &quot;year&quot;,<br>        &quot;round&quot;,<br>        name_circuit,<br>        country_circuit,<br>        name_team,<br>        id_driver AS id_rookie,<br>        name_driver_last AS name_rookie_last,<br>        name_driver_first AS name_rookie_first,<br>        &quot;session&quot;,<br>        &quot;position&quot;,<br>        EXTRACT(EPOCH FROM &quot;time&quot;) AS time_rookie,<br>        ROW_NUMBER() OVER (PARTITION BY &quot;year&quot;, &quot;round&quot;, name_team, id_driver ORDER BY <br>            CASE <br>                WHEN &quot;session&quot; = &#39;Q3&#39; THEN 3<br>                WHEN &quot;session&quot; = &#39;Q2&#39; THEN 2<br>                WHEN &quot;session&quot; = &#39;Q1&#39; THEN 1<br>            END DESC) AS rn<br>    FROM<br>        temp_rookie_results<br>    WHERE <br>        &quot;session&quot; LIKE &#39;Q%&#39;<br>        AND &quot;position&quot; &lt;&gt; &#39;DNQ&#39;<br>        AND ind_rookie = &#39;rookie&#39;<br>),<br>session_max_teammate AS (<br>    SELECT<br>        &quot;year&quot;,<br>        &quot;round&quot;,<br>        name_circuit,<br>        country_circuit,<br>        name_team,<br>        id_driver AS id_teammate,<br>        name_driver_last AS name_teammate_last,<br>        name_driver_first AS name_teammate_first,<br>        &quot;session&quot;,<br>        &quot;position&quot;,<br>        EXTRACT(EPOCH FROM &quot;time&quot;) AS time_teammate,<br>        ROW_NUMBER() OVER (PARTITION BY &quot;year&quot;, &quot;round&quot;, name_team, id_driver ORDER BY <br>            CASE <br>                WHEN &quot;session&quot; = &#39;Q3&#39; THEN 3<br>                WHEN &quot;session&quot; = &#39;Q2&#39; THEN 2<br>                WHEN &quot;session&quot; = &#39;Q1&#39; THEN 1<br>            END DESC) AS rn<br>    FROM<br>        temp_rookie_results<br>    WHERE <br>        &quot;session&quot; LIKE &#39;Q%&#39;<br>        AND &quot;position&quot; &lt;&gt; &#39;DNQ&#39;<br>        AND ind_rookie = &#39;teammate&#39;<br>),<br>rookie_final AS (<br>    SELECT<br>        r.&quot;year&quot;,<br>        r.&quot;round&quot;,<br>        r.name_circuit,<br>        r.country_circuit,<br>        r.name_team,<br>        r.id_rookie,<br>        r.name_rookie_last,<br>        r.name_rookie_first,<br>        r.&quot;session&quot; AS session_final_rookie,<br>        r.&quot;position&quot; AS position_rookie,<br>        r.time_rookie<br>    FROM<br>        session_max_rookie r<br>    WHERE<br>        r.rn = 1<br>),<br>teammate_final AS (<br>    SELECT<br>        t.&quot;year&quot;,<br>        t.&quot;round&quot;,<br>        t.name_circuit,<br>        t.country_circuit,<br>        t.name_team,<br>        t.id_teammate,<br>        t.name_teammate_last,<br>        t.name_teammate_first,<br>        t.&quot;session&quot; AS session_final_teammate,<br>        t.&quot;position&quot; AS position_teammate,<br>        t.time_teammate<br>    FROM<br>        session_max_teammate t<br>    WHERE<br>        t.rn = 1<br>),<br>results_full AS (<br>    SELECT <br>        r.&quot;year&quot;,<br>        r.&quot;round&quot;,<br>        r.name_circuit,<br>        r.country_circuit,<br>        r.name_team,<br>        r.id_rookie,<br>        r.name_rookie_last,<br>        r.name_rookie_first,<br>        r.session_final_rookie,<br>        r.position_rookie,<br>        r.time_rookie,<br>        t.id_teammate,<br>        t.name_teammate_last,<br>        t.name_teammate_first,<br>        t.session_final_teammate,<br>        t.position_teammate,<br>        t.time_teammate,<br>        CASE <br>            WHEN r.session_final_rookie = t.session_final_teammate THEN ROUND(r.time_rookie / t.time_teammate * 100, 2)<br>            ELSE NULL<br>        END AS time_relative,<br>        CASE<br>            WHEN r.session_final_rookie &gt; t.session_final_teammate THEN 1<br>            WHEN r.session_final_rookie = t.session_final_teammate<br>                AND r.time_rookie &lt; t.time_teammate THEN 1<br>            ELSE 0<br>        END AS quali_win<br>    FROM<br>        rookie_final r<br>    INNER JOIN<br>        teammate_final t<br>     ON r.&quot;year&quot; = t.&quot;year&quot;<br>     AND r.&quot;round&quot; = t.&quot;round&quot;<br>     AND r.name_team = t.name_team<br>)<br>SELECT <br>    id_rookie,<br>    name_rookie_last,<br>    name_rookie_first,<br>    name_team,<br>    id_teammate,<br>    name_teammate_last,<br>    name_teammate_first,<br>    &quot;year&quot;,<br>    ROUND(AVG(time_relative), 2) AS time_relative_avg,<br>    SUM(quali_win) AS quali_win_total,<br>    ROUND(SUM(quali_win) * 1.0 / COUNT(*) * 100, 2) AS quali_win_pct<br>FROM<br>    results_full<br>WHERE <br> id_rookie &lt;&gt; id_teammate<br>GROUP BY<br>    id_rookie,<br>    name_rookie_last,<br>    name_rookie_first,<br>    name_team,<br>    id_teammate,<br>    name_teammate_last,<br>    name_teammate_first,<br>    &quot;year&quot;;</pre><p>Without further ado, let’s walk through the results!</p><p>We’ll start with a scatterplot comparing qualifying win percentage (x-axis) to average relative lap time (y-axis) and qualifying win count (size of each bubble/dot). As a side note, the Jupyter notebook utilized to generate all plots also resides <a href="https://github.com/AnthonyDalke/f1data/blob/main/piastri/docs/analysis.ipynb">in my project repo</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*fCct4QZDKIBrxTYypH5xiQ.png" /><figcaption>Qualifying scatterplot</figcaption></figure><p>What does this show? Well, unfortunately, our buddy Oscar doesn’t fare all too well, coming in at the bottom half on apparently all three metrics. I can’t help but view this as a noteworthy argument against his case, since, anecdotally speaking, I recall journalists and commentators pointing to the undoubtedly high peaks of his 2023 season as harbingers of future stardom. I would contend nothing, aside from wet weather sessions, showcases a driver’s utmost potential than standout qualifying performances, when the fuel loads draw down to their minimum, and the grip — and pressure — levels ramp up to their maximum.</p><p>On that note, let’s take a look at which rookies <em>have</em> stood out in qualifying since 2003, the first year of data in my history.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cOVBhPc8zlJjU9ePVNX8ZQ.png" /><figcaption>Qualifying performance by relative lap time and “wins”. Click to expand.</figcaption></figure><p>On the left, we have a bar chart for average relative lap time, with total qualifying wins as the bar color, which adds the valuable context of how many head-to-head matchups the rookie had against their teammate. Without this context, Bruno Senna’s record against Karun Chandhok in 2010 looks more impressive than Adrian Sutil’s greater advantage over Markus Winkelhock in their single head-to-head matchup in 2007, for example. Interestingly, Sutil had two teammates that year but never lost a comparable session to either. Unfortunately, racing for a backmarker against admittedly undistinguished teammates, along with <a href="https://en.wikipedia.org/wiki/Adrian_Sutil#Shanghai_nightclub_incident_and_assault_conviction">controversy</a> a few years later may ultimately overshadowed the promising start to his career.</p><p>Who else stands out? Keep in mind, the shorter the bar and the brighter the color, the better. In this view, I would argue Mick Schumacher, whose results carry the caveat of occurring against the most notorious pay driver in recent F1 memory; George Russell, who deservingly earned the monicker “Mr. Saturday” for his qualifying prowess at Williams; Jules Bianchi, <a href="https://en.wikipedia.org/wiki/Jules_Bianchi#Death">who died</a> in a tragic accident before ascending to a Ferrari race seat (what could have been?); and Charles Leclerc, <a href="https://www.formula1.com/en/latest/article/leclerc-opens-up-on-bianchi-tribute-helmet-as-he-says-former-ferrari-protege.iacdmsRymEiOxoyAQfCdu">Bianchi’s godson</a>, stand out for their combination of pace advantage and consistency. Valtteri Bottas, who certainly went on to a successful career with Mercedes, closely follows.</p><p>On the right, we see qualifying wins represented as both a count (bar size) and percentage or rate (color). Here, the larger the bar size, the better, with a brighter color still signifying superior results. The same four aforementioned drivers — Schumacher, Russell, Bianchi, and Leclerc — again impress, literally jumping to the top of the (virtual) page, with Bottas again following in their wake. Sebastian Buemi, who has enjoyed substantially greater success in endurance racing and Formula E than F1 (where he still <a href="https://www.gpblog.com/en/news/277073/horner-thanks-buemi-for-work-in-simulator-for-red-bull.html">contributes</a> as a simulator driver for Red Bull) also managed a strong showing. Eagle-eyed readers may notice a chap called Lando Norris, Piastri’s rookie teammate, in the middle of the list. We should keep this in mind as important context; Lando’s rookie season presented an early indication of his status as one of the best driver’s in today’s F1, so Oscar shouldered quite the challenge as a rookie!</p><p>I’ll wrap up this section with a couple additional observations. I must confess, I had no idea Gianmaria Bruni turned in one of the most dominant rookie seasons, at least by these metrics, of the past couple decades! And more pertinent to the topic at hand, unfortunately, Oscar doesn’t make an land on either bar chart. Consequentially, again, keeping in mind the strength of his teammate, his rookie qualifying results come off as solid, not spectacular. But, of course, the points get awarded on race day (setting aside the gimmick of sprint races…), where we now turn our focus.</p><p><strong>Race Analysis</strong></p><p>With races, I employed a similar framework, with a relative metric for time percentages — how long it took for each driver to complete an entire race distance (e.g., 01:21:24.376 vs. 01:22:48.128) — and an absolute metric for races won or lost — whether a driver posted a lower (better) finishing position than their teammate (e.g., seventh versus twelfth).</p><p>The SQL queries also resembled those of the qualifying analysis, both in terms of approach…</p><pre>→ Find the minimum season year for driver<br> - → Find the results for their team in that season by round<br> - - → Filter out rounds with a DNF (Did Not Finish) for either driver<br> - - - → Find the finishing position for each driver<br> - - - - → Calculate the total race time by incrementing the winner&#39;s overall <br>           time by each driver&#39;s interval from the winner</pre><p>…and syntax.</p><pre>WITH results_rookie AS (<br> SELECT <br>  &quot;year&quot;,<br>  &quot;round&quot;,<br>  name_circuit,<br>  country_circuit,<br>  name_team,<br>  id_driver AS id_rookie,<br>        name_driver_last AS name_rookie_last,<br>        name_driver_first AS name_rookie_first,<br>        &quot;position&quot; AS position_rookie,<br>        EXTRACT(EPOCH FROM &quot;time&quot;) AS time_rookie<br> FROM<br>  temp_rookie_results<br> WHERE <br>  &quot;session&quot; = &#39;Race&#39;<br>  AND ind_rookie = &#39;rookie&#39;<br>  AND &quot;position&quot; &lt;&gt; &#39;DNF&#39;<br>), results_teammate AS (<br> SELECT <br>  &quot;year&quot;,<br>  &quot;round&quot;,<br>  name_circuit,<br>  country_circuit,<br>  name_team,<br>  id_driver AS id_teammate,<br>        name_driver_last AS name_teammate_last,<br>        name_driver_first AS name_teammate_first,<br>        &quot;position&quot; AS position_teammate,<br>        EXTRACT(EPOCH FROM &quot;time&quot;) AS time_teammate<br> FROM<br>  temp_rookie_results<br> WHERE <br>  &quot;session&quot; = &#39;Race&#39;<br>  AND ind_rookie = &#39;teammate&#39;<br>  AND &quot;position&quot; &lt;&gt; &#39;DNF&#39;<br>), results_full AS (<br>    SELECT <br>        r.&quot;year&quot;,<br>        r.&quot;round&quot;,<br>        r.name_circuit,<br>        r.country_circuit,<br>        r.name_team,<br>        r.id_rookie,<br>        r.name_rookie_last,<br>        r.name_rookie_first,<br>        r.position_rookie,<br>        r.time_rookie,<br>        t.id_teammate,<br>        t.name_teammate_last,<br>        t.name_teammate_first,<br>        t.position_teammate,<br>        t.time_teammate, <br>        ROUND(r.time_rookie / t.time_teammate * 100, 2) AS time_relative,<br>        CASE<br>            WHEN r.position_rookie::INT &lt; t.position_teammate::INT THEN 1<br>            ELSE 0<br>        END AS race_win<br>    FROM<br>        results_rookie r<br>    INNER JOIN<br>        results_teammate t<br>     ON r.&quot;year&quot; = t.&quot;year&quot;<br>     AND r.&quot;round&quot; = t.&quot;round&quot;<br>     AND r.name_team = t.name_team<br>)<br>SELECT <br>    id_rookie,<br>    name_rookie_last,<br>    name_rookie_first,<br>    name_team,<br>    id_teammate,<br>    name_teammate_last,<br>    name_teammate_first,<br>    &quot;year&quot;,<br>    ROUND(AVG(time_relative), 2) AS time_relative_avg,<br>    SUM(race_win) AS race_win_total,<br>    ROUND(SUM(race_win) * 1.0 / COUNT(*) * 100, 2) AS race_win_pct<br>FROM<br>    results_full<br>WHERE <br> id_rookie &lt;&gt; id_teammate<br>GROUP BY<br>    id_rookie,<br>    name_rookie_last,<br>    name_rookie_first,<br>    name_team,<br>    id_teammate,<br>    name_teammate_last,<br>    name_teammate_first,<br>    &quot;year&quot;;</pre><p>While reviewing the outputs, I noticed a perplexing nuance of the race data: some of the race results from the API differed from the actual results, with more DNF’s (Did Not Finish) appearing in the data than reality. If I only had the race data for this analysis, I would have considered this a potential disqualification (no pun intended) and dedicated additional time to reconciling the disagreements. However, with the luxury of falling back on the qualifying data, I instead simply accepted this as a limitation of the race data and assigned greater weight on the qualifying analysis.</p><p>Nevertheless, for the sake of completeness, we can still walk through the race results, continuing with the plotting framework introduced in the qualifying analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/1*j4CfM1QWwFMoboe8By2xJQ.png" /><figcaption>Race scatterplot</figcaption></figure><p>Right off the bat, we can make two observations: this version of the scatterplot contains fewer datapoints than the qualifying version, due to the complication described above, and young Oscar lands in almost the exact same spot. How about the bar charts?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EIkBPxddy-5pZtsXzYLdXQ.png" /><figcaption>Race performance by relative lap time and “wins”. Click to expand.</figcaption></figure><p>Here, he finally makes an appearance, on the right chart for race win count. However, notice the dark purple color of his bar, signifying a low percentage of race wins in his rookie season. In other words, yes, his relatively high count of race wins benefitted from a historically long season.</p><p>Accounting for this context, some expected names like infamous 2021 rivals Lewis Hamilton (arguably the most impressive on this viewing, since he squared up against another all-time great, in Fernando Alonso) and Max Verstappen rise to the top. However, some unexpected names, like Heikki Kovalainen (who other analyses <a href="https://f1metrics.wordpress.com/2019/11/22/the-f1metrics-top-100/">have actually recognized</a>, as well) and Cristiano da Matta also score well. Mick Schumacher’s score carries the same caveat for quality of competition. And although one can say the same for Jules Bianchi, his results once again prompt the haunting question of what could have been.</p><p><strong>Conclusion</strong></p><p>So, there we have it: Oscar Piastri’s rookie season, while boasting high points, especially when considered in the context of the quality of his teammate, doesn’t particularly stand out statistically and historically. Now, does this mean he won’t ascend to the heights predicted by many in the F1 orbit? Of course not! After all, teams operate with reams of telemetry and other data unavailable to those of us in the general public, not to mention considerably deeper expertise of the sport. However, this analysis offered an assessment of his performance with data we <em>do</em> have at our disposal.</p><p>Now, you may ask, what’s next? In all honesty, this project took me <em>significantly</em> longer than anticipated, even when accounting for realities of working on it nights and weekends alongside a full-time career and parenting four young kids. Of course, I had to take breaks when work and/or family live grew especially demanding. Still, when embarking on the journey over “Christmas break” last year, I would not have expected it to take almost a full year to complete.</p><p>For that reason, this may end up as the final installment of the series. I’d envisioned utilizing it as the foundation for additional practice and training, on topics such as automated data quality checks, CI/CD tooling, dbt, DuckDB, and Polars. I won’t entirely rule out that possibility, but I certainly won’t regard it with the same level of certainty. At the very least, I plan to take a break over the holidays.</p><p>Nevertheless, I found the experience worthwhile, educational, and satisfying. If you followed along, I sincerely hope you felt the same way and we both learned a bit more about the fascinating world of Formula 1 (and, I suppose, the data world, too ;-) )! Thank you for reading!</p><p><strong>I. </strong><a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-c8d803d4f1f7"><strong>Introduction</strong></a></p><p><strong>II. </strong><a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-430544218107"><strong>Data Requirements Gathering</strong></a></p><p><strong>III. </strong><a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-72473e5db5ce"><strong>Data Architecture</strong></a></p><p><strong>IV. </strong><a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-9efaea07b18b"><strong>Data Modeling</strong></a></p><p><strong>V. </strong><a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-8bb3e1aecd59"><strong>Development</strong></a></p><p><strong>VI. Analysis (today)</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=624e3deb8c74" width="1" height="1" alt=""><hr><p><a href="https://medium.com/anthonydalke/oscar-piastri-star-in-the-making-part-vi-624e3deb8c74">Oscar Piastri: Star in the Making? Part VI</a> was originally published in <a href="https://medium.com/anthonydalke">AnthonyDalke</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Oscar Piastri: Star in the Making?]]></title>
            <link>https://medium.com/anthonydalke/oscar-piastri-star-in-the-making-8bb3e1aecd59?source=rss----7cf377b6f0e4---4</link>
            <guid isPermaLink="false">https://medium.com/p/8bb3e1aecd59</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[formula-1]]></category>
            <category><![CDATA[f1]]></category>
            <dc:creator><![CDATA[Anthony Dalke]]></dc:creator>
            <pubDate>Wed, 23 Jul 2025 19:21:36 GMT</pubDate>
            <atom:updated>2024-12-18T01:42:51.677Z</atom:updated>
            <content:encoded><![CDATA[<h3>Oscar Piastri: Star in the Making? Part V</h3><h3>Development</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*fvT63yit5lOgrAf5LtpCyQ.jpeg" /><figcaption>Obligatory Python code stock image :-)</figcaption></figure><p>At long last, we come to the point of this project some (many?) have awaited: the code!</p><p>For the sake of any less technical readers, I’ll strive to strike a balance between highlighting key details and keeping the discussion at a bigger-picture level.</p><p><strong>Code Repository Structure</strong></p><p>To begin, let’s traverse through the project directory in <a href="https://github.com/AnthonyDalke/f1data/tree/main/piastri">my GitHub repository</a>. It contains a few sub-directories, along with multiple files that configure the infrastructure.</p><ul><li>src: This directory houses the Python scripts powering the ETL (extract, transform, and load) processes.</li><li>docs: This directory contains reference and EDA (exploratory data analysis) materials. As of now, this only consists of a Jupyter notebook to experiment with the functionality of the Fast F1 API.</li><li>functions: The Python file in this directory defines “helper” functions imported in scripts saved to src directory. I stored this in a dedicated directory for the sake of modularity. In other words, this made the functions easier to maintain, since I knew to navigate specifically to this file whenever I wanted to make a modification, rather than searching through the main ETL script (saved in the src sub-directory).</li><li>init-db.sql: This file defines SQL queries to create the schemas, tables, and indexes of a PostgreSQL database to serve as the destination of the data pulled from the Fast F1 API.</li><li>requirements.txt: This file delineates the dependencies for the Python scripts.</li><li>Dockerfile: This file configures the Docker container to utilize for the project infrastructure. I made the decision to Dockerize from the start, to practice containerization and promote reproducibility, should anyone want to build their own version of the project.</li><li>docker-compose.yml: Lastly, this file orchestrates the project by triggering the Postgres database build with theinit-db.sql file, followed by the main etl.py script in the src sub-directory.</li></ul><p><strong>Database Overview</strong></p><p>Next, it makes sense to examine the <a href="https://github.com/AnthonyDalke/f1data/blob/main/piastri/init-db.sql">init-db.sql</a> DDL (data definition language) file, which, as the second “D” in DDL suggests, defines the Postgres database where the process lands data.</p><p>In order to limit the length of this post, I won’t copy and paste the entirety of the file; interested readers can certainly click through the above links to view the actual code. Instead, I’ll highlight key considerations factoring into my approach.</p><p>—All tables reside in a single schema, sessions, for the sake of simplicity.</p><p>— One denormalized table, events_denormalized, and multiple normalized tables get created. As explained in <a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-9efaea07b18b">the previous installment of this series</a>, I went with both to practice data modeling and ultimately compare the performance of queries pulling the same results from the normalized and denormalized tables.</p><p>— I created at least one index on each table. Indexes constitute one of the single most powerful optimization tools of PostgreSQL SELECT queries, at the expense of impeding performance of INSERT queries. This use case will see significantly more of the former than the latter query (races producing new data occur once a week at the most), making this tradeoff easy to evaluate.</p><p>— Those indexes overlap with the primary keys of each table, on the grounds that JOINs and WHERE clauses will revolve around those fields.</p><p>Now that we’ve established foundational knowledge of the eventual data produced by this broader process, we can now move on to the logic driving the process.</p><p><strong>Data Classes</strong></p><p>Within the src directory of the repo I created a processing sub-directory with files defining classes to represent data objects instantiated with each API call.</p><p>—data_event.py isolates key details from the session object the API returns for individual events. For instance, it returns attributes like the year, round, and circuit from the raw session object.</p><p>— data_quali.py cleanses, formats and reshapes raw data for qualifying sessions.</p><p>— Similarly, data_race.py performs similar actions on raw data for race sessions.</p><p>— Note, data_quali.py and data_race.py output data as Pandas DataFrames with the same structure, to facilitate joining elsewhere in the broader ETL process.</p><p>— data_normalized.py essentially takes DataFrames instantiated from the aforementioned classes and creates additional DataFrames to load into the normalized tables in the Postgres database. For example, the .get_df_drivers() method creates a DataFrame to load into the sessions.drivers table.</p><p>As an avid fan of consistency, I incorporated a similar structure for data_quali.py, data_race.py, and data_event.py. Each contains private methods __get_df_raw(), __get_df_processed(), and __get_df_final(), along with an “orchestration” method to run each sequentially and utilize the output in the following step. In other words, the output of __get_df_raw() gets applied as the input to __get_df_processed(), which gets applied as the input to __get_df_final(). This adheres to the familiar ETL pattern of extracting, transforming, and loading data from its raw state to a usable one.</p><p>To offer a peek behind the curtain, I originally devised the various methods as individual functions for each “family” of data, as in one set of functions for qualifying data, one for race data, one for event data, and one for normalized data. Then, I reflected on how the broader process re-creates the objects for each round and year and identified an opportunity to refactor the functions into reusable classes with methods to perform the reptitive data manipulation. As a side benefit, this enabled me to practice object-oriented programming, a discipline where I admittedly lack extensive experience!</p><p><strong>Helper Functions</strong></p><p>Next, we’ll take a look at the functions.py file within the functions sub-directory. Here, I defined functions to perform more isolated actions stitching together steps in the broader process, hence referring to them as “helper functions”. I’ll offer a brief overview of each.</p><p>— setup_logger() simply configures a logger to track progress during runs of the process.</p><p>— get_years() returns a list of all the individual years between two years, inclusive of the start and end.</p><p>— get_rounds() calls retrieves the rounds for a given year via the Fast F1 API’s get_event_schedule() function.</p><p>— get_data_session() calls the API’s get_session() function for a given year, round, and session (for example, the race for round 1 of 2022).</p><p>— get_df_denormalized() concatenates DataFrames for session results and event details into a single larger DataFrame for loading into a denormalized table — events_denormalized in this case.</p><p>— get_env_var() extracts environment variables from a .env file and sets them as actual environment variables.</p><p>— set_env_var() retrieves environment variables and assigns them to Python variables, to then reference as arguments to other functions.</p><p>— write_df_postgres() takes a DataFrame and writes it to a given table in the Postgres database.</p><p>— email_missing_data() sends an email with dictionaries listing any session objects, events, qualifying sessions, or races that failed to return data, supplying a form of data quality monitoring.</p><p>These functions get imported and called in etl.py, which we’ll explore in the next section.</p><p><strong>ETL Script</strong></p><p>With the heavy lifting for the processing already shouldered by the data classes and helper functions, the etl.py script located in the src directory essentially just ties together everything to perform the actual extraction, transformation, and loading (hence, the file name).</p><p>— The extract_transform_history() function iterates through the rounds of each year under consideration; instantiates, fetches, and prepares the qualifying, race, and event data via the data classes for each; then combines the iterations into a single, larger DataFrame for each. Note, the process sleeps for three seconds between the steps for each type of data (for instance, three seconds between qualifying and race data steps) to avoid hitting rate limits with the Fast F1 API.</p><p>— The extract_transform_tables() enacts a different form of ETL, extracting data from the DataFrames created with the previous function, transforming it to the structure applicable to each table in the Postgres database, and loading it into new DataFrames specific to each table.</p><p>— The load_postgres() function executes the actual loads in the database by creating mappings of the relevant table name and primary key(s) for each DataFrame.</p><p>— Finally, the main() function sets the holistic workflow in motion, extracting the environment variables stored in a .env file (not committed to the repo for the sake of security), determining the years to pull, and calling the aforementioned functions, emailing about any data missing from the API calls.</p><p><strong>Containerization Approach</strong></p><p>This serves as a fitting segue to the containerization of the project, since the Dockerfile contains a command to run etl.py when the container starts. Zooming out to view the Dockerfile more broadly, it implements a simple series of commands.</p><ol><li>Utilize a slim version of Python 3.9 (this use case didn’t demand any particularly cutting-edge features of Python).</li><li>Define the container’s working directory as /app.</li><li>Extend the Python path to include /app.</li><li>Copy the files in my local clone of the GitHub repo to the container.</li><li>Install the dependencies enumerated in requirements.txt.</li><li>Run etl.py.</li></ol><p>Then, the docker-compose.yml file steps in as the conductor of the symphony, if you’ll permit an analogy. It outlines two services, one for the Postgres database and one for the Python app. Let’s delve into a few key details for the Postgres service.</p><ol><li>It incorporates environment variables stored in the .env file to avoid hard-coding directly in the Docker Compose file.</li><li>It maps the value of the port environment variable to 5432.</li><li>It designates the location of volumes to preserve the data loaded into the database. This eliminates the need to re-load any years already processed after stopping and starting the container.</li><li>Finally, it offers health checks to monitor the status of the database, which the Python app service leverages.</li></ol><p>The Python app involves a few key details of its own.</p><ol><li>As just noted, it observes the health check of the database before launching the service.</li><li>It recognizes the .env file for the environment variables.</li><li>It then applies the values of the variables.</li></ol><p>Thanks to the Docker Compose file, running the process becomes as straightforward as setting the years to pull in the .env file, navigating to the project directory after cloning the repo, and then entering either docker-compose build, followed by docker-compose up or just docker-compose up --build in one fell swoop!</p><p>I worked my way through the 2003 through 2024 seasons in just this fashion, pulling one to five seasons at a time, depending on the time I had available to monitor the results as they trickled through the process.</p><p><strong>Conclusion</strong></p><p>And there we have it: the code for this project! As always, I welcome any feedback or suggestions for improvement. Next time, we’ll hone in on answering the questions that sparked this endeavor in the first place. Does Oscar Piastri’s rookie season portend greatness? Come back to learn more!</p><p><strong>I. </strong><a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-c8d803d4f1f7"><strong>Introduction</strong></a></p><p><strong>II. </strong><a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-430544218107"><strong>Data Requirements Gathering</strong></a></p><p><strong>III. </strong><a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-72473e5db5ce"><strong>Data Architecture</strong></a></p><p><strong>IV. </strong><a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-9efaea07b18b"><strong>Data Modeling</strong></a></p><p><strong>V. Development (today)</strong></p><p><a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-part-vi-624e3deb8c74"><strong>VI. Analysis</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8bb3e1aecd59" width="1" height="1" alt=""><hr><p><a href="https://medium.com/anthonydalke/oscar-piastri-star-in-the-making-8bb3e1aecd59">Oscar Piastri: Star in the Making?</a> was originally published in <a href="https://medium.com/anthonydalke">AnthonyDalke</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Oscar Piastri: Star in the Making? Part IV]]></title>
            <link>https://medium.com/anthonydalke/oscar-piastri-star-in-the-making-9efaea07b18b?source=rss----7cf377b6f0e4---4</link>
            <guid isPermaLink="false">https://medium.com/p/9efaea07b18b</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[f1]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[formula-1]]></category>
            <dc:creator><![CDATA[Anthony Dalke]]></dc:creator>
            <pubDate>Wed, 23 Jul 2025 19:21:30 GMT</pubDate>
            <atom:updated>2024-12-18T01:42:34.350Z</atom:updated>
            <content:encoded><![CDATA[<h3>Data Modeling</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*8VTqfq_MdkiufkSs-4RydA.jpeg" /><figcaption>Canonical data modeling example</figcaption></figure><p>Data Modeling generally fails to garner as much attention as flashier topics within data engineering. However, that has begun to change, with prominent voices in the DE world, perhaps most notably <a href="https://www.youtube.com/watch?v=JeeqpK3o3LQ">Zach Wilson</a> and <a href="https://practicaldatamodeling.substack.com/">Joe Reis</a>, emphasizing the <em>fundamental</em> (see what I did there — Joe writes at length with co-author Matt Housley about data modeling in their book <a href="https://www.amazon.com/_/dp/1098108302?smid=ATVPDKIKX0DER&amp;_encoding=UTF8&amp;tag=oreilly20-20">Fundamentals of Data Engineering</a>) role data modeling can play.</p><p>Joe and Matt recommend tackling data modeling in stages, beginning with a conceptual model, advancing to a logical model, and culminating with a physical model. This exercise can illuminate considerations such as normalization, primary and foreign key relationships, and data types.</p><p>Still, theory only goes so far. I wanted the experience of walking through each step of that journey, again, with Joe and Matt’s book as my guide. Why not build on the understanding of how to utilize the FastF1 API from <a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-72473e5db5ce">the last installment</a> of this project to practice modeling the data?</p><p><strong>Conceptual Data Model</strong></p><p>As stated above, data modeling should begin at the conceptual level — thinking about the real-world entities, activities, and relationships intended to capture in the data. In a business context, this could involve contemplating how a transaction moves through a retail store’s processes, to lean on a common example. For the purposes of this project, I made the following observations.</p><p>— F1 revolves around events.</p><p>— Individual drivers participate in those events.</p><p>— Those events take place at circuits.</p><p>— The drivers finish events with local maximum and overall results, such as fastest lap and finishing position, respectively.</p><p>— -They compile a history of sessions.</p><p>— They also drive with teammates, who offer their most direct comparisons.</p><p>A highly simplified visualization of these relationships might look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*1BMruu-BbzgP4nO7mKNNYA.png" /><figcaption>Simple and visual conceptual data model</figcaption></figure><p><strong>Logical Data Model</strong></p><p>With this “directional” sense of data entities and relationships established, I proceeded to the logical level, where I brainstormed the tables to appropriately encompass the entities in the conceptual model. This consisted of fields, data types, and primary and foreign keys, all stated from a general, not database engine-specific, standpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UDvImq5nKuSQRVK7Vl04yQ.png" /><figcaption>Visualized logical data model</figcaption></figure><p><strong>Physical Data Model</strong></p><p>Finally, I progressed to the physical level. At this point, the model grows even more specific and granular, layering in database-level considerations such as schemas, exact data types, and join relationships. Notice the field names shift from more natural language to standardized conventions with underscores. Also note <strong>bolded</strong> fields indicate an index. Since I decided on a Postgres database, the data types shown here pertain to Postgres.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gf8jwVLdlHjJ1aYRsiTffQ.png" /><figcaption>Visualized physical data model</figcaption></figure><p><strong>Normalization</strong></p><p>Attentive readers may have noted an observation: my discussion of data modeling assumed a degree of normalization. I don’t want to skip over this point: normalization vs. denormalization constitutes one of the most fundamental trade-offs in data modeling. The “correct” choice revolves around how the strengths of each align with the particular demands of use cases.</p><p>In short, normalization optimizes for storage and promotes data consistency by avoiding data duplication. This comes at the expense of compute, requiring potentially complex joins.</p><p>On the other hand, denormalization optimizes for compute at the expense of storage, accepting the cost of housing additional, potentially duplicated, records to avoid computationally expensive joins. For less technical user bases, this can supply the benefit of a lower learning curve, as well.</p><p>In my case, I wanted to practice with both paradigms, assessing the process of modeling and impact on performance of each. To that end, I constructed a denormalized data model to test alongside the normalized model discussed above. Furthermore, I stepped through the transformation of that denormalized model to the <a href="https://www.geeksforgeeks.org/first-normal-form-1nf/">first normal</a> and <a href="https://www.geeksforgeeks.org/second-normal-form-2nf/">second normal</a> forms.</p><p>To begin, the denormalized model looked like the following image. Again, <strong>bolded</strong> fields received indexes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*BC48-zhpCNSqhRTH7YvwpA.png" /><figcaption>Denormalized data model</figcaption></figure><p>Considering how I expect the API data to populate the fields, the denormalized model seemingly satisfies the requirements for the first normal form: no nested or duplicated values. Treating the year, round, id_driver and session fields as a composite key, the records should contain unique values. Stated more succinctly, each driver only appears for one team in a given session in a given round and year. Furthermore, the exploration undertaken in my previous article suggested none of the fields in question produce nested values.</p><p>Advancing to the second normal form calls for removing partial dependencies. This does mandate certain changes. First, the country_circuit field depends onname_circuit. Second, name_driver_last and name_driver_first depend on id_driver. To achieve second normal form, let’s move the partial dependency fields to dedicated tables called circuit and driver.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*G4sOW649qzutw3fZ7E0mMA.png" /><figcaption>Second normal form data model</figcaption></figure><p>While additional normal forms exist, I stopped at this point, as I had intended the exercise as a means to simply grow more comfortable moving between denormalization and the levels of normalization. In full transparency, this marked my first experience methodically stepping through this process, so I welcome feedback, especially on any mistakes!</p><p><strong>Where to Go from Here</strong></p><p>Moving forward, the focus of these pieces will shift toward coding. That will come to the delight of some, but for any less technical readers, rest assured I’ll try to explain what I had in mind as I walk through code.</p><p>As a note of caution, the weekly publishing schedule I’ve followed to this point will extend out of necessity, as, again, in full transparency, the development remains a work in progress.</p><p>In the meantime, if you haven’t, I invite you to take the pause as an opportunity to catch up on the previous articles, all linked below! Thank you for reading!</p><p><strong>I. </strong><a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-c8d803d4f1f7"><strong>Introduction</strong></a></p><p><strong>II. </strong><a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-430544218107"><strong>Data Requirements Gathering</strong></a></p><p><strong>III. </strong><a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-72473e5db5ce"><strong>Data Architecture</strong></a></p><p><strong>IV. Data Modeling (today)</strong></p><p><a href="https://medium.com/p/8bb3e1aecd59/edit"><strong>V. Development</strong></a></p><p><a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-part-vi-624e3deb8c74"><strong>VI. Analysis</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9efaea07b18b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/anthonydalke/oscar-piastri-star-in-the-making-9efaea07b18b">Oscar Piastri: Star in the Making? Part IV</a> was originally published in <a href="https://medium.com/anthonydalke">AnthonyDalke</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Oscar Piastri: Star in the Making? Part III]]></title>
            <link>https://medium.com/anthonydalke/oscar-piastri-star-in-the-making-72473e5db5ce?source=rss----7cf377b6f0e4---4</link>
            <guid isPermaLink="false">https://medium.com/p/72473e5db5ce</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[f1]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[formula-1]]></category>
            <dc:creator><![CDATA[Anthony Dalke]]></dc:creator>
            <pubDate>Wed, 23 Jul 2025 19:21:23 GMT</pubDate>
            <atom:updated>2024-12-18T01:42:07.431Z</atom:updated>
            <content:encoded><![CDATA[<h3>Data Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kREAgyQvZ0ObE5vcOyi3Xg.jpeg" /></figure><p>Welcome to the third installment in this series assessing the historical strength of Oscar Piastri’s rookie season! Parts <a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-c8d803d4f1f7">I</a> and <a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-430544218107">II</a> respectively focused on an overview and data requirements gathering. Today, we’ll get more granular (and wet our coding beaks), identifying where to find required data points in the <a href="https://docs.fastf1.dev/">FastF1</a> API’s ecosystem and how to translate that into data architecture.</p><p>Recall that in <a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-430544218107">the previous part</a> of this project, I concluded the Results and EventsSchedule topics from the API satisfied my data requirements. While this helped get a “lay of the land”, I wanted to dig deeper, pinpointing the specific fields to retrieve and where to find them. To explore the structure of the data in the in the API’sSession and EventSchedule objects, I took the quick-and-dirty approach of entering a few basic commands in a Jupyter notebook.</p><pre>import fastf1 as ff1<br><br>schedule = ff1.get_event_schedule(1994)<br>print(f&quot;Round numbers in 1994 season: {schedule.RoundNumber.to_list()}&quot;)<br><br>session_quali = ff1.get_session(2020, 1, &quot;Q&quot;)<br><br>session_quali.load()<br>session_event = session_quali.event<br>print(f&quot;Preview of event data in session object: {session_event}&quot;)<br><br>session_race = ff1.get_session(2020, 1, &#39;R&#39;).results()<br><br>session_race.load()<br>session_results = session_race.results<br>print(f&quot;Preview of results data in session object: {session_results}&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7z9ii1GqHGuJSKtdhpHhsg.png" /><figcaption>Retrieving round numbers in a given season</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NABVaWBJacF7o_YoUnixGw.png" /><figcaption>Exploring the contents of session event data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RfChv2DFQU2rZQKfrZi-WA.png" /><figcaption>Exploring the contents of session result data</figcaption></figure><p>I continued playing around to gain a sense of the fields in each object. To summarize my findings, I assembled tables connecting the fields I ultimately wanted for the analysis to the API object exposing them and their assigned column names in the API. That resulted in the following.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ouboGhQ4RR06SXeqaYcq1A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ak0qFhyrt8uZ0ycJ08g12A.png" /></figure><p>During this exploration, I also noted a few observations about working with the API.</p><p>— The get_session() function call takes roughly 15 to 20 seconds for the initial load of a single session. After that, the API leverages caching to reduce subsequent calls of the same session’s data to a single second.</p><p>— For qualifying data, only the Position field contains values, as opposed to race data, which both Position and ClassifiedPosition.</p><p>— Also for qualifying data, values can differ by era. For example, historical years featured different qualifying formats, so no values appear for Q3 sessions.</p><p>— The Status field indicates whether a driver could not finish a race. Alternatively, records with a value of “R” for ClassifiedPosition correspond to a DNF, as well.</p><p>— Rate limiting could affect larger data pulls, such as for multiple seasons. Incorporating the sleep function from Python’s time module should reduce the impact.</p><p>Next, I started thinking about how to structure the pipeline and project infrastructure. My mind naturally gravitates toward bulletpoints, so that resulted in the following.</p><p>— Since the API natively incorporates Pandas dataframes to represent data, it made sense to embrace a Pandas-centric approach to data transformations. Pandas reaches limitations at greater data volumes, since it stores data in memory, but that wouldn’t come into play with this project.</p><p>— I wanted the option to store this data for future analyses or other projects, so I decided to create a Postgres database and write to it via a library like sqlalchemy.</p><p>— For the actual analysis, a SQL-, rather than Python-centric, approach held greater appeal, since it opened the door to experimenting with tools like dbt at some point.</p><p>— I made a point of containerizing the project to practice my Docker skills and aid reproducibility.</p><p>To offer a basic visual depiction of the data architecture, I envisioned it looking something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s5IPXk01-WvuTrU11h_NIA.png" /><figcaption>Simplified data architecture</figcaption></figure><p>At that point, I felt fairly comfortable with the broad strokes of the project and set my sights on practicing another data engineering skill I’ll explain next time: data modeling.</p><p>Thank you for reading, and I hope you come back again!</p><p><strong>I. </strong><a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-c8d803d4f1f7"><strong>Introduction</strong></a></p><p><strong>II. </strong><a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-430544218107"><strong>Data Requirements Gathering</strong></a></p><p><strong>III. Data Architecture (today)</strong></p><p><a href="https://medium.com/p/9efaea07b18b/edit"><strong>IV. Data Modeling</strong></a></p><p><a href="https://medium.com/p/8bb3e1aecd59/edit"><strong>V. Development</strong></a></p><p><a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-part-vi-624e3deb8c74"><strong>VI. Analysis</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72473e5db5ce" width="1" height="1" alt=""><hr><p><a href="https://medium.com/anthonydalke/oscar-piastri-star-in-the-making-72473e5db5ce">Oscar Piastri: Star in the Making? Part III</a> was originally published in <a href="https://medium.com/anthonydalke">AnthonyDalke</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Oscar Piastri: Star in the Making? Part II]]></title>
            <link>https://medium.com/anthonydalke/oscar-piastri-star-in-the-making-430544218107?source=rss----7cf377b6f0e4---4</link>
            <guid isPermaLink="false">https://medium.com/p/430544218107</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[formula-1]]></category>
            <category><![CDATA[f1]]></category>
            <dc:creator><![CDATA[Anthony Dalke]]></dc:creator>
            <pubDate>Wed, 23 Jul 2025 19:21:18 GMT</pubDate>
            <atom:updated>2024-12-18T01:41:35.454Z</atom:updated>
            <content:encoded><![CDATA[<h3>Data Requirements Gathering</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*NYelDHZe15Ld5voooEuTkQ.png" /><figcaption>Courtesy of the FastF1 API GitHub page</figcaption></figure><p>In <a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-c8d803d4f1f7">the first installment</a> of this series, I explained its purpose and structure. Today, we delve into an unglamorous but essential phase of any data project: requirements gathering.</p><p>Taking the time to probe, clarify, and document requirements may feel like an impediment — an obstacle to summit before the real fun begins. After all, who doesn’t love rolling up their sleeves and diving into the data itself, writing that sweet, sweet code, enjoying the satisfaction of building something that runs, and probing for answers? Patience… We’ll get there, but the time spent up front to solidify what data we need, where to go for it, and what to seek from it will prove worth the investment.</p><p>When considering requirements, I like to start with the end goal and work backward. What problem(s) do we ultimately want to solve? Once we establish that, what question(s) can we answer to solve the problem(s)? Working back from that, what data points do we require? And then working back from <em>that</em>, where can we obtain the data? Placed within the context of this endeavor, my thought process emerged as follows:</p><p><strong>Problem to solve</strong></p><ul><li>Assess how Oscar Piastri’s rookie season compared to others in recent F1 history.</li></ul><p><strong>Questions to Ask</strong></p><ul><li>How did his qualifying pace relative to his teammate compare to recent F1 rookies?</li><li>How about his race results relative to his teammate?</li></ul><p><strong>Required Data Points</strong></p><ul><li>Qualifying lap times by driver, Grand Prix weekend, and session (if a GP weekend saw a dry Q1 but wet Q3, simply taking a driver’s quickest time overall in qualifying might lead to misleading conclusions, since their slower Q3 lap time would have actually set the grid, making distinguishing Q1 from Q2 and Q3 important)</li><li>Race finishing position by driver and Grand Prix, with indications of reliability (DNF — Did Not Finish — and DNS — Did Not Start) to compare only full races</li><li>Team and driver references — namely, which drivers raced for which teams, to identify teammates and a driver’s first season</li></ul><p><strong>Data Source Evaluation</strong></p><ul><li>Google searches for F1 data sources alerted me to the <a href="https://docs.fastf1.dev/">FastF1 API</a>. I dug into the documentation and compared the <a href="https://docs.fastf1.dev/#available-data">data points available through the API</a> to my requirements. Stated succinctly, that process went as follows:</li></ul><p>— Finishing positions by driver and session come from a combination of the API’s <em>Results</em> and <em>EventsSchedule</em> topics.</p><p>— Team info (drivers by team) also comes from the <em>Results</em> topic.</p><p>— Qualifying times by driver and session come from the <em>Results</em> and <em>EventsSchedule</em> topics, as well.</p><p>— Driver info can additionally come from the <em>Results</em> topic, as we could technically isolate the minimum year and round number (round number refers to a Grand Prix’s ordinal position in the year’s schedule)</p><ul><li>Thus, the API appeared perfectly fit for purpose!</li></ul><p>At that point, I could confidently conclude FastF1 satisfied my requirements, and I needed to look no further. Instead, I could devote that time toward extending gratitude to the API’s creators and maintainers for their bountiful work!</p><p>In the next installment, we’ll get a little more technical, walking through how I structured the project, both from process and code standpoints, and more closely examined the API documentation to determine where to find the specific data points I sought.</p><p>Thank you for reading!</p><p><strong>I. </strong><a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-c8d803d4f1f7"><strong>Introduction</strong></a></p><p><strong>II. Data Requirements Gathering (today)</strong></p><p><a href="https://medium.com/p/72473e5db5ce/edit"><strong>III. Data Architecture</strong></a></p><p><a href="https://medium.com/p/9efaea07b18b/edit"><strong>IV. Data Modeling</strong></a></p><p><a href="https://medium.com/p/8bb3e1aecd59/edit"><strong>V. Development</strong></a></p><p><a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-part-vi-624e3deb8c74"><strong>VI. Analysis</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=430544218107" width="1" height="1" alt=""><hr><p><a href="https://medium.com/anthonydalke/oscar-piastri-star-in-the-making-430544218107">Oscar Piastri: Star in the Making? Part II</a> was originally published in <a href="https://medium.com/anthonydalke">AnthonyDalke</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Oscar Piastri: Star in the Making?]]></title>
            <link>https://medium.com/anthonydalke/oscar-piastri-star-in-the-making-c8d803d4f1f7?source=rss----7cf377b6f0e4---4</link>
            <guid isPermaLink="false">https://medium.com/p/c8d803d4f1f7</guid>
            <category><![CDATA[f1]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[formula-1]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Anthony Dalke]]></dc:creator>
            <pubDate>Wed, 23 Jul 2025 19:20:57 GMT</pubDate>
            <atom:updated>2024-12-18T01:40:53.362Z</atom:updated>
            <content:encoded><![CDATA[<h3>Oscar Piastri: Star in the Making? Part I</h3><h3>Introduction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/1*hO5DhShuNhuJ-BaFcV1_Jg.jpeg" /><figcaption>The man himself</figcaption></figure><p>Every so often a new Formula 1 driver bursts onto the scene and captures the attention of fans and media. They garner lofty labels like “future champion”, “young gun”, or “budding star”. Twenty-two-year-old Oscar Piastri has emerged as the latest such figure, on the heels of an impressive rookie 2023 season, punctuated by standout performances in the <a href="https://youtube.com/shorts/muV0_3WHVYc?si=BTBUI6fUPURDsXZv">Belgian</a>, <a href="https://www.youtube.com/watch?v=wL2zFNvfGNs">Japanese</a>, and <a href="https://www.youtube.com/watch?v=3N8ijzInRrk">Qatar</a> Grands Prix, the latter of which included a sprint race victory. Piastri has largely built on his impressive rookie campaign, recently notching <a href="https://youtu.be/jUphBQWJcM0?si=cTlhhy51irL53vWJ">his first Grand Prix victory</a> in Hungary.</p><p>As a fan of sports like baseball, hockey and (American) football, sadly I’ve found F1 lacking from a statistical standpoint. Sure, we can easily enough observe simple “outcome” metrics like points, race wins, and pole positions, but the absence of underlying “process” statistics, such as car traits — downforce levels, tire temperatures, battery states, etc. — saddles the outside observer with relatively sparse samples of only somewhat informative data. Furthermore, the level of contextual details unavailable to the public renders comparative analysis even more challenging. For example, teams rarely divulge the impact of damage or suboptimal car setups, and we rarely gain insight into fuel levels, especially in practice and qualifying sessions.</p><p>So, does that mean we should throw up our hands and abandon empirical analysis? Of course not! Rather, it means we make the best out of what we <em>do</em> have available, avoiding broad, sweeping conclusions in most cases and acknowledging caveats and shortcomings.</p><p>To that end, I set out to answer a specific, simple question: how did Piastri’s rookie season compare to others in recent F1 history? To place this within the lexicon of the data and broader business worlds, this would amount to the business problem definition. To answer this question, I identified two metrics to calculate:</p><ol><li><strong>A rookie driver’s average qualifying gap to his teammate</strong>. As noted by the greatest current F1 journalist, <a href="https://x.com/SportmphMark?ref_src=twsrc%5Egoogle%7Ctwcamp%5Eserp%7Ctwgr%5Eauthor">Mark Hughes</a>, a driver’s peaks often provide the most telling indications of his potential. What better way to assess peaks than to hone in on the most demanding moment of a Grand Prix weekend, when the fuel levels come down, the power levels come up, the grippiest tires get fitted, and drivers have to summon the absolute limits of their skills?</li><li><strong>A rookie’s average position finish relative to their teammate</strong>. If the previous metric speaks to outright performance, this speaks to consistency, adaptability, and versatility. And while generally speaking, the best qualifiers turn in the best race results, plenty of exceptions to the rule exist. Just ask Jarno Trulli, who none other than Fernando Alonso himself <a href="https://www.racefans.net/2014/08/18/f1-fanatic-round-up-1808-2/">anointed</a> as his most difficult teammate in qualifying, only to finish his career with a single win and 11 podiums. Or even consider current (and three-time) champion Max Verstappen, who has 61 career wins on “only” 40 career poles. At the end of the day, points determine the standings, and races obviously determine the points.</li></ol><p>This series will unfold in the following installments, which I hope will depict my general approach to framing and solving data problems. I also devised this project as a means to practice skills relevant to my job as a Data Engineer. I invite you to come along for the ride (pun very much intended) and learn whether the numbers indicate the young <a href="https://www.abc.net.au/news/2023-03-31/oscar-piastri-formula-1-career-grand-prix-starting-grid/102172834">Australian</a> is as impressive as the surface results suggest!</p><p><strong>I. Introduction (today)</strong></p><p><a href="https://medium.com/p/430544218107/edit"><strong>II. Data Requirements Gathering</strong></a></p><p><a href="https://medium.com/p/72473e5db5ce/edit"><strong>III. Data Architecture Overview</strong></a></p><p><a href="https://medium.com/p/9efaea07b18b/edit"><strong>IV. Data Modeling</strong></a></p><p><a href="https://medium.com/p/8bb3e1aecd59/edit"><strong>V. Development</strong></a></p><p><a href="https://medium.com/@anthonydalke/oscar-piastri-star-in-the-making-part-vi-624e3deb8c74"><strong>VI. Analysis</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8d803d4f1f7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/anthonydalke/oscar-piastri-star-in-the-making-c8d803d4f1f7">Oscar Piastri: Star in the Making?</a> was originally published in <a href="https://medium.com/anthonydalke">AnthonyDalke</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Much Does Defense Matter in the NHL?]]></title>
            <link>https://medium.com/anthonydalke/how-much-does-defense-matter-in-the-nhl-cdd2318169a1?source=rss----7cf377b6f0e4---4</link>
            <guid isPermaLink="false">https://medium.com/p/cdd2318169a1</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[sports-analytics]]></category>
            <category><![CDATA[nhl]]></category>
            <category><![CDATA[hockey]]></category>
            <dc:creator><![CDATA[Anthony Dalke]]></dc:creator>
            <pubDate>Wed, 23 Jul 2025 19:20:16 GMT</pubDate>
            <atom:updated>2019-07-06T03:54:36.716Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*EpvKJIQQbgf8wXUmnrX3iA.jpeg" /><figcaption>Duncan Keith and Brent Seabrook, the stalwarts of the Blackhawks’ blue line</figcaption></figure><p>If you have even a passing interest in sports, you’ve likely heard the truism “defense wins championships.” Countless debates to this effect have reigned throughout the years. I suppose I’ve come to make my contribution.</p><p>Really, though, I set out to answer a very specific question: do good NHL teams tend to owe their success more to defensemen than forwards? I’ve considered this in the past, largely due to a hypothesis the 2009–2010 Blackhawks team that broke the franchise’s Stanley Cup drought reached its shot-dominating heights thanks to a sterling defensive corps. After all, few teams can boast skilled puck-movers, such as Duncan Keith, Brian Campbell and Nick Leddy, and breakout passers, like Keith again and Brent Seabrook, up and down their pairings. This question really started swirling in my mind after the team unexpectedly nabbed the third pick in the NHL Draft lottery. With no prospect ranked as the consensus third-best, the merits of using that choice on another defenseman — more specifically, Bowen Byram — in the wake of selecting a blueliner with their first pick in each of the past three drafts emerged as a fascinating topic of discussion. That brought me to my specific question: do teams that derive a greater percentage of their total Wins Above Replacement (WAR) from defenseman tend to produce better records, in the form of points?</p><p>I also set out on this project with an ulterior motive: to practice data wrangling, exploratory data analysis (EDA) and web scraping in Python. I’ll begin by explaining my data sourcing approach, then walk through the organization and manipulation of that data and finally examine the results.</p><p>When considering options for data, two sources emerged as viable options: Evolving-Hockey’s Wins Above Replacement (<a href="https://hockey-graphs.com/2019/01/16/wins-above-replacement-history-philosophy-and-objectives-part-1/">WAR</a>) leaderboard and Hockey-Reference’s Point Shares history. Both offered calculations of the relative value contributed by players, albeit with different methodologies. I settled on the former because Evolving-Hockey organizes and presents their data in the exact format and fashion I had in mind, with the ability to aggregate WAR by team, season and positional grouping (forwards vs. defensemen). Furthermore, since the primary goal of this exercise revolves around programming practice, rather than breaking new ground in hockey research, the merits of each metric’s methodology quite frankly mattered less than how each website displayed their data.</p><p>To obtain a large, relevant sample, I exported all teams and seasons since the 2005–06 season, the first following the 2004–05 lockout. This acted as a clean starting point for the “modern NHL”, with the introduction of the hard salary cap and migration away from the “Dead Puck Era” of the 1990s and early 2000s.</p><p><strong>Initial Data Cleansing and Manipulation</strong></p><p>Then, the Pythonic fun began. I downloaded the WAR data from <a href="https://evolving-hockey.com/">Evolving-Hockey’s site</a>, imported it and then arranged it into a “tidy” format conducive to the summary statistics and plotting I planned to eventually perform.</p><p>In addition to WAR, I wanted to consider correlations between a team’s forward vs. defense orientation and goal differential. <a href="https://www.vox.com/videos/2017/6/5/15740632/luck-skill-sports">Studies</a> have pinpointed hockey as the major sport most dependent on luck (the term “puck luck” often pops up in hockey circles). While goal differential bears a strong relationship (and likely autocorrelation) with team point totals, teams exert more direct influence on the former than the latter, therefore allowing a less confounded view into the connections between team structure and performance — more signal, less noise, to use a common analogy. To take things to another level, I also incorporated Evolving-Hockey’s <a href="http://rpubs.com/evolvingwild/395136">Expected Goals metric</a>, which further reduces the impact of luck on goal differential.</p><p>So, to sum up, in addition to points totals, I decided to compare percentage of team WAR generated by defensemen to goal differential and expected goal differential.</p><pre># Install necessary packages</pre><pre>import pandas as pd<br>import numpy as np<br>import os<br>from bs4 import BeautifulSoup as soup<br>import requests<br>from pandas import DataFrame<br>import matplotlib.pyplot as plt<br>from scipy import stats</pre><pre># Set working directory<br>os.getcwd()<br>os.chdir(‘/Users/anthony/Documents/Hockey’)</pre><pre># Import data<br>war = pd.read_csv(“EvolvingWAR.csv”)</pre><pre># Create pivot table of total WAR and games played by team, season and position<br>war_pivot = pd.pivot_table(data = war, values = ‘WAR’, index = [‘Team’, ‘season’], columns = ‘position’, aggfunc = np.sum, margins = True, fill_value = 0)</pre><pre># Add calculation of percentage of total WAR contributed by defensemen<br>war_df = pd.concat([war_pivot, war_pivot[&#39;D&#39;] / war_pivot[&#39;All&#39;] * 100], axis = 1)<br>war_df.reset_index(inplace = True)<br>war_df.columns = [‘Team’, ‘Season’, ‘D_WAR’, ‘F_WAR’, ‘All_WAR’, ‘D_Pct’]</pre><pre># Import team Expected Goals totals by season<br>xgoals_files = [&#39;Evolving_Hockey_standard_team_stats_All_no_adj_2019-05-01.csv&#39;, &#39;Evolving_Hockey_standard_team_stats_All_no_adj_2019-05-01-2.csv&#39;, &#39;Evolving_Hockey_standard_team_stats_All_no_adj_2019-05-01-3.csv&#39;, &#39;Evolving_Hockey_standard_team_stats_All_no_adj_2019-05-01-4.csv&#39;, &#39;Evolving_Hockey_standard_team_stats_All_no_adj_2019-05-01-5.csv&#39;, &#39;Evolving_Hockey_standard_team_stats_All_no_adj_2019-05-01-6.csv&#39;, &#39;Evolving_Hockey_standard_team_stats_All_no_adj_2019-05-01-7.csv&#39;, &#39;Evolving_Hockey_standard_team_stats_All_no_adj_2019-05-01-8.csv&#39;, &#39;Evolving_Hockey_standard_team_stats_All_no_adj_2019-05-01-9.csv&#39;, &#39;Evolving_Hockey_standard_team_stats_All_no_adj_2019-05-01-10.csv&#39;, &#39;Evolving_Hockey_standard_team_stats_All_no_adj_2019-05-01-11.csv&#39;, &#39;Evolving_Hockey_standard_team_stats_All_no_adj_2019-05-01-12.csv&#39;]<br>xgoals_data = []</pre><pre>for filename in xgoals_files:<br>    df = pd.read_csv(filename, index_col = None, header = 0)<br>    xgoals_data.append(df)</pre><pre>xgoals_df = pd.concat(xgoals_data, axis = 0, ignore_index = True)<br>xgoals_df.columns = [&#39;Team&#39;, &#39;Season&#39;, &#39;TOI&#39;, &#39;GP&#39;, &#39;GF&#39;, &#39;GA&#39;, &#39;G_Diff&#39;, &#39;xGF&#39;, &#39;xGA&#39;, &#39;xG_Diff&#39;, &#39;SF&#39;, &#39;SA&#39;, &#39;S_Diff&#39;, &#39;FF&#39;, &#39;FA&#39;, &#39;F_Diff&#39;, &#39;CF&#39;, &#39;CA&#39;, &#39;C_Diff&#39;]</pre><pre># Create list of unique seasons<br>seasons_list = xgoals_df[&#39;Season&#39;].unique().tolist()</pre><pre># Merge war_df and xgoals_df<br>stats_df1 = pd.merge(war_df[[&#39;Team&#39;, &#39;Season&#39;, &#39;All_WAR&#39;, &#39;D_Pct&#39;]], xgoals_df[[&#39;Team&#39;, &#39;Season&#39;, &#39;G_Diff&#39;, &#39;xG_Diff&#39;]], left_on = [&#39;Team&#39;, &#39;Season&#39;], right_on = [&#39;Team&#39;, &#39;Season&#39;])</pre><p><strong>Web Scraping</strong></p><p>Next came the acquisition of team point totals. Rather than repeating the “brute force” method of downloading and then importing CSV’s from a website, I turned to web scraping to obtain the data, to practice different applications of Python. I relied on the invaluable <a href="https://www.hockey-reference.com/">Hockey-Reference</a>.</p><pre># Scrape standings<br>team_season_df = pd.DataFrame()<br>points_tag = []<br>season_counter = 0</pre><pre>hf_url = [&#39;<a href="https://www.hockey-reference.com/leagues/NHL_2019_standings.html&#39;">https://www.hockey-reference.com/leagues/NHL_2019_standings.html&#39;</a>, &#39;<a href="https://www.hockey-reference.com/leagues/NHL_2018_standings.html&#39;">https://www.hockey-reference.com/leagues/NHL_2018_standings.html&#39;</a>, &#39;<a href="https://www.hockey-reference.com/leagues/NHL_2017_standings.html&#39;">https://www.hockey-reference.com/leagues/NHL_2017_standings.html&#39;</a>, &#39;<a href="https://www.hockey-reference.com/leagues/NHL_2016_standings.html&#39;">https://www.hockey-reference.com/leagues/NHL_2016_standings.html&#39;</a>, &#39;<a href="https://www.hockey-reference.com/leagues/NHL_2015_standings.html&#39;">https://www.hockey-reference.com/leagues/NHL_2015_standings.html&#39;</a>, &#39;<a href="https://www.hockey-reference.com/leagues/NHL_2014_standings.html&#39;">https://www.hockey-reference.com/leagues/NHL_2014_standings.html&#39;</a>, &#39;<a href="https://www.hockey-reference.com/leagues/NHL_2013_standings.html&#39;">https://www.hockey-reference.com/leagues/NHL_2013_standings.html&#39;</a>, &#39;<a href="https://www.hockey-reference.com/leagues/NHL_2012_standings.html&#39;">https://www.hockey-reference.com/leagues/NHL_2012_standings.html&#39;</a>, &#39;<a href="https://www.hockey-reference.com/leagues/NHL_2011_standings.html&#39;">https://www.hockey-reference.com/leagues/NHL_2011_standings.html&#39;</a>, &#39;<a href="https://www.hockey-reference.com/leagues/NHL_2010_standings.html&#39;">https://www.hockey-reference.com/leagues/NHL_2010_standings.html&#39;</a>, &#39;<a href="https://www.hockey-reference.com/leagues/NHL_2009_standings.html&#39;">https://www.hockey-reference.com/leagues/NHL_2009_standings.html&#39;</a>, &#39;<a href="https://www.hockey-reference.com/leagues/NHL_2008_standings.html&#39;">https://www.hockey-reference.com/leagues/NHL_2008_standings.html&#39;</a>]</pre><pre>for url in hf_url:    <br>    team_tag = []<br>    response = requests.get(url)<br>    content = response.content</pre><pre>html = soup(content, &#39;html.parser&#39;)<br>    table = html.find_all(&#39;tr&#39;, attrs = {&#39;class&#39;: &#39;full_table&#39;})<br>    <br>    for i in range(0, len(table)):<br>        team_tag.append(table[i].find(&#39;a&#39;)[&#39;href&#39;])<br>        str(team_tag[i])<br>        team_tag[i] = team_tag[i].split(&#39;/&#39;)<br>        team_tag[i][0] = seasons_list[season_counter]<br>    <br>    points = html.find_all(&#39;td&#39;, attrs = {&#39;data-stat&#39;: &#39;points&#39;})<br>    for i in range(0, len(points)):<br>        points_tag.append(points[i].text.strip())<br>  <br>    team_df = DataFrame.from_records(team_tag)<br>    team_season_df = team_season_df.append(team_df)<br>    season_counter += 1</pre><pre>points_df = pd.DataFrame(points_tag, columns = [&#39;Points&#39;])<br>team_season_df.columns = [&#39;Season&#39;, &#39;DF_Name&#39;, &#39;Team&#39;, &#39;HTML&#39;]</pre><p><strong>Data Blending and Manipulation</strong></p><p>After that, it became a matter of combining these “raw materials” and preparing the data for final analysis. It required some effort to arrange, align and then combine the WAR and goal differential stats and point totals.</p><pre># Concatenate points_df and team_season_df<br>team_season_df.reset_index(inplace = True, drop = True)<br>points_df.reset_index(inplace = True, drop = True)<br>stats_df2 = pd.concat([team_season_df, points_df], axis = 1)<br>stats_df2.drop([&#39;DF_Name&#39;, &#39;HTML&#39;], axis = 1, inplace = True)</pre><pre># Compare unique values of Seaason and Team columns<br>df2_season = sorted(stats_df2[&#39;Season&#39;].unique().tolist())<br>df1_season = sorted(stats_df1[&#39;Season&#39;].unique().tolist())<br>df2_team = sorted(stats_df2[&#39;Team&#39;].unique().tolist())<br>df1_team = sorted(stats_df1[&#39;Team&#39;].unique().tolist())</pre><pre>season_check = []<br>team_check = []<br>for i in range(0, len(df2_season) - 1):<br>    season_check.append(df2_season[i] == df1_season[i])<br>for i in range(0, len(df2_team) - 1):<br>    team_check.append(df2_team[i] == df1_team[i])</pre><pre># Replace stats_df2 team names that don&#39;t match stats_df1</pre><pre>stats_df2[&#39;Team&#39;].replace([&#39;LAK&#39;, &#39;NJD&#39;, &#39;SJS&#39;, &#39;TBL&#39;, &#39;VEG&#39;, &#39;PHX&#39;], [&#39;L.A&#39;, &#39;N.J&#39;, &#39;S.J&#39;, &#39;T.B&#39;, &#39;VGK&#39;, &#39;ARI&#39;], inplace = True)</pre><pre># Create final analysis dataframe</pre><pre>analysis_df = pd.merge(stats_df1, stats_df2, left_on = [&#39;Team&#39;, &#39;Season&#39;], right_on = [&#39;Team&#39;, &#39;Season&#39;])<br>analysis_df[&#39;Points&#39;] = pd.to_numeric(analysis_df[&#39;Points&#39;])</pre><p><strong>Plotting!</strong></p><p>This resulted in having the data finally ready for the scatterplots I envisioned to check for correlations. I started by plotting the percentage of WAR contributed by defensemen to total points for every team’s season since 2005–06.</p><pre>plt.scatter(analysis_df[&#39;D_Pct&#39;], analysis_df[&#39;Points&#39;])<br>plt.xlabel(&#39;Percentage of WAR from Defensemen&#39;)<br>plt.ylabel(&#39;Points&#39;)<br>plt.yticks(np.arange(36, 128, step = 10))<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*cUm08vjlacFH3aEK9JaSkQ.png" /></figure><p>Well, the spread of this data certainly jumps out, with a small number of outliers distorting this graph and blurring the meaningful patterns clustered between -100 and 100 percent of WAR from defensemen. Negative percentages may seem odd, but they can, in fact, happen, as players fairly regularly post negative WAR numbers. Now, a team’s <em>entire defensive corps</em> netting out with a negative total occurs less frequently, but it does happen. This dataset contains only seven of these outliers — less than two percent of its over 350 team-season combinations, so I opted to exclude them and continue.</p><pre># Investigate and remove outliers<br>analysis_df[analysis_df[&#39;D_Pct&#39;] &lt; -100]<br>analysis_df[analysis_df[&#39;D_Pct&#39;] &gt; 100]<br>analysis_df_reduced = analysis_df[analysis_df[&#39;D_Pct&#39;] &gt; -100]<br>analysis_df_reduced = analysis_df_reduced[analysis_df_reduced[&#39;D_Pct&#39;] &lt; 100]</pre><p>Finally, the moment I’d waited for. Does a correlation between WAR percentage from defensemen and team points exist?</p><pre># Plot D_Pct against Points without outliers<br>plt.scatter(analysis_df_reduced[&#39;D_Pct&#39;], analysis_df_reduced[&#39;Points&#39;], c = &#39;b&#39;, edgecolors = &#39;y&#39;)<br>plt.xlabel(&#39;Percentage of WAR from Defensemen&#39;)<br>plt.ylabel(&#39;Points&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*U4lOqgopEssfrACg4jAecQ.png" /></figure><p>Well, it certainly appeared so! Tweaking the scatterplot’s colors made the individual points a bit easier to distinguish and revealed a positive, if imperfect, relationship between WAR from defensemen and points. I tried adding a linear trendline to see if it further clarified the picture.</p><pre># Add linear trendline to plot</pre><pre>slope, intercept, r_value, p_value, std_err = stats.linregress(analysis_df_reduced[&#39;D_Pct&#39;], analysis_df_reduced[&#39;Points&#39;])<br>line = slope * analysis_df_reduced[&#39;D_Pct&#39;] + intercept<br>plt.plot(analysis_df_reduced[&#39;D_Pct&#39;], analysis_df_reduced[&#39;Points&#39;], &#39;o&#39;, analysis_df_reduced[&#39;D_Pct&#39;], line, mfc = &#39;b&#39;, mec = &#39;y&#39;)<br>plt.xlabel(&#39;Percentage of WAR from Defensemen&#39;)<br>plt.ylabel(&#39;Points&#39;)<br>plt.show()<br>print(&#39;r-squared: &#39;, r_value ** 2)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*Q-rD7HLvQQzw1x6dN9Wn4w.png" /></figure><p>The trendline did seem to drive home the point (no pun intended). However, it came with an R-squared value of only 0.12, indicating it didn’t produce the greatest fit. So, while we don’t have a slam-dunk, we can draw a nice <em>directional</em> conclusion that <strong>teams with stronger defensive corps indeed end up with better records</strong>.</p><p>I could have stopped here, but I felt curious about a couple additional considerations. First, I wanted to see what kind of relationship <em>total</em> team WAR had with points.</p><pre># Plot All_WAR against Points<br>plt.scatter(analysis_df_reduced[&#39;All_WAR&#39;], analysis_df_reduced[&#39;Points&#39;], c = &#39;g&#39;, edgecolors = &#39;y&#39;)<br>plt.xlabel(&#39;Total Team WAR&#39;)<br>plt.ylabel(&#39;Points&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*HCS8z8P4VB8SK3G6cul0Hg.png" /></figure><p>Wow, quite the strong correlation! This shouldn’t come as a surprise, since teams with greater WAR totals employ, quite frankly, stronger rosters. In other words, large WAR totals by definition signify good teams.</p><p>What about goal differential? I mentioned importing it but hadn’t shown any analysis with it. I started by comparing actual goal differential to points.</p><pre># Plot G_Diff and xG_Diff against Points<br>plt.scatter(analysis_df_reduced[&#39;G_Diff&#39;], analysis_df_reduced[&#39;Points&#39;], c = &#39;c&#39;, edgecolors = &#39;m&#39;)<br>plt.xlabel(&#39;Goal Differential&#39;)<br>plt.ylabel(&#39;Points&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*F7UvDdDhKYCoQx7md8W3nQ.png" /></figure><p>Well, this certainly made sense, since the fundamental challenge in hockey centers (again, no pun intended) on outscoring the opponent. Incidentally, the smaller linearly associated set of points below the larger one correspond to the lockout-shortened 2012–2013 season (fewer games played mean fewer points). Next, I checked Evolving-Hockey’s Expected Goals metric.</p><pre>plt.scatter(analysis_df_reduced[&#39;xG_Diff&#39;], analysis_df_reduced[&#39;Points&#39;], c = &#39;y&#39;, edgecolors = &#39;k&#39;)<br>plt.xlabel(&#39;Expected Goal Differential&#39;)<br>plt.ylabel(&#39;Points&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*TvYyQ3pyGNXzNEmewnzC3A.png" /></figure><p>This actually pointed to an intriguing implication. The more confounded relationship expected goal differential has with points than actual goal differential illustrated how much luck can disconnect underlying team performance from “top-line” results. Nonetheless, a fairly strong correlation between both actual and expected goal differential and points arose.</p><p>With that said, why not compare percentage of WAR from defensemen to these two metrics, beginning with actual goal differential?</p><pre># Plot D_Pct against G_Diff and xG_Diff<br>plt.scatter(analysis_df_reduced[&#39;D_Pct&#39;], analysis_df_reduced[&#39;G_Diff&#39;], c = &#39;y&#39;, edgecolors = &#39;b&#39;)<br>plt.xlabel(&#39;Percentage of WAR from Defensemen&#39;)<br>plt.ylabel(&#39;Goal Differential&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*59Ny_74ALkYoTY-P69-Ekw.png" /></figure><p>This looked almost identical to the plot of percentage of WAR from defensemen and points, which made sense due to the strong linear relationship between goal differential and points. In other words, this exhibited somewhat of an associative property between the three metrics. Did something similar exist with expected goal differential?</p><pre>plt.scatter(analysis_df_reduced[&#39;D_Pct&#39;], analysis_df_reduced[&#39;xG_Diff&#39;], c = &#39;r&#39;, edgecolors = &#39;b&#39;)<br>plt.xlabel(&#39;Percentage of WAR from Defensemen&#39;)<br>plt.ylabel(&#39;Expected Goal Differential&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*YAGpYcZS4LVeBVri8YpdfA.png" /></figure><p>Yes, that indeed proved the case.</p><p><strong>Conclusions</strong></p><p>What did this exercise ultimately uncover? Well, strong linear relationships between total team WAR, goal differential and expected goal differential and team point totals exist. Nothing groundbreaking there. However, at least in terms of correlations, teams that operate from the backend outward, with strong defensive pairings anchoring their rosters, actually generally look better-positioned for success in the modern NHL.</p><p>This opens new areas of consideration and discussion. The NHL and hockey community in general have less precise measurements of performance for defensemen than forwards. For example, until player tracking data becomes widespread, we cannot quantify skills like gap control and positional awareness, two of the most important components of defensive play. Furthermore, <a href="https://theathletic.com/1050014/2019/06/27/how-much-term-should-nhl-teams-give-players-in-free-agency/">teams have displayed greater variability in their valuations of defensemen</a>, illustrating the greater degree of subjectivity. Therefore, organizations with a comparative advantage in scouting defensemen can more effectively deploy their cap-limited resources filling out this slightly more important part of their rosters. Longer-term, the teams that hit the ground running with player tracking data and wield it to model the performance of defensemen will gain a leg up on the competition.</p><p>New, more precise and powerful data sources may eventually change the picture, but as of now, it does appear defense wins championships — okay, at least Presidents’ Trophies — in the NHL.</p><p><em>Footnote: All code and data used for this analysis exist in a GitHub respository.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cdd2318169a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/anthonydalke/how-much-does-defense-matter-in-the-nhl-cdd2318169a1">How Much Does Defense Matter in the NHL?</a> was originally published in <a href="https://medium.com/anthonydalke">AnthonyDalke</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Who Am I, and Why Am I Here, Anyway?]]></title>
            <link>https://medium.com/anthonydalke/who-am-i-and-why-am-i-here-anyway-88579085dcdc?source=rss----7cf377b6f0e4---4</link>
            <guid isPermaLink="false">https://medium.com/p/88579085dcdc</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Anthony Dalke]]></dc:creator>
            <pubDate>Sun, 29 Apr 2018 18:55:20 GMT</pubDate>
            <atom:updated>2018-04-29T18:55:19.751Z</atom:updated>
            <content:encoded><![CDATA[<p>Data science. We hear about it all the time. You might say it has grown into fully-fledged “buzzword” status, and I might agree. But I would follow by suggesting it has become so popular for some rather important reasons. Sure, businesses, governments, non-profits, and other organizations have realized tangible value from building data-driven cultures, improving decision-making with targeted reporting, and melding quantitative with qualitative analysis. Sure, technically and numerically inclined people have gravitated toward headlines about “Data Scientist” becoming a top career choice. However, I would argue this overlooks an essential consideration: data science is fun!</p><p>Yes, taking a general question and shaping it into a specific problem to answer is fun. Yes, brainstorming datasets to evaluate and modeling approaches to try is fun. Yes, vetting conventional wisdom with actual data is fun. Yes, seeing the “light go on” in your audience when you share information they find insightful is fun. And yes, the lifelong learning conducive to — some might even say required by — data science is fun.</p><p>So, what brings me to the field? Well, elements of everything I just listed, but let me provide some additional background…</p><p>I’ve always had an inquisitive nature (in fact, I often jokingly remind people my parents referred to me as “J. Edgar Hoover” as a kid, even though I had no idea who he was) and a fondness for numbers and facts, which laid the foundation for my future professional interests. However, I actually don’t come from the type of technical background most people associate with data science. Rather, I majored in supply chain management for my undergraduate degree at the University of Illinois at Urbana-Champaign. I began as a finance major, initially seeking to become an investment manager. I changed to accountancy after taking my introductory accountancy classes and learning about the strength of UIUC’s program. Then, I, quite frankly, started growing bored, particularly with the more intangible, theoretical topics within accountancy (for example, deciding which time period to choose for recognizing expenses). I also learned about UIUC’s supply chain management program, attended an info session, and liked what I heard. I preferred the more tangible nature of the subject. I liked how it blended detail-oriented focus with big-picture, strategic thinking. And, of course, since this took place right after the ’08 Financial Crisis reared its ugly head, the program’s record of 100% job placement appealed to me.</p><p>Consequently, I applied and interviewed for the program and ended up graduating from it. I started my career in a rather traditional supply chain role with 3M, in what they dubbed their Optimized Operations program, which equips entry-level employees with Lean Six Sigma training and deploys them at company locations. I got placed in their Ames, IA, plant. I worked there for about a year and a half, dividing my time between planning and scheduling production and leading a Lean Six Sigma project. I also witnessed the power of using data to make better decisions. Collaborating with colleagues, we brought more data-driven, objective approaches to processes previously shrouded in gut feeling and subjectivity. Now, in terms of methodology, I wouldn’t call anything we did groundbreaking, but the fact even those simplistic approaches could make a noticeable difference resonated with me. It sounds cliched, but I first started thinking about the power of objectivity over subjectivity back when I read Moneyball during high school, but I hadn’t really seen firsthand examples in the workplace. It got my wheels turning.</p><p>Now, my wife and I both hail from the Chicago suburbs, so nearly as soon as we moved out to Iowa I started thinking about ways we could move back home. Fortunately, in May 2012 I received an offer for a more technical supply chain role in 3M’s DeKalb distribution hub. This marked the opportunity that shifted my technical skills and interest into another gear. My job had a three-fold focus: leading the local team dedicated to slotting inventory in the warehouse (in other words, figuring out where to store product once it arrived in the warehouses), managing more Lean Six Sigma projects, and supporting the Warehouse Management System (WMS) that drove the DC’s operations. The inventory slotting piece afforded additioanl opportunities to push decision-making in a more data-driven direction, as I worked with a colleague to create and refine metrics that supported our guidelines on where to store product. To that point, our predecessors had relied in part on metrics but more on their accumulated knowledge of the individual items and feedback from operators out on the warehouse floor. To craft these metrics, I built and progressively improved an MS Access database. That experience, along with my technical support duties, rapidly accelerated my familiarity and comfort with SQL and relational databases. The fact I also had to become a local subject matter expert on the WMS software without having any prior experience with it also served as a tremendous learning tool, as it illustrated learning curves represent just that: curves, not insurmountable obstacles.</p><p>At that point, I made the move from 3M to HAVI, a consulting firm based in the Chicago subrubs. I had taken a step back and realized I’d gained experience in the production/manufacturing and distribution/warehousing components of the supply chain, but I’d lacked firsthand exposure to the purchasing/sourcing component. The chance to fill that gap while continuing to drive more data-driven decision-making attracted me to my first role with the company. There, I served as the data management and analytics resource for a sourcing group within the company, adding experience with MS Access databases and learning some master data management techniques.</p><p>A few months after I started with the company, I attended an informational overview of its supply chain network optimization group. I loved what I heard, so I reached out to one of its managers in a genuine effort to learn more about what they did. As our conversations continued and our relationship grew, we agreed a role in the group would offer a mutual fit. I thought my experience in the three broad buckets of the supply chain — sourcing, manufacturing, and distribution — instilled an ability to intuit how changes in certain elements of supply chains would reverberate elsewhere. From a developmental standpoint, I thought the nature of their work would continue to sharpen my technical and analytical skills. I eventually made a formal move into the team and ended up loving it. Not only did my analytical skills improve as hoped, but I got the opportunity to work on a project of an entrepreneurial nature. To provide context, at that time, the supply chain network optimization team typically got engaged by customers for projects at set time intervals, when customers opened sourcing reviews for product categories. We hypothesized proactive monitoring of the categories would help identify when business conditions “on the ground” changed enough to violate the various assumptions that grounded past category management decisions or even raise the potential for incremental category spend savings, by rebalancing lines of supply in networks. Making this a reality required a great deal of brainstorming with my manager, envisioning how our monitoring tools should look, what metrics to create for them, where to obtain the supporting data, and how to construct them. After I built prototype dashboards in Tableau, we obtained feedback from customers and iterated through refinements. We then established a monthly cadence for reviewing the dashboards with the customers to discuss opportunities for network studies. I still count this as my very favorite professional experience, as I reveled in the more explorative “R&amp;D” nature of the project.</p><p>While I worked in HAVI’s supply chain network optimization group, I also decided to pursue an M.S. in Business Analytics at the University of Notre Dame. I chose the program because it accelerated the shift in my broader career trajectory in a more technical direction, and its part-time structure fit my working schedule. Since the program equips students to liaise between the business and technical sides of analytics organizations, I figured it aligned with my background and longer-term professional interests. As I proceeded through the curriculum, I completed coursework on machine learning, data visualization, data management, analytics project management, and statistics.</p><p>After I graduated, I remained in HAVI’s supply chain network optimization group for a little over six months, at which point one of my senior leaders suggested I transfer to the marketing analytics group within his department. He described it as a chance to apply more of the advanced analytics techniques I learned in my master’s program, while lending a fresh perspective to the team and gaining exposure to a different application of analytics. I made the move in Fall 2016. I encountered a massive learning curve, with different types of questions to answer, different data sources to use, different types of customers, and, I would argue, an entirely different mindset, as I had only worked with supply chain organizations to that point. Thankfully, with time, I grew more comfortable.</p><p>Still, I didn’t feel quite satisfied with my role, especially its focus on external client delivery, something I believed I <em>could</em> do but didn’t particularly <em>like</em> doing. Additionally, the insufficent resourcing of the team imposed impediments to analytics research and experimentation, as we, quite frankly, had to rely on the tried-and-true approaches we knew, rather than trying anything new. I’d worked on a few projects that allowed me build random forest models, I’d taken continuing education courses such as Andrew Ng’s canonical <em>Machine Learning</em>. I’d also learned Python thanks to materials like DataQuest.io and DataCamp. However, my role didn’t provide sufficient opportunity to practice. As a result, I didn’t think I could develop the skills that truly interested me — namely, learning new modeling approaches and digging deeper into the wonderful world of data science. Consequently, I moved to my current role at JPMorgan Chase, where I provide a variety of analytics and reporting to internal customers in the firm’s Commercial Banking line of business.</p><p>Hopefully, this (now long-winded) post has evinced a common thread of continuing education. As I mentioned, I’ve always had an inquisitive nature, which inherently trains my thoughts toward reading, thinking, and contemplation, which, in turn, fits with the demands and culture of data science. I’d told myself for quite some time that I should start a blog, to document my learning and force me to explain what I ingest, which, in turn, should help me even better understand it. I don’t know if I’ll focus on a particular domain or subject matter. However, I <em>can</em> say I’ll lean heavily on writing tutorials, beginning with SQL and then advancing to Python, since this overlaps with the requirements of my job. I’ll likely then move on to machine learning theory and application.</p><p>So, to (finally!) conclude, I hope this has painted a picture of where I come from, why I started this blog, and where I hope to take it. I would feel humbled and honored if you came along for the ride. At all times, I welcome any feedback and suggestions you may have! Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88579085dcdc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/anthonydalke/who-am-i-and-why-am-i-here-anyway-88579085dcdc">Who Am I, and Why Am I Here, Anyway?</a> was originally published in <a href="https://medium.com/anthonydalke">AnthonyDalke</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>