<?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 Alex Federation on Medium]]></title>
        <description><![CDATA[Stories by Alex Federation on Medium]]></description>
        <link>https://medium.com/@afederation?source=rss-b240a8c56406------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*eTLcYYmSOhNkmA7zfg8XdA.jpeg</url>
            <title>Stories by Alex Federation on Medium</title>
            <link>https://medium.com/@afederation?source=rss-b240a8c56406------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 06:15:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@afederation/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[Quickly Transfer a Kaggle dataset into a Google bucket]]></title>
            <link>https://medium.com/data-science/quickly-transfer-a-kaggle-dataset-into-a-google-bucket-ac21aefceb15?source=rss-b240a8c56406------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac21aefceb15</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[kaggle-api]]></category>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Alex Federation]]></dc:creator>
            <pubDate>Sun, 29 Sep 2019 07:03:01 GMT</pubDate>
            <atom:updated>2019-10-01T04:10:14.226Z</atom:updated>
            <content:encoded><![CDATA[<p>15 days. I was shocked at how long it was going to take to upload a relatively small (20GB) image dataset from my local machine to a Google Cloud Platform (GCP) bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tzFfCwyHPJv4SWkE5X8Bwg.jpeg" /></figure><p>In this article, I’ll go through the alternative approach that shortened this process to a 2-hour operation using a GCP Virtual Machine (VM). The key is creating a VM in the same zone as your bucket, downloading the file there and then transferring it to the bucket.</p><p>If you don’t have a bucket, go set that up first, and remember what zone you decide to use. You can use all the standard settings without issue.</p><p>The next step was to create a VM. I went with 4 cores, so we could take advantage of the multiprocessing option during the image transfer. Other than that, it was a pretty standard set-up, keeping all the defaults. The exceptions were expanding startup disk to 100 GB to accommodate the unzipped data and using Ubuntu 18 LTS, just a personal preference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*EPtfEkVmVyoZn3yhVZX3Ig.png" /><figcaption>GCP VM setup</figcaption></figure><p>Once the VM spun up, I connected with the ssh tool provided by the <a href="https://cloud.google.com/pubsub/docs/quickstart-cli">Google CLI</a> (which you may need to install on your local machine)</p><pre>gcloud compute ssh --project [NAME OF YOUR PROJECT] --zone [ZONE NAME] [NAME OF VM]</pre><p>Once on the VM, I installed pip and the kaggle API.</p><pre>## Install pip<br>&gt; curl <a href="https://bootstrap.pypa.io/get-pip.py">https://bootstrap.pypa.io/get-pip.py</a> -o get-pip.py<br>&gt; sudo apt-get install python3-distutils<br>&gt; sudo python3 get-pip.py<br>## Install kaggle API<br>&gt; pip install kaggle</pre><p>In order to download files from Kaggle, you need an API token saved on the VM. You can go into your Kaggle account, download a new token and scp it onto the VM. Once on the VM, create a hidden folder called “.kaggle” and move the key there</p><p><strong>On your local machine:</strong></p><pre>&gt; gcloud compute scp Downloads/kaggle.json kaggle-download:~</pre><p><strong>On the VM:</strong></p><pre>&gt; mkdir .kaggle<br>&gt; mv kaggle.json .kaggle</pre><p>At this point, the Kaggle API should be good to go! Navigate to the competition or dataset you’re interested in and copy the API command into the VM and the download should start. Many of the datasets are zipped, so you’ll need to install the unzip tool and extract the data.</p><pre>&gt; sudo apt-get install unzip<br>&gt; unzip [DATASET].zip</pre><p>Then all that’s left is to authenticate your google account on the VM and transfer the data! The -m flag allows us to use multithread processing and the -r recursively transfers everything in the data folder. For me, it took ~2h to run this whole process for ~20GB of data.</p><pre>&gt; gcloud auth login<br>&gt; gsutil -m cp -r [DATA FOLDER] gs://[BUCKET NAME]</pre><p>Remember to kill the VM when you finish. I just delete it and spin up a new one whenever I need to download something new. Happy Kaggling!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac21aefceb15" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/quickly-transfer-a-kaggle-dataset-into-a-google-bucket-ac21aefceb15">Quickly Transfer a Kaggle dataset into a Google bucket</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How fast is fast.ai? Building a world-class pathologist in an evening]]></title>
            <link>https://medium.com/swlh/how-fast-is-fast-ai-building-a-world-class-pathologist-in-an-evening-3c3062df0c70?source=rss-b240a8c56406------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c3062df0c70</guid>
            <category><![CDATA[towards-data-science]]></category>
            <category><![CDATA[fastai]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[convolutional-network]]></category>
            <dc:creator><![CDATA[Alex Federation]]></dc:creator>
            <pubDate>Tue, 28 May 2019 21:17:33 GMT</pubDate>
            <atom:updated>2019-09-05T22:11:56.746Z</atom:updated>
            <content:encoded><![CDATA[<h3>How fast is fast.ai? Building a world-class ophthalmologist in an evening</h3><h3>Background</h3><p>I’m working through the <a href="http://course.fast.ai/">fast.ai</a> deep learning course this summer, and the instructor Jeremy often brags (in a good way, like a proud dad) about how students in the course can quickly get near-world-class models built with the fast.ai library. I wanted to put this idea to the test and decided to apply approaches <em>from the first lecture only</em> to a highly-cited cell paper from last year.</p><p>As a biologist, a Cell paper can be the highlight of one’s career. Cell publishes the best work from across all fields of biology, and the <a href="http://www.cell.com/cell/fulltext/S0092-8674(18)30154-5">Kermany <em>et. al.</em></a> paper from last year represented a breakthrough in applying deep learning to ocular pathology. Briefly, they used an imaging technology called retinal optical coherence tomography (OCT) to image healthy and diseased eyes (3 possible conditions) and employed a panel of expert ophthalmologists to classify them. They had multiple experts classify a subset of photos so they could get a measure of how accurate the humans were as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GJg_Yu1a6VvcO8KnFBv6sQ.jpeg" /><figcaption>a colorized OCT scan</figcaption></figure><p>Interestingly, they took a similar approach to what we’ve been working on — transfer learning with a convolutional neural network. Let’s see how our simple approach compares.</p><pre><strong>%</strong>reload_ext autoreload<br><strong>%</strong>autoreload 2<br><strong>%</strong>matplotlib inline</pre><pre><strong>from</strong> fastai.vision <strong>import</strong> <strong>*</strong></pre><h3>Load the data</h3><p>Luckily, the data are already organized and released on the kaggle platform. They have a nice, pip-able API for accessing their data. You need an API token, and all the details are explained well in the <a href="https://github.com/Kaggle/kaggle-api">docs</a>.</p><pre>pip install kaggle<br>kaggle datasets download -d paultimothymooney/kermany2018</pre><h3>Pre-process the data</h3><p>Here, I used the API provided by fast.ai to get the data organized into a training and validation set, apply the standard transforms and normalize the data using statistics from imagenet, our pre-trained model.</p><pre>src <strong>=</strong> (ImageList<strong>.</strong>from_folder(path)<br>       <strong>.</strong>split_by_folder(train<strong>=</strong>&#39;train&#39;, valid<strong>=</strong>&#39;test&#39;)<br>       <strong>.</strong>label_from_folder())<br>tfms <strong>=</strong> get_transforms()<br>data <strong>=</strong> (src<strong>.</strong>transform(tfms, size<strong>=</strong>128)<br>        <strong>.</strong>databunch()<strong>.</strong>normalize(imagenet_stats))</pre><p>And we can take a look at the images and labels to make sure all looks good.</p><pre>data<strong>.</strong>show_batch(rows<strong>=</strong>3, figsize<strong>=</strong>(12,9))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*1SWSyv5gzIpZBJ3a_mvyqg.png" /></figure><h3>Train the model</h3><p>We’re trying to classify the eyes into one of 4 categories.</p><ol><li>Healthy</li><li>Choroidal Neovascularization (blood vessel formation in the eye, related to macular degeneration)</li><li>Diabetic macular edema (fluid in the retina)</li><li>Drusen (fat deposits in the retina)</li></ol><p>We’re using the Resnet-34 convolutional neural network architecture pre-trained with the <a href="http://www.image-net.org/">imagenet</a> dataset.</p><pre>learn <strong>=</strong> cnn_learner(data, models<strong>.</strong>resnet34, metrics<strong>=</strong>[accuracy, error_rate])<br>learn<strong>.</strong>fit_one_cycle(4)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qefgq-V8UlpXGGTW1qtVgw.png" /><figcaption>4 epochs using resnet-34</figcaption></figure><pre>learn<strong>.</strong>save(&#39;stage-1&#39;)</pre><p>97% before fine-tuning? That’s not a bad start. How does our confusion matrix look? The biggest difficulty the model is having is between Drussen and CNV, which is the same confusion that was most common in the human experts, an encouraging sign.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*mlojfxHY6yx4nhpTv9MdXw.png" /></figure><h3>Stepping it up — resnet50</h3><p>The final strategy presented in Lecture 1 was increasing the size of the network up to a 50-layer CNN and increasing the image size. I’ll try that here and let it go for 4 epochs. Keep in mind that in the Cell paper, they trained for 100 epochs to a 96.6% accuracy.</p><p>First, we use the learning rate finder to find the learning rate where we’re decreasing loss at the fastest rate, then use that to train the last few layers of the network (8 epochs). Then we’ll unfreeze the model, train for a few more epochs to fine-tune the whole model (4 more epochs) and see how we’re doing.</p><pre>data <strong>=</strong> (src<strong>.</strong>transform(tfms, size<strong>=</strong>256)<br>        <strong>.</strong>databunch(bs<strong>=</strong>32)<strong>.</strong>normalize(imagenet_stats))<br>learn <strong>=</strong> cnn_learner(data, models<strong>.</strong>resnet50, metrics<strong>=</strong>[accuracy, error_rate])</pre><pre>learn<strong>.</strong>lr_find()<br>learn<strong>.</strong>recorder<strong>.</strong>plot()</pre><pre>lr <strong>=</strong> 0.001<br>learn<strong>.</strong>fit_one_cycle(4, slice(lr))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*GvjWP512VLJqYBYMFQuFhw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tucOfPxd1JswSb73sR79hg.png" /></figure><pre>learn<strong>.</strong>save(&#39;rn50-stage-1&#39;)</pre><p>And lastly, unfreeze the model and tune the entire set of parameters.</p><pre>learn<strong>.</strong>unfreeze()<br>learn<strong>.</strong>fit_one_cycle(4, slice(5e-6, lr<strong>/</strong>5))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oNMWljQXOCgkCIMYMCWaUw.png" /></figure><pre>learn<strong>.</strong>save(&#39;rn50-stage-2&#39;)</pre><h3>Conclusion</h3><p>We can get ~99% accuracy using the same dataset as Kermany <em>et. al.</em> with the fast.ai workflow, even for a seemingly complex problem like retinal pathology. The model in the paper is ~96% accurate and the best human expert was in the 99% range, so we’re definitely in good company with this result.</p><p>My take-aways are twofold: 1. The fast.ai library works exceptionally well out of the box 2. Deep learning is an incredibly fast-moving field</p><p>This exercise is not meant to take anything away from the original authors. The task of assembling and annotating the dataset is an impressive feat in itself, and their model is incredibly good at triaging cases with a low false-negative rate, which is a key metric for clinical use.</p><p>What this exercise does highlight is one of the barriers to entry for someone trying to get into deep learning coming from another scientific field. Things are moving so quickly, it’s intimidating to catch up on the basics knowing that in 18 months a Cell paper can get surpassed by a python library. So for me, it has been really encouraging to take the library and do something useful, while still catching up on the basics as I go.</p><p>Moving forward, it has been shown that medical imaging models are highly sensitive to the instrumentation and hospital where the images were generated (<a href="https://arxiv.org/abs/1807.00431">ref</a>). I’m working with a friend at Baylor Medical Center to gather an additional set of OCT images as a test set to compare the two models with data from an unrelated institution. The results of that experiment will be a good test for both models and I’ll be sure to provide an update.</p><p>Adapted from <a href="https://www.alexfederation.com/blog/001-rescue-forecast/">my website</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c3062df0c70" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/how-fast-is-fast-ai-building-a-world-class-pathologist-in-an-evening-3c3062df0c70">How fast is fast.ai? Building a world-class pathologist in an evening</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>
        <item>
            <title><![CDATA[RescueForest: Predicting Emergency Response with Random Forests]]></title>
            <link>https://medium.com/data-science/rescueforest-predicting-emergency-response-with-random-forests-70c5d65df730?source=rss-b240a8c56406------2</link>
            <guid isPermaLink="false">https://medium.com/p/70c5d65df730</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[fastai]]></category>
            <category><![CDATA[hiking]]></category>
            <category><![CDATA[towards-data-science]]></category>
            <category><![CDATA[random-forest]]></category>
            <dc:creator><![CDATA[Alex Federation]]></dc:creator>
            <pubDate>Fri, 24 May 2019 19:44:55 GMT</pubDate>
            <atom:updated>2019-05-26T01:28:54.261Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*999neRKUikRNMi5w06nM0Q.jpeg" /><figcaption>King County SAR on the job</figcaption></figure><p>I’m finishing up the material in the fast.ai <a href="http://course18.fast.ai/ml">Introduction to ML</a> course and it has been fantastic. The learning philosophy, which the instructor Jeremy describes as a top-down approach, worked really well for my learning style. The general idea is that you learn HOW to do ML before you learn WHY it works — the same way you learn HOW to play baseball before learning WHY you might use one particular strategy at a given time.</p><p>I wanted to do a small capstone project to practice what I learned, so I decided to study emergency response prediction — particularly for an organization called <a href="http://www.kingcountysar.org/">King County Search and Rescue</a> (SAR), which I volunteer as a member of. We do a variety of rescue missions, but the most common call is to help injured or lost hikers in the wilderness surrounding Seattle. It’s mostly a volunteer-run organization, so resources are inherently limited. Having a method to predict the likelihood of a call on any given day might help us prioritize resources and preparation to best serve the community.</p><p>I broke the project into three general steps covered in the course: 1. Data Exploration and cleaning 2. Building a simple model and using it to study feature importance 3. Feature engineering and tuning the model</p><p>This post will cover my general approach and findings. Detailed code and notebooks can be found in my project’s <a href="https://github.com/afederation/SAR_predict">repo</a>.</p><h3>Data Exploration, Cleaning</h3><p>Before building the model, I want to understand the nature of the data we have. There are several data sources we’re using, and we’ll be linking all of them together by the date. Python’s <a href="https://docs.python.org/2/library/datetime.html">datetime</a> library was key for this and made these operations much easier.</p><h3>Outcome Data</h3><p>The goal of the project was to predict whether or not a SAR call happened on a particular day. I’ve downloaded this from the organization’s internal database and removed some information for privacy. Loading the data into python and pandas allows for some simple plots to make sure we’re focusing on the most relevant data. I had to narrow the dates into a range from 2002 to current date, since the data before this was incomplete.</p><p>Some exploratory plots show that we have calls on 29% of days, which means the data is somewhat imbalanced, but not horribly so. Calls happen most frequently on weekends and in the summer. We know this by intuition, and the data backs this up. This also confirms that there is probably some information within the date alone that may have some predictive power.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/0*17n9SC8PD32IP9Lb.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/0*q923WOZ8SDoS7QQL.png" /></figure><p>But first, we need a tidy dataset. Essentially, we a table with every date in the range we’re considering and give a boolean that reports on the presence/absence of a call on that day. A simple script to convert the raw sar_data into a clean_table accomplished this by taking advantage of the panda’s date_range function.</p><pre>date_range <strong>=</strong> pd<strong>.</strong>date_range(start<strong>=</strong>&#39;1/1/2002&#39;, end<strong>=</strong>&#39;4/01/2019&#39;)<br>clean_table <strong>=</strong> []<br><strong>for</strong> d <strong>in</strong> date_range:<br>    <strong>if</strong> sar_data<strong>.</strong>date<strong>.</strong>isin([d])<strong>.</strong>any(): <em># check if date in in table containing all calls</em><br>        clean_table<strong>.</strong>append([d,1])<br>    <strong>else</strong>:<br>        clean_table<strong>.</strong>append([d,0])               <br>sar_clean <strong>=</strong> pd<strong>.</strong>DataFrame(clean_table)<br>sar_clean<strong>.</strong>columns <strong>=</strong> [&#39;date&#39;,&#39;mission&#39;]</pre><h3>Features</h3><p>Using the date column from the clean_table table, we can use the nifty fast.ai function that extracts information like day of week, year, month, etc. from a datetime object. After applying that to our tidy table, we have ~13 features to start with.</p><p>Along with these, we’ll integrate some weather information from NOAA. There are a bunch of cool <a href="https://www.ncdc.noaa.gov/cdo-web/">tools</a> they provide that data scientists will find useful, and I encourage anyone interested in integrating weather data to check it out.</p><p>Ideally, we’d be able to use weather forecast data for this project, rather than actual weather data. When we’re planning ahead, we’ll only have access to forecasts, which obviously differ from the actual weather quite often. All the resources I found that keep these data were paid services, so for I’ll have to settle with the NOAA data for now.</p><p>I downloaded weather data from two local weather stations — Boeing Field, which is just south of Seattle, and Mount Gardner, which is in the mountain range where most of our missions occur. We get information on temperature, wind, sun and precip, which is a good picture of the weather on a given day. A couple sanity checks make sure the data are organized in the way we expect (hot in the summer, more rain in the winter). Merging these with the clean_table using pandas.merge give us our initial data set that contains the following features:</p><p>[Year&#39;, &#39;Month&#39;, &#39;Week&#39;, &#39;Day&#39;, &#39;Dayofweek&#39;, &#39;Dayofyear&#39;, &#39;Is_month_end&#39;, &#39;Is_month_start&#39;, &#39;Is_quarter_end&#39;, &#39;Is_quarter_start&#39;, &#39;Is_year_end&#39;, &#39;Is_year_start&#39;, &#39;Elapsed&#39;, &#39;DATE&#39;, &#39;AWND_x&#39;, &#39;PRCP_x&#39;, &#39;TAVG_x&#39;, &#39;TMAX_x&#39;, &#39;TMIN_x&#39;, &#39;TSUN&#39;, &#39;WT01&#39;, &#39;WT02&#39;, &#39;WT03&#39;, &#39;WT05&#39;, &#39;WT08&#39;, &#39;WT10&#39;, &#39;AWND_y&#39;, &#39;PRCP_y&#39;, &#39;SNWD&#39;, &#39;TAVG_y&#39;, &#39;TMAX_y&#39;, &#39;TMIN_y&#39;, &#39;TOBS&#39;, &#39;WESD&#39;]`</p><h3>Feature Engineering</h3><h3>Test, Train, Initial Model</h3><p>Selecting an appropriate validation and test set was an important topic in the course. I’m taking a similar approach here as the Kaggle competitions for bulldozer auctions and grocery store sales predictions that Jeremy discussed. In these situations, we need to use data from the past to predict the future, so we sort the data by date and hold out the most recent 15–20% of the data for the validation set. We’ll do the same thing here.</p><p>For the test set, I’ll use a more ‘real-life approach’ and just test my model on this year in real-time.</p><p>For model evaluation, the built-in scoring functions probably aren’t ideal. There’s only a mission 29% of the time, so a naive model always predicting ‘no call’ will be correct with 71% accuracy. ROC curves are a decent approach for this situation, so I used these for model evaluation. These weren’t extensively discussed in the fast.ai course, as they focused mostly on regression problems. As a refresher, I found <a href="https://medium.com/greyatom/lets-learn-about-auc-roc-curve-4a94b4d88152">this article</a> to be helpful.</p><p>Next, a simple random forest built with scikit-learn gave some signal in the ROC curve (AUC=0.61), so I moved ahead with this to understand the data at hand a bit better.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/0*atP23_2k6j7gByxP.png" /></figure><p>When digging into the feature importances used in the model, things seemed to make sense. The day of week, days elapsed (just a running count of days since the beginning of the dataset) and day of year were the three most important features. The most important weather feature was the wind in Seattle, which may be reporting on the presence of a storm? The next few weather features were temps, which isn’t a surprise.</p><p>In the course, Jeremy keeps all features that show an importance, even if they may be correlated. There’s no doubt that temperatures in nearby places are correlated, but the model is supposed to deal with this with an ensemble approach. In the future, it may be worth doing some additional feature engineering to remove some redundancies. I did remove a few features that had very low importance without and didn’t hurt performance after removal.</p><h3>Holiday Data</h3><p>Will adding holiday data help the model? I used pandas.tseries.holiday which contains a database of US holidays and tried a few different approaches, summarized below: - Add a column with a boolean for is_holiday - Add columns for days_until_next_holiday and days_since_last_holiday - Add a column for days_away_from_nearest_holiday</p><p>The last approach was most effective, which makes sense. The days surrounding holidays are most likely to be days off of work and correspond to an increase in hikers. The ROC improves from 61% to 65% by including this information.</p><h3>Google Trends</h3><p>I discovered a cool feature of google trends data during this project. There isn’t an API, but just playing around with the web interface, I was able to get the search frequency on the general topic of ‘hiking’ in the King County region — our exact zone of response. The data are seasonal as expected, and I was hoping they might capture other events happening that may increase or decrease interest in hiking during the short-term.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/0*JMXa7hasQ_RZoYxU.png" /></figure><p>Adding this feature gave a confusing result — the ROC doesn’t improve, but when you look at feature importance, it’s the second most important feature. Does this just mean that the trend data is redundant with some of the date features? I decided to keep it and move forward.</p><h3>Building the Final Model</h3><p>Okay, so now the final model. I compared three tree-based algorithms with the same basic parameters and the AUCs are summarized below.</p><ul><li>Random Forest: 0.59</li><li>AdaBoost: 0.61</li><li>XGBoost: 0.63</li></ul><p>XGBoost did the best, so a tool the opportunity to learn about how to tune these models. The main approach I utilized was sklearn’s build in <a href="https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.GridSearchCV.html">grid search</a> functionality. This took a long time to run, but the results give me the best combination parameters the model could find. This brought our AUC up to 0.67.</p><h3>Model Evaluation</h3><p>I’m going to monitor the model’s performance all year, but as of writing this article, the model is predicting correctly 2⁄3 of the time. It’s a hard problem, with a lot of randomness and a small amount of data. That being said, it has made a difference for my life so far, letting me have gear ready ahead of time on the days it predicts a high call probability.</p><p>Still, there’s definitely room for improvement. I’m going to continue trying new models as I learn them and adding in additional data as I find it. I’m also excited to hear suggestions from anyone with other ideas for features or ways I can improve my approach. And thanks for Jeremy, Rachel and the fast.ai team for a great experience!</p><p>Adapted from <a href="https://www.alexfederation.com/blog/001-rescue-forecast/">my website</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70c5d65df730" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/rescueforest-predicting-emergency-response-with-random-forests-70c5d65df730">RescueForest: Predicting Emergency Response with Random Forests</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>
    </channel>
</rss>