<?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 José Manuel Ureña on Medium]]></title>
        <description><![CDATA[Stories by José Manuel Ureña on Medium]]></description>
        <link>https://medium.com/@joseurena?source=rss-ed58a6df4bcc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*OBJxj2AiWaDsgrZb.</url>
            <title>Stories by José Manuel Ureña on Medium</title>
            <link>https://medium.com/@joseurena?source=rss-ed58a6df4bcc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 16:25:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@joseurena/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[Tesseract-OCR : Evaluating Handwritten Text Recognition]]></title>
            <link>https://joseurena.medium.com/tesseract-ocr-evaluating-handwritten-text-recognition-1c6db85b2e7f?source=rss-ed58a6df4bcc------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c6db85b2e7f</guid>
            <category><![CDATA[ocr-tesseract]]></category>
            <category><![CDATA[text-extraction]]></category>
            <category><![CDATA[ocr]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[lstm]]></category>
            <dc:creator><![CDATA[José Manuel Ureña]]></dc:creator>
            <pubDate>Thu, 24 Jun 2021 23:52:58 GMT</pubDate>
            <atom:updated>2022-02-16T18:38:43.085Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EcjtaXo5HUVfIObxs0-I3A.jpeg" /><figcaption>Hand written notes</figcaption></figure><h3>Tesseract-OCR: Evaluating Handwritten Text Recognition</h3><p>The Why, What And Who:</p><p>As Data Scientists (DS), they often ask us to produce evaluations of models’ capabilities. We do this to help identify the best approach or approaches for specific use cases and deployment environments.</p><h3>Key objectives for our DS team:</h3><p>Project manager entrusted us to achieve the following aims for the Story Squad’s app:</p><ol><li>Explore, apply, and implement new image preprocessing techniques to help improve the Tesseract-OCR.</li></ol><p>2. Provide a baseline metrics to evaluate Google Vision and Tesseract-OCR pipeline objectively.</p><pre>#to install Tesseract-ocr<br>sudo apt install tesseract-ocr</pre><pre>#check Tesseract version<br>tesseract — version</pre><pre>#To extract text out an image<br>tesseract sample_image.png stdout -l eng</pre><p><strong>Optical character recognition (OCR)</strong> is the extraction of typed or printed text, for example, from a PDF or image, into a text string. OCR of typed text is a well-understood problem. Human Handwritten Text Recognition (HTR) is more challenging, because of uniqueness of individuals’ handwriting styles. Specially for kids’ handwriting between the ages of 8–12.</p><p>We were part of a 4 member DS team. Our DS team was part of a large multifunctional development team of docents of other Data Scientists, Stack Engineers, iOS developers, and Front End developers.</p><h3>What is Story Squad?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*2_kQpqazSfcV5hPMpPbiYg.jpeg" /><figcaption>Story Squad Logo</figcaption></figure><p><strong>Story Squad</strong> is the dream of a former teacher, Graig Peterson, to create opportunities for children to have creative writing and drawing time, off-screen. Here’s how it works: Story Squad provides users of the website a new chapter in an ongoing story each weekend. They read the story, and then follow with both a writing and drawing prompt to spend an hour off-screen writing and drawing. When they’re done, they upload photos of each. <br>The team transcribes the stories into text, analyzed for complexity, screened for inappropriate content, and then sent to a moderator. <strong><em>(1)</em></strong></p><p>(<a href="https://www.storysquad.education/">https://www.storysquad.education/</a>)</p><p>For this project, we work with-in an agile framework; therefore, we have constant interactions with external stakeholders from the Story Squad team, which helps understand and develop the main user story and break it down into tasks to achieve the primary objectives.</p><p><strong>Stakeholder User Story</strong></p><p>Because of the related cost of using Google cloud vision as the current project’s OCR solution to transcribe thousands of handwritten docs. <br>Story Squad wants to evaluate objectively Google vision and Tesseract-OCR. <br>To see if, the team can use Tesseract as the main OCR for the Story Squad app.</p><h3>Known Unknowns: The Challenge working with Tesseract-OCR</h3><p>Tesseract-OCR support for handwritten offline text is poor, as of version 4, there is no human handwritten traineddata file available. Also, the training process for the integrated LSTM model is not straightforward, and it is labor intensive. Because of resources, and time constraints, we could not have access to a trained LSTM model which generalizes well human handwritten text. As our testing will show, we have to rely heavily on preprocessing techniques to test if Tesseract-OCR in its default configuration could produce useful text transcription of handwriting samples.</p><p>Major hurtle was that none of the DS team members had experience working with Tesseract-OCR specifically, and the OCR topic. Previous teams have done some work to build out parts of the Tesseract-OCR pipeline. There were some functional parts, but the performances of the train model inherited, it isn’t as good as the Google Vision API.</p><blockquote>“It’s not that I’m so smart, it’s just that I stay with problems longer.” — Albert Einstein</blockquote><p>Sticking to a UPER framework (Understand, Plan, Execute, Review). <br>We spent a significant amount of time researching, reading, viewing videos, and learning. So, we can fully understand how to work with-in the Tesseract-OCR framework. Once we have brought ourselves to speed on the subject, and we felt confident. We planned and executed without many issues. We also conducted reviews of our plan with individuals outside our 4 member team, and try to use best practices with our git push request to smooth out the approval process of our code.</p><h3>The Metrics:</h3><p>The metrics we used were Character Error Rate (CER), Word Error Rate (WER) and Levenshtein distance (LDR).</p><p>- A CER of 10% means that every tenth character is incorrectly identified (and these are not only letters but also punctuations, spaces, etc.). (2)</p><p>- The WER shows how good the exact reproduction of the words in the text is. As a rule, the WER is three to four times higher than the CER and is proportional to it. <strong><em>(2)</em></strong></p><p>- The Levenshtein distance is a string metric for measuring the difference between two sequences. Informally, the Levenshtein distance between two words is the minimum number of single-character edits (insertions, deletions or substitutions) required to change one word into the other. Named after the Soviet mathematician Vladimir Levenshtein, who considered this distance in 1965. <strong><em>(3)</em></strong></p><h3>The process:</h3><p>After creating a PipEnv environment through Linux Terminal in our Windows 10 machine. We mainly use OpenCV <strong><em>(4)</em></strong> and its cv2 module for our pre-processing of the images before text extraction by Tesseract-OCR. The cv2 functions we used: resizing, BGR to RGB, BGR to GRAY, and Adaptive threshold. We tried other functions with mix results and process cost, but we settled for the few previously mentioned functions, as we got the biggest bang for our processing cost. Although openCV <strong><em>(4)</em></strong> has a deskew function, we had better results using [sbrunner/deskew repo](<a href="https://github.com/sbrunner/deskew">https://github.com/sbrunner/deskew</a>) <strong><em>(5)</em></strong></p><h3>Original Image &amp; Ground Truth</h3><p>We used a sample with handwriting to test our hypothesis against the ground truth text, using the CER, WER, and LDR. <strong>Ground truth</strong> is information that is known to be true.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xDgN0L2RfkS8Kc7uTwsRqw.jpeg" /></figure><p>We found better results by deskewing the image first, then applying the other preprocessing steps. We need it to use skimage io module to read the image.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c80bae2a2be112a441f2e28dd58c063/href">https://medium.com/media/3c80bae2a2be112a441f2e28dd58c063/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/41daafc96af993c28bc5238947ccc944/href">https://medium.com/media/41daafc96af993c28bc5238947ccc944/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7IRUPYxed38ZGo8H7gAOtQ.png" /></figure><h3>Tesseract-OCR Evaluation results</h3><p>The team evaluated our results using a python wrapper pytesseract <strong><em>(6)</em></strong> for Tesseract-OCR Binary . We also used two other libraries to produce our scores, asrtoolkit for CER, WER) <strong><em>(7)</em> </strong>and fuzzywuzzy<strong><em> (8)</em></strong> for <strong>Levenshtein distance.</strong></p><p>We created <strong>seven hypotheses</strong> text extractions to compare with our ground truth text and pass both the individual hypothesis and ground truth to each of the evaluating functions. For more detail information on the results of each evaluation, please visit the following <a href="https://www.notion.so/7-hypotheses-to-test-35137e0eceb54116ac574da2dbb2e1a1">link.</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eaeee9fcb74c962b03eff8c852b15dcb/href">https://medium.com/media/eaeee9fcb74c962b03eff8c852b15dcb/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc302ab772309d8dee0848b3ba466ee4/href">https://medium.com/media/bc302ab772309d8dee0848b3ba466ee4/href</a></iframe><h3>Results from our evaluation:</h3><p>As per the below results, CER and WER a rating close to 0 is desirable, close to 100 is <strong>not</strong> desirable. LDR a rating close to 100 is desirable and near 0 is <strong>not</strong> desirable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*a9_C4w16KkG7jzoqpQAsCg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*ewsxdIWFFQTCHO1Ki9z_vg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*wjB28y7BTV-iQkplSIxCDw.png" /></figure><h3>As the results from our evaluation showed in the above graphs:</h3><ol><li>Preprocessing techniques used improved Tesseract-OCR performance even with the default eng.traineddata. <strong><em>(10)</em></strong></li><li>As expected, Google cloud vision produces far better results at this stage of the project.</li><li>Although we used for <strong>hypothesis #5 </strong>a custom trained data ssq.traineddata <strong><em>(10)</em></strong> results actually were less desirable than using the default eng.traineddata. I theorize the LSTM custom trained model, it’s still not generalizing well.</li></ol><p>As per the Story Squad project, there are definitely some challenges up-ahead. Improving the LSTM model for better text extraction, I think will be key. <br>This will allow to see the impact of further preprocessing methods or steps. <br>As per our code, there are some improvements that to be done, such as adding further preprocessing steps and arguments to control the parameters within the cv2 module. Creating a helper function out of the deskew process and integrating it into the “pre_process_image” function.</p><p>I was extremely lucky to be part of this project. I would like to thank the team at Story Squad. It such an innovated idea to use technology to engage kids to spend off-screen time writing and drawing. As well as using their imagination and storytelling capabilities.</p><p>As per myself, the challenges encountered by our lack of knowledge of the OCR subject. Allow me to put into practice a growth mind set, and learn a few new skills, frameworks, and libraries. I am always pleasantly surprise by the bounty of information and open-source projects that allow us to push forward our knowledge and hopefully contribute back to the data science community as well. I also plan to continue working on the OCR and Machine Vision subjects to further my knowledge and capabilities.</p><h3>Citations</h3><p><em>(1)</em> Lambda-School-Labs/story-squad-ds Lambda-School-Labs/story-squad-ds (2021). Available at: <a href="https://github.com/Lambda-School-Labs/story-squad-ds">https://github.com/Lambda-School-Labs/story-squad-ds</a> (Accessed: 22 June 2021).</p><p><em>(2)</em> Word Error Rate &amp; Character Error Rate — How to evaluate a model (2019). Available at: <a href="https://rechtsprechung-im-ostseeraum.archiv.uni-greifswald.de/word-error-rate-character-error-rate-how-to-evaluate-a-model/">https://rechtsprechung-im-ostseeraum.archiv.uni-greifswald.de/word-error-rate-character-error-rate-how-to-evaluate-a-model/</a> (Accessed: 22 June 2021).</p><p><em>(3)</em> Levenshtein distance — Wikipedia Levenshtein distance — Wikipedia (2021). Available at: <a href="https://en.wikipedia.org/wiki/Levenshtein_distance">https://en.wikipedia.org/wiki/Levenshtein_distance</a> (Accessed: 22 June 2021).</p><p><em>(4) Image preprocessing </em><a href="https://docs.opencv.org/master/d2/de6/tutorial_py_setup_in_ubuntu.html">OpenCV: Install OpenCV-Python in Ubuntu</a></p><p><em>(5) Image Text Deskewing </em><a href="https://github.com/sbrunner/deskew">sbrunner/deskew</a></p><p><em>(6) Tesseract-OCR python Wrapper </em><a href="https://pypi.org/project/pytesseract/">pytesseract</a></p><p><em>(7) CER and WER ratings </em><a href="https://pypi.org/project/asrtoolkit/">asrtoolkit</a></p><p><em>(8) </em>Levenshtein distance rating <a href="https://pypi.org/project/fuzzywuzzy/">fuzzywuzzy</a></p><p><em>(9) </em><a href="https://cloud.google.com/vision/docs/fulltext-annotations">Document Text Tutorial | Cloud Vision API | Google Cloud</a></p><p><em>(10) Tesseract training repo </em><a href="https://github.com/dakotagporter/tesstrain">dakotagporter/tesstrain</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c6db85b2e7f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Austin Animal Center Shelter Outcomes]]></title>
            <link>https://joseurena.medium.com/austin-animal-center-shelter-outcomes-290dbf78cbf2?source=rss-ed58a6df4bcc------2</link>
            <guid isPermaLink="false">https://medium.com/p/290dbf78cbf2</guid>
            <category><![CDATA[animals]]></category>
            <category><![CDATA[lambda-school]]></category>
            <category><![CDATA[animal-shelters]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[José Manuel Ureña]]></dc:creator>
            <pubDate>Sun, 25 Oct 2020 23:50:49 GMT</pubDate>
            <atom:updated>2020-10-27T01:46:38.438Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*GBRVE5GntE6fX8jFSbpKtQ.png" /><figcaption>Niko Urena</figcaption></figure><h3>Dataset, Model Target</h3><p><strong>Dataset use for this blog post is from Austin Animal Center Shelter Outcomes, dataset can be found at Kaggle</strong> <a href="https://www.kaggle.com/aaronschlegel/austin-animal-center-shelter-outcomes-and">https://www.kaggle.com/aaronschlegel/austin-animal-center-shelter-outcomes-and</a></p><p><strong>Code for the ML model:</strong> <a href="https://github.com/urenajose/DSPT8-DS-Unit-2-Build/blob/main/DS_Unit_2_Build_ACC_Shelter_Dataset_ipyn.ipynb">https://github.com/urenajose/DS-Unit-1-Build/blob/master/Unit%202%20build/DS_Unit_2_Build_ACC_Shelter_Dataset_ipyn.ipynb</a></p><p><strong>The Dataset shape is (78244, 22), all the columns are string type, most of the information is categorical, with some columns having date time information.</strong></p><pre> 0   age_upon_outcome  78248 non-null  object<br> 1   animal_id         78256 non-null  object<br> 2   animal_type       78256 non-null  object<br> 3   breed             78256 non-null  object<br> 4   color             78256 non-null  object<br> 5   date_of_birth     78256 non-null  object<br> 6   datetime          78256 non-null  object<br> 7   monthyear         78256 non-null  object<br> 8   name              54370 non-null  object<br> 9   outcome_subtype   35963 non-null  object<br> 10  outcome_type      78244 non-null  object<br> 11  sex_upon_outcome  78254 non-null  object</pre><p>I selected the target for the model “outcome_type”, although it is a categorical multi-class problem I decided to make it into a binary problem did the animal lived or died ?</p><pre>Adoption           33112<br>Transfer           23499<br>Return to Owner    14354<br>Euthanasia          6080<br>Died                 680<br>Disposal             307<br>Rto-Adopt            150<br>Missing               46<br>Relocate              16<br>NaN                   12</pre><h3>Baseline</h3><p><strong>Lived = 1 and Died = 0, was the categories were unified I end up with the following results 90.9% of the animals lived, where 9.1% died. As the majority occurs with 90% frequency making the classes have a huge imbalanced.</strong></p><pre>df_shelter[&#39;Target&#39;].value_counts(normalize=True)<br>1.0    0.90968<br>0.0    0.09032</pre><h3>Random Forest</h3><p>Without wrangling the data any further I decided to use a Random Tree Classifier model and Ordinal Encoder to verify feature importance and do an early score on the Dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0xSDu1XcSX7hhjlwE9IpIg.jpeg" /><figcaption>Roc curve for Random Forest Model</figcaption></figure><h3>1st Permutation importance</h3><p>As per the permutation importance of this early model:</p><pre>0.0649 ± 0.0008	animal_type<br>0.0622 ± 0.0010	sex_upon_outcome<br>0.0370 ± 0.0009	breed<br>0.0356 ± 0.0005	age_upon_outcome<br>0.0303 ± 0.0005	animal_id<br>0.0301 ± 0.0004	color</pre><p>Also, it gave me an unexpected <strong>cross validation score</strong> of 0.9499, I image will be much lower.</p><p>As far as, this model distinguishing between classes the model had a <strong>ROC AUC</strong> of 0.862</p><pre>                precision    recall  f1-score   support<br><br>         0.0       0.90      0.48      0.62      1421<br>         1.0       0.95      0.99      0.97     14227<br><br>    accuracy                           0.95     15648<br>   macro avg       0.92      0.74      0.80     15648<br>weighted avg       0.95      0.95      0.94     15648</pre><h3>XGB Classifier</h3><p>I proceeded to wrangle the data and creating some extra features, to see if I can improve the model but also to give the model some flexibility in the type of predictions I could attempt. I used a <strong>XGB Classifier</strong> early stop of 50 rounds, I utilize an Ordinal Encoder. My cross validation score was not greatly improve compare to Random forest resulting in .952, in the other hand the model ROC AUC score improve drastically by .913 a .05 differences. I also so changes in my classification report score in which the recall for Dead animal outcomes was improved compare to Random forest Score.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EN6N531qwPgM6PubmDYVTA.jpeg" /><figcaption>Roc Curv XGB classier model</figcaption></figure><pre>               precision    recall  f1-score   support<br><br>         0.0       0.89      0.51      0.64      1405<br>         1.0       0.95      0.99      0.97     14244<br><br>    accuracy                           0.95     15649<br>   macro avg       0.92      0.75      0.81     15649<br>weighted avg       0.95      0.95      0.94     15649</pre><p>I proceeded to run another permutation importance to see if some features I had created have contributed to the model some of them did such is the case of “Name_known”, which return a 1 if the name of the animal was known, or 0 if the name of the animal was null, also the year the animal was born had higher importance than complete date of birth.</p><h3>2nd Permutation Importance</h3><pre>0.0450 ± 0.0011	animal_type<br>0.0367 ± 0.0005	Name_known<br>0.0134 ± 0.0004	breed<br>0.0093 ± 0.0006	age_upon_outcome_d<br>0.0088 ± 0.0004	sex_upon_outcome<br>0.0068 ± 0.0006	year_birth<br>0.0038 ± 0.0006	datetime<br>0.0028 ± 0.0002	year_outcome<br>0.0026 ± 0.0003	date_of_birth<br>0.0021 ± 0.0002	day_outcome<br>0.0019 ± 0.0002	color<br>0.0018 ± 0.0003	month_outcome<br>0.0017 ± 0.0004	month_birth<br>0.0013 ± 0.0002	selected_breed<br>0.0002 ± 0.0001	sex</pre><p>A general rule the effect of each feature is diluted the more features the model has. But I expect some of these extra features will give more flexibility in policy creation and insights from the model and more flexibility in ways to look at the data.</p><h3>Logistic Regression</h3><p>Finally, I use the Dataset with a Logistic Regression Model which perform similar to Random Forest model with a Cross Validation Score of .948 , and with a better ROC AUC Score .895, just lily worst than the XGB Classifier. The Logistic regression model was much quicker with a Wall time: 282 µs (microseconds); compare XGB Classifier .495 ms (milliseconds). Also much, much faster than the 23.6 s (seconds) of the Random Forest.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EN6N531qwPgM6PubmDYVTA.jpeg" /></figure><pre>               precision    recall  f1-score   support<br><br>         0.0       0.84      0.48      0.61      1405<br>         1.0       0.95      0.99      0.97     14244<br><br>    accuracy                           0.95     15649<br>   macro avg       0.90      0.74      0.79     15649<br>weighted avg       0.94      0.95      0.94     15649</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplotly.com%2F%7Eurena.jose%2F35.embed%3Fautosize%3Dtrue&amp;display_name=Plotly&amp;url=https%3A%2F%2Fchart-studio.plotly.com%2F%7Eurena.jose%2F35%2F&amp;image=https%3A%2F%2Fchart-studio.plotly.com%2Fstatic%2Fwebapp%2Fimages%2Fplotly-logo.8d56a320dbb8.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=plotly" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/a77b7d376b8a6635b88bcac4efdb6336/href">https://medium.com/media/a77b7d376b8a6635b88bcac4efdb6336/href</a></iframe><p><strong>Conclusion </strong>about the model selection: XGB Boost model will produce best result. If we had a larger dataset the Logistic Regression model might be desirable because its superior in speed. The random forest being the least desirable model out of the three.</p><h3>Understanding our XGB Classifier Model</h3><h4>The partial dependence plot (PDP)</h4><p>Animals that were either spayed or neutered (fix), their outcomes improve. Female that were not spayed did better than males not neutered. If the status was unknown decrease the outcome significantly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KN4A4121fWeo8vM7GNv3Eg.jpeg" /><figcaption>PDP for feature “Sex upon outcome”</figcaption></figure><p>If the animal had a name at the time of outcome, it improve the outcome of the animal. as much as 10%</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7NrAaxLtaU-kB8fVrspffw.jpeg" /><figcaption>PDP Interact does animal have a name? And top breed.</figcaption></figure><p>The younger the animal the less negative impact on the outcome not having a name had.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sh-mJl9l_UNGwQZcBDW4BA.jpeg" /><figcaption>PDP Interact does animal have a name? And age of animal (days)</figcaption></figure><h3>Drilling down to specific observation</h3><p>If we look at the overall transformed training data average impact on model output magnitude. Shows those features with greater impact.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EW8pa2wUCSk0CRBv6MMDxQ.png" /></figure><p><strong>For an observation representing a bat </strong>the feature representing the year of birth and Date and time of the outcome have the most significant high impact. The fact the bat is a bat has a huge impact in lowering the score.</p><pre>animal_type                         Other<br>breed                                 Bat<br>color                               Brown<br>date_of_birth         2014-09-09T00:00:00<br>datetime              2015-09-10T09:08:00<br>sex_upon_outcome                  unknown<br>Name_known                              0<br>age_upon_outcome_d                    366<br>sex                               unknown<br>year_birth                           2014<br>month_birth                             9<br>year_outcome                         2015<br>month_outcome                           9<br>day_outcome                            10<br>selected_breed                Non_dog_cat</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wn4r7mgZIyAklNa81jGXSg.png" /></figure><p><strong>For an observation representing a cat</strong> the feature representing sex upon outcome = neutered male has the biggest positive magnitude; as well as only being ~3 months of age and having a name like “Yoda” does not hurt either!</p><pre>animal_type                           Cat<br>breed                   Domestic Longhair<br>color                         Brown Tabby<br>date_of_birth         2014-03-16T00:00:00<br>datetime              2014-06-20T18:22:00<br>sex_upon_outcome            neutered male<br>Name_known                              1<br>age_upon_outcome_d                     96<br>sex                                  male<br>year_birth                           2014<br>month_birth                            16<br>year_outcome                         2014<br>month_outcome                           6<br>day_outcome                            20<br>selected_breed                        Cat<br>Name: 21087, dtype: object</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pCwBaRIzNrx6F9gwXDV_IA.png" /></figure><p><strong>“Yoda” the Cat:</strong> features average impact on prediction output magnitude. Here we can see more clearly what features have the greatest magnitude on Yoda’s outcome and being a Jedi is not one of them. Also, we can see that feature magnitude does not align 1:1 with the features&#39; magnitude of the overall model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ph0Fk2m_fMoqQxB_e3gY9Q.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=290dbf78cbf2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Is our Mental Health System ready for the Covid-19 aftermath?]]></title>
            <link>https://joseurena.medium.com/is-our-mental-health-system-ready-for-the-covid-19-aftermath-fa75a08243ab?source=rss-ed58a6df4bcc------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa75a08243ab</guid>
            <category><![CDATA[mental-health]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[mental-health-facilities]]></category>
            <dc:creator><![CDATA[José Manuel Ureña]]></dc:creator>
            <pubDate>Fri, 28 Aug 2020 04:14:44 GMT</pubDate>
            <atom:updated>2025-03-11T20:50:47.595Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dWc7S4JRxAbEe9Fa8jiHoA.png" /><figcaption>Paget Michael Creelman <a href="https://bit.ly/2Qys0M2">https://bit.ly/2Qys0M2</a></figcaption></figure><h3>Mental Health Facilities Capacity &amp; Covid-19 aftermath</h3><h4>Is our mental health system ready for the Covid-19 aftermath? USA Mental Health Facilities and services, analysis of the National Mental Health Services Survey (N-MHSS): 2019.</h4><p>If we take into consideration the following two quotes, one by National Institute of Mental Health (NIMH), and the other by The New England Journal of Medicine and after looking at how many Mental Health facilities with have, there are reasons to be concern.</p><h4><em>“Mental illnesses are common in the United States. Nearly one in five U.S. adults live with a mental illness (46.6 million in 2017)”</em></h4><p><em>(NIMH » Mental Illness (2019). Available at: </em><a href="https://www.nimh.nih.gov/health/statistics/mental-illness.shtml"><em>https://www.nimh.nih.gov/health/statistics/mental-illness.shtml</em></a><em> (Accessed: 21 August 2020).)</em></p><h4>“Stressors that undoubtedly will contribute to widespread emotional distress and increased risk for psychiatric illness associated with Covid-19.”</h4><p>“Uncertain prognoses, looming severe shortages of resources for testing and treatment and for protecting responders and health care providers from infection, imposition of unfamiliar public health measures that infringe on personal freedoms, large and growing financial losses, and conflicting messages from authorities are among the major stressors that undoubtedly will contribute to widespread emotional distress and increased risk for psychiatric illness associated with Covid-19.” <br><em>Mental health and the Covid-19 Pandemic | NEJM “Mental Health and the Covid-19 Pandemic | NEJM” (2020), p. Available at: </em><a href="https://www.nejm.org/doi/full/10.1056/NEJMp2008017"><em>https://www.nejm.org/doi/full/10.1056/NEJMp2008017</em></a><em> (Accessed: 19 August 2020).</em></p><h4>I used the National Mental Health Services Survey 2019 (N-MHSS-2019) (2) questionnaire and dataset to explore what the data shows.</h4><p>Obviously, the subject of Mental health and Substance abuse is vast, and we cannot cover all ramifications of a potential surge in demand for these services in a blog-post. Hence, I focused on a certain aspect of the data to find some insights, but I must recognize is barely scratching the surface. <strong>I focused my attention mainly on the supply side of the mental health equation, the number of facilities and services they offer.</strong></p><h3>Let’s look at the forest before we look at the trees:</h3><p>2019-USA Projected <strong>Population</strong>, <strong>331,433,217</strong><br>according to US Census (1)</p><p><strong>12,472 </strong>Total Number Of<strong> Known Mental Health Facilities</strong> eligible from the N-MHSS-2019 report. (2)</p><p>Base on the reporter facilities, there are <strong>3.8 Facilities</strong> Nationwide <strong>per 100,000 </strong>people according to my-data analysis.</p><p><strong>Let’s look at the details of the N-MHSS-2019 data by State.</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplotly.com%2F%7Eurena.jose%2F24.embed%3Fautosize%3Dtrue&amp;display_name=Plotly&amp;url=https%3A%2F%2Fchart-studio.plotly.com%2F%7Eurena.jose%2F24%2F&amp;image=https%3A%2F%2Fchart-studio.plotly.com%2Fstatic%2Fwebapp%2Fimages%2Fplotly-logo.8d56a320dbb8.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=plotly" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/61e360158ca31b2e2065f66a42818578/href">https://medium.com/media/61e360158ca31b2e2065f66a42818578/href</a></iframe><p>Total numbers sometimes can mislead, hence the <strong>graph below</strong> shows how each state fairs out in several facilities per 100,000 of its residents. As we can see, some of our most populous states, such as <strong>CA, NY, TX and FL, lag in number facilities per 100,000 people. (1)</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplotly.com%2F%7Eurena.jose%2F8.embed%3Fautosize%3Dtrue&amp;display_name=Plotly&amp;url=https%3A%2F%2Fchart-studio.plotly.com%2F%7Eurena.jose%2F8%2F&amp;image=https%3A%2F%2Fchart-studio.plotly.com%2Fstatic%2Fwebapp%2Fimages%2Fplotly-logo.8d56a320dbb8.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=plotly" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3fc9a1812248913aa06c2e290122d19b/href">https://medium.com/media/3fc9a1812248913aa06c2e290122d19b/href</a></iframe><p>It is not sufficient to just have enough facilities; it is equally important, the number of services provided by the facilities. For this post, we won’t examine the quality of given services as it is not the scope.</p><h3>What does data show about the mental health services provided by the above enumerated facilities?</h3><p>To better visualize the data, we have used PCA method on the features of the dataset that represent the different questions about the services for each known Mental Health facility.</p><figure><img alt="The above graph shows the alignment or grouping of states from the PCA of the sum-total of the feature(s) of a given state." src="https://cdn-images-1.medium.com/max/1000/1*zSg-5FTvygOqDZNHF3i1UA.png" /><figcaption>The above graph shows the alignment or grouping of states from the PCA of the sum-total of the feature(s) of a given state. Because of rendering time, Dinamic plot can be view <a href="https://chart-studio.plotly.com/~urena.jose/10/#/">https://chart-studio.plotly.com/~urena.jose/10/#/</a></figcaption></figure><h3>Examples of services the features of dataset represent are:</h3><ul><li>Court-ordered outpatient treatment</li><li>Therapeutic foster care</li><li>Mental health intake</li><li>Suicide prevention services</li></ul><p><strong>We can clearly see in the above graph that California (CA) and New York (NY) are outliers</strong>, which can be expected since both states projected <strong>populations number: $39,512,223 and $19,399878 respectively (2010 Census)</strong>, and those states <strong>rank 1 and 2 in numbers of facilities</strong> but <strong>what about Texas (TX) and Florida (FL)?</strong> The same intuition should follow with <strong>population size of 28,995,881 and 21,477,737 respectively</strong>. Also, if we reference our first graph in which <strong>FL occupies 4th place and TX occupies a 10th place in the total number of facilities. </strong>TX and FL should be outliers in the total number of services available per facility, as well. Data shows that is not the case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*R1to1wECSW6exHGY42-EzQ.png" /></figure><h3>To better understand some differences of a total number of services offer per State. Let’s zoom into Florida (FL) and Pennsylvania (PA), as the PCA data show them closed together relative to other states.</h3><p>To make an adequate comparison, I selected 125 features of the 140 found in the dataset. In which at least one facility in either state answer yes to offering the service represented by the dataset’s feature. Also, some multiple-choice questions regarding categorical labeling were omitted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*H_FGaVeheBQ8BRmMZPxeHg.gif" /></figure><h4>After running a statistical t-test FL and PA facilities’ features, data shows there is around 66% commonality between the two states base on 125 features selected.</h4><h4>Below we can see (3) graphs showing the mean/average of the selected 125 features from the dataset, representing services or specifics of a service by index number.</h4><p><strong>Blue</strong> plot corresponds to <strong>National means</strong>, followed by <strong>Florida in red</strong> and State of <strong>Pennsylvania in green.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IfpHJ2t-GTUuXiLGovlqSA.png" /></figure><p>Let’s pick individual features from the above graph and see how they compare at a <strong>National level</strong>, and per individual states selected: <strong>FL and PA.</strong></p><h3>Feature number 100</h3><p>Represents facilities which: <strong>Accept Medicare as a source of payment for mental health treatment services. National mean or average 68%, FL is 66%, PA 56%</strong></p><h3>Feature number 50</h3><p>Represents facilities which: <strong>Accept children (aged 12 years or younger) for treatment</strong>. <strong>National mean or average of facilities is 59%, FL is 55% and PA 64%</strong></p><h3>Feature number 75</h3><p>Represents facilities which: <strong>Staff provide mental health treatment services in a language other than English</strong>. <strong>National mean or average of facilities is 73%, FL is 81% and PA 59%</strong></p><h3>Feature number 76</h3><p>Which represents facilities which: <strong>Staff provide mental health treatment services in Spanish</strong>. <strong>National mean or average of facilities is 95%, FL is 98% and PA 89%</strong></p><h3>Feature number 86</h3><p>Which represents facilities which: <strong>Staff provide mental health treatment services in Hindi</strong>. <strong>National mean or average of facilities is 16%, FL is 5% and PA 26%</strong></p><h3>Feature number 65</h3><p>Which represents facilities which: <strong>Facility offers dedicated mental health treatment program for veterans. National mean or average of facilities is 17%, FL is 26%, PA 14%</strong></p><h4>Let’s look at the last feature listed above (65) representing services for Veterans: Roughly 19.5 million Americans are veterans.</h4><p>According to a report by US Census Bureau roughly 18 million Americans, or about 7 percent of the adult population, who were veterans of the U.S. Armed Forces in 2018. This report uses data from the 2014 Survey of Income and Program Participation to describe the wealth of veterans of various ages. The projection for the veteran population for 2019 is 19.5 Million in 2020. (3) (4)</p><h3>I focused on veterans as a sample group to show cause and effect and potential impact of a lack of Mental Health facilities and services.</h3><p>As for full disclosure, I am an Army veteran which uses VA health services.</p><h3>“Recent military operations in Iraq and Afghanistan represent the most sustained ground combat operations involving American forces since the Vietnam era.”</h3><p>“Many military personnel experience high-intensity guerrilla warfare and the chronic threat of roadside bombs and improvised explosive devices. Some soldiers endure multiple tours of duty, many experience traumatic injury, and more of the wounded survive than ever before. Reports have suggested high rates of mental health disorders including posttraumatic stress disorder (PTSD), depression, and alcohol use disorders among active duty military personnel and veterans of Operation Iraqi Freedom (OIF) and, to a lesser extent, Operation Enduring Freedom (OEF).” <em>K. H. Seal </em>(5)</p><p>“In fiscal year (FY) 2017, over 1.7 million Veterans received mental health treatment in a VA mental health program; this number has risen each year from about 900,000 in FY2006. Nearly one-third (29.2 percent) of these patients received care from a mental health care provider working in the primary care clinic, while 350,000 (70.8 percent) had their depression documented by providers who only practice primary care.” (6)</p><h3>The Data shows: There is 1 Mental Health Facility per 100,000 Veterans Nationwide.</h3><p>As per facilities which <strong>offers dedicated mental health treatment program for veterans</strong> and only those included final N-MHSS-2019 report. Population base on the USA Census projection of Veteran 2019 population. (4)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*7jtO2N6cN975VEXg" /><figcaption>(U.S. Air Force photo by Staff Sgt. Joshua Magbanua)<em> (Photo Credit: Staff Sgt. Joshua Joseph Magbanua)</em></figcaption></figure><h3>“Lack of access to mental health services contributing to the high suicide rates among veterans” Ronal D. Hester (7)</h3><p>So If we take a population such as Veterans that are at significant risk to be affected by mental illness. You add the effects of Covid-19 pandemic and how it is projected to affect our general population in the USA. The situation for veterans currently dealing with mental health issues that our part of our communities could aggravate. For those veterans who are not affected by combat traumas or that are not using mental health facilities. We could see a spike in mental health issues in this cohort as part of the general risk pool of the general population.</p><h3>Conclusion</h3><p>If we take the NIMH’s number of <strong>46.6 million U.S. Adults</strong>, that live with a mental illness in 2017. Let’s assume that levels of mental illness have remained flat, that is still a staggering 14% of US adults dealing with a mental illness. Obviously, to deal with any health challenges, you need health facilities and access to services.</p><p><strong>Veterans represent a unique segment of the population</strong>. Specially at risk for mental health illness for the reasons listed above. I think using the veterans as a sample population gives us insight into our Mental Health system capacity and efficacy and potential pitfalls.</p><p><strong>Covid-19 has shown American public deficiencies we have in our society and systems.</strong> Many systems such as state unemployment, schools, health facilities and supply chains, to mention a few, our being stress to their full capacity. The Mental Health system could be one that gets stress in the aftermath of the covid-19 pandemic, to deadly and disastrous consequences, unless we direct attention and resources into that Health segment.</p><p>The number of Mental Health facilities and the services these facilities provide it is just one aspect of the overall mental health outcome picture. I invite the readers to visit some work cited as well as <a href="https://www.mhanational.org/issues/ranking-states">https://www.mhanational.org/issues/ranking-states</a></p><p><strong>Work cited:</strong></p><p>(1) <a href="https://www.census.gov/data/tables/time-series/demo/popest/2010s-state-total.html#par_textimage">https://www.census.gov/data/tables/time-series/demo/popest/2010s-state-total.html#par_textimage</a></p><p>(2) Substance Abuse and Mental Health Services Administration, National Mental Health Services Survey (N-MHSS): 2019. Data on Mental Health Treatment Facilities. Rockville, MD: Substance Abuse and Mental Health Services Administration, 2020.</p><p>(3) Anon (2020) <a href="http://va.gov/">Va.gov</a>. Available at: <a href="https://www.va.gov/vetdata/docs/Demographics/New_Vetpop_Model/Vetpop_Infographic2020.pdf">https://www.va.gov/vetdata/docs/Demographics/New_Vetpop_Model/Vetpop_Infographic2020.pdf</a> (Accessed: 26 August 2020).</p><p>(4) <a href="https://www.census.gov/topics/population/veterans.html#:~:text=This%20report%20looks%20at%20the,U.S.%20Armed%20Forces%20in%202018.&amp;text=This%20report%20uses%20data%20from,of%20veterans%20of%20various%20ages">https://www.census.gov/topics/population/veterans.html#:~:text=This report looks at the,U.S. Armed Forces in 2018.&amp;text=This report uses data from, of veterans of various ages</a>.</p><p>(5) <em>Seal, K. H. Seal, K. (2007) “Bringing the War Back Home”, Archives of Internal Medicine, 167(5), p. 476. doi: 10.1001/archinte.167.5.476.</em></p><p>(6) (2020) <a href="http://mentalhealth.va.gov/">Mentalhealth.va.gov</a>. Available at: <a href="https://www.mentalhealth.va.gov/docs/VA-Office-of-Mental-Health-and-Suicide-Prevention-Guidebook-June-2018-FINAL-508.pdf">https://www.mentalhealth.va.gov/docs/VA-Office-of-Mental-Health-and-Suicide-Prevention-Guidebook-June-2018-FINAL-508.pdf</a> (Accessed: 26 August 2020).</p><p>(7) Ronal D. Hester Health Care Administration, Nicole Wertheim College of Nursing &amp; Human Services, Florida International University, Miami, FL 33199 USA</p><p><a href="https://github.com/urenajose/DS-Unit-1-Build/blob/master/National_Mental_Health_Unit_1_build.ipynb">GitHub codebook</a></p><h4><strong>Datasets utilized</strong></h4><ul><li><a href="https://www.datafiles.samhsa.gov/sites/default/files/field-uploads-protected/studies/N-MHSS-2019/N-MHSS-2019-datasets/N-MHSS-2019-DS0001/N-MHSS-2019-DS0001-bundles-with-study-info/N-MHSS-2019-DS0001-bndl-data-tsv.zip">https://www.datafiles.samhsa.gov/sites/default/files/field-uploads-protected/studies/N-MHSS-2019/N-MHSS-2019-datasets/N-MHSS-2019-DS0001/N-MHSS-2019-DS0001-bundles-with-study-info/N-MHSS-2019-DS0001-bndl-data-tsv.zip</a><br>Shape (12472, 140)</li><li><a href="https://raw.githubusercontent.com/urenajose/DS-Unit-1-Build/master/USApopestimate2019.csv">https://raw.githubusercontent.com/urenajose/DS-Unit-1-Build/master/USApopestimate2019.csv</a><br>Shape (52, 6)</li><li><a href="https://www2.census.gov/programs-surveys/popest/datasets/2010-2019/national/totals/nst-est2019-popchg2010_2019.csv?#">https://www2.census.gov/programs-surveys/popest/datasets/2010-2019/national/totals/nst-est2019-popchg2010_2019.csv?#</a><br>Shape(57, 67)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa75a08243ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>