<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>wids2021 &amp;mdash; Iman Codes</title>
    <link>https://iman.codes/tag:wids2021</link>
    <description>sometimes it&#39;s fun</description>
    <pubDate>Thu, 21 May 2026 19:49:00 +0000</pubDate>
    <item>
      <title>WiDS 2021 Datathon - Lessons Learned</title>
      <link>https://iman.codes/wids-2021-datathon-lessons-learned?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[Well, I perhaps didn&#39;t do as much as I wanted to after my last post. Life sneaks up on you sometimes, y&#39;know? I had a surprisingly busy mid-Feb till now, and even now I&#39;m more focused on other stuff, both work and personal. The Women in Data Science Conference is long over! But I do have some things I learned and thought it&#39;d be a good to have a final summary post.&#xA;&#xA;!--more--Something that I found was that it was very weird to have my data split by hospital ID. I know that probably happens in other applications, but in my work life, it&#39;d be really weird to have, for example, all the clients in one city in the training data and then all the clients from another city for prediction purposes. I especially find it weird because it&#39;s not like hospital locations change over time (or at least, not quickly!) so I don&#39;t really know why it was split up like this. Location is also a very important factor in health, so that&#39;s why this is my biggest complaint haha.&#xA;&#xA;I also have to say that I&#39;m not a big fan of datathon optimizing towards the best scores - I don&#39;t think this gets us anywhere in real life. Is it really worth tuning parameters for hours for the incremental gain? Or rather, should we be tuning parameters without the input of a subject matter expert? At work, I work on lower-stakes models, but we still work very closely with our business partners, aka the subject matter experts! If I were building a healthcare model, I&#39;d be asking the medical professionals - what&#39;s the risk to a patient of a false positive? A false negative? Do the results even make sense? Can we explain what&#39;s going on in the model?&#xA;&#xA;Perfection (getting the highest scores) also feels so artificial and &#34;school project&#34;-like. I hated this attitude in school and hate it in my professional life too, because good enough is GOOD ENOUGH and perfection is not a good character trait. Perfection is not attainable, and not a true reflection of the messy nature of human lives, so I don&#39;t think we should try to get the &#34;best&#34; models out their either. The effort spent on creating such perfect models could be better spent collecting more data or cleaning the current data or anything to do with the data, which I think would lead to better real-world results rather than an arbitrary number.&#xA;&#xA;I think that the quest for the highest score also leans more towards the more sophisticated techniques, which tend to be less explainable!! In a high-stakes setting like healthcare, I think this is unacceptable. As in my first post, we saw how a completely transparent basic equation discriminated against Blacks and how it took so many years for people to think, &#34;hey wait maybe this is bad actually?&#34; - institutionalizing this in black box models that are difficult to explain don&#39;t help this situation at all!&#xA;&#xA;I suppose all of this (my ranting about getting the Highest Score mostly) may not hold true for research or cutting-edge AI tech companies, but at the end of the day, you still need to sell your product, the model, to an end user who may or may not be as tech-savvy as yourself. I&#39;m always asking, &#34;What are you actually going to do with that model?&#34; At least, that&#39;s my poorly educated opinion, haha.&#xA;&#xA;Also something that I realized when working on this: proper pipelining is so important. I&#39;m still learning to do this properly too, but I didn&#39;t realize how good I had it at work now that we&#39;ve built a more functional pipeline. It&#39;s hard for me to explain but it felt so awkward and clunky to have to read in my train and predict sets and then do all my processing on them, and the code was very messy, being stored all in one notebook. And as a datathon, this work isn&#39;t going to be productionized so there&#39;s no incentive to create a &#34;pipeline.&#34; I did try and write my code to be reusable, but I had no reason to create a functional structure to my code, so it&#39;s just... there.&#xA;&#xA;Anyway, I suppose with all my complaints out of the way, I can talk about the good things I learned haha.&#xA;&#xA;It was interesting to work on healthcare data, although I&#39;m still unsure about someone without a healthcare background doing so. I learned so many random things about diabetes and different measurements just so I could understand what was going on!&#xA;&#xA;I also got to play with the Explainable Boosting Model and the Interpretable ML package. That was pretty fun to noodle around with.&#xA;&#xA;I generally enjoyed working on this data and everything, and I think it was a good experience overall! I think I&#39;m just too focused on making things useful in the real world, haha. It&#39;s a good thing that I work in the industry!&#xA;&#xA;#wids2021 #datascience]]&gt;</description>
      <content:encoded><![CDATA[<p>Well, I perhaps didn&#39;t do as much as I wanted to after my last post. Life sneaks up on you sometimes, y&#39;know? I had a surprisingly busy mid-Feb till now, and even now I&#39;m more focused on other stuff, both work and personal. The Women in Data Science Conference is long over! But I do have some things I learned and thought it&#39;d be a good to have a final summary post.</p>

<p>Something that I found was that it was very weird to have my data split by hospital ID. I know that probably happens in other applications, but in my work life, it&#39;d be really weird to have, for example, all the clients in one city in the training data and then all the clients from another city for prediction purposes. I especially find it weird because it&#39;s not like hospital locations change over time (or at least, not quickly!) so I don&#39;t really know why it was split up like this. Location is also a very important factor in health, so that&#39;s why this is my biggest complaint haha.</p>

<p>I also have to say that I&#39;m not a big fan of datathon optimizing towards the best scores – I don&#39;t think this gets us anywhere in real life. Is it really worth tuning parameters for hours for the incremental gain? Or rather, should we be tuning parameters without the input of a subject matter expert? At work, I work on lower-stakes models, but we still work very closely with our business partners, aka the subject matter experts! If I were building a healthcare model, I&#39;d be asking the medical professionals – what&#39;s the risk to a patient of a false positive? A false negative? Do the results even make sense? Can we explain what&#39;s going on in the model?</p>

<p>Perfection (getting the highest scores) also feels so artificial and “school project”-like. I hated this attitude in school and hate it in my professional life too, because good enough is GOOD ENOUGH and perfection is not a good character trait. Perfection is not attainable, and not a true reflection of the messy nature of human lives, so I don&#39;t think we should try to get the “best” models out their either. The effort spent on creating such perfect models could be better spent collecting more data or cleaning the current data or anything to do with the data, which I think would lead to better real-world results rather than an arbitrary number.</p>

<p>I think that the quest for the highest score also leans more towards the more sophisticated techniques, which tend to be less explainable!! In a high-stakes setting like healthcare, I think this is unacceptable. As in my first post, we saw how a completely transparent basic equation discriminated against Blacks and how it took <em>so many years</em> for people to think, “hey wait maybe this is bad actually?” – institutionalizing this in black box models that are difficult to explain don&#39;t help this situation at all!</p>

<p>I suppose all of this (my ranting about getting the Highest Score mostly) may not hold true for research or cutting-edge AI tech companies, but at the end of the day, you still need to sell your product, the model, to an end user who may or may not be as tech-savvy as yourself. I&#39;m always asking, “What are you actually going to do with that model?” At least, that&#39;s my poorly educated opinion, haha.</p>

<p>Also something that I realized when working on this: proper pipelining is so important. I&#39;m still learning to do this properly too, but I didn&#39;t realize how good I had it at work now that we&#39;ve built a more functional pipeline. It&#39;s hard for me to explain but it felt so awkward and clunky to have to read in my train and predict sets and then do all my processing on them, and the code was very messy, being stored all in one notebook. And as a datathon, this work isn&#39;t going to be productionized so there&#39;s no incentive to create a “pipeline.” I did try and write my code to be reusable, but I had no reason to create a functional structure to my code, so it&#39;s just... there.</p>

<p>Anyway, I suppose with all my complaints out of the way, I can talk about the good things I learned haha.</p>

<p>It was interesting to work on healthcare data, although I&#39;m still unsure about someone without a healthcare background doing so. I learned so many random things about diabetes and different measurements just so I could understand what was going on!</p>

<p>I also got to play with the Explainable Boosting Model and the Interpretable ML package. That was pretty fun to noodle around with.</p>

<p>I generally enjoyed working on this data and everything, and I think it was a good experience overall! I think I&#39;m just too focused on making things useful in the real world, haha. It&#39;s a good thing that I work in the industry!</p>

<p><a href="https://iman.codes/tag:wids2021" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">wids2021</span></a> <a href="https://iman.codes/tag:datascience" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">datascience</span></a></p>
]]></content:encoded>
      <guid>https://iman.codes/wids-2021-datathon-lessons-learned</guid>
      <pubDate>Tue, 06 Apr 2021 22:29:15 +0000</pubDate>
    </item>
    <item>
      <title>WiDS Datathon 2021 - Still Going</title>
      <link>https://iman.codes/wids-datathon-2021-still-going?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[I know I said in my last post that I&#39;d keep the blog updated, so here I am doing just that.&#xA;&#xA;I don&#39;t have too much to say though - I&#39;ve tried a few things that didn&#39;t improve the performance much, but I did try a lot of things that made it worse! Learning from failure is still learning though, haha. &#xA;&#xA;I did find that I preferred using EBM to xgboost, even though xgboost is my go-to at work. Not sure if it&#39;s just because I didn&#39;t really have the patience to do xgboost &#34;properly&#34; in my spare time or not, but hey, if it means I can focus on the things that are important to me, I&#39;m okay with that. Especially since this is something I&#39;m noodling around with when I have the time after work.&#xA;&#xA;(I&#39;ve also not had as much spare time recently since my new desk is finally ready to be picked up, and I&#39;ve had to clean up so much stuff so it&#39;ll actually fit where I want it to. I never realized working from home full-time would mean my place would get so much messier.)&#xA;&#xA;Anyway, some of the things that I tried out:&#xA;&#xA;recalculating BMI from the weight/height - I think I mentioned this in an earlier post but I actually didn&#39;t do it until after my first submission hahaha whoops&#xA;KNN missing value imputation&#xA;binning various numeric continuous variables (e.g. age)&#xA;creating new features from BMI such as an obesity indicator or body fat percentage (type 2 diabetes seems to be linked to obesity)&#xA;&#xA;I&#39;m currently trying to see if there&#39;s a good way to get my hospital IDs back in, since I think location is so important for a geographically diverse dataset. A patient would theoretically be local to the hospital they&#39;re sent to, and the lifestyle of someone in NYC would be different than someone in SoCal would be different than the lifestyle of an Albertan, and that affects disease incidence!&#xA;&#xA;But we&#39;ll see how that goes haha.&#xA;&#xA;#wids2021 #datascience]]&gt;</description>
      <content:encoded><![CDATA[<p>I know I said in my last post that I&#39;d keep the blog updated, so here I am doing just that.</p>

<p>I don&#39;t have too much to say though – I&#39;ve tried a few things that didn&#39;t improve the performance much, but I did try a lot of things that made it worse! Learning from failure is still learning though, haha.</p>

<p>I did find that I preferred using EBM to xgboost, even though xgboost is my go-to at work. Not sure if it&#39;s just because I didn&#39;t really have the patience to do xgboost “properly” in my spare time or not, but hey, if it means I can focus on the things that are important to me, I&#39;m okay with that. Especially since this is something I&#39;m noodling around with when I have the time after work.</p>

<p>(I&#39;ve also not had as much spare time recently since my new desk is finally ready to be picked up, and I&#39;ve had to clean up so much stuff so it&#39;ll actually fit where I want it to. I never realized working from home full-time would mean my place would get so much <em>messier</em>.)</p>

<p>Anyway, some of the things that I tried out:</p>
<ul><li>recalculating BMI from the weight/height – I think I mentioned this in an earlier post but I actually didn&#39;t do it until after my first submission hahaha whoops</li>
<li>KNN missing value imputation</li>
<li>binning various numeric continuous variables (e.g. age)</li>
<li>creating new features from BMI such as an obesity indicator or body fat percentage (type 2 diabetes seems to be linked to obesity)</li></ul>

<p>I&#39;m currently trying to see if there&#39;s a good way to get my hospital IDs back in, since I think location is so important for a geographically diverse dataset. A patient would theoretically be local to the hospital they&#39;re sent to, and the lifestyle of someone in NYC would be different than someone in SoCal would be different than the lifestyle of an Albertan, and that affects disease incidence!</p>

<p>But we&#39;ll see how that goes haha.</p>

<p><a href="https://iman.codes/tag:wids2021" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">wids2021</span></a> <a href="https://iman.codes/tag:datascience" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">datascience</span></a></p>
]]></content:encoded>
      <guid>https://iman.codes/wids-datathon-2021-still-going</guid>
      <pubDate>Sun, 07 Feb 2021 16:37:33 +0000</pubDate>
    </item>
    <item>
      <title>WiDS 2021 Datathon - Generating the Submission</title>
      <link>https://iman.codes/wids-2021-datathon-generating-the-submission?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[Not sure what to say here. I shoved everything into a notebook and trained a model with all the work that I did, and then generated a submission file!&#xA;&#xA;For reference, here&#39;s my final model performance:&#xA;&#xA;Final Model Performance&#xA;&#xA;(I want to note that hospital ID made such a big difference in the performance of my model, and having to drop that column was such a loss for me! I&#39;m so disappointed that the train and predict sets were split in this manner!)&#xA;&#xA;Anyway, my first submission to the datathon gave me an AUC of 0.83715. In datathon terms, I&#39;m ranked 207 at the time of submission! Which is actually kinda good for a first pass. In the real world, I&#39;d probably be pretty happy with this haha. I&#39;d move to comparing the true/false positives/negatives since this is for healthcare, and there are probably more serious implications of false negatives! In the real world, this is also the point where I&#39;d talk to the subject matter expert (probably a doctor) about the results and ask them if it makes sense.&#xA;&#xA;Global feature importance for final model&#xA;&#xA;That&#39;s where the explainable model comes in. At work, I&#39;ve used SHAP which is quite similar, but it&#39;s explaining the model after the fact. It&#39;s still better than, &#34;well, that&#39;s what the model learned from the data,&#34; though, haha. This is where we can go through what the model learned overall, as well as a few randomly selected patients, to see if everything makes sense from an expert&#39;s point of view. At work, we went even further to discuss the implications of our results on clients and to analyze what, if anything, our work meant to their work.&#xA;&#xA;Then, if everyone&#39;s satisfied with the work, I&#39;d move towards putting this model into production, so that it can benefit more people. The results would be proven to be useful and coherent, so then we could move towards getting the results into people&#39;s hands. I suppose in this case, it&#39;d be nurses who input various patient values into the model to see if the patient may be diabetic, allowing them to adjust care if needed.&#xA;&#xA;But since this is a datathon and not the real world, I&#39;m going to continue to finagle with this data and modelling. I got to play a bit with InterpretML and the EBM, so I&#39;m going to go to back and try to squeeze all that extra juice out to see how high I can get into the rankings haha. This probably will involve me using good ol&#39; xgboost, which at least can be explained after the fact with some ease. I may also go back to do some more feature cleaning or engineering or even see if I have the patience to do the imputation methods I didn&#39;t want to wait for earlier haha.&#xA;&#xA;I&#39;ll keep the blog updated with my progress!&#xA;&#xA;#datascience #wids2021]]&gt;</description>
      <content:encoded><![CDATA[<p>Not sure what to say here. I shoved everything into a notebook and trained a model with all the work that I did, and then generated a submission file!</p>

<p>For reference, here&#39;s my final model performance:</p>

<p><img src="https://i.snap.as/zfLpGiu4.png" alt="Final Model Performance"/></p>

<p>(I want to note that hospital ID made such a big difference in the performance of my model, and having to drop that column was such a loss for me! I&#39;m so disappointed that the train and predict sets were split in this manner!)</p>

<p>Anyway, my first submission to the datathon gave me an AUC of 0.83715. In datathon terms, I&#39;m ranked 207 at the time of submission! Which is actually kinda good for a first pass. In the real world, I&#39;d probably be pretty happy with this haha. I&#39;d move to comparing the true/false positives/negatives since this is for healthcare, and there are probably more serious implications of false negatives! In the real world, this is also the point where I&#39;d talk to the subject matter expert (probably a doctor) about the results and ask them if it makes sense.</p>

<p><img src="https://i.snap.as/yOeNJNgb.png" alt="Global feature importance for final model"/></p>

<p>That&#39;s where the explainable model comes in. At work, I&#39;ve used SHAP which is quite similar, but it&#39;s explaining the model after the fact. It&#39;s still better than, “well, that&#39;s what the model learned from the data,” though, haha. This is where we can go through what the model learned overall, as well as a few randomly selected patients, to see if everything makes sense from an expert&#39;s point of view. At work, we went even further to discuss the implications of our results on clients and to analyze what, if anything, our work meant to their work.</p>

<p>Then, if everyone&#39;s satisfied with the work, I&#39;d move towards putting this model into production, so that it can benefit more people. The results would be proven to be useful and coherent, so then we could move towards getting the results into people&#39;s hands. I suppose in this case, it&#39;d be nurses who input various patient values into the model to see if the patient may be diabetic, allowing them to adjust care if needed.</p>

<p>But since this is a datathon and not the real world, I&#39;m going to continue to finagle with this data and modelling. I got to play a bit with InterpretML and the EBM, so I&#39;m going to go to back and try to squeeze all that extra juice out to see how high I can get into the rankings haha. This probably will involve me using good ol&#39; xgboost, which at least can be explained after the fact with some ease. I may also go back to do some more feature cleaning or engineering or even see if I have the patience to do the imputation methods I didn&#39;t want to wait for earlier haha.</p>

<p>I&#39;ll keep the blog updated with my progress!</p>

<p><a href="https://iman.codes/tag:datascience" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">datascience</span></a> <a href="https://iman.codes/tag:wids2021" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">wids2021</span></a></p>
]]></content:encoded>
      <guid>https://iman.codes/wids-2021-datathon-generating-the-submission</guid>
      <pubDate>Sat, 30 Jan 2021 22:48:10 +0000</pubDate>
    </item>
    <item>
      <title>WiDS Datathon 2021 - Hyperparameter Tuning</title>
      <link>https://iman.codes/wids-datathon-2021-hyperparameter-tuning?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[This is a really short post since I didn&#39;t actually tune too many hyperparameters of the Explainable Boosting Model. In fact, I don&#39;t think there were actually too many that I wanted to tune anyway haha. Plus, hyperparameter tuning in an explainable model felt weird to me, but I didn&#39;t get much sleep last night so my words aren&#39;t great right now haha.&#xA;&#xA;Anyway, I used Bayesian Optimization to tune the minimum samples in a leaf as well as the maximum leaves. I didn&#39;t run it too much, and then I got something that gave me a slightly higher AUC! Huzzah!&#xA;&#xA;It&#39;s convenient because I also had this tweet retweeted onto my timeline today - it feels so true that initial data prep has much more of a difference on how the model performs than parameter tuning or even picking more &#34;sophisticated&#34; models.&#xA;&#xA;I have a draft post going that I&#39;ll clean up and post once this is all done about &#34;lessons learned&#34; since I have so many thoughts about this that don&#39;t belong in my nice little &#34;workflow&#34; type posts haha. I&#39;ve realized that there&#39;s a pretty big difference between a datathon to get perfection vs how I work in the real world, after all.&#xA;&#xA;#datascience #wids2021]]&gt;</description>
      <content:encoded><![CDATA[<p>This is a really short post since I didn&#39;t actually tune too many hyperparameters of the Explainable Boosting Model. In fact, I don&#39;t think there were actually too many that I wanted to tune anyway haha. Plus, hyperparameter tuning in an explainable model felt weird to me, but I didn&#39;t get much sleep last night so my words aren&#39;t great right now haha.</p>

<p>Anyway, I used Bayesian Optimization to tune the minimum samples in a leaf as well as the maximum leaves. I didn&#39;t run it too much, and then I got something that gave me a slightly higher AUC! Huzzah!</p>

<p>It&#39;s convenient because I also had <a href="https://twitter.com/fchollet/status/1353422914071142400" rel="nofollow">this tweet</a> retweeted onto my timeline today – it feels so true that initial data prep has much more of a difference on how the model performs than parameter tuning or even picking more “sophisticated” models.</p>

<p>I have a draft post going that I&#39;ll clean up and post once this is all done about “lessons learned” since I have so many thoughts about this that don&#39;t belong in my nice little “workflow” type posts haha. I&#39;ve realized that there&#39;s a pretty big difference between a datathon to get perfection vs how I work in the real world, after all.</p>

<p><a href="https://iman.codes/tag:datascience" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">datascience</span></a> <a href="https://iman.codes/tag:wids2021" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">wids2021</span></a></p>
]]></content:encoded>
      <guid>https://iman.codes/wids-datathon-2021-hyperparameter-tuning</guid>
      <pubDate>Sat, 30 Jan 2021 02:25:31 +0000</pubDate>
    </item>
    <item>
      <title>WiDS Datathon 2021 - Feature Selection</title>
      <link>https://iman.codes/wids-datathon-2021-feature-selection?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[So, now that I&#39;ve done the initial work in exploring the data and some data cleaning/preprocessing, it&#39;s time to actually do modelling type things. Not that I&#39;ve been skimping on modelling, but it&#39;s the Serious Modelling now!&#xA;&#xA;First of all, I&#39;ve simply been tossing all the features into a model and hoping for the best. However, we have a lot of features in here, and I&#39;m not sure if it&#39;s all relevant information! In fact, I&#39;m pretty sure a doctor might not know if it&#39;s relevant, unless it&#39;s something like glucose which is key to diagnosing diabetes. The beauty of machine learning is that it&#39;s supposed to learn and reveal those unknown relationships and patterns that humans can&#39;t spot.&#xA;&#xA;But, that means there&#39;s probably a lot of noise in this data. Do we really need to keep some of those other disease indicators? Who knows! Not me. But that&#39;s why we do feature selection - we can remove the features that seem to be making the performance worse, or at least seem to be irrelevant.&#xA;&#xA;I&#39;m going to use Boruta for this. It was originally implemented in R but is available in Python too. The gist of it, as I understand it, is that Boruta pits &#34;shadow features&#34; against the actual features, and if the shadow features are more important than the true features, it means the actual ones aren&#39;t as useful. These shadow features are the true features but randomized. Boruta also runs iteratively, and each time a true feature has a higher importance than a shadow feature, Boruta becomes more and more confident that it&#39;s a relevant feature.&#xA;&#xA;I probably didn&#39;t explain that very well, but hopefully I got the point across... there are much better articles out there that go into how it works haha. I&#39;m just here to use it! &#xA;&#xA;I did end up having to one-hot encode my categorical variables for this, since Boruta uses a Random Forest base (or rather, any tree-based model - I&#39;ve used it with xgboost at work, too). &#xA;&#xA;Not much to say here except I let it run for 100 iterations and in the end, I got 153 confirmed features, 50 rejected features, and 5 tentative features. Which is great! Now I know what to drop and what to keep. By the way, tentative features means that Boruta isn&#39;t quite sure if they&#39;re relevant or not, so then it&#39;s up to the data scientist. In my case, 3 of the 5 were pairs of a min/max, so I put those with their accepted or rejected counterparts. The final ones were first hour bilirubin, which were like almost 90% missing, so I discarded that. Finally, some categoricals were accepted and some were not. I&#39;m on the fence about whether to keep all of them, or to simply take the informative ones. I&#39;ll think about it and come back to it later, I guess.&#xA;&#xA;#datascience #wids2021 ]]&gt;</description>
      <content:encoded><![CDATA[<p>So, now that I&#39;ve done the initial work in exploring the data and some data cleaning/preprocessing, it&#39;s time to actually do modelling type things. Not that I&#39;ve been skimping on modelling, but it&#39;s the Serious Modelling now!</p>

<p>First of all, I&#39;ve simply been tossing all the features into a model and hoping for the best. However, we have a lot of features in here, and I&#39;m not sure if it&#39;s all relevant information! In fact, I&#39;m pretty sure a doctor might not know if it&#39;s relevant, unless it&#39;s something like glucose which is key to diagnosing diabetes. The beauty of machine learning is that it&#39;s supposed to learn and reveal those unknown relationships and patterns that humans can&#39;t spot.</p>

<p>But, that means there&#39;s probably a lot of noise in this data. Do we really need to keep some of those other disease indicators? Who knows! Not me. But that&#39;s why we do feature selection – we can remove the features that seem to be making the performance worse, or at least seem to be irrelevant.</p>

<p>I&#39;m going to use <a href="https://www.jstatsoft.org/article/view/v036i11" rel="nofollow">Boruta</a> for this. It was originally implemented in R but is available in Python too. The gist of it, as I understand it, is that Boruta pits “shadow features” against the actual features, and if the shadow features are more important than the true features, it means the actual ones aren&#39;t as useful. These shadow features are the true features but randomized. Boruta also runs iteratively, and each time a true feature has a higher importance than a shadow feature, Boruta becomes more and more confident that it&#39;s a relevant feature.</p>

<p>I probably didn&#39;t explain that very well, but hopefully I got the point across... there are much better articles out there that go into how it works haha. I&#39;m just here to use it!</p>

<p>I did end up having to one-hot encode my categorical variables for this, since Boruta uses a Random Forest base (or rather, any tree-based model – I&#39;ve used it with xgboost at work, too).</p>

<p>Not much to say here except I let it run for 100 iterations and in the end, I got 153 confirmed features, 50 rejected features, and 5 tentative features. Which is great! Now I know what to drop and what to keep. By the way, tentative features means that Boruta isn&#39;t quite sure if they&#39;re relevant or not, so then it&#39;s up to the data scientist. In my case, 3 of the 5 were pairs of a min/max, so I put those with their accepted or rejected counterparts. The final ones were first hour bilirubin, which were like almost 90% missing, so I discarded that. Finally, some categoricals were accepted and some were not. I&#39;m on the fence about whether to keep all of them, or to simply take the informative ones. I&#39;ll think about it and come back to it later, I guess.</p>

<p><a href="https://iman.codes/tag:datascience" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">datascience</span></a> <a href="https://iman.codes/tag:wids2021" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">wids2021</span></a></p>
]]></content:encoded>
      <guid>https://iman.codes/wids-datathon-2021-feature-selection</guid>
      <pubDate>Fri, 29 Jan 2021 20:24:20 +0000</pubDate>
    </item>
    <item>
      <title>WiDS Datathon 2021 - Preprocessing</title>
      <link>https://iman.codes/wids-datathon-2021-preprocessing?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[I had a lot of grand plans for preprocessing data. And then I remembered that I&#39;m using my tiny little Surface Pro.&#xA;&#xA;Anyway, I did do some stuff here, and I did a bunch of research (aka googling terms and reading papers), so I guess it wasn&#39;t all a loss haha.&#xA;&#xA;I don&#39;t actually get to do too much of this at work. Or rather, the data I work with is very different than the datathon dataset, so I don&#39;t use the techniques here, since it wouldn&#39;t be appropriate. So it was kind of fun to do something I hadn&#39;t done in a while!&#xA;&#xA;!--more--The first thing I wanted to do was fix up some of the categorical variables. Luckily, the Explainable Boosting Model takes categorical features in directly, so I mostly had to clean up the missing values. Some, like ethnicity, already had an &#34;Other/Unknown&#34; category, so that was an easy fix! Others, like gender, did not. &#xA;&#xA;For this situation, I kind of just... shoved everything into an &#34;other&#34; column. Not that I didn&#39;t want to impute this data, but the only two categorical columns with missing values were gender and ICU admit source. I wish I had doctor knowledge for the latter, and the former - well, I figured if it&#39;s missing, it might be for a reason? I won&#39;t get into gender discussion, and there&#39;s the whole thing where the data dictionary says the gender here is the &#34;genotypical sex&#34; (in which case, why not name the column that?) - but regardless, there weren&#39;t that many missing and I figured it&#39;d be safest (patient-wise) to keep it as unknown.&#xA;&#xA;Also, in general, I&#39;m kind of uncomfortable imputing medical information. To me it&#39;s kind of weird... especially since some of the columns here are like 80-90% missing! Is it really worth keeping if you&#39;re going to train on like 90% made-up information?&#xA;&#xA;Of course, I&#39;m not the only one with this issue, so I did look up a couple papers on how others imputed medical data and how it worked out for them. In this paper, they say:&#xA;&#xA;&#34;In cases where it is not possible to have the complete-case dataset, researchers  should be aware of this potential impact, use different imputation methods for  predictive modeling, and discuss the resulting interpretations with medical experts or compare to the medical knowledge when choosing the imputation method that yields the most reasonable interpretations.&#34;&#xA;&#xA;Which honestly, yes, if I were working on this in the real world, I would absolutely be consulting with an actual expert on what&#39;s reasonable here. &#xA;&#xA;I also came across A Safe-Region Imputation Method for Handling Medical Data with Missing Values by Shu-Fen Huang and Ching-Hsue Cheng. Their method sounded pretty reasonable and had good results, and I really wanted to try it out, but uh. Let&#39;s be honest here. I&#39;m not smart enough to implement this, especially not if I&#39;m only working on this for a couple hours after work.&#xA;&#xA;So those two papers led me to want to try KNN and missForest, but uh. Then I tried running the code. And it turns out I also don&#39;t have the patience to actually have it run on my Surface Pro, because it kept going to sleep while I was trying to run things. I gave up on this train of thought, which is unfortunate because I did want to compare things. Ah well.&#xA;&#xA;Bonus - now I don&#39;t need to one-hot encode my categoricals?&#xA;&#xA;Anyway, what I did instead was fill in the missing values from least to most missing with the mean or median and if there was an improvement to the AUC, I kept it and moved to the next feature.&#xA;&#xA;But first, going back to categoricals, I also wanted to collapse the hospital IDs, as I said in my exploration post. I came across this paper and wanted to try it out. I&#39;m ... probably doing it incorrectly since I don&#39;t want to dedicate too much time to it, but I thought I&#39;d give it a try anyway.&#xA;&#xA;The key sentence here is &#34;...only urban districts are used as categorical predictor in a regression model to  explain the monthly  rent, and districts are potentially fused (without further restrictions)...&#34; - so I took the hospital IDs, one-hot encoded them, and then fit them to lasso and plotted out the path.&#xA;&#xA;It worked out, kinda!&#xA;&#xA;Hospital ID coefficient paths (LASSO)&#xA;&#xA;Emphasis on the kinda.&#xA;&#xA;Anyway, I thought I&#39;d bin up these coefficients to see how to collapse the hospital IDs, since I clearly wouldn&#39;t be able to do it by looking at the paths haha.&#xA;&#xA;Here&#39;s a few of my bin attempts, in histogram form:&#xA;&#xA;Hospital ID - 20 bins&#xA;&#xA;Hospital ID - 50 bins&#xA;&#xA;Hospital ID - 0.025 bin size&#xA;&#xA;Hospital ID - 0.05 bin size&#xA;&#xA;(Ignore that I&#39;m bad at labelling my plots - the bottom two are actually 0.025 and 0.05 respectively)&#xA;&#xA;Anyway, based on these, I decided to go with bin sizes of 0.025. It kind of seemed the most reasonable!&#xA;&#xA;So I mapped these bin assignments back to the hospital ID (made a new column called &#34;hospitalbin&#34; and dropped &#34;hospitalid&#34; essentially) and then trained a new &#34;baseline&#34; model to see how that affected the AUC. I also made sure all my categoricals were being treated as categoricals instead of continuous.&#xA;&#xA;(Also, I considered binning age, but I like keeping age as a continuous variable for the most part - I think this is a Me thing, and I may do it later to see if I can get improvements in the AUC for generating actual predictions).&#xA;&#xA;Oh - and in this whole process, I also discovered that I could drop ICU ID - it&#39;s linked to specific hospitals, and covered by the ICU Type column. Just wanted to mention it for my own sake.&#xA;&#xA;Baseline model performance with Hospital IDs binned&#xA;&#xA;And would you look at that - I already get a slight improvement over the &#34;just shove everything in&#34; model shown in the last post! That had an AUC of 0.8567 for reference.&#xA;&#xA;Feature importance for baseline binned model&#xA;&#xA;Plus we can even see here that hospital bins are important! Woo! Go team! Feature engineering isn&#39;t a lie!&#xA;&#xA;The unfortunate thing about this though, is that the submission set uses completely different hospital IDs so this work amounted to nothing, whoops. But hey, it would&#39;ve been nice to use it for a proxy for location!&#xA;&#xA;So then I continued onto doing my whole &#34;mean or median or 0s&#34; missing value imputation test run. I only did it this long and convoluted way because, well, I have time, I wasn&#39;t doing the fancy methods I actually wanted to try out, and I might as well do something that I wouldn&#39;t do at work. At work, all the missing values are 0&#39;s because I work with financial data - if a client doesn&#39;t have a product, it&#39;ll usually be a missing value, and that&#39;s definitely a 0! Although it&#39;d be nice if someone imputed me some more money into my bank account some days hahaha.&#xA;&#xA;It took a while to run (yay, loops!) but I did it so it regularly told me what was going on so I didn&#39;t get frustrated with it haha. I won&#39;t share it since it&#39;s kinda boring and probably not very important to see. I also cleaned it up a bit - if a min value was dropped but the corresponding max value used median, then I set both of them to be median.&#xA;&#xA;Oh, and one last thing that I did - I checked to make sure the min values were actually smaller than the max values, and if not, I swapped them. I got the idea from the 3rd place solution notebook in the 2020 WiDS Datathon, although they did it slightly differently (filled with NA if the min value was smaller than the max).&#xA;&#xA;After all this work - there wasn&#39;t even an improvement in the AUC. I won&#39;t show you, and it wasn&#39;t that bad, but it wasn&#39;t an increase haha. But that&#39;s what future steps are for haha.&#xA;&#xA;#datascience #wids2021]]&gt;</description>
      <content:encoded><![CDATA[<p>I had a lot of grand plans for preprocessing data. And then I remembered that I&#39;m using my tiny little Surface Pro.</p>

<p>Anyway, I <em>did</em> do some stuff here, and I did a bunch of research (aka googling terms and reading papers), so I guess it wasn&#39;t all a loss haha.</p>

<p>I don&#39;t actually get to do too much of this at work. Or rather, the data I work with is very different than the datathon dataset, so I don&#39;t use the techniques here, since it wouldn&#39;t be appropriate. So it was kind of fun to do something I hadn&#39;t done in a while!</p>

<p>The first thing I wanted to do was fix up some of the categorical variables. Luckily, the Explainable Boosting Model takes categorical features in directly, so I mostly had to clean up the missing values. Some, like ethnicity, already had an “Other/Unknown” category, so that was an easy fix! Others, like gender, did not.</p>

<p>For this situation, I kind of just... shoved everything into an “other” column. Not that I didn&#39;t want to impute this data, but the only two categorical columns with missing values were gender and ICU admit source. I wish I had doctor knowledge for the latter, and the former – well, I figured if it&#39;s missing, it might be for a reason? I won&#39;t get into gender discussion, and there&#39;s the whole thing where the data dictionary says the gender here is the “genotypical sex” (in which case, why not name the column that?) – but regardless, there weren&#39;t that many missing and I figured it&#39;d be safest (patient-wise) to keep it as unknown.</p>

<p>Also, in general, I&#39;m kind of uncomfortable imputing medical information. To me it&#39;s kind of weird... especially since some of the columns here are like 80-90% missing! Is it really worth keeping if you&#39;re going to train on like 90% made-up information?</p>

<p>Of course, I&#39;m not the only one with this issue, so I did look up a couple papers on how others imputed medical data and how it worked out for them. In <a href="https://www.medrxiv.org/content/10.1101/2020.06.06.20124347v1.full.pdf" rel="nofollow">this paper</a>, they say:</p>

<p>“In cases where it is not possible to have the complete-case dataset, researchers  should be aware of this potential impact, use different imputation methods for  predictive modeling, and discuss the resulting interpretations with medical experts or compare to the medical knowledge when choosing the imputation method that yields the most reasonable interpretations.”</p>

<p>Which honestly, yes, if I were working on this in the real world, I would absolutely be consulting with an actual expert on what&#39;s reasonable here.</p>

<p>I also came across <a href="https://www.mdpi.com/2073-8994/12/11/1792/pdf" rel="nofollow"><em>A Safe-Region Imputation Method for Handling Medical Data with Missing Values</em></a> by Shu-Fen Huang and Ching-Hsue Cheng. Their method sounded pretty reasonable and had good results, and I really wanted to try it out, but uh. Let&#39;s be honest here. I&#39;m not smart enough to implement this, especially not if I&#39;m only working on this for a couple hours after work.</p>

<p>So those two papers led me to want to try KNN and missForest, but uh. Then I tried running the code. And it turns out I also don&#39;t have the patience to actually have it run on my Surface Pro, because it kept going to sleep while I was trying to run things. I gave up on this train of thought, which is unfortunate because I did want to compare things. Ah well.</p>

<p>Bonus – now I don&#39;t need to one-hot encode my categoricals?</p>

<p>Anyway, what I did instead was fill in the missing values from least to most missing with the mean or median and if there was an improvement to the AUC, I kept it and moved to the next feature.</p>

<p>But first, going back to categoricals, I also wanted to collapse the hospital IDs, as I said in my exploration post. I came across <a href="https://projecteuclid.org/euclid.aoas/1294167814" rel="nofollow">this paper</a> and wanted to try it out. I&#39;m ... probably doing it incorrectly since I don&#39;t want to dedicate too much time to it, but I thought I&#39;d give it a try anyway.</p>

<p>The key sentence here is “...only urban districts are used as categorical predictor in a regression model to  explain the monthly  rent, and districts are potentially fused (without further restrictions)...” – so I took the hospital IDs, one-hot encoded them, and then fit them to lasso and plotted out the path.</p>

<p>It worked out, kinda!</p>

<p><img src="https://i.snap.as/3cx2rIb5.png" alt="Hospital ID coefficient paths (LASSO)"/></p>

<p>Emphasis on the <em>kinda</em>.</p>

<p>Anyway, I thought I&#39;d bin up these coefficients to see how to collapse the hospital IDs, since I clearly wouldn&#39;t be able to do it by looking at the paths haha.</p>

<p>Here&#39;s a few of my bin attempts, in histogram form:</p>

<p><img src="https://i.snap.as/bmCgktXx.png" alt="Hospital ID - 20 bins"/></p>

<p><img src="https://i.snap.as/3WsnQhkf.png" alt="Hospital ID - 50 bins"/></p>

<p><img src="https://i.snap.as/XT6JZuD8.png" alt="Hospital ID - 0.025 bin size"/></p>

<p><img src="https://i.snap.as/CvB0w0Om.png" alt="Hospital ID - 0.05 bin size"/></p>

<p>(Ignore that I&#39;m bad at labelling my plots – the bottom two are actually 0.025 and 0.05 respectively)</p>

<p>Anyway, based on these, I decided to go with bin sizes of 0.025. It kind of seemed the most reasonable!</p>

<p>So I mapped these bin assignments back to the hospital ID (made a new column called “hospital<em>bin” and dropped “hospital</em>id” essentially) and then trained a new “baseline” model to see how that affected the AUC. I also made sure all my categoricals were being treated as categoricals instead of continuous.</p>

<p>(Also, I considered binning age, but I like keeping age as a continuous variable for the most part – I think this is a Me thing, and I may do it later to see if I can get improvements in the AUC for generating actual predictions).</p>

<p>Oh – and in this whole process, I also discovered that I could drop ICU ID – it&#39;s linked to specific hospitals, and covered by the ICU Type column. Just wanted to mention it for my own sake.</p>

<p><img src="https://i.snap.as/3MOuYLb6.png" alt="Baseline model performance with Hospital IDs binned"/></p>

<p>And would you look at that – I already get a slight improvement over the “just shove everything in” model shown in the last post! That had an AUC of 0.8567 for reference.</p>

<p><img src="https://i.snap.as/gKRuMu49.png" alt="Feature importance for baseline binned model"/></p>

<p>Plus we can even see here that hospital bins are important! Woo! Go team! Feature engineering isn&#39;t a lie!</p>

<p>The unfortunate thing about this though, is that the submission set uses completely different hospital IDs so this work amounted to nothing, whoops. But hey, it would&#39;ve been nice to use it for a proxy for location!</p>

<p>So then I continued onto doing my whole “mean or median or 0s” missing value imputation test run. I only did it this long and convoluted way because, well, I have time, I wasn&#39;t doing the fancy methods I actually wanted to try out, and I might as well do something that I wouldn&#39;t do at work. At work, all the missing values are 0&#39;s because I work with financial data – if a client doesn&#39;t have a product, it&#39;ll usually be a missing value, and that&#39;s definitely a 0! Although it&#39;d be nice if someone imputed me some more money into my bank account some days hahaha.</p>

<p>It took a while to run (yay, loops!) but I did it so it regularly told me what was going on so I didn&#39;t get frustrated with it haha. I won&#39;t share it since it&#39;s kinda boring and probably not very important to see. I also cleaned it up a bit – if a min value was dropped but the corresponding max value used median, then I set both of them to be median.</p>

<p>Oh, and one last thing that I did – I checked to make sure the min values were actually smaller than the max values, and if not, I swapped them. I got the idea from the 3rd place solution notebook in the 2020 WiDS Datathon, although they did it slightly differently (filled with NA if the min value was smaller than the max).</p>

<p>After all this work – there wasn&#39;t even an improvement in the AUC. I won&#39;t show you, and it wasn&#39;t that bad, but it wasn&#39;t an increase haha. But that&#39;s what future steps are for haha.</p>

<p><a href="https://iman.codes/tag:datascience" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">datascience</span></a> <a href="https://iman.codes/tag:wids2021" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">wids2021</span></a></p>
]]></content:encoded>
      <guid>https://iman.codes/wids-datathon-2021-preprocessing</guid>
      <pubDate>Thu, 28 Jan 2021 17:45:00 +0000</pubDate>
    </item>
    <item>
      <title>WiDS Datathon 2021 - Exploration</title>
      <link>https://iman.codes/wids-datathon-2021-exploration?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[The Women in Data Science conference is hosting a datathon, which I decided to participate in. &#xA;&#xA;I thought it&#39;d be a good way to get &#34;back to basics&#34; and actually work on a problem from start to finish. My job right now is very much focused on improvements and productionization, so it feels like I haven&#39;t done any modelling in ages! Plus there have been a few things I&#39;ve been meaning to play around with, and this was the perfect opportunity to do so.&#xA;&#xA;And since my code/notebooks tend to be a huge mess (I guess that&#39;s what happens when you write code by jumping around all over the place...), plus I have this fancy blog that actually needs content, why not turn it into blog posts? It&#39;s a great idea all around.&#xA;&#xA;!--more--So let&#39;s get into the first part: exploring the data.&#xA;&#xA;I knew from the start - since this is healthcare data - that I wanted to use an explainable model. Also, I&#39;d recently heard about InterpretML at the Toronto Machine Learning Summit that happened this past November. I feel really strongly that in a field where the model results will have a major impact on the people it&#39;s being applied to (Cynthia Rudin called it, in her own talk about interpretability vs. explainability, a high-stakes decision) should have results be interpretable and explainable from the start. &#xA;&#xA;In this case, if my model spits out that a patient admitted to ICU definitely has diabetes, I want the doctors and nurses and everyone to know why my model absolutely believes this. After all, I&#39;m not a doctor. I barely have any understanding of biology! Why should I be even working on healthcare data? (Which is a separate thing all on its own - I also feel strongly that you should have a good understanding of the context where your data comes from). If the decisions are explainable, then actual experts can go in and correct the decisions if they&#39;re wrong, too. &#xA;&#xA;Plus, these sorts of decisions will have a disproportionate impact on the people they&#39;re being applied to. What if my model&#39;s garbage and says someone doesn&#39;t have diabetes, but they do, and then they end up with really inappropriate care? There&#39;s also the whole thing about not having your model have equity issues. If your model is explainable from the beginning, you can see if you&#39;re going really wrong somewhere. I&#39;m thinking of this article in Wired that discusses a study that shows Black patients with kidney disease were systematically treated as &#34;less severe&#34; than white patients due to a calculation that bakes race right into it - and this is something that&#39;s explainable! And while I&#39;m definitely not a doctor, and I&#39;m consulting Wikipedia here, apparently &#34;African, Hispanics, and South Asians, particularly those from Pakistan, Sri Lanka, Bangladesh, and India, are at high risk of developing [chronic kidney disease].&#34; Plus, it also says, &#34;Administration of antihypertensive drugs generally halts disease progression in white populations but has little effect in slowing kidney disease among black people.&#34;&#xA;&#xA;So, race does have an impact on people&#39;s health (I mean, outside of the social aspects, which I&#39;m also not really qualified to talk about but was briefly touched on in the Wired article), but it needs to also make sense. I was looking at Wikipedia again, to learn about diabetes (as I said - not a doctor!) and saw that, for Type II diabetes, &#34;Women seem to be at a greater risk as do certain ethnic groups, such as South Asians, Pacific Islanders, Latinos, and Native Americans. This may be due to enhanced sensitivity to a Western lifestyle in certain ethnic groups.&#34; The dataset does contain an &#34;ethnicity&#34; column, which may be useful in identifying whether or not someone has diabetes, but we&#39;re not saying how severe it is, like the kidney function thing.&#xA;&#xA;I&#39;m not sure if my thought process got through, but hopefully it did haha.&#xA;&#xA;Anyway, back to the actual data! &#xA;&#xA;InterpretML has a bunch of super convenient things, like something that&#39;ll plot out basic histograms for me. It&#39;s not perfect, but I love being able to just... select something to see the histogram. I usually hate doing the initial plotting work (even though it&#39;s simple and basic - no one said it was rational), so I adore this!&#xA;&#xA;Histogram of target variable&#xA;&#xA;This gave me a bit of a basic understanding of what was going on in the data, but of course, I&#39;ll probably need to do my own better plots or just run some calculations.&#xA;&#xA;Histogram of weight of patients&#xA;&#xA;This is the weight of patients, with orange meaning they are labelled as having diabetes. This is one of the plots where I&#39;d probably replot it in a different way, or run some numbers, to get a better understanding of what&#39;s going on here. But also - from the reading about diabetes on Wikipedia, I&#39;m pretty confident that weight will probably be important in the model anyway haha. But also, check out the bar on the left.&#xA;&#xA;I filled in all missing values with 0 as an initial approach (I&#39;ll do missing value imputation, I promise!). Mostly, InterpretML couldn&#39;t handle missing values, so I shoved them in for now.&#xA;&#xA;Anyway, I was using one of their example notebooks and decided, what the heck, let&#39;s train an explainable boosting model on this data, doing nothing but very improperly shoving a bunch of 0s into the missing values.&#xA;&#xA;And I mean, it wasn&#39;t that bad??? Amazingly???&#xA;&#xA;ROC-AUC for initial model&#xA;&#xA;But I like doing garbage model training at first to see what the model thinks is important.&#xA;&#xA;Overall feature importance&#xA;&#xA;Intuitively, from all that Wikipedia-doctor-ing I did, these results make sense. Glucose is very important in the diagnosis, and increasing age is also a factor in Type II diabetes. &#xA;&#xA;Something else is that we see BMI is an important feature! But, we also see weight! BMI and weight are pretty related to each other... But if we try to look for it, we don&#39;t see height.&#xA;&#xA;Effect of height on model predictions&#xA;&#xA;It also looks like this. So it doesn&#39;t really look that clear-cut.&#xA;&#xA;BMI&#39;s kind of a weird measure, socially, since it&#39;s not super reliable for indicating obesity, which is a factor that increases the risk of diabetes. There&#39;s also no other measurements in the data set that I could use for better/alternative indicators of obesity, like hip to waist ratio.&#xA;&#xA;I think I&#39;ll be playing around with either removing BMI or calculating it myself after imputing missing weights/heights.&#xA;&#xA;Effect of ethnicity on model predictions&#xA;&#xA;I wanted to show this plot to show how ridiculous it is to replace all the missing values with 0s haha. There&#39;s already an unknown/other! I can use that!&#xA;&#xA;Anyway, going back to the overall importance, we also see hemoglobin, which I thought was kind of interesting because other than glucose tests, there&#39;s a glycated hemoglobin (HbA1c) test to determine if you have diabetes.&#xA;&#xA;It seems like this paper suggests that HbA1c is linearly related to Hb - &#34;The linear relationship between [Hb] and HbA1c holds true for anaemic and non-anaemia populations&#34; and &#34;We recommend that, absent risks factors for and symptoms relatable to diabetes, marginal elevations in HbA1c levels (i.e. HbA1c   6%) in anaemic patients should warrant confirmation of diagnosis using fasting blood glucose and 2HPPG or OGTT,&#34; so if the Hb levels are low, glucose might be even more important.&#xA;&#xA;This paper, entitled Racial and ethnic differences in the relationship between HbA1c and blood glucose: implications for the diagnosis of diabetes, emphasizes that there are racial differences with using this - &#34;reliance on HbA1c as the sole, or even preferred, criterion for the diagnosis of diabetes creates the potential for systematic error and misclassification. HbA1c must be used thoughtfully and in combination with traditional glucose criteria when screening for and diagnosing diabetes.&#34;&#xA;&#xA;So I think it might be interesting to see if this dataset has that show up.&#xA;&#xA;Something else that we see in the &#34;top&#34; features is hospital_id, which is the identifier for which hospital a patient was admitted to. I want to use this as a proxy for location, because there&#39;s a location component in the prevalence of diabetes - see this CDC pdf for a couple maps. However, there&#39;s like over 200 unique IDs in this, so I want to figure out how to collapse this down in a logical manner! &#xA;&#xA;Anyway, this is just a bunch of stuff I thought I&#39;d write up. I wanted to organize my thoughts a bit better than a massive Markdown cell in my notebook filled with really messy notes, too, hahahaha.&#xA;&#xA;#datascience #wids2021]]&gt;</description>
      <content:encoded><![CDATA[<p>The <a href="https://www.widsconference.org/" rel="nofollow">Women in Data Science conference</a> is hosting a <a href="https://www.widsconference.org/datathon.html" rel="nofollow">datathon</a>, which I decided to participate in.</p>

<p>I thought it&#39;d be a good way to get “back to basics” and actually work on a problem from start to finish. My job right now is very much focused on improvements and productionization, so it feels like I haven&#39;t done any modelling in ages! Plus there have been a few things I&#39;ve been meaning to play around with, and this was the perfect opportunity to do so.</p>

<p>And since my code/notebooks tend to be a huge mess (I guess that&#39;s what happens when you write code by jumping around all over the place...), plus I have this fancy blog that actually needs content, why not turn it into blog posts? It&#39;s a great idea all around.</p>

<p>So let&#39;s get into the first part: exploring the data.</p>

<p>I knew from the start – since this is healthcare data – that I wanted to use an explainable model. Also, I&#39;d recently heard about <a href="https://github.com/interpretml/interpret" rel="nofollow">InterpretML</a> at the <a href="https://torontomachinelearning.com/" rel="nofollow">Toronto Machine Learning Summit</a> that happened this past November. I feel really strongly that in a field where the model results will have a major impact on the people it&#39;s being applied to (Cynthia Rudin called it, in her own talk about interpretability vs. explainability, a high-stakes decision) should have results be interpretable and explainable from the start.</p>

<p>In this case, if my model spits out that a patient admitted to ICU definitely has diabetes, I want the doctors and nurses and everyone to know why my model absolutely believes this. After all, I&#39;m not a doctor. I barely have any understanding of biology! Why should I be even working on healthcare data? (Which is a separate thing all on its own – I also feel strongly that you should have a good understanding of the context where your data comes from). If the decisions are explainable, then actual experts can go in and correct the decisions if they&#39;re wrong, too.</p>

<p>Plus, these sorts of decisions will have a disproportionate impact on the people they&#39;re being applied to. What if my model&#39;s garbage and says someone doesn&#39;t have diabetes, but they do, and then they end up with really inappropriate care? There&#39;s also the whole thing about not having your model have equity issues. If your model is explainable from the beginning, you can see if you&#39;re going really wrong somewhere. I&#39;m thinking of <a href="https://www.wired.com/story/how-algorithm-blocked-kidney-transplants-black-patients/" rel="nofollow">this article</a> in Wired that discusses a study that shows Black patients with kidney disease were systematically treated as “less severe” than white patients due to a calculation that bakes race right into it – and this is something that&#39;s explainable! And while I&#39;m definitely not a doctor, and I&#39;m consulting <a href="https://en.wikipedia.org/wiki/Chronic_kidney_disease" rel="nofollow">Wikipedia</a> here, apparently “African, Hispanics, and South Asians, particularly those from Pakistan, Sri Lanka, Bangladesh, and India, are at high risk of developing [chronic kidney disease].” Plus, it also says, “Administration of antihypertensive drugs generally halts disease progression in white populations but has little effect in slowing kidney disease among black people.”</p>

<p>So, race does have an impact on people&#39;s health (I mean, outside of the social aspects, which I&#39;m also not really qualified to talk about but was briefly touched on in the Wired article), but it needs to also make sense. I was looking at Wikipedia again, to learn about <a href="https://en.wikipedia.org/wiki/Diabetes" rel="nofollow">diabetes</a> (as I said – not a doctor!) and saw that, for <a href="https://en.wikipedia.org/wiki/Type_2_diabetes" rel="nofollow">Type II diabetes</a>, “Women seem to be at a greater risk as do certain ethnic groups, such as South Asians, Pacific Islanders, Latinos, and Native Americans. This may be due to enhanced sensitivity to a Western lifestyle in certain ethnic groups.” The dataset does contain an “ethnicity” column, which may be useful in <em>identifying</em> whether or not someone has diabetes, but we&#39;re not saying how <em>severe</em> it is, like the kidney function thing.</p>

<p>I&#39;m not sure if my thought process got through, but hopefully it did haha.</p>

<p>Anyway, back to the actual data!</p>

<p>InterpretML has a bunch of super convenient things, like something that&#39;ll plot out basic histograms for me. It&#39;s not perfect, but I love being able to just... select something to see the histogram. I usually hate doing the initial plotting work (even though it&#39;s simple and basic – no one said it was rational), so I adore this!</p>

<p><img src="https://i.snap.as/OxzNoFO8.png" alt="Histogram of target variable"/></p>

<p>This gave me a bit of a basic understanding of what was going on in the data, but of course, I&#39;ll probably need to do my own better plots or just run some calculations.</p>

<p><img src="https://i.snap.as/ueFJMzSX.png" alt="Histogram of weight of patients"/></p>

<p>This is the weight of patients, with orange meaning they are labelled as having diabetes. This is one of the plots where I&#39;d probably replot it in a different way, or run some numbers, to get a better understanding of what&#39;s going on here. But also – from the reading about diabetes on Wikipedia, I&#39;m pretty confident that weight will probably be important in the model anyway haha. But also, check out the bar on the left.</p>

<p>I filled in all missing values with 0 as an initial approach (I&#39;ll do missing value imputation, I promise!). Mostly, InterpretML couldn&#39;t handle missing values, so I shoved them in for now.</p>

<p>Anyway, I was using one of their example notebooks and decided, what the heck, let&#39;s train an explainable boosting model on this data, doing nothing but very improperly shoving a bunch of 0s into the missing values.</p>

<p>And I mean, it wasn&#39;t that bad??? Amazingly???</p>

<p><img src="https://i.snap.as/vkfXVdQs.png" alt="ROC-AUC for initial model"/></p>

<p>But I like doing garbage model training at first to see what the model thinks is important.</p>

<p><img src="https://i.snap.as/VA6iYMPj.png" alt="Overall feature importance"/></p>

<p>Intuitively, from all that Wikipedia-doctor-ing I did, these results make sense. Glucose is very important in the diagnosis, and increasing age is also a factor in Type II diabetes.</p>

<p>Something else is that we see BMI is an important feature! But, we also see weight! BMI and weight are pretty related to each other... But if we try to look for it, we don&#39;t see height.</p>

<p><img src="https://i.snap.as/QcH18PLX.png" alt="Effect of height on model predictions"/></p>

<p>It also looks like this. So it doesn&#39;t really look that clear-cut.</p>

<p>BMI&#39;s kind of a weird measure, socially, since it&#39;s not super reliable for indicating obesity, which is a factor that increases the risk of diabetes. There&#39;s also no other measurements in the data set that I could use for better/alternative indicators of obesity, like hip to waist ratio.</p>

<p>I think I&#39;ll be playing around with either removing BMI or calculating it myself after imputing missing weights/heights.</p>

<p><img src="https://i.snap.as/lEDrerqr.png" alt="Effect of ethnicity on model predictions"/></p>

<p>I wanted to show this plot to show how ridiculous it is to replace all the missing values with 0s haha. There&#39;s already an unknown/other! I can use that!</p>

<p>Anyway, going back to the overall importance, we also see hemoglobin, which I thought was kind of interesting because other than glucose tests, there&#39;s a glycated hemoglobin (HbA1c) test to determine if you have diabetes.</p>

<p>It seems like <a href="https://www.bjmp.org/content/anemia-and-hemoglobin-a1c-level-there-case-redefining-reference-ranges-and-therapeutic-goals" rel="nofollow">this paper</a> suggests that HbA1c is linearly related to Hb – “The linear relationship between [Hb] and HbA1c holds true for anaemic and non-anaemia populations” and “We recommend that, absent risks factors for and symptoms relatable to diabetes, marginal elevations in HbA1c levels (i.e. HbA1c &gt;6%) in anaemic patients should warrant confirmation of diagnosis using fasting blood glucose and 2HPPG or OGTT,” so if the Hb levels are low, glucose might be even more important.</p>

<p><a href="https://pubmed.ncbi.nlm.nih.gov/22238408/" rel="nofollow">This paper</a>, entitled <em>Racial and ethnic differences in the relationship between HbA1c and blood glucose: implications for the diagnosis of diabetes</em>, emphasizes that there are racial differences with using this – “reliance on HbA1c as the sole, or even preferred, criterion for the diagnosis of diabetes creates the potential for systematic error and misclassification. HbA1c must be used thoughtfully and in combination with traditional glucose criteria when screening for and diagnosing diabetes.”</p>

<p>So I think it might be interesting to see if this dataset has that show up.</p>

<p>Something else that we see in the “top” features is hospital_id, which is the identifier for which hospital a patient was admitted to. I want to use this as a proxy for location, because there&#39;s a location component in the prevalence of diabetes – see <a href="https://www.cdc.gov/diabetes/pdfs/data/statistics/national-diabetes-statistics-report.pdf" rel="nofollow">this CDC pdf</a> for a couple maps. However, there&#39;s like over 200 unique IDs in this, so I want to figure out how to collapse this down in a logical manner!</p>

<p>Anyway, this is just a bunch of stuff I thought I&#39;d write up. I wanted to organize my thoughts a bit better than a massive Markdown cell in my notebook filled with really messy notes, too, hahahaha.</p>

<p><a href="https://iman.codes/tag:datascience" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">datascience</span></a> <a href="https://iman.codes/tag:wids2021" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">wids2021</span></a></p>
]]></content:encoded>
      <guid>https://iman.codes/wids-datathon-2021-exploration</guid>
      <pubDate>Fri, 22 Jan 2021 23:06:42 +0000</pubDate>
    </item>
    <item>
      <title>tags</title>
      <link>https://iman.codes/tags?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[I try to tag my posts, and here they are, with a description of what they should contain:&#xA;&#xA;datascience&#xA;  as a data scientist, I do the data science-y things on a regular basis&#xA;&#xA;meta&#xA;  it&#39;s about this blog itself, or maybe about me, idk&#xA;&#xA;css&#xA;  it&#39;s about CSS, and probably about the blog style&#xA;&#xA;wids2021&#xA;  Women in Data Science 2021: all about the conference and the datathon&#xA; ]]&gt;</description>
      <content:encoded><![CDATA[<p>I try to tag my posts, and here they are, with a description of what they should contain:</p>

<p><a href="https://iman.codes/tag:datascience" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">datascience</span></a>
&gt; as a data scientist, I do the data science-y things on a regular basis</p>

<p><a href="https://iman.codes/tag:meta" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">meta</span></a>
&gt; it&#39;s about this blog itself, or maybe about me, idk</p>

<p><a href="https://iman.codes/tag:css" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">css</span></a>
&gt; it&#39;s about CSS, and probably about the blog style</p>

<p><a href="https://iman.codes/tag:wids2021" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">wids2021</span></a>
&gt; Women in Data Science 2021: all about the conference and the datathon</p>
]]></content:encoded>
      <guid>https://iman.codes/tags</guid>
      <pubDate>Fri, 22 Jan 2021 18:58:46 +0000</pubDate>
    </item>
  </channel>
</rss>