<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Christophe Brown on Medium]]></title>
        <description><![CDATA[Stories by Christophe Brown on Medium]]></description>
        <link>https://medium.com/@christophebrown?source=rss-c7799fc4035d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*YAz3-mFTuJwoNvJNhozX4Q.jpeg</url>
            <title>Stories by Christophe Brown on Medium</title>
            <link>https://medium.com/@christophebrown?source=rss-c7799fc4035d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 01:49:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@christophebrown/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[When Data and Code Collide: How Data Scientists and Engineers Can Build Magic Together]]></title>
            <link>https://christophebrown.medium.com/when-data-and-code-collide-how-data-scientists-and-engineers-can-build-magic-together-ade74758794e?source=rss-c7799fc4035d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ade74758794e</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[teamwork]]></category>
            <category><![CDATA[business]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Christophe Brown]]></dc:creator>
            <pubDate>Tue, 10 Dec 2024 00:52:35 GMT</pubDate>
            <atom:updated>2024-12-10T00:52:35.449Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>“Data scientists are explorers, engineers are builders. Together, they can create wonders — if they don’t get lost arguing over the map.”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*S90BE8D0uIXngS86ibKDyQ.png" /></figure><p>Picture this: a data scientist spends months crafting a predictive model that’s 95% accurate. Meanwhile, the engineering team works tirelessly to build the infrastructure to deploy it. But when launch day comes, the model doesn’t fit the system, the system doesn’t fit the business need, and the project gets shelved. What went wrong?</p><p>This isn’t just a hypothetical — it’s the cautionary tale of what happens when data scientists and engineers work in silos. The good news? It doesn’t have to end this way. With the right principles, collaboration can turn friction into breakthrough solutions.</p><h3>Start with the Problem, Not the Code</h3><p>Before opening a Jupyter Notebook or writing a line of code, ask one question: “What’s the business problem we’re solving?” Data scientists often dive into exploration, while engineers think in terms of implementation. But without a shared understanding of the goal, both sides risk wasting time.</p><p><strong>Example</strong>: If the problem is “reduce customer churn,” both teams should work together to translate that into actionable objectives, like “predict customers at risk of leaving within 30 days.” This clarity ensures that data scientists focus on the right models and engineers can design for deployment from day one.</p><p><strong>Key Takeaway</strong>: A clear problem statement is the blueprint for success.</p><h3>Think Big, Start Small</h3><p>The allure of complexity is real, but perfection is the enemy of progress. Instead of aiming for a flawless solution, start with something simple that works. Iterate from there.</p><p><strong>Example</strong>: Begin with a basic rule-based model for churn prediction and deploy it quickly. Use it as a benchmark for more sophisticated approaches, like machine learning models, as the teams refine their understanding and capabilities.</p><p><strong>Key Takeaway</strong>: Build iteratively, celebrate small wins, and use each iteration to align further.</p><h3>Communicate Like You’re on the Same Team (Because You Are)</h3><p>Data scientists speak in terms of algorithms and insights; engineers talk scalability and runtime constraints. Without translation, these conversations can feel like different languages. Regular, clear communication is essential.</p><p><strong>Example</strong>: Engineers should outline system constraints early: “The model must run in under 200ms per request.” Data scientists should share insights in actionable terms, like “This feature contributes most to the prediction accuracy, so let’s focus here.”</p><p><strong>Key Takeaway</strong>: Treat communication as a deliverable, not an afterthought.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UXFX90rDma3Fi-Tv38PM8g.png" /></figure><h3>Keep It Simple, Make It Practical</h3><p>Simplicity isn’t just elegant — it’s efficient. A machine learning model with 15 hidden layers might boost accuracy, but if a simple logistic regression solves most of the problem, why complicate things? Both teams should prioritize practicality over complexity.</p><p><strong>Example</strong>: For a customer churn problem, a simpler model might yield 80% of the solution while taking a fraction of the time to deploy and maintain. This frees up resources to iterate later if needed.</p><p><strong>Key Takeaway</strong>: Complexity is a tool, not the goal.</p><h3>Tie Everything to Business Impact</h3><p>Here’s the golden rule: if it doesn’t deliver value, it’s not worth doing. Every solution, whether it’s a model or a pipeline, should directly address a business need.</p><p><strong>Example</strong>: Instead of saying, “The model is 90% accurate,” frame the impact: “With this model, we can reduce churn by 15%, translating to $500k in monthly savings.” Engineers and stakeholders will rally behind outcomes like that.</p><p><strong>Key Takeaway</strong>: Always measure success in terms of business outcomes, not just technical achievements.</p><h3>Conclusion: Collaboration is the Competitive Edge</h3><p>The relationship between data scientists and engineers is like a high-stakes partnership. When aligned, their work transforms businesses; when misaligned, it creates headaches. By starting with shared goals, building iteratively, communicating clearly, and focusing on value, these teams can turn missteps into milestones.</p><p>The next time you’re in a room with data scientists and engineers, ask this: “Are we solving the right problem, the right way, for the right reason?” If the answer is yes, congratulations — you’re building magic.</p><p>Thank you for taking the time to read my article. You can find more of my stories at https://christophebrown.medium.com.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ade74758794e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Debunking r/WallStreetBets with Machine Learning]]></title>
            <link>https://medium.com/geekculture/debunking-r-wallstreetbets-with-machine-learning-257a867ecc76?source=rss-c7799fc4035d------2</link>
            <guid isPermaLink="false">https://medium.com/p/257a867ecc76</guid>
            <category><![CDATA[social-media]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[stock-market]]></category>
            <dc:creator><![CDATA[Christophe Brown]]></dc:creator>
            <pubDate>Wed, 26 Jan 2022 06:02:54 GMT</pubDate>
            <atom:updated>2022-01-26T14:53:32.439Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*13ZaZ2AtTvIrIZaQ" /><figcaption>Photo by <a href="https://unsplash.com/@brett_jordan?utm_source=medium&amp;utm_medium=referral">Brett Jordan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In 2021, the investment world was turned upside down by a small community of day traders known to the world as r/WallStreetBets. They took on the investment sharks by collectively shooting their shot against stocks like Gamestop and eventually AMC. The event was big enough to <a href="https://www.theverge.com/2021/1/28/22254584/gamestop-robinhood-short-reddit-wallstreetbets-aoc-ted-cruz">turn politicians’ heads</a>, influence <a href="https://www.youtube.com/watch?v=uQwvYnTvR3c">Reddit’s first Super Bowl ad</a>, and inspire a vision for the future of the small investor. It&#39;s a spectacle we&#39;ve never seen before and one we’re wondering if it will happen again. One major takeaway is that the amount of eyes watching the subreddit and the stock exchange has grown at least tenfold.</p><p>This had me thinking about the influence of social media on the stock market. Is any correlation with the stock market and the activity on r/WallStreetBets</p><p>As per usual, we’re going to investigate this using machine learning.</p><h3>What Data can be used here?</h3><p>To do this, we need data for both Reddit and the stock market, and from there we need a common attribute to link the two together. Here are the two tools I came across that helped with getting started:</p><p><strong>Beneath</strong> is a serverless real-time data platform. They have datasets covering trending Reddit posts, the Ethereum blockchain, and most importantly: r/WallStreetBets analytics. For this experiment, I’ll be using a <a href="https://beneath.dev/examples/wallstreetbets-analytics/table:r-wallstreetbets-posts-stock-mentions">dataset of stock symbol mentions in posts</a>.</p><p><strong>Alpha Vantage</strong> is a developer-friendly API that provides financial market data. It can be used for historic information on a variety of publicly-traded stock prices. See the example below for Tesla (TSLA) stock.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*WrRU6_f_WuzU-WO3NQmFdw.png" /><figcaption>Historic stock prices for Tesla, visualized using matplotlib. Graphic by author.</figcaption></figure><h4>Connecting the Dots</h4><p>As I mentioned earlier, Beneath has data on stock mentions on the r/WallStreetBets subreddit. This data set specifically refers to top-level posts, rather than comments on a post. Some other data points provided include the number of stock symbol mentions found in the title, the time the post was made, and the length of the post body, among other features. Speaking of which, here are the top 50 stocks mentioned on r/WallStreetBets posts:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L78moyRpY7EXHc9ZlYvIvw.png" /><figcaption>Top 50 Stock Symbols Mentioned on r/WallStreetBets posts between March 9, 2021 to January 12, 2022. Graphic by author.</figcaption></figure><p>Furthermore, since we have the times at which posts were made we can break down posts by month. Here’s are the monthly breakdowns for the top two symbols GME and AMC:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m52QMVEM0aK_gpAKUIZ2Pw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oBqWf2D6hUNdqRYVR0m0zQ.png" /><figcaption>Monthly mentions of Gamestop and AMC on r/WallStreetBets posts. Graphic by author.</figcaption></figure><p>Given that we have data available as a time series, we can intuitively map it to historic stock performance. We can look at the stocks growth numbers month-over-month and assess if there is a trend with, say, stock mentions or post length.</p><p>Though before we continue, I have to make a confession and make a slight adjustment — I am not a stock analyst (nor should my blogs be taken as financial advice!) and hadn’t immediately noticed that Alpha Vantage provides <em>unadjusted</em> stock data at its free tier. These means that the API will show prices that a stock was not actually traded at. For example, if this code sequence is ran:</p><pre>from alpha_vantage.timeseries import TimeSeries<br>ts = TimeSeries(key=key, output_format=&#39;pandas&#39;) # key is an API key<br>nvda, _ = ts.get_daily(symbol=&#39;NVDA&#39;, outputsize=&#39;full&#39;)<br>nvda.loc[&#39;2021-01-14&#39;]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yCYHIrlwO3vdJNJbqHmRKA.png" /><figcaption>Output of the code sequence above. Graphic by author.</figcaption></figure><p>What returns is the stock for NVIDIA trading between $527.22 and $543.99 for the day, whereas at the time of writing the all-time high is actually closer to $325.85. Long story short, this results in discrepancies over time that make the data less accurate for the machine learning algorithm.</p><p>I could have used regression to approach this problem, but because the numbers don’t line up cleanly, we’ll instead shift this to a <em>binary classification </em>problem, where the classes will be whether a stock <strong>increased in the past month</strong> or <strong>decreased in the past month</strong><em>.</em> To accomplish this, we manipulate the numbers as follows:</p><ol><li>Get the daily average price for each day the market was open:<br> (high + low) / 2.</li><li>Get the monthly average price by averaging daily averages over a month.</li><li>Compare the monthly average of one month to the monthly average of the next month. Is there an increase or decrease?</li><li>An increase converts the data point to a +1, and a decrease is a -1. Now we have our class labels! We’ll cross reference both stocks and date to append the labels to the Reddit data.</li></ol><p>Our cleaned dataset will look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a481e9d5c017b1a312809ade5e1d47b5/href">https://medium.com/media/a481e9d5c017b1a312809ade5e1d47b5/href</a></iframe><p>Here’s a list of all the features I have available:</p><ul><li><strong>num_mentions_title: </strong>How many time a stock symbols are mentioned in the post title.</li><li><strong>num_mentions_body: </strong>How many stock symbols are mentioned in the post body.</li><li><strong>num_unique_symbols_title: </strong>The number of unique symbols in the title. For example, having both “GOOGL” and “AMZN” in the post title would result in this value equal to 2.</li><li><strong>num_unique_symbols_body: </strong>The number of unique symbols in the post body.</li><li><strong>length_title: </strong>Character length of the title.</li><li><strong>length_body: </strong>Character length of the body.</li><li><strong>num_unique_posts: </strong>Number of posts that have mention the stock symbol in the post at least once. This is acquired through counting the corresponding the rows from the given data set.</li></ul><p>With this prepared, let’s talk for a moment about machine learning application.</p><h3>Learning from the Data</h3><p>Since we’re addressing a classification problem, we’ll use the handy Gradient Boosted Tree. This decision is motivated by the robustness of the algorithm. See this excerpt from [1]<em> </em>that I often reference when practicing machine learning:</p><blockquote>Similarly to other tree-based models, the algorithm works well without scaling and on a mixture of binary and continuous features. As with other tree-based models, it also often does not work well on high-dimensional sparse data.</blockquote><p>If you’re new to Gradient Boosted Trees, they are a type of <em>decision tree</em>. Decision trees are learned classifiers (or regressors) that make a prediction based on thresholds learned from training data. For example, a stock price can go up or down, and my model might make that prediction depending on whether there were above 300 mentions of a stock on the subreddit last month, or below 300 mentions last month. For Gradient Boosted Trees, we first combine many trees in to a <em>random</em> <em>forest</em>, or a collection of decision trees working together to make a prediction. The “Gradient Boosted” element implies that one tree learns from another in training, rather than trees learning independently and averaging their prediction.</p><p>Here are the parameters I’ll modify to create different models. See the <a href="https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.GradientBoostingClassifier.html">scikit-learn documentation</a> for more details:</p><ul><li><strong>learning_rate</strong>: this modifies the contribution of each tree</li><li><strong>n_estimators</strong>: the number of boosting stages, or number of trees that one tree can learn from</li><li><strong>max_depth</strong>: the maximum depth of a tree</li><li><strong>min_samples_split</strong>: the minimum number of samples required to split a node (i.e. for a branch-off to occur from that now)</li><li><strong>min_samples_leaf</strong>: the minimum number of samples required to be at a leaf node</li><li><strong>max_features</strong>: the number of features to consider when looking for the best split</li></ul><p>With that, let’s zoom out for a moment and consider the next steps.</p><h4>Metrics and Parameter Tuning</h4><p>We’ll take the data shown above, attempt to fit a model to it, observe the performance, and tune parameters to get the best performance as we can. The performance metric I’m using is the AUC-ROC curve. <a href="https://towardsdatascience.com/understanding-auc-roc-curve-68b2303cc9c5">Here’s a fantastic post by </a><a href="https://medium.com/@narkhedesarang?source=post_page-----68b2303cc9c5-----------------------------------">Sarang Narkhede</a> <a href="https://towardsdatascience.com/understanding-auc-roc-curve-68b2303cc9c5">explaining the metric in detail</a>, but if you’re short on time, it helps us distinguish between our ground truth values and predicted values by measuring true positives, false negatives, true negatives, and false positives of our predictions. The AUC score sits between 0 and 1 with generally the higher, the better prediction performance.</p><p>To start off, I will train a model using just learning_rate=0.0001, n_estimators=10000, and max_depth=4. Once trained, I will use that model to predict on both the training data set and the testing data set.</p><pre>Train AUC: 0.513355592654424<br>Test AUC: 0.4996242753882487</pre><p>Pretty low scores! Scores around 0.5 suggest that the model is about just as effective as guessing whether a stock will go up or down. A respectable AUC should not be lower than, say, 0.65 to have <em>any</em> utility. Ideally we want to be predicting at a better score above 0.7. But we aren’t done, let’s conduct a sweep for all the parameters to see if there exists a sweet spot that will improve the AUC. We’ll try to find the best value for each parameter, then train a final model and examine its performance.</p><p>Below you will find an interval defined for each parameter, and the AUC performance from tuning <em>only </em>that parameter, which the remaining parameters are set to their defaults as outlined in the <a href="https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.GradientBoostingClassifier.html">scikit-learn documentation</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*q2--5zicO7Da0kLswN3cIQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*iBVoPQBIvhzQejMWWQ_yuw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*QGZIdRXtlZvZExDljTUmAA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*dE59m3-GXZgcn0nkKAR4Gw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*MZo0duNUJ0UNog80vFnl7w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*xW-svf0ANinLaSd_5Zq9gw.png" /><figcaption>Gradient boosted trees parameter tuning for r/WallStreetBets and historic stock market data. Graphics by author.</figcaption></figure><p>We can gather a few things here. First, by observing at the blue lines for training, we see that we can increase AUC scores and therefore achieve some sort of “fit” to the training data. This is good news for starters, but our experiment’s hypothesis also depends on <em>test</em> data performance, which is very underwhelming at a glance.</p><p>You’ll also see the upward trends for learning rate, tree depth, and n_estimators, showing that our model <em>capacity</em> increases when using these parameters. Simply put, this means the we can reduce our training error using these parameters. Looking closely, we can also see a slight upward trend for testing AUC for these three values. Though no model reaches even a 0.6 AUC score, we’ll give the benefit of the doubt to the data, and now train a model using all parameters.</p><p>Here’s what I’ve set each parameter to:</p><ul><li>learning_rate=0.5,</li><li>n_estimators=200,</li><li>max_depth=3,</li><li>min_samples_split=0.1,</li><li>min_samples_leaf=0.2,</li><li>max_features=6</li></ul><p>And the results:</p><pre>Train AUC: 0.6432344797435151<br>Test AUC: 0.5291709844559586</pre><p>Unfortunately, we aren’t seeing any meaningful jump in scores here. I mentioned earlier that we can achieve some kind of fit to the training data, but alas this fails to translate to testing data. In context, this means that we can model <em>some</em> of the historical events of r/WallStreetBets, but we cannot model it such that we can predict how the subreddit will affect the future of the stock market (nor crypocurrency exchange, for that matter).</p><p>My last trick here was to select training data more carefully. Gamestop and AMC stock mentions on the subreddit dwarf that of any other stock, making them huge outliers that can affect the model interpretation for mentions of any other stock symbol. Yet, even after removing them, there is still no significant increase to AUC score:</p><pre>Train AUC: 0.647909558084076<br>Test AUC: 0.5176788542312194</pre><h4>Does this come as a surprise?</h4><p>The stock market is influenced by a variety of market forces. Regulations, politics, company performance, current events, and <em>occasionally</em> an onslaught of YOLO investors in the form of a subreddit. Nobody has been able to model the entire stock market perfectly (or at least, if they have, they did not tell anybody), and that largely includes the internet.</p><p>That said, hopefully you aren’t reading this blog seeking validation for chucking your life savings into r/WallStreetBets. If you are, I hear they have a <a href="https://www.reddit.com/r/wallstreetbets/?f=flair_name%3A%22Loss%22">subcommunity to console those who experience losses</a>.</p><h3>Conclusion and Next Steps</h3><p>In this blog, we took a closer look at how r/WallStreetBets intersects with the stock market. We examined activity on the subreddit and conducted an analysis as to whether or not there was any significant correlation between mentions of stocks and and monthly increase or decrease in stock price. We found that, using machine learning, we failed to find any meaningful signs of influence that Reddit has on the market.</p><p>That is not exclusively to the fault of Reddit, however. Some shortcomings of this experiment include the limitation of data. Having the upvote-to-downvote ration of posts would have been a good indicator for how well a post is received, and subsequently its potential to influence. Additionally, our data sets pull information from top-level posts, and does not draw symbol mentions from comments, nor does it assess any kind of sentiment that the community has toward or against a post. Additionally, while gradient boosted trees area robust model, perhaps there is an alternative algorithm or architecture that could have better luck.</p><p>To wrap up, the stock market is complex, but it is finite. Various researchers, scientists, and analysts have spent years modeling trends in the market in hopes of finding a way to perfect the methodology of investment strategy. You won’t find it here though, nor on r/WallStreetBets, so I advise that you be smart about your investments by sticking to facts and listening to experts.</p><p>If you’d like to view the source code for this experiment, you are welcome e to check out my <a href="https://github.com/ChristopheBrown/sm-ml.git">Github repo</a>. It includes some things I did not talk about here, such as data preprocessing and additional parameter tuning methods.</p><h3>References</h3><p>[1] A. C. Müller, S. Guido, Introduction to machine learning with Python: a guide for data scientists. (“ O’Reilly Media, Inc.”, 2016)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=257a867ecc76" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/debunking-r-wallstreetbets-with-machine-learning-257a867ecc76">Debunking r/WallStreetBets with Machine Learning</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Attempting to Predict the Result of an NBA Game before you could Finish Watching the First Half]]></title>
            <link>https://medium.com/data-science/attempting-to-predict-the-result-of-an-nba-game-before-you-could-finish-watching-the-first-half-4a1a97cfa31b?source=rss-c7799fc4035d------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a1a97cfa31b</guid>
            <category><![CDATA[hands-on-tutorials]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-dives]]></category>
            <category><![CDATA[nba]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Christophe Brown]]></dc:creator>
            <pubDate>Mon, 03 Jan 2022 22:31:21 GMT</pubDate>
            <atom:updated>2022-01-04T22:12:18.257Z</atom:updated>
            <content:encoded><![CDATA[<h4><a href="https://towardsdatascience.com/tagged/hands-on-tutorials">Hands-on Tutorials</a></h4><h4>Using the Support Vector Machines algorithm</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dZPbijsnKxVfNoqc" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Modeling natural processes with machine learning is not easy. Your average data scientist can spend countless hours scraping data together, let alone cleaning it. From there, they also must consider what assumptions are being made about the data and how to best model it using any one of many algorithms. Based on what comes back from analysis, one must consider any biases in their model or if they selected the <em>best</em> data from what was available.</p><p>In this blog I will make an attempt at trying all of this out. Continuing with my theme of machine learning in professional sports, namely the National Basketball Association (NBA). My goal today is to create a machine learning model that can predict the outcome of a game, but with play-by-play data from <em>only</em> <em>the first half</em> of play.</p><p>Those who watch sports regularly understand that many factors influence the <em>tide</em> of a game, let alone the final result. Depending on the sport, you might observe any number of big plays, penalties, or sheer luck that can shift the balance between teams. Can we really expect an algorithm to see past all this?</p><p>Let’s make a hypothesis.</p><p>First, let’s get a foundational understanding of the data being used.</p><p>Basketball is a straightforward game — work with teammates to score the ball in the basket while preventing the other team from doing so. Organized teams perform “plays” throughout a game to advance the ball towards the opponent’s basket or to defend their own basket. A play may or may not go in a team’s favor, however. As I mentioned, teams are subject to big plays coming from either side, which will shift the tide of a matchup in one way or another. So, despite the data constraint of only having play-by-play data from the first half of games, it is within our interest to have as much information as possible to work with to understand these tide shifts.</p><p>An NBA play is recorded when any of the following occur during a game:</p><ul><li>Basket is scored (free throws included)</li><li>Shot attempt is blocked or rebounded</li><li>Penalty or foul is called from a referee</li><li>Timeout is called from either team</li><li>Turnover (e.g. a steal)</li><li>Player substitution</li></ul><p>Plays occur by happenstance or through strategy. But that doesn’t matter here. What matters is whether or not a play is indicative of a team getting closer to winning or closer to losing. The only one in the list above that is not indicative of either winning or losing is a player substitution (although this is an assumption being made, it’s a relatively safe one). We can justify the others:</p><ul><li>Scoring points puts a team in a better position to win</li><li>Blocking or rebounding shots prevents the other team from scoring</li><li>Penalties put teams in tough situations, as well as provide opportunities for the opposing team</li><li>Teams often call a timeout to ease the pressure on themselves, make adjustments, or slow down the other team</li><li>Turnovers present opportunities for opponents to score</li></ul><p>That said, the outcome of a game is to either win or lose, so it makes sense to categorize this data into “winning plays” and “losing plays”. I chose to structure it like this given a Team A is playing against a Team B:</p><p>“Winning” plays for Team A (“Losing” plays for Team B):</p><ul><li>Team A scores a basket</li><li>Team A blocks a shot</li><li>Team A secures an <em>offensive</em> or <em>defensive</em> rebound (Note that scoring <em>offensive</em> rebounds implies that an earlier shot attempt was missed. In a sense, both of these plays cancel each other out. I chose to keep them in for the sake of having the data points.)</li><li>Team B incurs a penalty or foul (In most cases this leads to turnovers or scoring opportunities for Team A.)</li><li>Team B calls a timeout (This assumes the timeout is called in response to Team A gaining an advantage.)</li><li>Team B incurs a turnover, of which leads to a possession by Team A</li></ul><p>Now, NBA play-by-play data can be formatted so it is easily understood by a machine learning model. Before exploring that, I want to mention some additional decisions and data points I collected for this experiment.</p><ol><li>The winner of a basketball game is determined exclusively by points scored. It does not matter how many penalties, substitutions, or turnovers happened once the clock runs out. Because points are the most significant type of play, I reserve an additional “scoring plays” variable. This means that a “winning play” will also count as a “scoring play” if the play leads to scoring a basket. This attempts to emphasize the importance of scoring as the model learns.</li><li>Some plays are more influential than others, especially with regards to the amount of time remaining in a game. If the score is close between teams, scoring a basket or blocking a shot can almost certainly change the outcome of a game. Because of this, I include another data point, which is the amount of seconds remaining in regulation (48 minutes).</li><li>A very difficult point to quantify in the NBA is <em>momentum</em>. This is more-or-less a psychological effect players experience when they have any number of good or bad plays in rapid succession. Momentum has been studied extensively to the point where <a href="https://scholar.google.com/scholar?hl=en&amp;as_sdt=0%2C33&amp;q=nba+momentum&amp;btnG=">research articles have been published on this</a>. It is debatable how to accurately model momentum, but I chose to model it via the amount of scoring plays, winning plays, and losing plays that occurred within the last 60 seconds of play. Each type of play is scaled to emphasize its importance. Below is the momentum equation I used for experimenting, where seconds is 60.</li></ol><p><em>momentum</em>(seconds)<em> = </em>(1 + <em>scoring_plays</em>(seconds)) * (1 + <em>good_plays</em>(seconds))<em> -</em> (2 *<em> bad_plays</em>(seconds))</p><p>Now, onto the machine learning.</p><h3>Neural Networks</h3><p>I spent a day wondering what could be a good algorithm to learn from this dataset. I found that there were roughly 200 plays in the first half of a given NBA matchup. On top of that, every team plays at least 82 games in a typical season, so we’re working with a lot of play-by-play data. No single data point could tell you much about the end-game result, either. This reminded me of machine learning on image data— as typically you’re working with thousands upon thousands of data points in the form of pixel data. And one pixel tells you next to nothing about what an image is. So I start off using a Neural Network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tb1YJMcl8MAKb_vT5E43LQ.png" /><figcaption>The basic structure of a neural network. Image by author.</figcaption></figure><p>A Neural Network functions by introducing data at the input layer and traversing (to simplify, this traversal happens “mathematically”) along a network of “hidden” layers consisting of nodes. Upon reaching the output layer, a prediction of the input data is made (i.e. “dog” or “cat” for an image, “win” or “lose” for NBA data). The prediction is often a confidence probability, like 70% likely to be a dog and 30% likely to be a cat. This probability is then fed back through the network via a process called “back-propagation” where the nodes throughout the network are tuned to correct any mistakes made during the most recent prediction. What I just described is the training process. Once trained (i.e. the network is reasonably able to predict with accuracy), new data can be fed forward from the input layer such that a prediction is made on the output layer.</p><p>To keep it brief, the Neural Network was a poor choice. I used the Multi-layer Perceptron (MLP) classifier offered through scikit-learn. I suspect my model was underfitting to the NBA data. Changing the number of hidden layers or nodes per hidden layer had almost no effect on the predictions of the data. I also attempted to change the amount of data provided — from just the first half up to the first three quarters. Even with a 50% increase in data, the model struggled to predict anything meaningful. Using data from the 2020–2021 NBA season, if a team had a good record, (winning about 65% of games), the prediction would be always winning. Similarly for teams with losing records, the predictions would be always losing. This tells me that the data I selected was inadequate for an MLP classifier.</p><p>Back to the drawing board.</p><h3>Support Vector Machines</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4E9Ztf18AQsnp3ggr8p_7g.png" /><figcaption>The objective of the Support Vector Machine algorithm is to find an ideal hyperplane that separates classes of data. In the image above, lines A, B, and C are learned lines or hyperplanes. The ideal hyperplane is the one with the maximum distance between both the star class and the circle class, which is line C. Image by author.</figcaption></figure><p>I figured that, because the only classes of interest in this experiment were winning and losing, it made sense that a machine learning interpretation of the data could have some sort of decision boundary, or some means of separating instances of wins and instances of losses. This brought me to the Support Vector Machine (SMV).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GlhdGVwBdkzLmvFrlJBzmA.png" /><figcaption>Diagram for how the hyperplane of an SVM separates game results via the margin of victory or defeat.</figcaption></figure><p>Rushikesh Pupale wrote a fantastic article introducing SVMs <a href="https://towardsdatascience.com/https-medium-com-pupalerushikesh-svm-f4b42800e989">that you can read here</a>. To summarize, the SVM algorithm finds the optimal hyperplane that separates our data by class. To translate, say I were to plot out all the data points that resulted in a win as well as all the data points that resulted in a loss. The SVM finds a plane, or line, on the plot that best separates the wins data from the losses data.</p><p>I swapped out the MLP classifier for the LinearSVC classifier from scikit-learn. It was an instant game-changer. Winning team were predicted as winning teams — but not undefeated teams — and unwinnning teams were predicted as expected. Below is a snapshot of the results using data from the first half (i.e. approximately the first 200 plays in the game). Without tuning hyperparameters, here’s how it went:</p><pre>Correctly predicted 66.67% for team PHILADELPHIA 76ERS<br>Correctly predicted 66.67% for team ATLANTA HAWKS<br>Correctly predicted 55.56% for team BOSTON CELTICS<br>Correctly predicted 83.33% for team BROOKLYN NETS<br>Correctly predicted 44.44% for team CHICAGO BULLS<br>Correctly predicted 44.44% for team CHARLOTTE HORNETS<br>Correctly predicted 66.67% for team CLEVELAND CAVALIERS<br>Correctly predicted 66.67% for team DALLAS MAVERICKS<br>Correctly predicted 38.89% for team DENVER NUGGETS<br>Correctly predicted 83.33% for team DETROIT PISTONS<br>Correctly predicted 44.44% for team GOLDEN STATE WARRIORS<br>Correctly predicted 83.33% for team HOUSTON ROCKETS<br>Correctly predicted 66.67% for team INDIANA PACERS<br>Correctly predicted 77.78% for team LOS ANGELES CLIPPERS<br>Correctly predicted 38.89% for team LOS ANGELES LAKERS<br>Correctly predicted 33.33% for team MEMPHIS GRIZZLIES<br>Correctly predicted 50.00% for team MIAMI HEAT<br>Correctly predicted 50.00% for team MILWAUKEE BUCKS<br>Correctly predicted 55.56% for team MINNESOTA TIMBERWOLVES<br>Correctly predicted 55.56% for team NEW ORLEANS PELICANS<br>Correctly predicted 55.56% for team NEW YORK KNICKS<br>Correctly predicted 83.33% for team OKLAHOMA CITY THUNDER<br>Correctly predicted 66.67% for team ORLANDO MAGIC<br>Correctly predicted 66.67% for team PHOENIX SUNS<br>Correctly predicted 33.33% for team PORTLAND TRAIL BLAZERS<br>Correctly predicted 77.78% for team SACRAMENTO KINGS<br>Correctly predicted 66.67% for team SAN ANTONIO SPURS<br>Correctly predicted 77.78% for team TORONTO RAPTORS<br>Correctly predicted 61.11% for team UTAH JAZZ<br>Correctly predicted 55.56% for team WASHINGTON WIZARDS</pre><p>With high accuracy rates for the 2020–2021 Nets, Pistons, Rockets, Clippers, Thunder, Kings, and Raptors this is looking good. The accuracy average across the league is 60.56%. This also happened with no tuning of hyper parameters in the SVM, so there is some room for improvement. But, before continuing, let’s take a moment to understand what a success metric might look like.</p><p>Obviously, the best indicator would be to predict 100% for each of the percentages above. This is highly unrealistic for reasons described earlier — the nature and context of competitive sports, utilization of available data, and assumptions made. It’s also inaccurate to achieve 100% accuracy for some teams while achieving 20% for others. Finally, achieving perfect accuracy would mean this model potentially overfits to this season, and would fail to generalize to future (or past) seasons where players’ experience levels change along with team rosters. Instead, I chose to optimize the model for the following:</p><p>Every game, an NBA team plays another NBA team. This means there will always be one winner and one loser. Given 82 games in a regular season, that means the League averages 41 wins and 41 losses. So, if this model works well, it will predict a League average of 41 wins, or a win rate of .500 if we’re not predicting off of 82 games. We’ll look at the League’s average number of wins after running to compare. This metric is more realistic (and forgiving) in that we are no longer stressed to pick each team’s games perfectly, but rather craft an expectation for all the teams collectively. No team exists in isolation, rather, it is the interactions between teams that make the NBA what it is.</p><h3>Hyper Parameter Optimization (Validation)</h3><p>The results above come from a vanilla (un-tuned) LinearSVC model. By using the SVC classifier from sklearn, we are given several parameters to explore. I’ll be drawing inspiration from Mohtadi Ben Fraj’s post <a href="https://medium.com/all-things-ai/in-depth-parameter-tuning-for-svc-758215394769">In Depth: Parameter tuning for SVC</a> and sweeping hyper parameters for polynomial and RBF kernels of the SVM.</p><p>C is a regularization hyper parameter. The strength of the regularization is inversely proportional to C. Gamma is a hyper parameter for non linear hyperplanes. For gamma, the higher the value it tries to exactly fit the training data set. Both values are swept along a logarithmic scale, from 0.1 to 1000.</p><p>I ran sweeps for the following cases (filename conventions included for cross-referencing the plots in the repository):</p><ul><li>gamma sweep for RBF kernel “svc_rbf_gamma_x”</li><li>gamma sweep for polynomial kernel (for degrees 0–6) “svc_poly_gamma_x_degree_y”</li><li>C sweep for RBF kernel “svc_rbf_c_x”</li><li>C sweep for polynomial kernel (for degrees 0–6) “svc_rbf_c_x_degree_y”</li></ul><p>The runtime for the full notebook took about 30 hours on my Macbook, resulting in enough data to create 16 different plots. It’s a bit much to post all of them here, but if you’d like a closer look, you can view the full source code and associated data and plots in the link towards the end of this blog. In the meantime, I’ll cover the more significant findings now.</p><p>First, looking at the polynomial sweep for C, there is next-to-no correlation for either season prediction accuracy or league win rate as different values of C or gamma are used. This was a bit disappointing to see, but I decided to look closer to find any less-obvious trends. To start, I include trend lines to show the overall rate of change across the sweep. For Average Season Prediction Accuracy (ASPA) all trend lines decline. This suggests that ASPA increases as C decreases (and regularization is more prevalent) and therefore lower values of C could yield a better fit to the training data.</p><p>As for League Average Win Rate (LAWR), three trend lines are decreasing and four trend lines are increasing. The direction of the trend line is less important here, however. What we want for this value is tighter fit around 0.500, as this indicates the model predicts for the league such that there would be as many winners and there are losers. The 4-degree polynomial has the closest LAWR trend to 0.500. The trend line also has a decline to match the corresponding ASPA trend. This could suggest that lower values of C combined with a 4-degree polynomial could yield better results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*YGwCH4ONWLdo8Oms" /><figcaption>Hyperparameter sweep snapshot with a four-degree polynomial kernel. Image by author.</figcaption></figure><p>Let’s look at the gamma sweep now.</p><p>Gamma determines how tight the model attempts to fit to the training data. We find across all the polynomial sweeps, the trend line typically decreases slightly or stays flat. This tells us that closely fitting the training data will typically drop generalization accuracy, in other words, overfit to the training data. Gamma can therefore be either ignored or included with lower values.</p><p>Aside from gamma and C, something else to notice is that LAWR typically is higher for higher degree-polynomials. Degrees 4, 5, and 6 have trend lines closer to 0.500 while lower degree-polynomials are further from 0.500.</p><p>One other mention I’d like to add is that the 0-degree polynomials are almost certain to underfit the data. This is because the number of model parameters (not hyper parameters) is very limited, and there is not enough to understand what <em>could</em> be learned from the training data. Plots for them are included, but their results should be taken lightly.</p><p>If we switch the polynomial kernel with an RBF kernel, we can see a significant correlation with gamma. As a matter of fact, for every power of 10 that gamma increases by, LAWR increases by about 2.5%. In terms of hitting the target LAWR at 0.500, the sweet spot happens around gamma=10. So, the utility of gamma varies depending on the kernel used for the SVM here.</p><p>When sweeping C for the RBF kernel, LAWR trends slightly upward, approaching 0.500 at higher values of C. Therefore for the RBF kernel, the effect of regularization is the <em>opposite</em> to that of the polynomial kernel. Here, as regularization <em>decreases</em> LAWR (and ASPA) improve.</p><p>With that said, I will train an SVM with a 4-degree polynomial, C=0.01, and gamma=0.001 and apply it to data from this season, 2021–22, and we will see how well it can predict the outcomes of games, given data from the first half.</p><h3>Model Testing</h3><p>The setup for testing is similar to that of training. I set up the model to predict on the first 25 games that each NBA team has played in the 2021–22 season. It should be noted that since we are predicting for a new season, the changes in team rosters should be acknowledged for any prediction results. With the model configured as specified above, this produced an ASPA of 0.5842 and a LAWR of 0.499.</p><p>This model is modest at best. Generally it performs well for teams that have a high win-loss ratio or a low win-loss ratio. In other words, the model predicts in-line with what it has seen previously. The bigger challenge is predicting teams that have a win-loss ratio close to 1.0. Under these circumstances, the model has to rely less on recent game trends and more on the play-by-play data. We can measure this effect by calculating the standard deviation of the number of wins each team receives in testing.</p><p>Teams can have a prediction of anywhere between 0 and 25 wins. With C=0.01 and gamma=0.001, the standard deviation is 12.21. This value is large, and being close to the mean win value of 12.5, we can conclude that the signal-to-noise ratio of the data is rather low. With minor tweaking to the parameters, I was able to get a lowest standard deviation of 9.65. Prediction performance is as expected with the LAWR of 0.499, but the results are inconclusive as to whether or not the outcome of a game can be predicted preemptively.</p><h3>Next Steps and Conclusion</h3><p>In this blog I detail a machine learning method of predicting the outcome of an NBA game given just play-by-play data from the first half of play. Various assumptions and decisions produce a model that can make predictions, but not with true conviction. Based on the results of the prediction, I believe proper next steps would be to reevaluate the data used in model training. Extracting additional features from the play-by-play data could allow the model to learn more information about what is happening during the game.</p><p>To take this even further, I would propose a model that is based at the player level, rather than the team level. This would make a model more robust across seasons, and account for a player’s contributions to whichever team they are playing for. For example, at the time of writing, Jayson Tatum has the most missed shots in the league. Compare to Kevin Durant with the most scored shots in the league. Kevin Durant missing a shot is less significant, because he will still reliably score throughout the rest of the game, and the opposite can be said for Tatum. A challenge here would be transitioning from other 30 teams to over 500 players and maintaining a data-rich data set.</p><p>Though the findings in this experiment are underwhelming, I personally find it intriguing for what I discovered thus far. From feature extraction to hyper parameter tuning, there is a lot of open-endedness to explore with this problem. Think this would be a great pick-up experiment for exploring deeper one day, for now this is the limit for unfunded research. :)</p><p>If you would like to view the source code used here, feel free to view it in its entirety in <a href="https://github.com/ChristopheBrown/nba-ml/tree/main/game_win_predictor">this Github repo</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a1a97cfa31b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/attempting-to-predict-the-result-of-an-nba-game-before-you-could-finish-watching-the-first-half-4a1a97cfa31b">Attempting to Predict the Result of an NBA Game before you could Finish Watching the First Half</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Predicting the Next Best Fantasy Football Team using the Non-negative Matrix Factorization Machine…]]></title>
            <link>https://medium.com/data-science/predicting-the-next-best-fantasy-football-team-using-the-non-negative-matrix-factorization-machine-48bc5724931d?source=rss-c7799fc4035d------2</link>
            <guid isPermaLink="false">https://medium.com/p/48bc5724931d</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[sports]]></category>
            <category><![CDATA[nfl]]></category>
            <dc:creator><![CDATA[Christophe Brown]]></dc:creator>
            <pubDate>Tue, 23 Nov 2021 15:32:58 GMT</pubDate>
            <atom:updated>2021-11-23T15:32:58.783Z</atom:updated>
            <content:encoded><![CDATA[<h3>Predicting the Next Best Fantasy Football Team using the Non-negative Matrix Factorization Machine Learning Algorithm</h3><p>Often hidden among numbers are patterns and trends that are invisible to the untrained eye. Whether in natural or synthetic processes, if we dive deep enough we can uncover new information without collecting new data points. This blog is a continuation of a series on sports and machine learning, this one being the first to highlight data from the National Football League (NFL).</p><p>The NFL has 1,696 players in the 2021 season— roughly triple to that of the Nation Basketball Association (NBA) at 510. There are also about five times the number of positions to play.</p><p>Where am I going with this? American football is a complex sport. It’s also widely viewed as the ultimate team sport. Many players with varied roles to execute a mission: to end a matchup with more points than the opponent. Passers, blockers, kickers, receivers, defenders, and rushers contested in a show of dominance over one-another. (If you are unfamiliar with American football, <a href="https://en.wikipedia.org/wiki/American_football_positions">this Wikipedia page</a> has a brief list with short definitions— the only important ones here are Quarterback and Receiver).</p><p>In doing so, you guessed it, a substantial amount of data is created. There are thousands of experiments that could be conceived to figure out what is the best formation to run, the best player to make a play, the best time to kick, and so on. This blog will explore one of the most basic elements of American football — completing a pass.</p><p>The rules of football define a completed pass as when an eligible Receiver successfully catches a forward pass thrown by the Quarterback without the ball touching the ground. So, we want to look at one of the factors that influences a completed pass: the “compatibility” between a Quarterback and a Receiver.</p><p><strong>The experiment of this blog is to use historic data from the NFL to determine which Receivers would pair well with a given Quarterback. We will explore this using non-negative matrix factorization (NMF).</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Kxvh8k_SW9IdhVs0" /><figcaption>Photo by <a href="https://unsplash.com/@cianleach?utm_source=medium&amp;utm_medium=referral">Cian Leach</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Assumptions</h3><p>To be transparent and thorough, there are many factors that can determine the outcome of an <em>attempted</em> pass. Here’s a shortlist of examples:</p><ul><li>The spiral as the ball flies through the air as well as the overall quality of the throw</li><li>The distance of the throw</li><li>Receiver’s running speed</li><li>Number of defender(s) trying to stop the catch</li><li>The position of the sun (occluding a Receiver’s vision)</li><li>Weather (a wet ball is harder to catch)</li></ul><p>Some of this information is actually collected through historic NFL data. However, this opens up a troublesome issue where we may have more <em>features</em> than <em>samples</em>, thus subjecting our machine learning models to <em>underfitting</em>. Should we take any combination of Quarterback and Receiver in the NFL, we almost certainly would <strong>not</strong> find a completed pass under every possible weather condition, against every defender in the League, all at varying running speeds and so on. Because of this, there is a significant assumption we must make to continue this experiment:</p><p><strong>Assumption: Historic NFL data on completed passes has latent information (including but not limited to: weather, throw quality, defenders, and distance) “encoded” in total passing yards.</strong></p><p>This assumption is, however, supported by the long-time partnerships between Receivers and Quarterbacks. The longer a duo has played together, the more play scenarios they would have experienced. This is good news for us because we effectively want to learn the “compatibility” between a Quarterback and Receiver, and translate how any one Receiver would work with another Quarterback and vice versa.</p><p>With that sorted out, let’s talk briefly about the machine learning technique that we’ll be focusing on.</p><h3>Non-negative Matrix Factorization (NMF)</h3><p>Non-negative matrix factorization is an unsupervised machine learning technique. Unsupervised in this case means that we have no pre-existing “scores” or “classes” that our training data belongs to. Therefore, we must first self-discover any naturally occurring patterns in the training data set. It begins a little like this:</p><ul><li>Given our initial data, we perform whatever feature extraction and data preprocessing to have our data represented in two dimensions. For this experiment, we have two-dimensional data (a matrix) with NFL Receivers along the first axis and NFL Quarterbacks along the second axis. The actual data points (the intersection of a Quarterback and a Receiver) are the total yards gained through completed passes. We’ll call this matrix <em>X</em>. Here’s a sample of what this looks like:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EHCoTy10buNmx4mq9HNHCQ.png" /><figcaption>Matrix <em>X</em>. Along the vertical axis are NFL Receiver, and along the horizontal axis are NFL Quarterbacks. The data contained include total receiving yards in the 2021 NFL season as of week 11.</figcaption></figure><ul><li>Our NMF algorithm is of “rank k”. This means we hand-select a value <em>k</em> that corresponds to the number of groupings we want to discover. I’ll elaborate on this more later.</li><li>The matrix (our initial data) is <em>factored</em> in a fashion similar to factoring a polynomial equation. This produces two new matrices <em>W</em> and <em>H</em> that we learn and analyze to collect new insights from.</li></ul><p>To recap: let the number of Receivers be represented by the term <em>R</em> and the number of Quarterbacks be represented by the term <em>Q</em>. Our given dataset of yards gained is represented by a matrix <em>X</em>. That is to say:</p><p><em>X</em> is a matrix of size <em>R</em> x <em>Q</em>. <em>X</em> will be factored into matrices <em>W</em> and <em>H</em>, where <em>W</em> is a matrix of size <em>R</em> x <em>k</em> and <em>H</em> is a matrix of size <em>k</em> x <em>Q</em>. This is important because in matrix multiplication, the “middle” dimension must match between two matrices, and the resulting matrix maintains the “outer” dimensions. Therefore:</p><p><strong>Given X, we learn <em>W</em> and <em>H</em> such that we satisfy the equation <em>X</em> ≈ <em>W</em> x <em>H.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mgMPkGE1qJm16KjG" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T8PE4FDLUJZXZ4lZ9kHmuw.png" /><figcaption>(From left to right) Matrix multiplication for <strong><em>X</em> ≈ <em>W</em> x <em>H </em></strong><em>demonstrates the desired outcome from NMF.</em></figcaption></figure><p>To achieve this, I will be using the NMF class conveniently provided in the <a href="https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.NMF.html">scikit-learn python package</a>. For more information on NMF, I recommend starting with <a href="https://yliapis.github.io/Non-Negative-Matrix-Factorization/">this blog</a> to dive deeper into the mathematics of NMF and its associated training algorithm. The NFL data used in this experiment comes from the <a href="https://github.com/cooperdff/nfl_data_py">nfl_data_py</a> Python package.</p><h3>Expectations and Experiment Setup</h3><p>The hypothesis of this experiment is that the NMF algorithm could find patterns among Quarterback-Receiver combos such that, we could discover new player combinations never-before-seen in the NFL that would make a great duos. Again, NMF declares rank-k matrices <em>W</em> and <em>H</em>, where <em>k</em> is effectively a number of “learned” groups or categories.</p><p>If this is not clear, <em>topic modeling</em> is another popular use case for NMF. When applying NMF to data from news articles, we can discover topics like sports articles, business articles, or political articles. We would choose <em>k</em> to represent the number of topics we would like to learn. In the context of NFL Quarterbacks and Receivers, we would be learning play styles or general compatibility between two players.</p><p>Matrices <em>W</em> and <em>H</em> are initialized randomly, and are updated through the <a href="https://en.wikipedia.org/wiki/Non-negative_matrix_factorization#Algorithms">NMF algorithm</a> such that the matrix multiplication of <em>W</em> and <em>H</em> are approximately equal to matrix <em>X</em>. As a result, <em>W</em> becomes a matrix of size <em>R </em>x <em>k</em> and <em>H</em> becomes a matrix of size <em>k </em>x <em>Q</em>.</p><p>To translate to English, this means <em>W</em> will tell us how closely a Receiver aligns with any of the <em>k</em> groups we learn. <em>H</em> will tell us how compatible each group is with a given Quarterback. For example, say we decided to learn k=4 groups. Let’s assume (in matrix <em>W</em>) the Receivers Rob Gronkowski, Tyreek Hill, DeAndre Hopkins, and Davante Adams had a high score for group 2 (high meaning closer to one). When we look over to matrix <em>H</em>, we may find that Quarterbacks Tom Brady, Patrick Mahomes, Kyler Murray, and Aaron Rodgers(the Receivers’ respective Quarterbacks throughout their careers) each have also a high score for group 2. This suggests that any combination of Quarterback and Receiver from group 2 should work well together, i.e. obtain many completions and passing yards. Below are examples of what matrices <em>W</em> and <em>H</em> could look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*By6dehpcfHtCodH_Savn2g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bfRMr9CW5k8GehOr9RYRuA.png" /><figcaption>(Left) Matrix W, where each Receiver has a score for how well they fit into. (Right) Matrix H, where each Quarterback has a score for how well they are expected to perform with a given group. Notice for matrix <em>W</em>, the rows sum to one. For matrix <em>H</em>, the columns sum to one. This format makes it so that the values in each matrix could be interpreted as probability of being a good match.</figcaption></figure><p>If you decide to look over the code (linked at the end of this blog), you’ll see that matrices <em>W</em> and <em>H</em> are <em>normalized</em> after being computed, this means their values are squished proportionally to be between 0 and 1. This simply makes the numbers easier to interpret; scores closer to zero indicate poor matchups, and scores closer to one indicate better matchups.</p><h3>Hyper Parameter Tuning</h3><p>To find the best results from this experiment, I studied four hyper parameters as they pertain to NMF. These included:</p><ol><li>The amount of data used for <em>X</em> before fitting (i.e. <em>learning</em>)<em> W</em> and <em>H</em></li><li><em>k</em> — the number of groupings learned</li><li><em>alpha</em> — a regularization parameter for learning <em>W</em> and <em>H </em>(regularization is an optional technique that can be used to have more control over how outliers can influence the algorithm)</li><li><em>tolerance</em> — stopping condition for the NMF algorithm. i.e. how close is the approximation <em>X</em> ≈ <em>W</em> x <em>H. </em>Lower tolerance means more training iterations (more on this in the results section).</li></ol><p>I studied hyper parameters 2 through 4 once with a small amount of data used in <em>X</em> (approx. two years of NFL data) and again with a large amount of data for <em>X</em> (approx. 12 years of NFL data). We’ll look at the small amount of data first.</p><p><strong>Note: </strong>In the following plots, all players who played Quarterback for at least <em>one completion</em> were used, however the <em>Average QB Scores </em>on the Y-axis are taken only from the 32 starting Quarterbacks in the League— one for each team.</p><h4>Adjusting <em>k</em></h4><p>The number of groups <em>k</em> was swept between values of 3 and 14. Lower values of <em>k</em> worked exceptionally well compared to higher values of <em>k</em>. This may be a result of the earlier assumption that various passing conditions are encoded in overall completed passing yards. This simplification may reduce the maximum complexity of this NMF model, such that models will underfit at higher <em>k</em> values. Alternatively, it’s possible that there are simply fewer calibers of Quarterback and Receiver duos in the NFL, such as with Quarterbacks who have won Most Valuable Player (MVP) awards and Quarterbacks who have not. It should be noted that, while the shape of the curves are generally the same, the peak scores at lower k values are higher with less data used — the plot on the left only takes data from the most recent two NFL seasons.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/0*TiifTa_6pQclGplS" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/0*t_1l3wdlACOCSewH" /><figcaption>Tuning of the rank-k hyper parameter</figcaption></figure><h4>Alpha</h4><p>The alpha, or regularization, parameter showed an oscillating behavior for two years of NFL data when it came to <em>Average QB scores</em>. Values of alpha were swept between 0 and 1, with scores peaking around alpha=0.4, alpha=0.7, and alpha=0.9. However, for 12 years of NFL data, the behavior has more fine-grained oscillations, with scores hitting a minimum from alpha=0.25 to alpha=0.4 while peaking at alpha=0.5. This discrepancy may be explained by there being more outliers found with more data being used, and thus the effects of the regularization are more prominent. This would yield a tighter-fit curve, as we see below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/0*sEDOGK6uazNf4ft7" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/0*9XVKzE8gbkkq8hWK" /><figcaption>Tuning of the alpha regularization hyper parameter</figcaption></figure><h4>Tolerance</h4><p>Finally, tolerance was swept between 0.001 and 0.01. Below we see step-shaped curves for both short-term and long-term data. Although the shapes are somewhat similar, notice that the peak <em>Average QB Score</em> is still higher for short-term NFL data (just under 0.3), as it was with sweeping other hyper parameters. The locations of the peak <em>Average QB Score</em> also occur at different locations, happening earlier for long-term data and towards the middle for short-term data.</p><p>Lower tolerance values mean that the algorithm goes through more training iterations. These graphs tell us that the long-term data (which also has <em>more</em> information) has its highest accuracy after more iterations of the NMF algorithm. The short-term data (which has <em>less </em>information) achieves its highest accuracy with less iterations. This would make sense as a more information-rich matrix <em>X</em> should take <strong>more</strong> iterations to learn proper matrices <em>W</em> and <em>H</em>. There are less iterations to learn <em>X</em> with short-term data, so we needn’t set the tolerance too low. In fact, setting it too low marginally lowers the <em>Average QB Score</em> as shown in the plot below on the left.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/0*VWQoGdoT1fARXXXV" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/0*AuTICS3GAyClUtTl" /><figcaption>Tuning of the tolerance hyper parameter</figcaption></figure><h4>Recap</h4><p>Let’s recap what we learned here. We’ve observed that using more, long-term data in our initial <em>X</em> matrix generally decreases the maximum compatibility scores between Quarterbacks and Receivers by about 25%. My theory for this is that older data biases the model to players with more historic success and longevity (e.g. Tom Brady, Aaron Rodgers, Russel Wilson). We also found that lower values for <em>k</em> increase the <em>Average QB Score</em> significantly, regardless of input data size. Unlike <em>k</em>, however, both the regularization parameter alpha and the tolerance are influenced by the amount of input data, with varying locations for their peak <em>Average QB Score</em>.</p><h3>Results</h3><p>With hyper parameters tuned, let’s look at some Quarterback-Receiver combos using the following criteria to maximize our accuracy metric — <em>Average QB Score:</em></p><ol><li>Short-term NFL data from only the 2020 and 2021 seasons</li><li><em>k</em>=3</li><li>alpha=0.9</li><li>tolerance=0.005</li></ol><p><strong>Note: </strong>Listed below are only the starting Quarterbacks for each NFL team. The receivers are the top 10 Receivers that had the highest compatibility score for their group.</p><pre>GROUP 1 out of 3 k-rank group(s)</pre><pre>average quarterback score: 0.13548700559442842</pre><pre>Quarterbacks: [‘J.Burrow’, ‘C.McCoy’, ‘T.Brady’, ‘M.Rudolph’, ‘J.Hurts’]</pre><pre>Receivers: [‘L.McCoy’, ‘R.Gronkowski’, ‘A.Brown’, ‘C.Brate’, ‘M.Evans’, ‘J.Mickens’, ‘C.Grayson’, ‘L.Fournette’, ‘O.Howard’, ‘C.Godwin’]</pre><pre>— — — — — — — — — — — — — — — — — — -</pre><pre>GROUP 2 out of 3 k-rank group(s)</pre><pre>average quarterback score: 0.2006553965063584</pre><pre>Quarterbacks: [‘J.Garoppolo’, ‘P.Walker’, ‘L.Jackson’, ‘P.Mahomes’, ‘T.Bridgewater’, ‘D.Carr’, ‘D.Prescott’]</pre><pre>Receivers: [‘A.Sherman’, ‘J.Gordon’, ‘T.Kelce’, ‘E.Fisher’, ‘B.Bell’, ‘D.Robinson’, ‘T.Hill’, ‘G.Dieter’, ‘M.Kemp’, ‘N.Keizer’]</pre><pre>— — — — — — — — — — — — — — — — — — -</pre><pre>GROUP 3 out of 3 k-rank group(s)</pre><pre>average quarterback score: 0.5274625854006478</pre><pre>Quarterbacks: [‘J.Herbert’, ‘T.Siemian’, ‘M.Jones’, ‘J.Brissett’, ‘B.Mayfield’, ‘Jos.Allen’, ‘Ty.Taylor’, ‘M.Ryan’, ‘C.Wentz’, ‘J.Fields’, ‘J.Goff’, ‘R.Tannehill’, ‘Aa.Rodgers’, ‘M.Stafford’, ‘M.White’, ‘T.Heinicke’, ‘R.Wilson’, ‘K.Cousins’, ‘T.Lawrence’]</pre><pre>Receivers: [‘C.Beasley’, ‘J.Brown’, ‘S.Diggs’, ‘J.Kumerow’, ‘T.Yeldon’, ‘I.McKenzie’, ‘S.Neal’, ‘E.Turner’, ‘J.Allen’, ‘D.Singletary’]</pre><p>You can see that group 3 has a higher average score than group 1 or group 2, this indicates stronger chemistry among group 3, with less confident chemistry in groups 1 and 2. A score of 1.0 would imply a near-perfect match. Unsurprisingly, this tends to happen as k approaches 32, where the algorithm almost perfectly learns the 32 NFL teams based on Quarterback and Receiver combinations. Additionally, If you look up some of these players as of the mid 2021–2022 season, you’ll notice there are many combinations where a Quarterback and Receiver from a group are on the same team. This is expected as preexisting duos in the League have withstood the test of time. In other words, they can “vouch for each other”. Aside from that, try swapping around group members on your fantasy football team and see how they perform!</p><h3>Conclusion</h3><p>I hope you learned something new and I hope you learned something useful from this blog. Here we covered non-negative matrix factorization and how to apply it to historic NFL data such that we can learn combinations of Quarterback and Receiver that may perform well together.</p><p>If you would like to view the source code of this experiment, check out this github repository: <a href="https://github.com/ChristopheBrown/nfl-ml">https://github.com/ChristopheBrown/nfl-ml</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=48bc5724931d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/predicting-the-next-best-fantasy-football-team-using-the-non-negative-matrix-factorization-machine-48bc5724931d">Predicting the Next Best Fantasy Football Team using the Non-negative Matrix Factorization Machine…</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Predicting the Probability of Scoring a Basket in the NBA using Gradient Boosted Trees]]></title>
            <link>https://medium.com/data-science/predicting-the-probability-of-scoring-a-basket-in-the-nba-using-gradient-boosted-trees-c157390fb17?source=rss-c7799fc4035d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c157390fb17</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[basketball]]></category>
            <category><![CDATA[sports]]></category>
            <dc:creator><![CDATA[Christophe Brown]]></dc:creator>
            <pubDate>Thu, 11 Nov 2021 17:42:45 GMT</pubDate>
            <atom:updated>2021-11-11T19:26:15.362Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In my <a href="https://towardsdatascience.com/simple-modeling-of-nba-positions-using-the-k-nearest-neighbors-machine-learning-algorithm-223b8addb08f">first blog</a> on Machine Learning in the NBA I wrote on how professional sports generate extensive amounts of data, opening a wide avenue of possibilities. We can look beyond the perception of spectators and deeper into the inner workings of the game of basketball.</p><p>With as much data as we have available, data scientists can be creative in both the models they create and the data used to create them. That brings us to this blog post. To start us off, let’s pose a bizarre question — and use Machine Learning to see if we can get close to a rational answer:</p><h4>You’re putting $1 million on the line for LeBron James to make a shot in a basketball game. How could you be certain that you will win the payout?</h4><p>Check out the companion video for this blog as well: <a href="https://youtu.be/Lxfsvw7rHgU">https://youtu.be/Lxfsvw7rHgU</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T6p4RRgYt7ux-BWz" /><figcaption>Photo by <a href="https://unsplash.com/@alschim?utm_source=medium&amp;utm_medium=referral">Alexander Schimmeck</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>The Stats</h3><p>We want to use information that will give us a strong indication as to whether or not James will score a basket. At the time of writing, <a href="https://www.basketball-reference.com/players/j/jamesle01.html">LeBron James has a 50.4% career shooting percentage</a>. Loosely speaking, that means if we look at his entire career dating back to 2003, every time he’s attempted a shot, the odds of him scoring were about the same as flipping a coin. Not great if we have $1 million on the line. We need to tip the scale in our favor.</p><p>Talent comes in all shapes and sizes in the NBA, and one example of this is seeing how different players have different play styles and shooting preferences. Some instances of this include:</p><ul><li>Shooting right-handed versus left-handed</li><li>Shooting long-range versus mid-range</li><li>Performing well under pressure (e.g. in the final seconds of a close game)</li></ul><p>Believe it or not, this information, and more, is captured in NBA stats data. We can leverage this data and exploit it to see how we can find the right basket attempt to place a bet on. While we’re on this note, I’ll mention that all of the data referenced henceforth in this blog comes from <a href="https://www.basketball-reference.com/">https://www.basketball-reference.com/</a>.</p><p>Without overcomplicating things, we’ll stick with just two criteria to build our model: <strong>location of the shot attempt</strong> and the <strong>stage of the game. </strong>Our model will use these features from LeBron James’ career shooting data:</p><ul><li>XY coordinates of shot attempt (i.e. the location on the court)</li><li>Distance from the player to the basket</li><li>Time remaining in the quarter when the shot took place</li><li>Whether or not the shot was attempted towards the end of a half</li><li>Whether or not the shot was in the fourth quarter</li></ul><p>The last two features are included to add further context to the stage of the game. In close matchups especially, those last-minute or last-second baskets can influence a game’s outcome significantly, and we want to capture that. This means we’re assuming that baskets scored as the game clock runs out are more valuable, and a player will be more incentivized to score a basket.</p><h3>Gradient Boosted Trees</h3><p>We’re going to try answering this question using Gradient Boosted Trees. These are a type of decision tree<em> </em>used in supervised machine learning.</p><p><strong>Decision trees</strong> are a widely-used family of algorithms where a “mathematical flowchart” is learned from the input features. <strong>Gradient Boosted Trees</strong> are a variant where decision trees are built in series, and each tree tries to correct the mistakes the of the previous one. One tree could look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3HK7pvlyyKdDQzDW8uzbvg.png" /><figcaption>One of many decision trees that can be used to determine the likelihood of scoring. Visualized with GraphViz.</figcaption></figure><p>Above, we can see a tree with its values learned from the input features. It shows us how each value gets us closer to the decision of the tree. The “samples” field tells us how many of the total samples (or basket attempts) fell in this category. The “value” field (as well as the darkness of the shade of color) tells us the more significant indicators are of this tree. The number of total trees used will be equivalent to the <em>n_estimators </em>parameter described below.</p><p>Learn more about Gradient Boosting here: <a href="https://arogozhnikov.github.io/2016/06/24/gradient_boosting_explained.html">Gradient Boosting explained [demonstration] (arogozhnikov.github.io</a></p><p>There are two hyper parameters we’ll spend time tuning in our trees:</p><ul><li><strong><em>n_estimators</em></strong>: number of boosting stages to perform (in other words, the number of trees in sequence; we “boost” or learn from one tree to the next)</li><li><strong><em>learning_rate</em></strong>: how strongly each tree learns from the last</li></ul><p>In this experiment, we expect the algorithm to learn “sweet spots” on the court to shoot from as well as a window marking the best time to take a shot. It may look something like “short-range to the hoop with about 3:26 left will yield a 73% chance at scoring a basket.”</p><p>What I like about decision trees is that they are simpler to understand in concept as well as in analysis. We’re looking for the highest probability of making a field goal attempt. This will be at some node of the tree, and there exists some combination of our feature set that will navigate us there.</p><h3>Results and Case Analysis</h3><p>We’ll spend more time discussing the approach and the results in this blog rather than the code setup. If you’re interested in the source code, I have a GitHub repository linked at the end of this blog.</p><h4>Train-Test Split</h4><p>LeBron James has <a href="https://www.basketball-reference.com/leaders/fga_active.html">more field goal attempts</a> than any active player in the 2021–22 season. This is great news for us in that we can use all of his scored baskets and all of his missed baskets to train a model to understand where and when he performs best. The features we’re using are known for each shot attempt, alongside whether or not the attempt was successful. For training the following models, I took a standard train-test-split with 75% of the data used to train and 25% used for testing. It’s important to shuffle the data before splitting it to avoid biasing our model to learn from only the first 3/4 of James’ career.</p><h4>Hyper Parameter Tuning</h4><p>Next, to maximize the likelihood of success, I ran a brief experiment to look at the influence of <em>learning_rate</em> and <em>n_estimators</em>. This helps select the best model.</p><p>I used learning rates between 0.01 and 0.1 with a step size of 0.01. Accuracy ramped up quickly and gradually tapered off, all while hovering within a 2% range. The best accuracy was 64.619% with a learning rate of 0.02.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*dF0pIAqEgxF4s_fpNqU7OA.png" /><figcaption>Tuning the learning_rate (lr) hyper parameter</figcaption></figure><p>Next, I tuned the n_estimators parameter. Accuracy peaked marginally higher at 64.733%. This was found using the learning_rate=0.02.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*AZKGBK-_KhZCYUvPzjLiOA.png" /><figcaption>Tuning the n_estimators hyper parameter</figcaption></figure><h4>Model Testing</h4><p>With our model ready for action, we can feed it test data to examine the probability of LeBron making a basket given his court position and time remaining on the game clock. I should note that the roughly 64% prediction accuracy is an <em>average</em> prediction rate across all of LeBron’s shots (i.e. the shots used to train the model). This means there are <em>specific</em> shooting scenarios where the model predicts whether or not a basket is scored with even greater accuracy. We can exploit those scenarios to win our cash prize.</p><p>With thousands of samples to select from, what I found to be the most insightful way to look at this was to look at the upper percentiles for his shooting. In other words, we can plot out the shot scenarios that LeBron is at least 70% likely to land a field goal:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*SZ33ekDtCxQ6nPL3SRMD-g.png" /><figcaption>70-percentile shooting by LeBron James (axes are X-Y court coordinates)</figcaption></figure><p>Very little surprise here. LeBron stands at a tall 6&#39;9&quot; weighing in at 250 pounds. Throughout his career, he’s had few issues driving straight to the basket, knocking down anything from clean layups to high-flying dunks. His most reliable shots should be right under the rim. That blue blob comprises of 609 unique shots. Interestingly enough, these are shots that exclusively take place with between 1:30 and 5:07 left on the game clock in any quarter.</p><p>Therefore, we now have an answer: despite LeBron James’ 50.4% shooting average, <strong>if we were to put $1 million on the line for LeBron James to score a basket, we’d have a 70% chance at winning on an attempt that’s right under the hoop with between 1:30 and 5:07 left on the game clock.</strong></p><p>What about other players?</p><p>We can apply this algorithm to any player in the League. Ideally those who are more experienced with scoring. Let’s briefly take a look at two other prolific shooters: Kevin Durant and Stephen Curry.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*BqkKsi-bWOAcFI43eKspWQ.png" /><figcaption>70-percentile shooting by Kevin Durant</figcaption></figure><p>Kevin Durant has a similar stature to James, and therefore makes baskets in the paint (under the rim) with ease. He is, however, known to be the “<a href="https://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=&amp;cad=rja&amp;uact=8&amp;ved=2ahUKEwjuxuegqIr0AhWwmeAKHQu6Ab8QFnoECAIQAQ&amp;url=https%3A%2F%2Fwww.instagram.com%2Feasymoneysniper%2F&amp;usg=AOvVaw2Eu6kKTr-khgEBaUtoF88r&amp;cshid=1636427725917698">@EasyMoneySniper</a>” hitting long range shots as well. If you were to place this same bet on Kevin Durant, you would have a few more locations to choose from, and you’ll want his shot to take place with between 2.8 seconds and 5:33 left on the game clock. Talk about clutch!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*HfD18MKBGEade0LUlStgBQ.png" /><figcaption>70-percentile shooting by Stephen Curry (4th quarter shots in orange)</figcaption></figure><p>If you happen to skip over the text in this blog and look only at these plots, you’d still see that Steph Curry is in a league of his own when it comes to shooting. Plotted above are 613 shots taken by Curry. To my surprise, Steph Curry has a <em>lower</em> career shooting percentage than LeBron James, at 47.6%. So <em>why </em>can we select a shot from Steph Curry from virtually anywhere?</p><p>Because Steph Curry <em>can</em> shoot from anywhere.</p><p>His shots are not concentrated like James’. He simply has the versatility to land from nearly anywhere on the court. If you want to place your bet on Curry instead, make sure it’s between 0.8 seconds and 11:53 remaining. That’s effectively any time throughout the game! I’ve also color-coded optional fourth-quarter shots in orange. Given his fourth-quarter performance still covers the entire court, Curry is solidified as one of the most reliable shooters the game has ever seen.</p><h4>Model Limitations</h4><p>With every great machine learning model comes its limitations. Provided we’re talking about professional basketball games here, we should acknowledge that there are many quantified and unquantified variables not accounted for in our model that could influence the outcome of a game or the outcome of a shot attempt. Some examples include:</p><ul><li>Contested shots: in a game, a player can attempt a shot completely unguarded, or have up to 5 defenders guarding them. Obviously, more defenders implies a tougher shot and a lower probability of scoring.</li><li>Injury history: players coming off of hand or foot injuries may be reluctant to shoot from one side or the other, even if it’s their dominant side. They may also choose to avoid heavy-contact, which is likely to happen under the rim (<a href="https://www.youtube.com/watch?v=s-Cny6Qqaa8&amp;ab_channel=BAKETS">some still prevail, however</a>).</li><li>Regular season vs. playoffs: While the model described in this blog accounts for shots made in both the regular season and the playoffs, no explicit distinguishment is made in the data itself. Some players are known to elevate their game in the NBA post-season or play more minutes overall, which can affect their in-game performance for the better or worse.</li></ul><p>Further studies would be needed in order to understand a player’s mentality when taking shots under pressure. We could additionally consider player physiology, such as how high they jump, the angling of their wrist and shoulders, or their visibility to the net. This data, however, is more scarce.</p><h4>Bias, Overfitting, and the Context of NBA Basketball</h4><p>In the proof-of-concept stages of this experiment, I shared a <a href="https://twitter.com/christophejmb/status/1457378199768346632">video to my Twitter followers</a> showing that LeBron James could, in fact, have as high as 98% likelihood of making a basket. Purely from a number’s standpoint, it <em>is</em> <em>possible</em> for a probability to be high. One scenario could look something like this:</p><p>Shaquille O’Neal is notoriously known for almost never taking a three-point shot throughout his 19 years in the league. In 22 total attempts, he’s scored once. Say that, instead, he scored all 22 of those attempts and his 3-point shooting percentage was near 100%. Looking at <em>all </em>of Shaq’s attempts, he’s attempted over 19,000 shots, most of which are two-point shot attempts averaging a scoring percentage of 58.3%. If his short-range, two-point baskets are successful at a rate of 58.3% and his long-range, three-point attempts are successful at a rate of 100%, you would expect our model to treat long-range three-pointers as an effective guaranteed shot. This is model <em>bias</em>,<em> </em>as we are overestimating the true likelihood of making a three-point attempt, which is widely-agreed as a more difficult shot.</p><p>The other scenario, which was the case as per my video, is the result of overfitting to the training data. This highlights the importance of tuning hyper parameters to select an adequate model that can perform in the context of professional sports. The competitive nature of the NBA would likely cause a high probability like this to never see the light of day.</p><h3>Conclusion</h3><p>To recap this blog, we covered a space-time analysis for how NBA players have varying likelihoods of scoring a basket. Using Gradient Boosted Trees, I created a model that would account for a player’s positioning on the court as well as the remaining time in the quarter to predict the likelihood that a respective combination would yield a scoring shot attempt. In analysis, we found that a player like LeBron James will often score shots close to the rim, and players like Steph Curry are even better than we thought, being able to reliably land a basket at almost any time, virtually anywhere.</p><p>I hope you learned something new and learned something useful in the blog. If you’re interested in checking out the source code, you can find my GitHub repo here:</p><p><a href="https://github.com/ChristopheBrown/nba-ml">ChristopheBrown/nba-ml: Main Repository for all NBA Machine Learning demos (github.com)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c157390fb17" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/predicting-the-probability-of-scoring-a-basket-in-the-nba-using-gradient-boosted-trees-c157390fb17">Predicting the Probability of Scoring a Basket in the NBA using Gradient Boosted Trees</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple Modeling of NBA positions using the K-Nearest Neighbors Machine Learning Algorithm]]></title>
            <link>https://medium.com/data-science/simple-modeling-of-nba-positions-using-the-k-nearest-neighbors-machine-learning-algorithm-223b8addb08f?source=rss-c7799fc4035d------2</link>
            <guid isPermaLink="false">https://medium.com/p/223b8addb08f</guid>
            <category><![CDATA[nba]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[sports]]></category>
            <dc:creator><![CDATA[Christophe Brown]]></dc:creator>
            <pubDate>Tue, 19 Oct 2021 14:32:42 GMT</pubDate>
            <atom:updated>2021-11-06T16:03:42.014Z</atom:updated>
            <content:encoded><![CDATA[<p>NBA season is heating up again, which means basketball fans around the world are gearing up to watch their favorite players captivate the world with long-range threes, poster dunks, and the ever-so-disrespectful ankle-breaking crossovers.</p><p>In the spirit of demonstrating absolute dominance, I want to share how the computer dominates the average fan (like myself) in basketball knowledge using Machine Learning.</p><p>In this blog I will show you <strong>how to create a machine learning model</strong> (in Python) that can <strong>learn NBA positions</strong> and play styles <strong>from only career points scored, assists, rebounds, blocks, and steals</strong>.</p><p>Check out the companion video here as well: <a href="https://www.youtube.com/watch?v=Va5X6zcNsPw">https://www.youtube.com/watch?v=Va5X6zcNsPw</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n88irFMSdM5dw-jh" /><figcaption>Photo by <a href="https://unsplash.com/@jcgellidon?utm_source=medium&amp;utm_medium=referral">JC Gellidon</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>The Fundamentals</h3><p>Anyone who watches modern NBA basketball knows that the league is one of the most data-rich resources out there. The NBA collects copious amounts of data on teams, players, and games. This data highlights some of the prestige and elite talent the NBA boasts. Here are some examples:</p><ul><li>LeBron James has played in the NBA for 18 seasons. The NBA regular season is 82 games long. After the regular season, 16 exceptional teams compete in the NBA playoffs for a chance at a championship. LeBron James, to date, has played 266 NBA playoff games. This means LeBron has also effectively played more than three extra NBA seasons-worth of games just from playoff appearances.</li><li>Dennis Rodman led the league in rebounds for 7 straight years, but his first year leading wasn’t until he was 30 years old.</li><li>In the 1961–1962 NBA season Wilt Chamberlain averaged 48.5 minutes per game. This sounds like a modest stat line at first, until you realize that a regulation NBA game runs out at 48 minutes. How did he do it? By playing every minute he could in each game he played, including several games going into overtime. A rare sight to see in any era of the NBA.</li></ul><p>In this blog, we’ll be referencing some of the more frequently-referenced data points. Namely: points scored, assists, rebounds, blocks, and steals. These stats are typically mentioned when discussing a player’s performance for any given game. Some special performances come to mind:</p><ul><li>On only five occasions in NBA history has a player averaged a triple-double (securing double-digits in three out of the five stats mentioned above) for an entire season. <a href="https://www.landofbasketball.com/records/triple_double_seasons.htm">Four of those occasions are courtesy of Russel Westbrook</a>.</li><li>LeBron James is the first and the only player to ever average a triple-double <a href="https://bleacherreport.com/articles/2715326-lebron-james-becomes-1st-player-to-average-triple-double-in-nba-finals-history">in the NBA finals</a>.</li><li>Draymond Green is the first and only player to ever secure a triple-double <a href="https://www.sbnation.com/2017/2/10/14584492/draymond-green-triple-double-nba-history-warriors-vs-grizzlies">without scoring double-digit points</a>.</li></ul><p>By now you should be seeing the amount of greatness that goes around in this sport.</p><p>Getting back to the basics — organized basketball is played in five positions:</p><ul><li>Point guard</li><li>Shooting guard</li><li>Small forward</li><li>Power forward</li><li>Center</li></ul><p>Which brings us to the goal of this blog — for a computer to learn these positions <strong>using just points scored, assists, rebounds, blocks, and steals. </strong>For simplicity, we’ll combine both guard positions and we’ll combine both forward positions for three total positions.</p><h3>The Machine Learning</h3><p>To accomplish this we’ll be using a K-Nearest Neighbors (KNN) classification algorithm. KNN is often viewed as one of the simplest machine learning models. If you’re just getting started with machine learning, here’s the gist of what you need to know (feel free to skip to below the plot image if you already know how KNN works):</p><p>K-Nearest Neighbors is a <em>supervised machine learning</em> technique. That means that our <em>training data</em> consists of the <em>features</em> of the data points (i.e. the values along the x-axis and y-axis) as well as the <em>class </em>that<em> </em>the data point belongs to (i.e. the color of the data points).</p><p>The algorithm, or model, works by plotting out the training data points first. Next, new data points (in practice, we call this <em>test data)</em>, whose features are known but their class is <strong>unknown</strong>, are plotted. The distance is measured between the test data point and N nearest neighbors (N=3 in the plot below).</p><p>From here it’s a majority-rules process, where if the majority of the neighbors are members of the red class, for example, the test data point is labeled as a red data point. That’s it!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*o6OV7NX4IZIUcFAquUamYg.png" /><figcaption>Predictions made by the three-nearest-neighbors</figcaption></figure><p>In this KNN instance, the features of our model will be career points scored, assists, rebounds, blocks, and steals. Our classes will be the three basketball positions: guard, forward, and center.</p><p>Let’s get into the code.</p><p>Beginning with our imports, we’ll use the scientific computing package numpy, the data manipulation and analysis package pandas, the plotting and visualization package matplotlib, along with the KNN classifier from the sklearn package. Finally, we’ll make use of the basketball_reference_scraper package from PyPi (<a href="https://pypi.org/project/basketball-reference-scraper/">you can pip install it here if you need to</a>). The basketball_reference_scraper package sources data and stats from <a href="https://www.basketball-reference.com/">https://www.basketball-reference.com/</a>. From basketball_reference_scraper. we need the players.get_stats function to retrieve career stats like points per game or rebounds per game.</p><pre>import numpy as np<br>import pandas as pd<br>import matplotlib.pyplot as plt<br>from matplotlib.pyplot import figure<br>from sklearn.neighbors import KNeighborsClassifier<br>from basketball_reference_scraper.players import get_stats</pre><p>Next up is out training data. Again, this is the data where our features and classes are known. This means we need to select some NBA players from each position. I chose to select some current players, but you can choose anyone who has some significant experience in the league (and is/was particularly good in their position!).</p><pre>POSITION_TYPES = [&#39;CENTER&#39;, &#39;GUARD&#39;, &#39;FORWARD&#39;]</pre><pre># Centers<br>centers=[<br>    &#39;nikola jokic&#39;,<br>    &#39;joel embiid&#39;,<br>    &#39;anthony davis&#39;,<br>    &#39;andre drummond&#39;,<br>    &#39;bam adebayo&#39;<br>]</pre><pre># Guards<br>guards=[<br>    &#39;damian lillard&#39;,<br>    &#39;stephen curry&#39;,<br>    &#39;luka doncic&#39;,<br>    &#39;jamal murray&#39;,<br>    &#39;james harden&#39;<br>]</pre><pre># Forwards<br>forwards=[<br>    &#39;giannis antetokounmpo&#39;,<br>    &#39;draymond green&#39;,<br>    &#39;pascal siakam&#39;,<br>    &#39;zion williamson&#39;,<br>    &#39;blake griffin&#39;<br>]</pre><p>Next we gather the stats from all these players:</p><pre>def fetch_player_career(player):<br>    career = get_stats(player, stat_type=&#39;PER_GAME&#39;, playoffs=False, career=False, ask_matches=False)<br>    <br>    # Drop rows containing &#39;Did Not Play&#39; by only returning rows with digits in the &quot;Games Played&quot; field<br>    career_stats = career[career[&#39;G&#39;].apply(lambda x: str(x).replace(&#39;.&#39;,&#39;&#39;).isdigit())]<br>    <br>    return career_stats</pre><pre>careers = []<br>nba_players = centers + guards + forwards<br>for player in nba_players:<br>    print(player)<br>    careers.append(fetch_player_career(player))</pre><p>Now we’re ready to prepare our training data. To do this, we’ll take the per-season, average stats. We’ll sum this and then divide by seasons played. This will give us per-game averages. We use per-game averages because it factors career-length into the model. In other words, if a player scored 2,000 career assists, it matters whether that player accomplished it within seven years or 15 years in the league, as it will show how efficient they were in their respective position.</p><p>So for example, if a player averaged 15 points per game in their first season, and 20 points per game in their second season, we’ll sum 15 and 20 to get 35, then divide by 2 seasons played to get a career average points-per-game of 17.5.</p><p>To also note, all that’s happening with y_train is that I’m declaring an array of size (15,) that holds position values encoded to match the 15 players used in our training data:</p><ul><li>center = 0</li><li>guard = 1</li><li>forward = 2</li></ul><pre>def extract_stats(career_stats):<br>    &#39;&#39;&#39;<br>    extract_stats() takes a player&#39;s stats and returns a numpy array of [PTS, AST, TRB, STL, BLK]<br>    &#39;&#39;&#39;<br>    total_seasons = len(career_stats)<br>    <br>    career_ppg = (sum(career_stats[&#39;PTS&#39;].astype(float)) / total_seasons)<br>    career_ast = (sum(career_stats[&#39;AST&#39;].astype(float)) / total_seasons)<br>    career_trb = (sum(career_stats[&#39;TRB&#39;].astype(float)) / total_seasons)<br>    career_stl = (sum(career_stats[&#39;STL&#39;].astype(float)) / total_seasons)<br>    career_blk = (sum(career_stats[&#39;BLK&#39;].astype(float)) / total_seasons)<br>    <br>    return np.array([career_ppg, career_ast, career_trb, career_stl, career_blk])</pre><pre>X_train = np.zeros((15,5))<br>for i in range(len(careers)):<br>    X_train[i] = extract_stats(careers[i])<br>    <br>y_train = np.array([0]*5 + [1]*5 + [2]*5)</pre><p>We’re ready to train our model! Go ahead and instantiate an instance of a KNN classifier and call its .fit() function on the training data:</p><pre>clf = KNeighborsClassifier()<br>clf.fit(X_train, y_train)</pre><p>Now that we have our classifier, I’ll write a “predict” function. This function will take our classifier, as well as any player’s stats (the return value from the extract_stats() function) and try to predict that player’s position based on the same career stats we looked at earlier.</p><pre>def predict_position(stats, clf):    <br>    position_id = clf.predict(stats)[0]<br>    position = POSITION_TYPES[position_id]<br>    return position</pre><p>Let’s see how the classifier performs on some star players…</p><pre>more_players = [<br>    &#39;michael jordan&#39;, # 1<br>    &#39;magic johnson&#39;,  # 1<br>    &#39;chris paul&#39;,  # 1<br>    &#39;marc gasol&#39;,  # 0<br>    &#39;dikembe mutombo&#39;,  # 0<br>    &#39;russell westbrook&#39;,  # 1<br>    &#39;kevin durant&#39;,  # 2<br>    &#39;larry bird&#39;,  # 2<br>    &#39;john stockton&#39;,  # 1<br>    &#39;derrick rose&#39;,  # 1<br>    &#39;charles barkley&#39;,  # 2<br>    &#39;demarcus cousins&#39;,  # 0<br>    &#39;kyrie irving&#39;,  # 1<br>    &#39;rudy gobert&#39;,  # 0<br>    &#39;kawhi leonard&#39;,  # 2<br>    &#39;devin booker&#39;,  # 1<br>    &#39;steve nash&#39;,  # 1<br>    &#39;tim duncan&#39;,  # 0<br>    &#39;dirk nowitzki&#39;,  # 2<br>    &#39;carmelo anthony&#39;,  # 2<br>    &#39;paul george&#39;,  # 2<br>    &#39;lebron james&#39;  # 2<br>]</pre><pre>X_test = np.zeros((len(more_players),5))</pre><pre>for i in range(len(more_players)):<br>    all_career_stats = fetch_player_career(more_players[i])<br>    stats = extract_stats(all_career_stats).reshape(1,-1)<br>    X_test[i] = (stats)</pre><pre>y_test = [1, 1, 1, 0, 0, 1, 2, 2, 1, 1, 2, 0, 1, 0, 2, 1, 1, 0, 2, 2, 2, 2]</pre><pre>correct_pred = 0</pre><pre>for p in range(len(X_test)):<br>    predicted_position = predict_position(X_test[p].reshape(1,-1), clf)<br>    actual_position = POSITION_TYPES[y_test[p]]</pre><pre>if predicted_position == actual_position:<br>        correct_pred += 1</pre><pre>print(f&#39;I think {more_players[p]} is a {predicted_position}. He played {actual_position} in his career&#39;)</pre><pre>I think michael jordan is a GUARD. He played GUARD in his career<br>I think magic johnson is a GUARD. He played GUARD in his career<br>I think chris paul is a GUARD. He played GUARD in his career<br>I think marc gasol is a FORWARD. He played CENTER in his career<br>I think dikembe mutombo is a CENTER. He played CENTER in his career<br>I think russell westbrook is a GUARD. He played GUARD in his career<br>I think kevin durant is a GUARD. He played FORWARD in his career<br>I think larry bird is a CENTER. He played FORWARD in his career<br>I think john stockton is a FORWARD. He played GUARD in his career<br>I think derrick rose is a CENTER. He played GUARD in his career<br>I think charles barkley is a CENTER. He played FORWARD in his career<br>I think demarcus cousins is a CENTER. He played CENTER in his career<br>I think kyrie irving is a GUARD. He played GUARD in his career<br>I think rudy gobert is a CENTER. He played CENTER in his career<br>I think kawhi leonard is a FORWARD. He played FORWARD in his career<br>I think devin booker is a GUARD. He played GUARD in his career<br>I think steve nash is a FORWARD. He played GUARD in his career<br>I think tim duncan is a CENTER. He played CENTER in his career<br>I think dirk nowitzki is a FORWARD. He played FORWARD in his career<br>I think carmelo anthony is a FORWARD. He played FORWARD in his career<br>I think paul george is a FORWARD. He played FORWARD in his career<br>I think lebron james is a GUARD. He played FORWARD in his career</pre><p>14 out of 20 positions predicted correctly. Not bad! Thats 70% accuracy. Let’s take a quick moment to understand our shortcomings and find areas for improvement.</p><pre>I think larry bird is a CENTER. He played FORWARD in his career<br>I think charles barkley is a CENTER. He played FORWARD in his career<br>I think derrick rose is a CENTER. He played GUARD in his career<br>I think steve nash is a FORWARD. He played GUARD in his career<br>I think john stockton is a FORWARD. He played GUARD in his career<br>I think lebron james is a GUARD. He played FORWARD in his career</pre><p>50% if our mispredictions are where our model predicted CENTER position. This means the model could overfitting to the center position. It helps to understand this from both a machine learning context as as well as a basketball context. A couple reasons for this could be</p><ul><li>NBA centers are known for getting more rebounds and blocks than the average player, so any exceptional, tall, or above-average guard forward forward might rack up blocks and rebounds, fooling the model into thinking they are centers.</li><li>The keen-eyed may notice the average age of the NBA centers used for our training is in the mid 20’s at the time of writing this blog, meaning that the model doesn’t fully understand how the center position is played over a career. It would help to have included some players who have played closer to a <em>full</em> career as a center like Kareem Abdul-Jabbar, Hakeem Olajuwon, or Dwight Howard.</li><li>We could include more data points per player as well. Stats like steals and assists are often not a part of the highlights when it comes to NBA centers, so the model will not learn much from them. A few good candidates include <em>defensive rebounds, 3-point attempts, </em>or<em> field-goal percentage</em>.</li><li>Even our model has to acknowledge greatness here. Truly exceptional players like <a href="https://www.statmuse.com/nba/ask/what-position-has-lebron-played">LeBron James</a> have played several position over their career. When selecting players, we should take caution to select players who shined in a role best-suited for them — like Shaq at center or Damian Lillard at point guard.</li></ul><p>Above all, with all the data created from the NBA, our biggest gains might come from using more training data to create our model. 15 players was a good start, but our model could become less prone to error by training on, say, 50 to 100 players, with more of them being NBA veterans.</p><p>Finally, below is a plot of the test set of NBA players. Because the five stats are hard to visualize in two dimensions, we’ll combine the stats into scoring-based stats and non-scoring-based stats. You’ll begin to see how certain positions are correlated to their stats. However, special players like Michael Jordan or LeBron James are skilled enough to appear above and beyond their “expected” regions. If it weren’t for such talent, our data would be linearly separable!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*QZDeQyKqReTNZ6dhaXZ9wQ.png" /></figure><p>Congratulations! If you made it this far, you have what it takes to apply machine learning to NBA stats for analysis. If you would like the full source code to this project, check out this Github repo: <a href="https://github.com/ChristopheBrown/knn_nba_positions">ChristopheBrown/knn_nba_positions (github.com)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=223b8addb08f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/simple-modeling-of-nba-positions-using-the-k-nearest-neighbors-machine-learning-algorithm-223b8addb08f">Simple Modeling of NBA positions using the K-Nearest Neighbors Machine Learning Algorithm</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An open letter to first-gen students]]></title>
            <link>https://christophebrown.medium.com/an-open-letter-to-first-gen-students-b7ae3d793bc6?source=rss-c7799fc4035d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7ae3d793bc6</guid>
            <category><![CDATA[future]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[college]]></category>
            <category><![CDATA[first-generation]]></category>
            <category><![CDATA[education]]></category>
            <dc:creator><![CDATA[Christophe Brown]]></dc:creator>
            <pubDate>Fri, 28 May 2021 04:00:33 GMT</pubDate>
            <atom:updated>2021-05-29T17:09:25.039Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3aTfvLxQYhgEJgPEh3_tLA.jpeg" /></figure><p><em>First-generation.</em></p><p><em>A term assigned to those who seek to establish a turning point in their lineage. It means to venture beyond perceived boundaries. To explore untraversed territory. To push on and push forward, navigating a path while paving it at the same time. Why does one do this?</em></p><p><em>There came a time in my youth where I thought deeply about what my family and my ancestors had gone through in order for me to be in the position I am in now. I am a descendant of immigrants. My mother, from Haiti and my father, from Trinidad and Tobago. To some, it may sound like a casual change of scenery. For my family, it meant finding salvation and eventually, opportunity. Generations prior to that have endured that which cannot be fairly compared to contemporary endeavors.</em></p><p><em>It is because of this revelation that I understand that I carry the emotion, the strength, and the will of those before me. True fighters and dreamers envision a future for their children where they can strive and prosper and achieve new heights. First-generation students hold this within them.</em></p><p><em>To my fellow first-generation students and graduates, your achievement is very special. Not only are you laying the foundation for a flourishing career, but you are creating an everlasting legacy. You’ve made a statement. Supported by all those who have sacrificed and endured with hopes that one day you can be doing what you do. That day has come, and your time is now. Your efforts and success is a testament to the willpower you carry in your body and your soul.</em></p><p><em>I write this for every first-gen student. I want this message to resonate with the world so they know that we are here, we know what it takes, and with our education we will continue to pioneer a future filled with prosperity and hope. The generations to come will be the beneficiaries, carrying the torch forward.</em></p><p><em>We will change the world.</em></p><p><em>Keep going. Each and every one of us — before, with, and after you — are counting on you, and we’re supporting you all the way.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7ae3d793bc6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Comfort Zone: the Introvert’s Dilemma]]></title>
            <link>https://christophebrown.medium.com/the-comfort-zone-the-introverts-dilemma-8d9978b9a2fa?source=rss-c7799fc4035d------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d9978b9a2fa</guid>
            <category><![CDATA[college]]></category>
            <category><![CDATA[introvert]]></category>
            <category><![CDATA[growth]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[confidence]]></category>
            <dc:creator><![CDATA[Christophe Brown]]></dc:creator>
            <pubDate>Sat, 06 Feb 2021 17:49:06 GMT</pubDate>
            <atom:updated>2021-02-06T17:49:06.436Z</atom:updated>
            <content:encoded><![CDATA[<p>A short read on embracing the qualities of introverted-ness and pushing forward.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vX_4gHF7DLqUftFs" /><figcaption>Photo by <a href="https://unsplash.com/@kilarov345?utm_source=medium&amp;utm_medium=referral">kilarov zaneit</a></figcaption></figure><h3>The Introvert’s Dilemma</h3><p>If you’re anything like me, you know the pains that come with being introverted. It’s amazing how I could describe a typical day of mine and the <em>mental image </em>painted in the mind of an introvert is entirely different from that of the extrovert. Let’s walk through an example for my day as a grad student. I’ll describe a typical day in 5 simple steps.</p><ol><li>Wake up — morning routine</li><li>Leave home to go to campus</li><li>Attend lecture for a couple of hours</li><li>Plan an evening schedule ( ̶u̶s̶u̶a̶l̶l̶y̶ always studying)</li><li>Have a meal and enjoying whatever is left of the evening</li></ol><p>I’m sure nothing seems off-putting so far, right? Let’s take a closer look at how this day could go from the perspective of an introvert.</p><ol><li>Morning routine involves waiting for roommates to clear out of the kitchen and bathroom before I can enjoy my own peace</li><li>The commute to campus is a few blocks away (this is New York City, after all), but I’d rather take the extra 2–3 blocks to the side-entrance of campus where there are less people; the likelihood I see someone I know is much lower. I also left 15 minutes early (or late) so I could decrease that likelihood further.</li><li>Attending lecture via a seat that has at least one chair between me and any of my classmates. I need my space. Oh, and no raising hands for questions, you’re not hearing my voice out in the open like that.</li><li>Planning an evening schedule. I could go to the coffee shop down the street. But there are people there. The library? People. The english department lounge? Living. Breathing. People. Home? Just me. Home it is.</li><li>Studying. I skipped out on the study group because, well, people. Good news at least is that there’s a lot of activity on the class’s online forum, so maybe I can get some help still. Bad news is all that activity is me posting questions, anonymously of course.</li></ol><p>If any of this list resonates with you, keep [listening] reading on. Let’s now take a look at how the introvert’s comfort zone is our enemy — and how we can confront it.</p><h3>Why is this a problem?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bXCi_P78e4WPTBNd" /><figcaption>Photo by <a href="https://unsplash.com/@villvilis?utm_source=medium&amp;utm_medium=referral">Vilintas Meškauskas</a></figcaption></figure><p><em>Introversion</em>, a term defined by psychiatrist Carl Jung, is the state of being predominantly interested in one’s own mental self (contrasted with <em>extroversion</em> — the state of primarily obtaining gratification from outside oneself). A harmless, albeit accurate definition. Introversion has been interpreted in many ways, including being shy, being modest, being someone who is more comfortable around a smaller group of people, or someone who finds their contentment within themselves versus with their interactions with the outside world. Again, still harmless. So, why would one suggest there is a problem? The truth is, being introverted isn’t a problem at all. It doesn’t lower your social status or value. It doesn’t discount your credentials — you can study at the same school, work the same job, and meet the same people as an introvert. So what gives? Well, the <em>problem</em> is not that introversion has chosen you, but rather when you choose it to define you.</p><p>Let’s expand upon that — continuing with school as our example. Out in the world, more so as you advance in your career, college serves two purposes and two purposes only: brand recognition and network. Now, more than ever, if there’s something you want to learn about, information is readily available for free, or at least cheaper than the cost of a four-year degree. Anything more you get out of college is not required to graduate and is completely on you. Extracurriculars — volunteering, joining a student organization, extensive research — are all optional depending on what you want to do once you graduate. If you lived every day in the introverted scenario I described, you’ll likely pass up on all of those opportunities. <em>This is the problem</em>. This is the Comfort Zone. If you choose to live life in a way that sacrifices opportunities to grow, you’re doing a disservice to yourself. It’s your responsibility and yours alone to ensure that you’re getting the experiences necessary to grow and develop. So now the question becomes: how do we confront our introverted-ness and achieve that?</p><h3>How can we confront it?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7nHiyIRz1dNH1HFH" /><figcaption>Photo by <a href="https://unsplash.com/@courtneymcook?utm_source=medium&amp;utm_medium=referral">Courtney Cook</a></figcaption></figure><p>Now that we have an understanding of how damaging the Comfort Zone is, let’s talk about how we can avoid the consequences. The first step is to look at your current situation — are you a college student? An early-to-mid career worker? Freelancer? Entrepreneur? Whichever of these apply to you, think very carefully about what it is you want out of your situation. Some advice from someone more experienced? A promotion or raise? An investment from a venture capitalist? An internship? A mentor? You name it. Once you’ve done that, you’ve established point A (where you’re at now) and point B (where you’d like to be). You just need to connect the points. There’s no cookie-cutter way to do this, unfortunately. A lot of what happens here is case-by-case.</p><p>For me, I find a lot of spontaneity when taking the steps between point A and point B. As a student I already know I have to go to class, study, and make the best grades I can. A few events occur during the semester that catch my attention:</p><ul><li>I’ll hear of a networking event that has a guest speaker I’d be interested from learning from</li><li>A faculty member or administrator wants me to speak to prospective students at an event</li><li>A student organization that’s involved in something I’m passionate about has openings for leadership positions</li><li>I can get extra credit on a project if I create a presentation and share with the class</li><li>There’s free food/coffee somewhere (“free” and “food” are the favorite words of any college student — so there’s bound to be others there)</li></ul><p>The events change all the time, but what doesn’t change is the immediate thought of being around groups of people, having eyes on you, or having to speak up and address a crowd. It makes me want to pass up the opportunity entirely. When those thoughts hit, what I need to do is think about why I was interested in this event in the first place? Why am I excited about it at all? Perhaps it’s the change to make someone happier, to share ideas with someone and learn from each other, to teach someone, or to gain something for myself. The next thought is that people are generally more worried about themselves than they are about me. Most of us — introverted, extroverted, or even a mix — get nervous in front of a crowd. Everyone has a social battery that eventually drains out. We’re all human, and we each have the ability to do amazing things. Big or small, the leap that we take by doing something important or exciting to us gets us that much closer to that point B. And once we see how much there is to gain from doing that presentation or stepping up to speak with so-and-so, it becomes that much easier to do it. Go in there expecting to fumble a word or two, knowing that if anyone else were in your position, they’d do the same. It’s a normal part of life. After you’ve tried it out once, the next time gets that much easier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*f70ApwIMY-v0ArVW" /><figcaption>Photo by <a href="https://unsplash.com/@miguel_photo?utm_source=medium&amp;utm_medium=referral">Miguel Henriques</a></figcaption></figure><h3>What can we gain from practicing this?</h3><p>These confrontational moments become easier the more you remove yourself from your Comfort Zone. Before you know it, you have more control over your hesitations, you’ll be more outgoing, and you’ll find a greater sense of growth within yourself over time. You’ll get better at speaking. You’ll be less timid in social interactions. You might even find yourself seeking out more opportunities like the one you just conquered. We’re all different, but we’re all on a journey to become better versions of ourselves.</p><p>Embrace your introverted-ness. Go out and become a better you.</p><p>I hope you enjoyed this piece on The Comfort Zone. I hope it lends you some strength for when your next big moment comes around. If you’d like more content like this, consider following me on Medium!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d9978b9a2fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Brief Introduction to Edge Computing and Deep Learning]]></title>
            <link>https://medium.com/swlh/a-brief-introduction-to-edge-computing-and-deep-learning-5af8c50e2f5c?source=rss-c7799fc4035d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5af8c50e2f5c</guid>
            <category><![CDATA[edge-computing]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Christophe Brown]]></dc:creator>
            <pubDate>Fri, 27 Nov 2020 21:22:12 GMT</pubDate>
            <atom:updated>2020-12-01T22:12:57.023Z</atom:updated>
            <content:encoded><![CDATA[<h4>For Deep Learning systems and applications, Edge Computing addresses issues with scalability, latency, privacy, reliability, and on-device cost.</h4><p>Welcome to my first blog on topics in artificial intelligence! Here I will introduce the topic of edge computing, with context in deep learning applications.</p><p>This blog is largely adapted from a survey paper written by Xiaofei Wang et al.: <em>Convergence of Edge Computing and Deep Learning: A Comprehensive Survey</em>. If you’re interested in learning more about any topic covered here, there are plenty of examples, figures, and references in the full 35-page survey: <a href="https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;arnumber=8976180">https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;arnumber=8976180</a>.</p><p>Now, before we begin, I’d like to take a moment and motivate why edge computing and deep learning can be very powerful when combined:</p><h3>Why is Deep Learning important?</h3><p>Deep learning is becoming an increasingly-capable practice in machine learning that allows computers to detect objects, recognize speech, translate languages, and make decisions. More problems in machine learning are solved with the advanced techniques that researchers discover by the day. Many of these advanced techniques, alongside applications that require scalability, consume large amounts of network bandwidth, energy, or compute power. Some modern solutions have been around to address these concerns, such as parallel computing with a Graphics Processing Unit (GPU) and optical networks for communication. However, with an explosive field like deep learning finding new methods and applications, a entirely new field is being fueled to match and possibly surpass this demand. Introducing: Edge Computing.</p><h3>Why is Edge Computing important?</h3><p>Edge computing is a distributed computing paradigm that brings computation and data storage closer to the location where it is needed, to improve response times and save bandwidth. Take for example the popular content streaming service Netflix. Netflix has a powerful recommendation system to suggest movies for you to watch. It also hosts an extraordinary amount of content on its servers that it needs to distribute. As Netflix scales up to more customers in more countries, its infrastructure becomes strained. Edge Computing can make this system more efficient. We’ll begin with the two major paradigms within Edge Computing: <strong>edge intelligence</strong> and the <strong>intelligent edge</strong>.</p><h4>Edge Intelligence</h4><p>More connected devices are being introduced to us by the day. Our phones, computers, tablets, game consoles, wearables, appliances, and vehicles are all gaining varying levels of intelligence — meaning they can communicate with other devices or perform computations to make decisions. This is edge intelligence. You might ask why this is important at all, but it turns out that as our products and services become more complex and sophisticated, new problems arise from latency, privacy, scalability, energy cost, or reliability perspectives. Use of edge intelligence is one way we can address these concerns. Edge intelligence brings a lot of the compute workload closer to the user, keeping information more secure, delivering content faster, and lessening the workload on centralized servers.</p><h4>Intelligent Edge</h4><p>Much like edge intelligence, the intelligent edge brings content delivery and machine learning closer to the user. Unlike edge intelligence, the intelligent edge introduces new infrastructure in a location convenient to the end user or end device. Let’s take our Netflix example again. Netflix has its headquarters in California, but wants to serve New York City, which is almost 5000 kilometers away. Combine latency with the time it takes to compute a recommended selection of movies for the millions of users, and you’ve got a pretty subpar service. The intelligent edge can fix this!</p><p>Instead of having an enormous datacenter with every single Netflix movie stored on it, let’s say we have a smaller datacenter with the top 10,000 movies stored on it, and just enough compute power to serve the population of New York City (rather than enough to serve all of the United States). Let’s also say we’ll build 5 of these data centers — one for each borough of New York City (Manhattan, Brooklyn, Queens, Bronx, Staten Island) — so that the data center is even closer to the end user and if one server needs maintenance, we have backups. What have we just done? We’ve introduced new infrastructure, albeit with less power, but just enough to provide an even better experience to the end user than by using the most powerful systems centralized in one location. The idea of edge intelligence is scalable too, we can imagine this on a country-wide scale or on the scale as simple as a single warehouse.</p><h3>What can we achieve if we combine the two?</h3><p>For the remainder of this blog, we’ll dive a bit deeper into Edge Computing paradigms to get a better understanding of how it can improve our deep learning systems, from training to inference. I will also briefly introduce a paper that discusses an edge computing application for smart traffic intersection and use it as context to make the following concepts make more sense.</p><h3>About COSMOS Smart Intersection:</h3><p>From the paper Abstract: Smart city intersections will play a crucial role in automated traffic management and improvement in pedestrian safety in cities of the future. They will (i) aggregate data from in vehicle and infrastructure sensors; (ii) process the data by taking advantage of low-latency high-bandwidth communications, edge cloud computing, and AI-based detection and tracking of objects; and (iii) provide intelligent feedback and input to control systems. The Cloud Enhanced Open Software Defined Mobile Wireless Testbed for City-Scale Deployment (COSMOS) enables research on technologies supporting smart cities.</p><p>You can view the full paper here: <a href="https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;arnumber=9156225">https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;arnumber=9156225</a>.</p><p>Smart cities are perhaps one of the best examples to demonstrate the need and potential for edge compute systems. In this application for traffic intersections, we could imagine that there are some challenges to address as we move to a more autonomous future:</p><ul><li>We want to make crossing the street safer for pedestrians while more cars become self-driven. We can do this by adding computer vision systems to intersections to watch for potential collisions. But vehicles travel very fast, so a real-time vision system must have ultra-low latency.</li><li>Large metropolitan cities easily have hundreds, if not thousands of intersections. If we wanted to add a vision system to some of them, a centralized compute system is more than likely to come across bottlenecks for data processing.</li><li>Every intersections is going to look a bit different from another, could you really train one vision system to work seamlessly at each intersection? What if some intersections have a lot more leaves that fall during autumn? Or more snow builds up during the winter? Taller buildings casting darker shadows? It seems that we might have an interest in machine learning models that can be adapted to changing conditions.</li><li>Constructions projects can happen any time, changing what an intersection looks like completely — in this case we may need to retrain our models, possibly while still performing inference. They say New York City is the city that never sleeps!</li></ul><p>This hopefully stimulates some ideas for how state-of-the-art deep learning solutions have limitations in an application like smart cities. Read on to see how edge computing can help address these concerns!</p><p><strong>Five essential technologies for Edge Deep Learning:</strong></p><ol><li><strong>Deep Learning Applications on the Edge: </strong>Technical frameworks for systematically organizing edge computing and DL to provide intelligent services</li><li><strong>Deep Learning Inference in in the Edge: </strong>Focusing on the practical deployment and inference of DL in the edge computing architecture to fulfill different requirements, such as accuracy and latency</li><li><strong>Edge Computing for Deep Learning: </strong>Which adapts the edge computing platform in terms of network architecture, hardware and software to support DL computation</li><li><strong>Deep Learning Training: </strong>Training DL models for edge intelligence at distributed edge devices under resource and privacy constraints</li><li><strong>Deep Learning for Optimizing the Edge: </strong>Application of DL for maintaining and managing different functions of edge computing networks (systems), e.g., edge caching, computation offloading</li></ol><p>Now, let’s take a closer look at each one.</p><h3>Deep Learning Applications on the Edge</h3><p>Applications on edge comprise of hybrid hierarchical architectures (try saying that five times fast). This architecture is divided into three levels: end, edge, and cloud. Here’s an example from the paper demonstrating a real-time video analytic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*M7eexd3-xjWXUOTZNG7c_Q.png" /><figcaption>The collaboration of end, edge, and cloud layer for performing real-time video analytic by deep learning.</figcaption></figure><p>At the cloud level, we have our traditional large deep neural network (DNN). It also [alternatively] contains a majority of a network that is shared between the cloud and the edge. At the edge level, we have both a minority of the network shared with the cloud alongside a smaller, trained deep neural network. Finally, at the end level are our end devices. These can be sensors or cameras for collecting data, or a variety of devices for observing results and information. What’s important to note here is the collaboration between the cloud and the edge. Edge infrastructure lives closer to the end level. Recall that the edge has less compute capability, so hosting our large DNN there will likely give us poor performance. However, we can still host a smaller DNN that can get results back to the end devices quickly. We can additionally have an early segment of a larger DNN operating on the edge, so that computations can begin at the edge and finish on the cloud. This is a solution that would reduce latency by removing the bottleneck at the edge level, and reducing propagation delay to the cloud level.</p><h3>Deep Learning Inference in in the Edge</h3><p>The best DNNs require deeper architectures and larger-scale datasets — thus indirectly requiring cloud infrastructure to handle the computational cost associated with deep architectures and large quantities of data. This requirement limits the ubiquity of the deployment of deep learning services, however.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WpmqCeKi5Gl0OjUXb7zOSg.png" /><figcaption>Optimization for model inputs, e.g., narrowing down the searching space of DL models.</figcaption></figure><p>The figure above depicts an inference system entirely on the edge — no cloud at all! Let’s break it down. Our camera system on the far left is placed near a common pedestrian walkway, let’s say it’s to help us find a child that was separated from their parent. To accomplish this task, our DNN must be capable of detection of humans as well as recognition, to make sure we find the right child (their parent shares a photo so we know what to look for). Sounds like a job for the cloud, right? What if, instead, we used an edge platform specifically for finding the Region-of-Interest (RoI). This yields a much smaller space that we need for object recognition, now that less-relevant parts of our image have been removed. We can feed the reduced search space to a second edge platform that performs the inference for matching the child in the photo provided. Therefore, this distributed system successfully completes the same task that normally would be allocated to the cloud. The ability to deploy a system like this dramatically increases the potential for system deployment in places further away — or completely disconnected — from the cloud!</p><h3>Edge Computing for Deep Learning</h3><p>So far we’ve talked about how we can stretch a DNN architecture across cloud, edge, and end devices. This is only one direction we can approach for deploying edge computing systems. Truly, the design, adaptation, and optimization of edge hardware and software are equally important. We will discuss that in this section.</p><ul><li><strong>Edge Hardware for DL: </strong>Designing an edge node will depend on whatever metrics matter most for an application, this can lead to the decisions one would make with regards to choosing to run on CPU, GPU, FPGA, or ASIC hardware.</li><li><strong>Communication and Computation Modes for Edge DL: </strong>There are a variety of ways we could go about communication modes for our edge system. We may need to define a threshold in which compute workload must offload from off the edge and to the cloud (such as during high network bandwidth usage). We may alternatively choose for several edge nodes to cooperate together on a task.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qHi6KVgrQ0x75CixGmWYfA.png" /><figcaption>Communication and computation modes for Edge DL.</figcaption></figure><ul><li><strong>Tailoring Edge Frameworks for DL: </strong>Commonly-used frameworks like Tensorflow and Py(Torch) work well, though their models developed in them may not be executable on the edge. Therefore frameworks themselves can be optimized to adapt to different configurations that best suit the available compute resources and data.</li><li><strong>Performance Evaluation for Edge DL: </strong>No standard testbench for edge DL exists at the time of writing — but to fully realize the potential of edge systems (as well as their combination with cloud and end devices), end-to-end metrics will be appropriate, especially for vehicular scenarios.</li></ul><h3>Deep Learning Training</h3><p>A variety of concerns may rise regarding training. For example, for real time training applications, aggregating data in time for training batches may incur high network costs. For different applications, merging data could violate privacy issues. While niche, these legitimate concerns justify an exploration into end-edge-cloud systems for deep learning training.</p><p>Distributed training has been around for some time. It can be traced back to a proposed edge computing solution to solve a large scale linear regression problem in the form of a decentralized stochastic gradient descent method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tff2lbPonfp2HuJAgFffRQ.png" /><figcaption>Distributed DL training at edge environments.</figcaption></figure><p>This figure shows two examples of a distributed training network. On the left, it is the end devices that train models from local data, with weights being aggregates at an edge device one level up. On the right, training data is instead fed to edge nodes that progressively aggregate weights up the hierarchy.</p><p><strong>Federated Learning:</strong> Federated Learning (FL) is also an emerging deep learning mechanism for training among end, edge, and cloud. Without requiring uploading data for central cloud training, Federated Learning can allow edge devices to train their local DL training, Federated Learning can allow edge devices to train their local DL models with their own collected data and upload only the updated model instead.</p><p>As depicted in the figure below, FL iteratively solicits a random set of edge devices to 1) down- load the global DL model from an aggregation server (use “server” in following), 2) train their local models on the down- loaded global model with their own data, and 3) upload only the updated model to the server for model averaging.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sxON1IPJw829DZHX6bVWVA.png" /><figcaption>Federated learning among hierarchical network architectures.</figcaption></figure><p>Federated learning can address several key challenges in edge computing networks: <strong>Non-IID training data</strong>, <strong>limited communication</strong>, <strong>unbalanced contribution</strong>, and <strong>privacy and security</strong>. See section 7, subsection B in the paper for more details for how FL achieves this.</p><h3>Deep Learning for Optimizing the Edge</h3><p>DNNs (general DL models) can extract latent data features, while DRL can learn to deal with decision-making problems by interacting with the environment. With regard to various edge management issues such as edge caching, offloading, communication, security protection, etc., 1) DNNs can process user information and data metrics in the network, as well as per- ceiving the wireless environment and the status of edge nodes, and based on these information 2) DRL can be applied to learn the long-term optimal resource management and task schedul- ing strategies, so as to achieve the intelligent management of the edge, viz., or intelligent edge.</p><p>This leaves significant room for open-endedness — where we can apply DNNs or DRL for resource management such as caching (i.e. reducing redundant data transmissions), task offloading, or maintenance. See the attached table from the paper to see how this may be used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D4BuwGYq832bxxyEsAasxQ.png" /></figure><h3>Lessons Learned and Open Challenges</h3><h4>Lessons Learned</h4><p>This blog covers use cases of edge computing for deep learning at a surface level, highlighting many applications for deploying deep learning systems as well as applications for metrics and maintenance. If these ideas resonated with you, you might agree that this opens the avenue for more deep learning applications like self-driving cars or cloud-based services like gaming or training DNNs entirely offline for research purposes.</p><h4>Open Challenges</h4><p>With the rising potential of edge computing and deep learning, the question is also raised as to how should we go about measuring performance of these new systems or determining compatibility across the end, edge, and cloud:</p><ul><li>Generalization of EEoI (Early Exit of Inference) — We dont always want to be responsible for choosing when to exit early. This is an area deep reinforcement learning can explore.</li><li>Hybrid model modification — our cloud model may need to be pruned to run on end nodes or end devices. Can it still perform after that?</li><li>Coordination between training and inference — Consider a deployed traffic monitoring system has to adjust for after road construction, weather/changing seasons. It must retrain itself. Training is expensive, so how can it be coordinated with inference once the roads open again?</li></ul><p>On top of this, the introduction of edge hardware comes with its own unique challenges. Some examples are:</p><ul><li>Edge for Data Processing</li><li>Microservice for Edge Deep Learning Services</li><li>Incentive and Trusty offloading mechanism for Deep Learning</li><li>Integration with DL for optimizing Edge</li></ul><p>Lastly (and before the details get too confusing!), we might also be interested in practical training principles at edge. The idea here is that want to have standards for how our system trains. A lot of these questions are open-ended, meaning a lot of solutions can (and cannot) be used to address the problem. Some questions that can serve as examples to ponder on: Where does training data coming from? Say we want to deploy Federated Learning model. To do this, that means the cloud is not a delegator of data. Is data collected on site? Are edge nodes communicating over the blockchain? There may be synchronization issues because of edge device constraints (i.e. power), and so on.</p><p>Thank you for checking out my blog! I hope you learned something new, and I hope you learned something useful. Leave a comment if this blog helped you! Also, feel free to connect with me on LinkedIn: <a href="http://linkedin.com/in/christophejbrown">http://linkedin.com/in/christophejbrown</a></p><p>References:</p><p>[1] X. Wang, Y. Han, V. C. M. Leung, D. Niyato, X. Yan and X. Chen, “Convergence of Edge Computing and Deep Learning: A Comprehensive Survey,” in IEEE Communications Surveys &amp; Tutorials, vol. 22, no. 2, pp. 869–904, Secondquarter 2020, doi: 10.1109/COMST.2020.2970550. Link: <a href="https://ieeexplore.ieee.org/document/8976180">https://ieeexplore.ieee.org/document/8976180</a></p><p>[2] S. Yang <em>et al</em>., “COSMOS Smart Intersection: Edge Compute and Communications for Bird’s Eye Object Tracking,” <em>2020 IEEE International Conference on Pervasive Computing and Communications Workshops (PerCom Workshops)</em>, Austin, TX, USA, 2020, pp. 1–7, doi: 10.1109/PerComWorkshops48775.2020.9156225. Link: <a href="https://ieeexplore.ieee.org/document/9156225">https://ieeexplore.ieee.org/document/9156225</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5af8c50e2f5c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/a-brief-introduction-to-edge-computing-and-deep-learning-5af8c50e2f5c">A Brief Introduction to Edge Computing and Deep Learning</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>