<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.2">Jekyll</generator><link href="https://lsaa2014.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://lsaa2014.github.io/" rel="alternate" type="text/html" /><updated>2022-05-05T13:33:32+00:00</updated><id>https://lsaa2014.github.io/feed.xml</id><title type="html">Danielle Taneyo</title><subtitle>Data Science Portfolio.</subtitle><author><name>Danielle Taneyo</name></author><entry><title type="html">SimpleStats or statistics for all</title><link href="https://lsaa2014.github.io/SimpleStats/" rel="alternate" type="text/html" title="SimpleStats or statistics for all" /><published>2022-05-05T00:00:00+00:00</published><updated>2022-05-05T00:00:00+00:00</updated><id>https://lsaa2014.github.io/SimpleStats</id><content type="html" xml:base="https://lsaa2014.github.io/SimpleStats/">&lt;p&gt;&lt;img src=&quot;https://lsaa2014.github.io/images/logo3.png&quot; alt=&quot;image-left&quot; class=&quot;align-left&quot; width=&quot;150&quot; height=&quot;150&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;background&quot;&gt;Background&lt;/h3&gt;

&lt;p&gt;Many people can’t afford to pay tools for their data analysis, others don’t have the time to learn new stuffs. We all need statistics, whether is just to create a simple graph like a histogram or to do t-test or more complex things.  &lt;br /&gt;
The goal of this app is to make data analysis easier. If you want to do a t-test, Anova, PCA, PLS or create a heatmap without writing any code this app is right for you. You can also create a bar graph, boxplot or a scatterplot to show the result.&lt;/p&gt;

&lt;!-- blank line --&gt;
&lt;figure class=&quot;video_container&quot;&gt;
  &lt;iframe src=&quot;https://drive.google.com/file/d/1OjS_KF24JCkYemvoeO1qYVLJoT1yUjYt/preview&quot; width=&quot;640&quot; height=&quot;480&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;true&quot;&gt;&lt;/iframe&gt;
&lt;/figure&gt;
&lt;!-- blank line --&gt;

&lt;p&gt;Go and play &lt;a href=&quot;https://simplestatsv0.herokuapp.com/&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to send me your feedback or any bug on my Linkedin&lt;/p&gt;</content><author><name>Danielle Taneyo</name></author><category term="streamlit" /><category term="t-test" /><category term="dataviz" /><category term="PCA/PLS" /><summary type="html">Background</summary></entry><entry><title type="html">Predict heart failure using ML</title><link href="https://lsaa2014.github.io/HeartApp/" rel="alternate" type="text/html" title="Predict heart failure using ML" /><published>2021-08-01T00:00:00+00:00</published><updated>2021-08-01T00:00:00+00:00</updated><id>https://lsaa2014.github.io/HeartApp</id><content type="html" xml:base="https://lsaa2014.github.io/HeartApp/">&lt;h3 id=&quot;background&quot;&gt;Background&lt;/h3&gt;

&lt;p&gt;Most of the models created for modeling survival for heart failure are only moderately accurate, and the predictive factors have limited interpretability.
Recent models have shown improvements, particularly when the survival 
outcome is combined with additional targets (for example, hospitalization). 
Despite the fact that scientists have identified a large number of predictors and indicators, there is no consensus on their relative importance in predicting survival &lt;a href=&quot;https://bmcmedinformdecismak.biomedcentral.com/articles/10.1186/s12911-020-1023-5#Sec8&quot;&gt;1&lt;/a&gt;. &lt;br /&gt;
The app uses the dataset from this study.  &lt;br /&gt;
The variables used are Age, Anaemia, High blood pressure, Creatinine phosphokinase, Diabetes, Ejection fraction, Sex, Platelets, Serum creatinine, Serum sodium, Smoking, Time and the target (death event).
The authors find that Random forest is the best algorithm, which corroborates my results.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://lsaa2014.github.io/images/heart/heartML.JPG&quot; alt=&quot;&quot; width=&quot;780&quot; height=&quot;600&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Go and play &lt;a href=&quot;https://heartfailureapp.herokuapp.com/&quot;&gt;here&lt;/a&gt;&lt;/p&gt;</content><author><name>Danielle Taneyo</name></author><category term="streamlit" /><category term="plotly" /><category term="heart failure" /><category term="ML" /><summary type="html">Background</summary></entry><entry><title type="html">Find foods rich in some nutrients</title><link href="https://lsaa2014.github.io/FoodNut/" rel="alternate" type="text/html" title="Find foods rich in some nutrients" /><published>2021-07-29T00:00:00+00:00</published><updated>2021-07-29T00:00:00+00:00</updated><id>https://lsaa2014.github.io/FoodNut</id><content type="html" xml:base="https://lsaa2014.github.io/FoodNut/">&lt;h3 id=&quot;background&quot;&gt;Background&lt;/h3&gt;

&lt;p&gt;With the rising of chronic diseases, cardiovascular disease, high blood pressure, type 2 diabetes, some cancers, LDL-cholesterol, and poor bone health, consumers are looking for food rich in some nutrients or compounds to prevent them.&lt;br /&gt;
Some of my friends and family usually ask me: which food is rich in calcium or iron? because I need more of these. I don’t always remember the food content that’s why I created this small dataviz. So, my goal here is to show to a consumer a list of foods rich in some nutrients like fiber, iron.&lt;/p&gt;

&lt;!-- blank line --&gt;
&lt;figure class=&quot;video_container&quot;&gt;
  &lt;iframe src=&quot;https://drive.google.com/file/d/1NU5W-SqmbRfUQcw65Lz3Q1S1V_pgsAi8/preview&quot; width=&quot;640&quot; height=&quot;480&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;true&quot;&gt;&lt;/iframe&gt;
&lt;/figure&gt;
&lt;!-- blank line --&gt;

&lt;p&gt;You can find the app &lt;a href=&quot;https://share.streamlit.io/lsaa2014/food_app/FoodNutrients.py&quot;&gt;here&lt;/a&gt;&lt;/p&gt;</content><author><name>Danielle Taneyo</name></author><category term="streamlit" /><category term="plotly" /><summary type="html">Background</summary></entry><entry><title type="html">Multiple models Nesarc data (with Python)</title><link href="https://lsaa2014.github.io/NesarcRF/" rel="alternate" type="text/html" title="Multiple models Nesarc data (with Python)" /><published>2021-01-25T00:00:00+00:00</published><updated>2021-01-25T00:00:00+00:00</updated><id>https://lsaa2014.github.io/NesarcRF</id><content type="html" xml:base="https://lsaa2014.github.io/NesarcRF/">&lt;p&gt;&lt;img src=&quot;https://lsaa2014.github.io/images/nesarc/nih.jpeg&quot; alt=&quot;image-center&quot; class=&quot;align-center&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;can-we-predict-the-antisocial-disorder-among-young-girls-aged-between-18-28-years-old&quot;&gt;Can we predict the antisocial disorder among young girls aged between 18-28 years old?&lt;/h2&gt;

&lt;h3 id=&quot;background&quot;&gt;Background&lt;/h3&gt;
&lt;p&gt;On the last post I used decision tree for prediction. On this one I will used random forest and logistic regression.
The predictors are:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;em&gt;S1Q6A&lt;/em&gt; HIGHEST GRADE OR YEAR OF SCHOOL COMPLETED&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;S1Q11A&lt;/em&gt; TOTAL FAMILY INCOME IN LAST 12 MONTHS&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;MAJORDEPLIFE&lt;/em&gt; MAJOR DEPRESSION IN LAST 12 MONTHS&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;SOCPDLIFE&lt;/em&gt; SOCIAL PHOBIA - LIFETIME (NON-HIERARCHICAL)&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;GENAXLIFE&lt;/em&gt; GENERALIZED ANXIETY DISORDER - LIFETIME&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;HISTDX2&lt;/em&gt; HISTRIONIC PERSONALITY DISORDER (LIFETIME DIAGNOSIS)&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;S11BQ1&lt;/em&gt; (BLOOD/NATURAL FATHER EVER HAD BEHAVIOR PROBLEMS)&lt;/li&gt;
  &lt;li&gt;REGION&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here I use sklearn pipeline.&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sklearn.pipeline&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Pipeline&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sklearn.preprocessing&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;StandardScaler&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;OneHotEncoder&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sklearn.compose&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ColumnTransformer&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;cat_col&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'MAJORDEPLIFE'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'HISTDX2'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'S11BQ1'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'SOCPDLIFE'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'GENAXLIFE'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'REGION'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;num_col&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'S1Q11A'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'S1Q6A'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;numeric_transformer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Pipeline&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;steps&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'scaler'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;StandardScaler&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())])&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;categorical_transformer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Pipeline&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;steps&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'onehot'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;OneHotEncoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;handle_unknown&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'ignore'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))])&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;preproces&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ColumnTransformer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;transformers&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'num'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numeric_transformer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num_col&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'cat'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;categorical_transformer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cat_col&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)])&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;classifiers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;RandomForestClassifier&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;LogisticRegression&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()]&lt;/span&gt; 

&lt;span class=&quot;c1&quot;&gt;#  Create the pipeline for each model and evaluate
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;acc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;model_names&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;clf&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;enumerate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;classifiers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    
    &lt;span class=&quot;c1&quot;&gt;# Define pipeline with the model
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;full_pipeline&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Pipeline&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;steps&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'preprocessing'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;preproces&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                                    &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'model'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;clf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)])&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;#  Fit training data and define number of folds in Cross-Validation
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;full_pipeline&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cross_val_score&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;full_pipeline&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;scoring&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'accuracy'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
    
    &lt;span class=&quot;c1&quot;&gt;#  Display accuracy
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;model_names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;clf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;__class__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;__name__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'{} Training Score: {}'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model_names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;round&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;full_pipeline&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;score&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'{} Testing Score: {}'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model_names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;round&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;full_pipeline&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;score&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))&lt;/span&gt;
    
&lt;span class=&quot;c1&quot;&gt;#  Boxplot to visualize the scores
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;boxplot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;labels&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model_names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;showmeans&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xlabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Models'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ylabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Accuracy'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Using cross validation, we can see that logistic regression has a higher accuracy than random forest.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://lsaa2014.github.io/images/nesarc/rf_lg.png&quot; alt=&quot;&quot; width=&quot;680&quot; height=&quot;400&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;most-important-features&quot;&gt;Most important features?&lt;/h3&gt;

&lt;p&gt;The most important feature to predict the antisocial disorder among young girls are:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;S1Q11A TOTAL FAMILY INCOME IN LAST 12 MONTHS&lt;/li&gt;
  &lt;li&gt;S1Q6A HIGHEST GRADE OR YEAR OF SCHOOL COMPLETED&lt;/li&gt;
  &lt;li&gt;REGION&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;https://lsaa2014.github.io/images/nesarc/feat_imp.png&quot; alt=&quot;&quot; width=&quot;680&quot; height=&quot;400&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;to-conclude&quot;&gt;To conclude&lt;/h2&gt;

&lt;p&gt;Family of Young girls with a antisocial disorder (coded 1 = “YES” and 0 = “NO”) has lower income than those without. The income is a good predictor of this disorder.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://lsaa2014.github.io/images/nesarc/family_income.png&quot; alt=&quot;&quot; width=&quot;680&quot; height=&quot;400&quot; /&gt;&lt;/p&gt;</content><author><name>Danielle Taneyo</name></author><category term="Nesarc" /><category term="Random Forest" /><category term="Logistic Regression" /><category term="pipeline" /><summary type="html"></summary></entry><entry><title type="html">Decision Tree Nesarc data (with Python)</title><link href="https://lsaa2014.github.io/NesarcDT/" rel="alternate" type="text/html" title="Decision Tree Nesarc data (with Python)" /><published>2019-07-25T00:00:00+00:00</published><updated>2019-07-25T00:00:00+00:00</updated><id>https://lsaa2014.github.io/NesarcDT</id><content type="html" xml:base="https://lsaa2014.github.io/NesarcDT/">&lt;p&gt;&lt;img src=&quot;https://lsaa2014.github.io/images/nesarc/nih.jpeg&quot; alt=&quot;image-center&quot; class=&quot;align-center&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;can-we-predict-the-antisocial-disorder-among-young-girls-aged-between-18-28-years-old&quot;&gt;Can we predict the antisocial disorder among young girls aged between 18-28 years old?&lt;/h2&gt;

&lt;h3 id=&quot;bacground&quot;&gt;Bacground&lt;/h3&gt;

&lt;p&gt;NESARC (National Epidemiologic Survey on Alcohol and Related Conditions) is project from the National Institute on Alcohol Abuse and Alcoholism (NIAAA). It is cross-sectional, based on a nationally representative sample of the civilian noninstitutionalized population of the United States aged 18 years and older.&lt;/p&gt;

&lt;p&gt;I choose this study because I am particular interested in the antisocial disorder so I choose all the variables related to the antisocial personality disorder (behavior) and look if there exists an association between them and the family history (iv) of antisocial personality among young girls aged.&lt;/p&gt;

&lt;p&gt;A study done by Farrington in 1993[1], concluded that the development of adult social dysfunction depended not only on established causes of antisocial behaviour such as economic deprivation and poor parenting but also on causes of internalizing disorders such as childhood nervousness and social isolation. So probably the family story is related to the antisocial behaviour[2-3]. My hypothesis is that the antisocial behaviour is related to the family status.&lt;/p&gt;

&lt;h3 id=&quot;what-is-the-percent-of-girls-aged-18-to-28-having-bloodnatural-mother-behavior-problems&quot;&gt;What is the percent of girls aged 18 to 28 having blood/natural mother behavior problems?&lt;/h3&gt;

&lt;p&gt;After subsetting the data with adults having blood/natural mother behavior problems, I found that 66% are girls and 33% are boys.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://lsaa2014.github.io/images/nesarc/percent.png&quot; alt=&quot;&quot; width=&quot;680&quot; height=&quot;400&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;decision-tree&quot;&gt;Decision Tree?&lt;/h3&gt;

&lt;p&gt;The final data for my study included girls aged between 18-28 years old having a blood/natural mother with behaviour problems (N=330) from the Nesarc data.&lt;/p&gt;

&lt;p&gt;Decision tree analysis was used to test nonlinear relationships among a series of explanatory variables such as major depression, generalized anxiety disorder, social phobia, histrionic personality disorder, total family income in last 12 months and a binary categorical response variable which is antisocial disorder. My final subtree included only major depression and histrionic personality disorder as explanatory variables because they were the best contributors to evaluate the antisocial behaviour.&lt;/p&gt;

&lt;p&gt;•	The accuracy or how often is the classifier correct was 0.82
•	the area under the curve (auc) was 0.59&lt;/p&gt;

&lt;p&gt;Decision Tree&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://lsaa2014.github.io/images/nesarc/nesarc.png&quot; alt=&quot;&quot; width=&quot;680&quot; height=&quot;400&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Roc curve&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://lsaa2014.github.io/images/nesarc/roc_curve.png&quot; alt=&quot;&quot; width=&quot;680&quot; height=&quot;400&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;to-conclude&quot;&gt;To conclude&lt;/h2&gt;

&lt;p&gt;The histrionic personality disorder was the first variable to separate the sample into two subgroups. Young girls with a histrionic personality disorder with a value less than .5 meaning those without histrionic disorder (coded 1 = “YES” and 0 = “NO”) were 116 having also no major depression. Among girls with no major depression(coded 1 = “YES” and 0 = “NO”) and no histrionic disorder 44 of them don’t have antisocial disorder while only 8 do have it. Among girls with major depression(right split) meaning major depression greater than 0.5, 47 have antisocial disorder while only 17 don’t have it.&lt;/p&gt;

&lt;p&gt;The two terminal nodes on the right side tell us that among girls with histrionic disorder and major depression 4 don’t have antisocial disorder while 9 have it. And among those with histrionic disorder without major depression only 2 don’t have antisocial disorder and none have it.&lt;/p&gt;

&lt;h4 id=&quot;references&quot;&gt;References&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Farrington DP (1993) Childhood origins of teenage antisocial behaviour and adult social dysfunction. J R Soc Med 86 (1):13-17&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Johnson JG, Cohen P, Smailes E, Kasen S, Oldham JM, Skodol AE, Brook JS (2014) Adolescent personality disorders associated with violence and criminal behavior during adolescence and early adulthood. Am J Psychiatry&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Lee JY, Brook JS, Finch SJ, Brook DW (2015) An Adverse Family Environment During Adolescence Predicts Marijuana Use and Antisocial Personality Disorder in Adulthood. Journal of Child and Family Studies:1-8&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;</content><author><name>Danielle Taneyo</name></author><category term="Nesarc" /><category term="Decision Tree" /><category term="Python" /><summary type="html"></summary></entry><entry><title type="html">Breast Cancer Classification (Python)</title><link href="https://lsaa2014.github.io/BreastCancerClassification/" rel="alternate" type="text/html" title="Breast Cancer Classification (Python)" /><published>2018-12-07T00:00:00+00:00</published><updated>2018-12-07T00:00:00+00:00</updated><id>https://lsaa2014.github.io/BreastCancerClassification</id><content type="html" xml:base="https://lsaa2014.github.io/BreastCancerClassification/">&lt;p&gt;&lt;img src=&quot;https://lsaa2014.github.io/images/breast_cancer/breastCancer.jpg&quot; alt=&quot;image-left&quot; class=&quot;align-left&quot; width=&quot;150&quot; height=&quot;150&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;using-machine-learning-to-predict-the-presence-of-breast-cancer&quot;&gt;Using machine learning to predict the presence of breast cancer?&lt;/h2&gt;

&lt;p&gt;From the last post, I will continue with the breast cancer dataset from University of Coimbra.&lt;/p&gt;

&lt;p&gt;Fortunatly, we don’t have missing values here. So, after some EDA, I used Lasso regression to select the most important predictors. Indeed, as the authors found, resistin, glucose, age and BMI are the most important.
data with zero, I considered it as Nans.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://lsaa2014.github.io/images/breast_cancer/Feat_imp.png&quot; alt=&quot;&quot; width=&quot;680&quot; height=&quot;400&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I used the algorithms from the paper: Logistic regression, SVM, Random Forest and others from scikit learn package: KNeighbors, Gaussian NB and DecisionTree. I calculated the recall on the training set which is 70% of the dataset. Here is the result&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://lsaa2014.github.io/images/breast_cancer/recall.JPG&quot; alt=&quot;&quot; width=&quot;380&quot; height=&quot;200&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Gaussian NB gave the highest recall/sensitivity of 87.5% which is within the range of [82.2%, 87.5%] on the paper. Compared to the paper SVM did not perform well here. I did not calculate the specificity here, so there much work to do.&lt;/p&gt;

&lt;h3&gt; What about the ROC curve? &lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;https://lsaa2014.github.io/images/breast_cancer/roc.png&quot; alt=&quot;&quot; width=&quot;680&quot; height=&quot;400&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The area under the curve of Gaussian NB is 76, this is less than the one of the paper, there is more feature engineering and tune parameters to do.
The most important parameters found where the same of the paper so we are on the right way to increase these metrics.&lt;/p&gt;</content><author><name>Danielle Taneyo</name></author><category term="Breast Cancer" /><category term="University of Coimbra" /><category term="Classification" /><category term="Python" /><summary type="html"></summary></entry><entry><title type="html">EDA of Breast Cancer University of Coimbra (with R)</title><link href="https://lsaa2014.github.io/BreastCancerEDA/" rel="alternate" type="text/html" title="EDA of Breast Cancer University of Coimbra (with R)" /><published>2018-10-30T00:00:00+00:00</published><updated>2018-10-30T00:00:00+00:00</updated><id>https://lsaa2014.github.io/BreastCancerEDA</id><content type="html" xml:base="https://lsaa2014.github.io/BreastCancerEDA/">&lt;p&gt;&lt;img src=&quot;https://lsaa2014.github.io/images/breast_cancer/breastCancer.jpg&quot; alt=&quot;image-left&quot; class=&quot;align-left&quot; width=&quot;150&quot; height=&quot;150&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;background&quot;&gt;Background&lt;/h2&gt;
&lt;p&gt;Breast cancer is an uncontrolled growth of epithelial cells originating in the ducts or breast lobules Carbone et al (1993). Breast cancer is the primary cause of cancer in women, accounting for one-third of all cancers. It is important to use routine blood analysis for breast cancer diagnosis.&lt;/p&gt;

&lt;h2 id=&quot;data&quot;&gt;Data&lt;/h2&gt;
&lt;p&gt;In this is exploratory analysis, I will use Breast Cancer data set from University of Coimbra. The data is from the &lt;a href=&quot;https://archive.ics.uci.edu/ml/datasets/Breast+Cancer+Coimbra#&quot;&gt;Uci archive&lt;/a&gt; using R. The paper can be found &lt;a href=&quot;https://bmccancer.biomedcentral.com/articles/10.1186/s12885-017-3877-1&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This data consist of 116 observations of 10 variables. The variables are:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Age (years)&lt;/li&gt;
  &lt;li&gt;BMI (kg/m2)&lt;/li&gt;
  &lt;li&gt;Glucose (mg/dL)&lt;/li&gt;
  &lt;li&gt;Insulin (µU/mL)&lt;/li&gt;
  &lt;li&gt;HOMA&lt;/li&gt;
  &lt;li&gt;Leptin (ng/mL)&lt;/li&gt;
  &lt;li&gt;Adiponectin (µg/mL)&lt;/li&gt;
  &lt;li&gt;Resistin (ng/mL)&lt;/li&gt;
  &lt;li&gt;MCP-1 (pg/dL)&lt;/li&gt;
  &lt;li&gt;Class variable (1 or 2) (1 means Healthy controls and 2 Patients)     &lt;br /&gt;
The class variable is the dependent or response variable.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;On this analysis, I want to respond to two questions:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Can Glucose, resistin and BMI can be used as biomarkers of breast cancer?&lt;/li&gt;
  &lt;li&gt;Is there a relationship between resistin and MCP-1?&lt;br /&gt;
The original data has 500 tested negatives and 268 positives after removing the missing values, we have 262 tested negatives and 130 positives.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;can-glucose-resistin-and-bmi-can-be-used-as-biomarkers-of-breast-cancer&quot;&gt;Can Glucose, resistin and BMI can be used as biomarkers of breast cancer?&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;BMI       &lt;br /&gt;
&lt;img src=&quot;https://lsaa2014.github.io/images/breast_cancer/ecdf_bmi.png&quot; alt=&quot;&quot; width=&quot;680&quot; height=&quot;400&quot; /&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On the above plot, we can see the empirical cumulative distribution function (ECDF) of BMI. It shows for any given number the percent of individuals that are below that threshold. We can see that for BMI equals to 32.5, we have around 75% of healthy below that value and 87.5% of unhealthy below it. In other word, there are more (25%) healthy people with BMI above 32.5 than unhealthy (12.5%).&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Glucose and resistin    &lt;br /&gt;
&lt;img src=&quot;https://lsaa2014.github.io/images/breast_cancer/glucose_resistin_by_class.png&quot; alt=&quot;&quot; width=&quot;680&quot; height=&quot;400&quot; /&gt;      &lt;br /&gt;
This plot shows that both glucose and resistin are higher on unhealthy patients than healthy.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;is-there-a-relationship-between-resistin-and-mcp-1&quot;&gt;Is there a relationship between resistin and MCP-1?&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;https://lsaa2014.github.io/images/breast_cancer/resistin_mcp.png&quot; alt=&quot;&quot; width=&quot;680&quot; height=&quot;400&quot; /&gt;      &lt;br /&gt;
There is a moderately strong relationship between resistin and MCP-1.&lt;/p&gt;

&lt;h2 id=&quot;to-conclude&quot;&gt;To conclude&lt;/h2&gt;
&lt;p&gt;From this analysis, we can see that Glucose, resistin and BMI could be used as biomarkers of breast cancer.&lt;/p&gt;</content><author><name>Danielle Taneyo</name></author><category term="Breast Cancer" /><category term="EDA" /><category term="R" /><category term="University of Coimbra" /><summary type="html"></summary></entry><entry><title type="html">Pima Indians diabete dataviz</title><link href="https://lsaa2014.github.io/DiabetesdataViz/" rel="alternate" type="text/html" title="Pima Indians diabete dataviz" /><published>2018-09-14T00:00:00+00:00</published><updated>2018-09-14T00:00:00+00:00</updated><id>https://lsaa2014.github.io/DiabetesdataViz</id><content type="html" xml:base="https://lsaa2014.github.io/DiabetesdataViz/">&lt;p&gt;Below we can see the correlation between Bmi and others variable (age, plasma glucose concentration, Diastolic blood pressure, Triceps skin fold thickness and Diabetes pedigree function).&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Correlation between Bmi and Triceps skin fold thickness is stronger for those who tested negative&lt;/li&gt;
  &lt;li&gt;As Bmi increased Triceps skin fold thickness increased also&lt;/li&gt;
  &lt;li&gt;Correlation between Bmi and Age seemed negative for positive test&lt;/li&gt;
  &lt;li&gt;With average Bmi more than 34, we found many positive and specially after more than 13 time of pregnant&lt;/li&gt;
  &lt;li&gt;With pedigree function more than 1.8 it is most likely that the test be positive&lt;/li&gt;
&lt;/ul&gt;
&lt;iframe src=&quot;https://public.tableau.com/views/Diabete_2/Diabetedashboard?:showVizHome=no&amp;amp;:embed=true&quot; width=&quot;85%&quot; height=&quot;800&quot;&gt;&lt;/iframe&gt;</content><author><name>Danielle Taneyo</name></author><category term="diabete" /><category term="DataViz" /><category term="Tableau" /><summary type="html">Below we can see the correlation between Bmi and others variable (age, plasma glucose concentration, Diastolic blood pressure, Triceps skin fold thickness and Diabetes pedigree function). Correlation between Bmi and Triceps skin fold thickness is stronger for those who tested negative As Bmi increased Triceps skin fold thickness increased also Correlation between Bmi and Age seemed negative for positive test With average Bmi more than 34, we found many positive and specially after more than 13 time of pregnant With pedigree function more than 1.8 it is most likely that the test be positive</summary></entry><entry><title type="html">Red Wine data visualization</title><link href="https://lsaa2014.github.io/RedWinedataViz/" rel="alternate" type="text/html" title="Red Wine data visualization" /><published>2018-07-23T00:00:00+00:00</published><updated>2018-07-23T00:00:00+00:00</updated><id>https://lsaa2014.github.io/RedWinedataViz</id><content type="html" xml:base="https://lsaa2014.github.io/RedWinedataViz/">&lt;p&gt;&lt;img src=&quot;https://lsaa2014.github.io/images/vino.jpg&quot; alt=&quot;image-center&quot; class=&quot;align-center&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Below we can see the correlation between pH/citric, sulphates/chlorides, pH/quality and alcohol/ quality on red wine.&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Correlation between pH and citric acid is stronger for high quality wine&lt;/li&gt;
  &lt;li&gt;As the quality decreased correlation between suphates and chlorides decreased also&lt;/li&gt;
  &lt;li&gt;High and medium wine have low pH&lt;/li&gt;
  &lt;li&gt;The average alcohol percentage of high quality wine is 11.5.&lt;/li&gt;
&lt;/ul&gt;

&lt;iframe src=&quot;https://public.tableau.com/views/Wine_Sul_Chl/Dashboard1?:showVizHome=no&amp;amp;:embed=true&quot; width=&quot;90%&quot; height=&quot;600&quot;&gt;&lt;/iframe&gt;

&lt;p&gt;NB. Watch out here the decimal separator is a comma instead of a dot, sorry for the confusion.&lt;/p&gt;</content><author><name>Danielle Taneyo</name></author><category term="red wine" /><category term="DataViz" /><category term="Tableau" /><summary type="html">Below we can see the correlation between pH/citric, sulphates/chlorides, pH/quality and alcohol/ quality on red wine. Correlation between pH and citric acid is stronger for high quality wine As the quality decreased correlation between suphates and chlorides decreased also High and medium wine have low pH The average alcohol percentage of high quality wine is 11.5.</summary></entry><entry><title type="html">Pima Indians Diabetes Classification (with Python)</title><link href="https://lsaa2014.github.io/DiabeteClassification/" rel="alternate" type="text/html" title="Pima Indians Diabetes Classification (with Python)" /><published>2018-07-07T00:00:00+00:00</published><updated>2018-07-07T00:00:00+00:00</updated><id>https://lsaa2014.github.io/DiabeteClassification</id><content type="html" xml:base="https://lsaa2014.github.io/DiabeteClassification/">&lt;p&gt;&lt;img src=&quot;https://lsaa2014.github.io/images/diabetes/pima indians.jpeg&quot; alt=&quot;image-left&quot; class=&quot;align-left&quot; width=&quot;150&quot; height=&quot;150&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;use-machine-learning-to-predict-if-a-female-will-be-tested-positive-or-not-for-diabete&quot;&gt;Use machine learning to predict if a female will be tested positive or not for Diabete?&lt;/h2&gt;

&lt;p&gt;From the last post, we will continue with the diabetes dataset.&lt;/p&gt;

&lt;p&gt;The first 5 rows show that there are many zero value in some columns, because we can’t have biological
data with zero, I considered it as Nans.&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;   &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;
   &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;pandas&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;
   &lt;span class=&quot;c1&quot;&gt;## Read the file
&lt;/span&gt;   &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;read_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'pima-indians-diabetes.data.txt'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;names&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Number_times_pregnant'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'PlasmaGlu'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; 
   &lt;span class=&quot;s&quot;&gt;'Dbpressure'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'Tricep_thickness'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'Hour_serum_insulin'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Bmi'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'Dpfunction'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'Age'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'Class variable'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
   &lt;span class=&quot;c1&quot;&gt;## Read the first 5 rows
&lt;/span&gt;   &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Here’s the first rows.           &lt;br /&gt;
&lt;img src=&quot;https://lsaa2014.github.io/images/diabetes/head_diabete.JPG&quot; alt=&quot;&quot; width=&quot;680&quot; height=&quot;400&quot; /&gt;    &lt;br /&gt;
I choose to replace all the 0/nans with the median by each class.&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;   &lt;span class=&quot;c1&quot;&gt;## Imputing nans with median from each class
&lt;/span&gt;   &lt;span class=&quot;n&quot;&gt;df1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fillna&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;groupby&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Class variable'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'median'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Here’s the first rows after imputing.
&lt;img src=&quot;https://lsaa2014.github.io/images/diabetes/head_after_imp.JPG&quot; alt=&quot;&quot; width=&quot;680&quot; height=&quot;400&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Just to remember, we have 2 classes: 0 and 1.
I used five algorithms from scikit learn package: KNeighbors, Random Forest, Gaussian NB, ExtraTrees and DecisionTree. Here is the accuracy on the training set.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://lsaa2014.github.io/images//diabetes/acc_target.JPG&quot; alt=&quot;&quot; width=&quot;380&quot; height=&quot;200&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Random forest model and decision tree gave the highest accuracy around 88% and we can have also the most important predictors.  &lt;br /&gt;
Let’s examine also the confusion matrix. We have:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;True negative (TN) = 139&lt;/li&gt;
  &lt;li&gt;True positive (TP) = 63&lt;/li&gt;
  &lt;li&gt;False negative (FN) = 18&lt;/li&gt;
  &lt;li&gt;False positive (FP) = 11&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because it’s better to predict a person which is negative as positive than a person which is positive as negative, the worse case here would be FN. So, in this case recall is a better metric, let’s calculate it. Recall is, out of the positive class, how many did I correctly predict as positive?    &lt;br /&gt;
Recall = TP / FN + TP -&amp;gt; 63 / (18+63) which is 0.78 &lt;br /&gt;
And precision, out of the cases I predicted be positive, how many are really positives?&lt;br /&gt;
Precision = TP / FP + TP -&amp;gt; 63 / (11+63) which is 0.85     &lt;br /&gt;
This is not so good because recall should be higher than precision for this problem.&lt;br /&gt;
&lt;img src=&quot;https://lsaa2014.github.io/images//diabetes/conf_Mat_Dia.png&quot; alt=&quot;&quot; width=&quot;380&quot; height=&quot;200&quot; /&gt;&lt;/p&gt;

&lt;h3&gt; What about the weight of the 5 most important features? &lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;https://lsaa2014.github.io/images/diabetes/imp_feat_Diabete.png&quot; alt=&quot;&quot; width=&quot;680&quot; height=&quot;400&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The most important features to predict diabetes are : 2-Hour serum insulin (mu U/ml), Triceps skin fold thickness (mm) and Plasma glucose concentration a 2 hours in an oral glucose tolerance test. 
Indeed, these are important parameters to evaluate diabetes.&lt;/p&gt;</content><author><name>Danielle Taneyo</name></author><category term="Diabetes" /><category term="Pima Indians" /><category term="Classification" /><category term="Python" /><summary type="html"></summary></entry></feed>