<?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 Aytaj Khankishiyeva on Medium]]></title>
        <description><![CDATA[Stories by Aytaj Khankishiyeva on Medium]]></description>
        <link>https://medium.com/@khankishiyeva99?source=rss-13466bf5eb1c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*MORP9-Yn5-qeuyf5</url>
            <title>Stories by Aytaj Khankishiyeva on Medium</title>
            <link>https://medium.com/@khankishiyeva99?source=rss-13466bf5eb1c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 18:11:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@khankishiyeva99/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[GLM and Logistic Regression]]></title>
            <link>https://medium.com/@khankishiyeva99/glm-and-logistic-regression-96324e6b5a15?source=rss-13466bf5eb1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/96324e6b5a15</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[logistic-regression]]></category>
            <category><![CDATA[rstudio]]></category>
            <category><![CDATA[dataset]]></category>
            <category><![CDATA[general-linear-model]]></category>
            <dc:creator><![CDATA[Aytaj Khankishiyeva]]></dc:creator>
            <pubDate>Tue, 20 Jun 2023 19:21:18 GMT</pubDate>
            <atom:updated>2023-06-20T19:21:18.609Z</atom:updated>
            <content:encoded><![CDATA[<p>This project is worked on the College Dataset from the ISLR. The purpose of this project using logistic regression to build a model that allows us to predict whether a university is private or public.</p><p><strong>Analysis</strong></p><p>For defining business question which is focused on prediction of university is private or public. Firstly, I started my analysis with Exploratory data analysis and using descriptive statistics, I observed that college data set contains 777 observations with 19 variables. It has only 2 categorical variables (X and Private), 1 numeric (S.F.Ratio) and 16 variables (Apps, Accept, Enroll, Top10perc, Top25perc, F.Undergrad, P.Undergrad, Outstate, RoomBoard, Books, Personal, PhD, Terminal, perc.alumni, Expend and Grad Rate) are integer. The contents of College variables are following:</p><p>Private- A factor with levels No and Yes that shows private or public university. Yes indicates Private, No means Public University</p><p>Apps- Number of applications obtained</p><p>Accept- Number of applications accepted</p><p>Enroll- Number of new students enrolled to college</p><p>Top10perc- Percentage of new students from top 10% of H.S. class</p><p>Top25perc- Percentage of new students from top 25% of H.S. class</p><p>F.Undergrad- Number of full-time undergraduates</p><p>P.Undergrad- Number of part-time undergraduates</p><p>Outstate- Out-of-state tuition</p><p>Room Board- Costs of Room and board</p><p>Books- Estimated book costs</p><p>Personal- Estimated personal spending</p><p>PhD- Percentage of faculty with Ph.D.’s</p><p>Terminal- Percentage of faculty with terminal degree</p><p>S.F.Ratio- Student and faculty ratio</p><p>perc.alumni- Percentage of alumni who donate</p><p>Expend- Instructional expenditure(costs) per student</p><p>Grad Rate- Graduation rate</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*nyes7W951n8Dl09xH0qSNg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*rf3CphOZe1ov9atuOgj_1g.png" /></figure><p>Describe function provides us descriptive information about numerical variables of data set. It is seen that n which shows number of observations excluding missing values, is 777 for all variables. That means that there is no missing values and college dataset is clean. Higher standard deviation than mean is observed in Apps, Accept, Enroll, Full time Undergraduate, and part time Undergraduate and it indicates data are more spread like abnormal distribution and it shows high variation between values. Skewness points of Top 25 %, Outstate, Room Board, Student and Faculty Ratio and % of alumni who donate are closer to zero and that indicates symmetric data distribution and positive values for skewness shows data are skewed right. Skewness points for % of faculty PhD, % of faculty with Terminal degree and Graduate Rate are also closer to zero and negative, which means data is normally distribution and negative values means variables are left skewed. Additionally, kurtosis points of Apps, Accept, Part time Undergraduate, Books and Expenditure variables are higher that indicate sharper peak of distribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*aKULn-3HDfPMqqZMxiH2-w.png" /></figure><p>Let see distribution of target variables in graph and counts of each value. We saw that most of the universities are private and 212 of universities are public. It is easy to observe distribution of values in Private variable from bar plot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*NJXN3ukY1fYBsRkj_muyfQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*Tx5e7-nhh0eYujN3DsroFQ.png" /></figure><p>Help of count () function, we can define exact amount of observations occurred in each value of Private variable. We have 565 private and 212 public college observations in College data sat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*qrHLVkY9CtZgCKIRwYX2fA.png" /></figure><p>I divided number of new students who enrolled to new college to groups based on average number of new students enrolled to college: High enroll that shows having equal and more new students enrolled rather than average number (780) and Low enroll that shows having less than 780 new students enrolled to college. Now let’s determine high enrolled and low enrolled observations whether happen in private or public university?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*hgQIz8FhuvI4g4lsOpFBVQ.png" /></figure><p>In result of graph, high enrolled observations are mostly observed in public colleges while low enrolled observations are mostly seen in private colleges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*OP7kE4u9WMBoq_N2tJx9rg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*-nhzucnoBP-d9FkiZlFX6Q.png" /></figure><p>Further, I checked normality of Enroll variable by help of Q-Q plot that provides correlation between given sample and normal distribution of Enrolled new students, and Shapiro-Wilk’s method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*KshBNVpXzHIaqRaFGwtKiQ.png" /></figure><p>In result, plot shows that only few observations occurred in confidence bands. If points of variables are close to line and located in confidence bands, we might say that the normality assumption are completed. Within help of qqPlot, I obtained exact outliers (582, 367). Furthermore, when p-value is greater than 0.05, that indicates distribution of data are not significant different from normal distribution. It shows normality.</p><p>But in our case, p-value (&lt;2.2e-16) is less than 0.05. It means that Enroll variable isn’t in normality. W value isn’t also close to 1, which indicates the distribution isn’t close to normal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*OEVguQY70b2wMGe1VfEhBA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*OJaikP2ifKGS5Jj3kDr0Cw.png" /></figure><p>I also checked the normality of Graduate Rate by using Q-Q plot and Shapiro-Wilk’s normality test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*DTkmwjKLGn8h03PPWk-xqw.png" /></figure><p>In result of Shapiro-Wilk’s normality test, although W (0.9948) is close to 1 and shows distribution is close to normal, however p-value for Graduate Rate (0.009424) is less than 0.95, that indicates the distribution of Graduate rate variable are significant different from normal distribution and doesn’t assume normality of variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*NwYa9gqgD5w3RZ2Ul7spTQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*LWgRjIkHjzXQkkCpRowovQ.png" /></figure><p>Additionally, by help of boxplot, I observed number of application obtained, percentage of new students from top 10% of H.S. class and number of full time undergraduates’ distribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*AFbRyuzc40oKLbjJuWxUBw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*9YY1nELbf_WtVYwB-3GtVw.png" /></figure><p>Boxplot shows distribution of Application obtained. It is seen that number of application that isn’t normally distributed and have more outliers above upper boards of boxplot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*l9wcd4Zgs16giIaK4BdkaQ.png" /></figure><p>Second Boxplot shows distribution of % of new students from top 10% of H.S. class, and also this variable have more outliers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*8ybLx6ou8H6BWGf7-8meZQ.png" /></figure><p>Third boxplot shows the distribution of number of full time undergraduates. It is easily seen that this variable isn’t normally distributed and have more outliers in above upper whiskers of box plot.</p><p><strong>Split dataset into training and testing set.</strong></p><p>Before starting split data into train and test set, I prefer to remove X column which contains names of colleges to easily build model. Then, I split my dataset into training and testing set in proportion of 80/20, respectively. I observed 622 rows I have in training and 155 rows in testing set with 18 variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*l_1Y0dJsJMnWUZ8em6KS3w.png" /></figure><p>By help of glm () function I created model with all independent variables based on training data set and according to summary result of this model, I chose significant variables to create my best model on training data set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*fSN5G3teZXAl-Q1Le6SfPQ.png" /></figure><p>From the summary of first model, we can observe coefficients, standard error, z-value and p value. From the boxplot, I am already aware that Enroll, Graduate Rate, Top10percentage are not significant. Now we can easily see which variables are significant by looking significance codes in below of summary. It seems that Outstate variable is significant, Full time undergraduate is significant within 99.99%, percentage of alumni, books and number of applications are significant within 99%, Terminal and Graduate rate are considered significant within 95%, but again there is 10% risk for significance.</p><p>Further, I created my second model to be more preferred rather than first model, I chose more significant variables: Full time Undergraduate, Out of state tuition, and percentage of alumni who donate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*MOxT8YQ3fASS54me8FApIw.png" /></figure><p>Model contains actually significant variables. We should notice null deviance which represents the model with only the intercept, and no any predictors while residual deviance which is the model with all predictors. As we see, null deviance is same for both model, but second model’ s residual deviance is higher than first model. Having more difference between null and residual deviance indicates better prediction. Furthermore, AIC which is model comparison technique, it is used to compare to models with same data sets and having lower AIC score means more preferred the model. The first model with low AIC, we try to reach the model fits better to data, but there is such sitaution that if we try to get lower AIC by adding more variables, we might lose significance of variable and that indicates this insignificant variables doesn’t mean anything for our model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*HqgFPhqQl-nkd2WzGndtTg.png" /></figure><p>Now let’s look at second model’s coefficients which we got these coefficients in log odds, and their interpretation is different, so I converted it to odds. Interpretation of coefficients is like the odds of Private increase by a factor of 0.999 for each 1 unit increase in number of Full time undergraduate; the odds of Private variable increase by a factor of 1.0007 for each 1 unit increase in out of tuition; the odds of Private variable increase by a factor of 1.065 for each 1 unit increase in percentage of alumni who donate.</p><p>Then, I created confusion matrix for training data set. One of the essential thing, I want to point is to figure out where is true positive and true negative in confusion matrix table. In table, we have predictions in rows, references (it is also called the actual values) in top. True positive (435) means we predicted yes and actual values of data set is yes. True negative (150) means we predicted no and our actual values of data is no. False positive (20) means we predicted yes, but actual value is no. The last, false negative (17) means we predicted no, but actual value is yes.</p><p>It is really good to have higher true negative and true positive, it means that our prediction matches to the actual value. But we have 17 false negative, it means that we predict No in private (it is not private college), but it is actually private, it is much damaged for new students rather than we predict Yes in private (it is private college), but it is actually public, it is not much damaged for new students. It is good that my model have lower false negative, and it has low risk to get damage.</p><p>The measure of performance of classification model is about accuracy metric, which we oftenly use it and it is combination of (TN+TP)/(TN+FP+FN+TP). In this model, accuracy is 94.05%, and this indicates great model. The precision of model is combination of TP/(FP+TP) equals to 435/(20+435)=0.9560 or ~96%. Recall of model is combination of TP/(TP+FN) which is 0.9624 or 96.24%. Specifity of model is combination of TN/(TN+FP) which is 88.24% in model. Having 96% precision indicates, 96% of all examples we predicted as positive is actually positive. Same level Recall with precision means, what we predicted as positive is almost all examples are positive. Specifity means that 88.24% of data is negative, when we predict it as negative. It comes from having high true negative rather than false positive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*V2x43FANGWj5Ocy4x8D9aw.png" /></figure><p>Then I created confusion matrix based on testing data set. Model accuracy level now is 92.26% which is lower than training data set. But there is not higher difference between them. In confusion matrix, we see that True positive (110) means we predicted yes and actual values of data set is yes. True negative (22) means we predicted no and our actual values of data is no. False positive (9) means we predicted yes, but actual value is no. The last, false negative (3) means we predicted no, but actual value is yes.</p><p>It is really good to have higher true negative and true positive compared to false negative and false positive, it means that our prediction fits to the actual value. We have 3 false negative, it means that we predict No in private (it is not private college), but it is actually private, it is much damaged for new students rather than we predict Yes in private (it is private college), but it is actually public, it is not much damaged for new students. It is good that my model have lower false negative, and it has low risk to get damage.</p><p>The precision of model is combination of TP/(FP+TP) equals to 110/(9+110)=0.9243 or ~92%. Recall of model is combination of TP/(TP+FN) which is 0.9735 or 97.35%. Specifity of model is combination of TN/(TN+FP) which is 78.57% in model. Having 92% precision indicates, 92% of all examples we predicted as positive is actually positive. High level Recall compared to precision means that 97.35% of examples are selected as positive, but 92 of all examples predicted as positive is actually positive. Specifity means that 78.57% of data is negative, when we predict it as negative. It comes from having high true negative rather than false positive</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*fRjBqKGL9yP1XeqZB6Fucw.png" /></figure><p>I plot ROC curve for traing data set which is Receiver Operating Characteristic and means to visualize the performance of binary variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*-RtdbXAJH90mcOpxv4AubQ.png" /></figure><p>ROC for y axis is almost reaching maximum level of TPR and on x-axis of FPR. ROC curve shows our model is capable of perfect predictions. Both Sensitivy-TP rate and Specifity-FP rate are range from 0 to 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*21lVxSKiy5shrVVEV046VQ.png" /></figure><p>I plot ROC curve for testing data set to visualize the performance of binary variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*rinivUz-wn2ySsDLO6DT3w.png" /></figure><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*4I776bdo-YYdI-xM0tWgQw.png" /></figure><p>ROC for y axis is perfectly reaching to 0.6 of TPR and starts on x-axis 0.70 of FPR perfectly. ROC curve shows our model is capable of perfect predictions. Again curve is close to top-left corner, it means model performance is good. Both Sensitivy-TP rate and Specifity-FP rate are range from 0 to 1.</p><p>When comparing ROC curve for model based on training and testing data set, model with training data set shows much better performance.</p><p>AUC which stands for area under curve for training and testing data set, when it is close to 1, it means better for the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*-RKsCMhlExNE85npfI1UaQ.png" /></figure><p>I got 0.9784 AUC based on training data set and 0.969 on testing data set. It indicates that my model based on training data set shows much more better performance for prediction.</p><p><strong>Summary</strong></p><p>Using Generalized Linear Regression model, I was planing to determine whether university is private or not, I created model with significant variables and check their accuracy, precision, sensitivity and specity of predictions. I reached high level accuracy and prediction for my model and in result, help of ROC curve and AUC, I was being sure that my model will shows better performance for predictions at about 97–98%.</p><p><strong>Reference</strong></p><p>Zach. (2021, May 20). <em>What is considered a good AIC value?</em> Statology. Retrieved February 3, 2022, from</p><p><a href="https://www.statology.org/what-is-a-good-aic-value/">https://www.statology.org/what-is-a-good-aic-value/</a></p><p>Dalpiaz, D. (2020, October 28). <em>R for statistical learning</em>. Chapter 10 Logistic Regression. Retrieved February 3, 2022, from</p><p><a href="https://daviddalpiaz.github.io/r4sl/logistic-regression.html">https://daviddalpiaz.github.io/r4sl/logistic-regression.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96324e6b5a15" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bike Sharing Usage & Weather in Washington, D.C.]]></title>
            <link>https://medium.com/@khankishiyeva99/bike-sharing-usage-weather-in-washington-d-c-1dd1a3005c65?source=rss-13466bf5eb1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/1dd1a3005c65</guid>
            <category><![CDATA[dashboard]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[tableau]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Aytaj Khankishiyeva]]></dc:creator>
            <pubDate>Fri, 24 Jun 2022 03:21:24 GMT</pubDate>
            <atom:updated>2022-06-24T03:21:24.207Z</atom:updated>
            <content:encoded><![CDATA[<p>This project is worked on the hour and day data sets which is related to the two-year historical log corresponding to years 2011 and 2012 from Capital Bikeshare system, Washington D.C., USA which is publicly available in <a href="http://capitalbikeshare.com/system-data.">http://capitalbikeshare.com/system-data.</a> The purpose of this project to build research questions according to data and create visualizations to display solutions of questions. Data set in hour contains 17379 observations and 17 variables while data set about day contains 731 observations and 16 variables. The business question on project is about observation trend of bike rentals in timeline and defining the effects of weather and environmental factors on bicycle usage in Washington, D.C. We used Excel to observe data sets and Tableau to make visualizations to display insights from data sets. In following we can view data sets on RStudio to determine variable type and which variable will be our dimensions and measures in Tableau:</p><p>We can mean, median, min, maximum, 1st and 3rd quarter of boxplot for each variable in data sets.</p><p>It helps us to determine variables’ type like numeric, integer or categorical.</p><p><strong>Analysis</strong></p><p><strong>1.</strong> Display Averege casual and registered rentals over 2011–2012 years by months.</p><p>The graph shows average casual and registered rentals for 2011 and 2012 by months. The line chart is commonly used in display of changing variable over some period. That’s why we chose line chart to clearly observe change over particular period. At the top right side, we can see legend which describe meaning of lines color. Sea green color indicates average casual bicycle rentals while light red color means average registered rentals for bicycle.</p><p>It is clearly seen from the graph that bike demand has increased over a year in 2012 in comparison of 2011.<strong> </strong>For 2011 year, we observe that demand of bicycle rentals on Average Registered users began to increase from March and average number of bikes rentals show the highest amount for June at almost 3.8K while Average Casual user began to increase from February and reached the highest demand for July at 1200 level; then demand of bicyle usage for registered started to decrease slightly from June to July and dropped till December within about 2.5K numbers while casual usage started to drop suddenly and got minimum level at almost 1K. In 2022 the variable for both of registered and casual users depicts the variation of high and low demand. As they are inclined from March to September and reached maximum demand for registered and casual users; then they suddenly started to decrease until December.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*6jdMJGbfG4pWs_fRRaklIA.png" /></figure><p><strong>2.</strong> Show comparison of average rentals by total, registered and casual on weekday.</p><p>The graph shows Average bicycle rentals by total, registered and casual throughout weekday. At the right top side, we can see legend which shows average total count, registered and casual users by pink, light red and sea green, respectively. At top, we can see each weekday with measurements while at left axis, number of all particular measures.</p><p>It is obviously seen from graph, average total and registered demand are the highest level on Thursday while average casual demand doesn’t show high demand. The high demand for casual users on average is observed for weekend at 60 counts. In spite of average total and registered users are in high demand level, averege casual bicycle demand are low for between Monday and Friday and show the lowest demand on Wednesday at about 23 count.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*ESStWgfkqSQPJ1BDRXXBjQ.png" /></figure><p><strong>3.</strong> Define distribution of Average registered and casual amount of bike rental over 24 hour.</p><p>The graph shows distribution of average registered and casual bike rentals over 24 hour by help of bar chart. At the left axis shows average casual measures while numbers on bars show average registered bike rentals by labels.</p><p>We can define the lowest casual user is below 10 on 4:00 AM when average registered bike rentals also show the lowest level within 5 counts. It is obvious that averege casual amount is normally distrubuted in comparison of averege registered rentals. Almost from 6:00 AM, average casual rentals started to increase and reach the highest level at 2:00 pm and continuing at approximately same path until 6:00 pm; then goes down until 4:00 am and reach minimum average usage level at that time.</p><p>Contrast to casual users, registered for bike rentals start from 6:00 am and reach the high registration level at 8:00 am; after that time it goes down suddently until 10:00 am, shows fractuation until 3:00 pm. at 5:00 pm it shows actual amount with casual rentals in which it reach the highest registered numbers for rental bikes, then it begins to decline until 4:00 am and shows lowest registeration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*aDpy4XTrKMCtuiN8d14NXw.png" /></figure><p><strong>4.</strong> Define top 10 hour based on Average total number of bicycle rentals throughout Weekday.</p><p>The graph shows top 10 hours based on Average casual number of rental bike customer througout Weekday. We used stacked bar chart to show Weekday changes on top 10 hour by different color which we can define color meaning by help of legend at top right side.</p><p>From bar chart, we can see the highest demanded time is 2:00 PM in which Saturday and Sunday are the highest demanded day within 150 and 136 counts while the lowest demand time by top hour is 11:00 PM in which Saturday and Friday users are 26 and 19 counts, respectively. On 03:00 PM Saturday and Sunday demand are almost same within 151 and 131 counts, respectively. From 02:00 PM until 05:00 PM, Friday demand doesn’t change much while from 02:00 PM until 04:00 PM, Thursday demand are same count within 42–45.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*9S8c725LrSjmm5_ProEkLQ.png" /></figure><p><strong>5.</strong> Predict rental bikes based on summary of total bike rentals according to seasons.</p><p>The graph shows Monthly rental bikes according to seasons based on total summary of rentals. We used stacked bar chart on horizontal way, which make easier for us to read month names. At the top right side, we can see season legend which are describe by 4 different colors while left axis shows us months accordingly.</p><p>We can observe the highest total rentals on August within 351,194 counts in Fall season. Second high rentals happens on July in same season with 344,948 counts. First two months show the lowest total bicycle rentals which happen on Springer season. December and March are not appropriate months for rentals with lower demand in effect of Winter and early Summer period. Although that October is already considered winter season, it keeps high demand for bike rentals.</p><p>In a summary of graph, we can recommend October, September, August, July, June, and May can be ideal time for bike rentals. In other word, fall and summer can be the best period for bike rentals.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*Mgi7BVxXj_8AjOY-ZLe4Lg.png" /></figure><p><strong>6.</strong> Observe Average Count of bike rentals by effects of average actual temperature, humidity and windspeed in 2012 year.</p><p>The graph shows average users for 2012 year by affection of weather condition such as average actual temperature, average humidity and average windspeed by months. At the top right side, we can see legend which describe color meaning in which pink color indicates average count, yellow average actual temperature, brown means humidity and grey means average windspeed.</p><p>From the graph, we can see the highest average count on September by reaching maximum level at 300. We highlighted maximum points for average actual temperature at 0.6975, averege humidity at 0.6827 and averege windspeed at 0.2245; minimum points like 0.2750, 0.5079, and 0.1551, respectively. When average count reach highest level on September, average temperature is almost 0.6, humidity is 0.65 and windspeed is about 0.18 which they create ideal weather condition for bike riders. January is seen for the lowest demanded month with high humidity and windspeed, low temperature which is not prefered by bike riders for rentals.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*eSYIElDPw56wUQF9J-RFAA.png" /></figure><p><strong>7.</strong> Give prediction of Average Number of Customer on four weathersit throughout months.</p><p>The graph shows average number of total bike rentals on four weathersit by months. At the top right, we can see month legend by different colors from blue-January to light brown- December.</p><p>At the left axis, we can observe average count while at top there are mentioned weathersit types.We can see that high demand happens on clear sky and partly cloudy weather condition in which the highest demand are observed in September. Drizzle and few cloudy weather condition are also suitable for bike rental in which August is considered as the highest demanded month. At first glance, we can think that heavy snow, rains and thunderstorms are the worst condition for bike rentals, however in January with light snow and light rain condition show the lowest average bike demand within 50 counts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*qtrak-f-EITk_rwMaFEZ3w.png" /></figure><p>Final Dashboard is following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*VJhJf_QasK5CFXB8CrPAGQ.png" /></figure><p><strong>Conclusion</strong></p><p>In a summary, we achieved our research purpose by defining solution for business questions by help of tools such as Microsoft Excel, RStudio, and Tableau. We observed difference between casual and registered bike rentals, affectation of weather condition like humidity, temperature and windspeed; how to increase and decrease bike rentals in different seasons and weather sits; we observed hourly, weekly, monthly and yearly distribution of bicycle rentals and highlighted special points. At the end of each question, we defined which condition has been suitable for bike rentals on Washington D.C. location over 2011–2012.</p><p><strong>Reference</strong></p><p>1. Fanaee-T, H., &amp; Gama, J. (2013, December 20). UCI Machine Learning Repository: Bike Sharing Dataset Data Set. UCI Machine Learning Repository. Retrieved March 19, 2022, from <a href="https://archive.ics.uci.edu/ml/datasets/bike%2Bsharing%2Bdataset">https://archive.ics.uci.edu/ml/datasets/bike%2Bsharing%2Bdataset</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1dd1a3005c65" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Predictive Analysis using Logistic, Random Forest, Decision Tree, Gradient Boosting and K-Nearest…]]></title>
            <link>https://medium.com/@khankishiyeva99/predictive-analysis-using-logistic-random-forest-decision-tree-gradient-boosting-and-k-nearest-d13793603d8b?source=rss-13466bf5eb1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d13793603d8b</guid>
            <category><![CDATA[random-forest]]></category>
            <category><![CDATA[logistic-regression]]></category>
            <category><![CDATA[gradient-boosting]]></category>
            <category><![CDATA[knn]]></category>
            <category><![CDATA[decision-tree]]></category>
            <dc:creator><![CDATA[Aytaj Khankishiyeva]]></dc:creator>
            <pubDate>Wed, 01 Jun 2022 16:48:22 GMT</pubDate>
            <atom:updated>2022-06-01T16:48:22.357Z</atom:updated>
            <content:encoded><![CDATA[<h3>Predictive Analysis using Logistic, Random Forest, Decision Tree, Gradient Boosting and K-Nearest classification model with Python code</h3><p><strong>Introduction</strong></p><p>This project is worked on the census dataset which I will allocate link in reference section. The purpose of this project using a nearest neighbors’ model with provided data to create classification model that allows us to find which variables contribute affluency to reach equal payment among US citizens. We are going to define feature importance of variables, how these variables take role in this case, determination of K value and finally accuracy level of our model. Before starting classification model, firstly, we should make data cleaning on our data, make sure that we have clean data, prepare this dataset for classification.</p><p><strong>Data Cleaning</strong></p><p>From the part of summary of data set, our data set contains 48841 observations with 15 variables: ‘39’, ‘77516’, ‘13’, ‘2174’, ‘0’ and ‘40’ are quantitative variables while ‘State-gov’, ‘Bachelors’, ‘Never-married’, ‘Adm-clerical’, ‘Not-in-family’, ‘White’, ‘Male’, ‘United-States’ and ‘&lt;=50K’ are categorical variables. Statistics summary of numerical variables showed us count, min, max, mean, standard deviation and quartiles of boxplot. When we observe counts of numerical values, we identified that numerical variables of data set don’t have missing values. Furthermore, we didn’t define any null values in our dataset. However, it is not guarantee for clean data. We have check frequency of our variables to identify any special characters or values in dataset. When we observe frequency of whole variables, we identified ‘?’ mark in ‘State-gov’, ‘Adm-clerical’, and ‘United-States’ column. I determined that ‘?’ mark takes 5.7% (2799/48841) of ‘State-gov’, 5.8% (2809/48841) of ‘Adm-clerical’ and 1.8% (857/48841) of ‘United-States’ variable; thus, I decided remove question mark value from these columns. Additionally, after observing distribution of all variables, I determined that ‘2174’ and ‘0’ columns contain more than 50% zero values which I thought have replaced missing values. From my perspective, having more than half of column with unnecessary values will not indicate any essential information for our model; therefore, I removed these two columns from our dataset. After this cleaning, we have 45221 values with 13 variables.</p><p>From the exploratory analysis part, I checked each variables distribution by visualization of each variable on Histogram; thus, I defined that ‘Private’ value takes high portion of ‘State-gov’ variable while rest of values takes below than 5000 counts of variable. Comparing with ‘State-gov’ and ‘Bachelors’ variables have normal distribution among values while ‘HS-grad’, ‘Some-college’, ‘Bachelors’ values are three high observed values in this column. For variable- ‘Never-married’, I noticed that ‘Married-civ-spouse’ takes almost half of whole column while ‘Married-AF-spouse’ is just 32 values out of 45221. For ‘Adm-clerical’ variable, we noticed 14 unique values in which ‘Craft-repair’, ‘Prof-specialty’ and ‘Exec-managerial’ took top three portions of variable while ‘Armed-Forces’ and ‘Priv-house-serv’ took lowest portion. ‘Husband’ values have more than 17500 counts among ‘Not-in-family’ column values when ‘White’ have got more than 85% percentage of ‘White’ column which shows race among population. When comparing male and female portion in ‘Male’ column which shows gender distribution, we observed that male takes more portion in comparison of female. Observing ‘United-States’ variable which shows 41 unique value which is hard to observe on histogram and United states 91% portion of this column and rest of them took Mexico, Philippines, Germany, Puerto-Rico, and other countries. Finally, when we look through distribution of income level which have indicated in ‘&lt;=50K’ column, we noticed ‘&lt;=50K’ income is higher than ‘&gt;50K’ income level in population.</p><p><strong>Analysis</strong></p><p>Before starting the analysis and modeling part, we began data preprocessing part to build different model. Firstly, we encoded categorical variables by transforming to numerical values to fit model. Then we split our data frame to x and y frames in which y variables is target variable with ‘&lt;=50K’ when x contains independent variables. After determining high correlation between variables, we checked Variance Inflation factors between all independent variables and target variable- ‘&lt;=50K’. We identified that ‘13’, ‘White’, ‘40’ and ‘United-States’ variable have high variance inflation to target variable. When having VIF higher than 10, it indicates multicollinearity and it will lead problem in model; therefore, we need to drop these high VIF variables from column. Using standard scaler function, we standardized our frame by removing high VIF variables. Using Smote function, we managed imbalanced data based on target data, now our target variable contains 68026 values with 8 variables. After that, we randomly divided our data frame into training and testing size with 80/20 size. Before k-nearest model, we created Logistic regression, Random Forest classification, Decision Tree classification and Gradient Boosting and checked their accuracy level with feature importance.</p><p>From the Logistic regression part, we identified ‘39’, ‘Bachelors’, ‘Adm-clerical’ and ‘Male’ have high positive impact in comparison to other predictors on target variable- ‘&lt;=50k’. ‘Never-married’ and ‘Not-in-family’ variables were assigned as negative effectors for income variable. We can observe feature importance coefficients of all variables in bar plot. In a conclusion, our Logistic regression showed 71% accuracy level which is not acceptable good.</p><p>From the Random Forest, we observed ‘39’, ‘77516’, ‘Bachelors’, ‘Never-married’, ‘Adm-clerical’, and ‘Not-in-family’ have high positive effects on income variable with 87% accuracy rate which is higher than Logistic regression model accuracy level having different predictors.</p><p>From the Decision Tree analysis, we noticed that ‘Not-in-family’, ‘Bachelors’, and ‘39’ are feature importance variables and in conclusion, we achieved 79% accuracy level which is acceptable. Then we checked feature importance in Gradient Boosting model with 85% accuracy rate and identified ‘39’, ‘Bachelors’, ‘Adm-clerical’, and ‘Not-in-family’ have positive effects on target variable. In a summary, we observed that Decision Tree and Gradient Boosting model showed ‘Not-in-family’ variable as main predictors for target variable.</p><p>Finally, we reached K-Nearest classification model with 8 neighbors. We calculated accuracy of the model is about 83% which is good accuracy level for our model. We classified K values over training and testing dataset and observed accuracy of both. We noticed from generated plot that training dataset accuracy reached 100% within number of neighbor equals 1 and suddenly went down having 3 neighbors and showed fluctuations. Instead of training data set, testing data set showed maximum accuracy level with 85.5% having 1 variable and it reached at least accuracy- 82% with just 2 neighbors and continued almost same path and achieved its maximum level with 83% accuracy level.</p><p><strong>Conclusion</strong></p><p>As a conclusion of our Income Inequality project, we have successfully achieved our assignment goals. By starting description of provided data set, we made exploratory analysis to observe distributions of values for each variable. After checking dataset, we generated some data cleaning techniques to have high quality of data set. We built Logistic, Random Forest, Decision Tree, Gradient Boosting and K-Nearest classification model to define most effective variable to our target variables and identified accuracy level for our models.</p><p>Coding on Python</p><pre><em>#Understanding Income Inequality</em><br><em>#Aytaj Khankishiyeva</em><br><em># Importing libraries</em><br><strong>import</strong> bamboolib <strong>as</strong> bam<br><strong>import</strong> pandas <strong>as</strong> pd<br><strong>import</strong> matplotlib.pyplot <strong>as</strong> plt<br><strong>import</strong> numpy <strong>as</strong> np<br><strong>import</strong> seaborn <strong>as</strong> sns</pre><pre><em>#Read the dataset</em><br>df<strong>=</strong>pd<strong>.</strong>read_csv(&#39;Desktop/adult-all.csv&#39;)</pre><pre><em>#View the dataset</em><br>df</pre><pre><em># to understand the type of varaible in the datasets</em></pre><pre>df<strong>.</strong>dtypes</pre><pre>Result:</pre><pre>39                int64<br>State-gov        object<br>77516             int64<br>Bachelors        object<br>13                int64<br>Never-married    object<br>Adm-clerical     object<br>Not-in-family    object<br>White            object<br>Male             object<br>2174              int64<br>0                 int64<br>40                int64<br>United-States    object<br>&lt;=50K            object<br>dtype: object</pre><pre><em>#Summary of dataset</em><br>print(&quot;Summary Statistics: \n&quot;, df<strong>.</strong>describe())</pre><pre>Result:</pre><pre>Summary Statistics: <br>                  39         77516            13          2174             0  \<br>count  48841.000000  4.884100e+04  48841.000000  48841.000000  48841.000000   <br>mean      38.643578  1.896664e+05     10.078029   1079.045208     87.504105   <br>std       13.710650  1.056039e+05      2.570965   7452.093700    403.008483   <br>min       17.000000  1.228500e+04      1.000000      0.000000      0.000000   <br>25%       28.000000  1.175550e+05      9.000000      0.000000      0.000000   <br>50%       37.000000  1.781470e+05     10.000000      0.000000      0.000000   <br>75%       48.000000  2.376460e+05     12.000000      0.000000      0.000000   <br>max       90.000000  1.490400e+06     16.000000  99999.000000   4356.000000   <br><br>                 40  <br>count  48841.000000  <br>mean      40.422391  <br>std       12.391571  <br>min        1.000000  <br>25%       40.000000  <br>50%       40.000000  <br>75%       45.000000  <br>max       99.000000</pre><pre><em># to identify the null values in the dataset</em><br>df<strong>.</strong>isnull()<strong>.</strong>sum()</pre><pre>Result:</pre><pre>39               0<br>State-gov        0<br>77516            0<br>Bachelors        0<br>13               0<br>Never-married    0<br>Adm-clerical     0<br>Not-in-family    0<br>White            0<br>Male             0<br>2174             0<br>0                0<br>40               0<br>United-States    0<br>&lt;=50K            0<br>dtype: int64</pre><pre><em><br># to identify the if there are any special charecters in the dataset</em><br><strong>for</strong> col <strong>in</strong> df:<br>    print (&#39;\nFrequency of variables %s&#39;<strong>%col</strong>)<br>    print (df[col]<strong>.</strong>unique())</pre><pre>Result:</pre><pre>Frequency of variables 39<br>[50 38 53 28 37 49 52 31 42 30 23 32 40 34 25 43 54 35 59 56 19 39 20 45<br> 22 48 21 24 57 44 41 29 18 47 46 36 79 27 67 33 76 17 55 61 70 64 71 68<br> 66 51 58 26 60 90 75 65 77 62 63 80 72 74 69 73 81 78 88 82 83 84 85 86<br> 87 89]<br><br>Frequency of variables State-gov<br>[&#39;Self-emp-not-inc&#39; &#39;Private&#39; &#39;State-gov&#39; &#39;Federal-gov&#39; &#39;Local-gov&#39; &#39;?&#39;<br> &#39;Self-emp-inc&#39; &#39;Without-pay&#39; &#39;Never-worked&#39;]<br><br>Frequency of variables 77516<br>[ 83311 215646 234721 ... 173449  89686 350977]<br><br>Frequency of variables Bachelors<br>[&#39;Bachelors&#39; &#39;HS-grad&#39; &#39;11th&#39; &#39;Masters&#39; &#39;9th&#39; &#39;Some-college&#39; &#39;Assoc-acdm&#39;<br> &#39;Assoc-voc&#39; &#39;7th-8th&#39; &#39;Doctorate&#39; &#39;Prof-school&#39; &#39;5th-6th&#39; &#39;10th&#39;<br> &#39;1st-4th&#39; &#39;Preschool&#39; &#39;12th&#39;]<br><br>Frequency of variables 13<br>[13  9  7 14  5 10 12 11  4 16 15  3  6  2  1  8]<br><br>Frequency of variables Never-married<br>[&#39;Married-civ-spouse&#39; &#39;Divorced&#39; &#39;Married-spouse-absent&#39; &#39;Never-married&#39;<br> &#39;Separated&#39; &#39;Married-AF-spouse&#39; &#39;Widowed&#39;]<br><br>Frequency of variables Adm-clerical<br>[&#39;Exec-managerial&#39; &#39;Handlers-cleaners&#39; &#39;Prof-specialty&#39; &#39;Other-service&#39;<br> &#39;Adm-clerical&#39; &#39;Sales&#39; &#39;Craft-repair&#39; &#39;Transport-moving&#39;<br> &#39;Farming-fishing&#39; &#39;Machine-op-inspct&#39; &#39;Tech-support&#39; &#39;?&#39;<br> &#39;Protective-serv&#39; &#39;Armed-Forces&#39; &#39;Priv-house-serv&#39;]<br><br>Frequency of variables Not-in-family<br>[&#39;Husband&#39; &#39;Not-in-family&#39; &#39;Wife&#39; &#39;Own-child&#39; &#39;Unmarried&#39; &#39;Other-relative&#39;]<br><br>Frequency of variables White<br>[&#39;White&#39; &#39;Black&#39; &#39;Asian-Pac-Islander&#39; &#39;Amer-Indian-Eskimo&#39; &#39;Other&#39;]<br><br>Frequency of variables Male<br>[&#39;Male&#39; &#39;Female&#39;]<br><br>Frequency of variables 2174<br>[    0 14084  5178  5013  2407 14344 15024  7688 34095  4064  4386  7298<br>  1409  3674  1055  3464  2050  2176  2174   594 20051  6849  4101  1111<br>  8614  3411  2597 25236  4650  9386  2463  3103 10605  2964  3325  2580<br>  3471  4865 99999  6514  1471  2329  2105  2885 25124 10520  2202  2961<br> 27828  6767  2228  1506 13550  2635  5556  4787  3781  3137  3818  3942<br>   914   401  2829  2977  4934  2062  2354  5455 15020  1424  3273 22040<br>  4416  3908 10566   991  4931  1086  7430  6497   114  7896  2346  3418<br>  3432  2907  1151  2414  2290 15831 41310  4508  2538  3456  6418  1848<br>  3887  5721  9562  1455  2036  1831 11678  2936  2993  7443  6360  1797<br>  1173  4687  6723  2009  6097  2653  1639 18481  7978  2387  5060  1264<br>  7262  1731  6612]<br><br>Frequency of variables 0<br>[   0 2042 1408 1902 1573 1887 1719 1762 1564 2179 1816 1980 1977 1876<br> 1340 2206 1741 1485 2339 2415 1380 1721 2051 2377 1669 2352 1672  653<br> 2392 1504 2001 1590 1651 1628 1848 1740 2002 1579 2258 1602  419 2547<br> 2174 2205 1726 2444 1138 2238  625  213 1539  880 1668 1092 1594 3004<br> 2231 1844  810 2824 2559 2057 1974  974 2149 1825 1735 1258 2129 2603<br> 2282  323 4356 2246 1617 1648 2489 3770 1755 3683 2267 2080 2457  155<br> 3900 2201 1944 2467 2163 2754 2472 1411 1429 3175 1510 1870 1911 2465<br> 1421]<br><br>Frequency of variables 40<br>[13 40 16 45 50 80 30 35 60 20 52 44 15 25 38 43 55 48 58 32 70  2 22 56<br> 41 28 36 24 46 42 12 65  1 10 34 75 98 33 54  8  6 64 19 18 72  5  9 47<br> 37 21 26 14  4 59  7 99 53 39 62 57 78 90 66 11 49 84  3 17 68 27 85 31<br> 51 77 63 23 87 88 73 89 97 94 29 96 67 82 86 91 81 76 92 61 74 95 79 69]<br><br>Frequency of variables United-States<br>[&#39;United-States&#39; &#39;Cuba&#39; &#39;Jamaica&#39; &#39;India&#39; &#39;?&#39; &#39;Mexico&#39; &#39;South&#39;<br> &#39;Puerto-Rico&#39; &#39;Honduras&#39; &#39;England&#39; &#39;Canada&#39; &#39;Germany&#39; &#39;Iran&#39;<br> &#39;Philippines&#39; &#39;Italy&#39; &#39;Poland&#39; &#39;Columbia&#39; &#39;Cambodia&#39; &#39;Thailand&#39; &#39;Ecuador&#39;<br> &#39;Laos&#39; &#39;Taiwan&#39; &#39;Haiti&#39; &#39;Portugal&#39; &#39;Dominican-Republic&#39; &#39;El-Salvador&#39;<br> &#39;France&#39; &#39;Guatemala&#39; &#39;China&#39; &#39;Japan&#39; &#39;Yugoslavia&#39; &#39;Peru&#39;<br> &#39;Outlying-US(Guam-USVI-etc)&#39; &#39;Scotland&#39; &#39;Trinadad&amp;Tobago&#39; &#39;Greece&#39;<br> &#39;Nicaragua&#39; &#39;Vietnam&#39; &#39;Hong&#39; &#39;Ireland&#39; &#39;Hungary&#39; &#39;Holand-Netherlands&#39;]<br><br>Frequency of variables &lt;=50K<br>[&#39;&lt;=50K&#39; &#39;&gt;50K&#39;]<br></pre><pre><em># Remove abnormals from State-gov column</em><br>df<strong>.</strong>drop(df<strong>.</strong>loc[df[&#39;State-gov&#39;]<strong>==</strong>&#39;?&#39;]<strong>.</strong>index, inplace<strong>=True</strong>)<br>df<br></pre><pre><em># Remove abnormals from Adm-clerical column</em><br>df<strong>.</strong>drop(df<strong>.</strong>loc[df[&#39;Adm-clerical&#39;]<strong>==</strong>&#39;?&#39;]<strong>.</strong>index, inplace<strong>=True</strong>)<br>df</pre><pre><em># Remove abnormals from United-States column</em><br>df<strong>.</strong>drop(df<strong>.</strong>loc[df[&#39;United-States&#39;]<strong>==</strong>&#39;?&#39;]<strong>.</strong>index, inplace<strong>=True</strong>)<br>df</pre><pre><em># Dropping &#39;2174&#39;, &#39;0&#39; because &gt;50% of data contains zero.</em><br>df <strong>=</strong> df<strong>.</strong>drop(columns<strong>=</strong>[&#39;2174&#39;])<br>df <strong>=</strong> df<strong>.</strong>drop(columns<strong>=</strong>[&#39;0&#39;])<br><br>df<br></pre><pre><em>#Descriptive Statistics</em><br>df[&quot;State-gov&quot;]<strong>.</strong>hist(bins<strong>=</strong>15)</pre><pre><em>#Histogram of State-gov variable</em><br>plt<strong>.</strong>show()</pre><pre><em>#Histogram of Bachelors variable</em><br>df[&quot;Bachelors&quot;]<strong>.</strong>hist(bins<strong>=</strong>15)<br>plt<strong>.</strong>show()</pre><pre><em>#Histogram of Never-married variable</em><br>df[&quot;Never-married&quot;]<strong>.</strong>hist(bins<strong>=</strong>15)<br>plt<strong>.</strong>show()</pre><pre><em>#Histogram of Adm-clerical variable</em><br>df[&quot;Adm-clerical&quot;]<strong>.</strong>hist(bins<strong>=</strong>15)<br>plt<strong>.</strong>show()</pre><pre><em>#Histogram of Not-in-family variable</em><br>df[&quot;Not-in-family&quot;]<strong>.</strong>hist(bins<strong>=</strong>15)<br>plt<strong>.</strong>show()</pre><pre><em>#Histogram of White variable</em><br>df[&quot;White&quot;]<strong>.</strong>hist(bins<strong>=</strong>15)<br>plt<strong>.</strong>show()<br></pre><pre><em>#Histogram of Male variable</em><br>df[&quot;Male&quot;]<strong>.</strong>hist(bins<strong>=</strong>15)<br>plt<strong>.</strong>show()</pre><pre><em>#Histogram of United-States variable</em><br>df[&quot;United-States&quot;]<strong>.</strong>hist(bins<strong>=</strong>15)<br>plt<strong>.</strong>show()</pre><pre><em>#Histogram of &lt;=50K variable</em><br>df[&quot;&lt;=50K&quot;]<strong>.</strong>hist(bins<strong>=</strong>15)<br>plt<strong>.</strong>show()</pre><pre><em>#Importing requierd libraries for data preprocessing and model building</em><br><strong>from</strong> sklearn.preprocessing <strong>import</strong> StandardScaler, LabelEncoder<br><strong>from</strong> sklearn.preprocessing <strong>import</strong> OneHotEncoder<br><strong>from</strong> sklearn.preprocessing <strong>import</strong> MinMaxScaler<br><strong>from</strong> sklearn.compose <strong>import</strong> ColumnTransformer<br><strong>from</strong> sklearn.model_selection <strong>import</strong> train_test_split<br><strong>from</strong> sklearn.linear_model <strong>import</strong> LogisticRegression<br><strong>from</strong> sklearn.tree <strong>import</strong> DecisionTreeClassifier<br><strong>from</strong> sklearn.ensemble <strong>import</strong> RandomForestClassifier<br><strong>from</strong> sklearn.ensemble <strong>import</strong> GradientBoostingClassifier<br><strong>from</strong> imblearn.pipeline <strong>import</strong> Pipeline<br><strong>from</strong> sklearn.metrics <strong>import</strong> confusion_matrix, classification_report</pre><pre><em>#Encoding categorical variables</em><br>obj_att <strong>=</strong> df<strong>.</strong>dtypes[df<strong>.</strong>dtypes <strong>==</strong> &#39;O&#39;]<strong>.</strong>index<strong>.</strong>values<br>le <strong>=</strong> LabelEncoder()<br><br><strong>for</strong> i <strong>in</strong> obj_att:<br>    df[i] <strong>=</strong> le<strong>.</strong>fit_transform(df[i])<br><br>df</pre><pre><em>#Splitting the data</em><br>x <strong>=</strong> df<strong>.</strong>drop(columns<strong>=</strong>[&#39;&lt;=50K&#39;])<br>y <strong>=</strong> df[&#39;&lt;=50K&#39;]<br>    <br>print(x<strong>.</strong>shape)<br>print(y<strong>.</strong>shape)</pre><pre>Result:</pre><pre>(45221, 12)<br>(45221,)</pre><pre>#######################################################</pre><pre><strong>from</strong> statsmodels.stats.outliers_influence <strong>import</strong> variance_inflation_factor<br><br><strong>def</strong> vif_calc(x):<br><br>    vif <strong>=</strong> pd<strong>.</strong>DataFrame()<br>    vif[&quot;variables&quot;] <strong>=</strong> x<strong>.</strong>columns<br>    vif[&quot;VIF&quot;] <strong>=</strong> [variance_inflation_factor(x<strong>.</strong>values, i) <strong>for</strong> i <strong>in</strong> range(x<strong>.</strong>shape[1])]<br><br>    <strong>return</strong>(vif)</pre><p>VARIANCE INFLATION FACTOR</p><pre>vif_calc(x)</pre><pre><em>#Standardizing the data</em><br>scaler <strong>=</strong> StandardScaler()<br><br>scaler<strong>.</strong>fit(x<strong>.</strong>drop(columns <strong>=</strong> [&#39;13&#39;,&#39;White&#39;,&#39;40&#39;,&#39;United-States&#39;]))<br>x_scal <strong>=</strong> scaler<strong>.</strong>transform(x<strong>.</strong>drop(columns <strong>=</strong> [&#39;13&#39;,&#39;White&#39;,&#39;40&#39;,&#39;United-States&#39;]))<br>x <strong>=</strong> pd<strong>.</strong>DataFrame(x_scal, columns<strong>=</strong>x<strong>.</strong>drop(columns <strong>=</strong> [&#39;13&#39;,&#39;White&#39;,&#39;40&#39;,&#39;United-States&#39;])<strong>.</strong>columns)<br>x</pre><pre><em>#handling imbalanced data in the target variable</em><br><strong>from</strong> collections <strong>import</strong> Counter<br><strong>from</strong> sklearn.datasets <strong>import</strong> make_classification<br><strong>from</strong> imblearn <strong>import</strong> under_sampling, over_sampling<br><strong>from</strong> imblearn.over_sampling <strong>import</strong> SMOTE<br><strong>from</strong> matplotlib <strong>import</strong> pyplot<br><br>smote <strong>=</strong> SMOTE()<br><br>x_bal, y_bal <strong>=</strong> smote<strong>.</strong>fit_resample(x, y)<br><br>print(x_bal<strong>.</strong>shape)<br>print(y_bal<strong>.</strong>shape)</pre><pre>Result:</pre><pre>(68026, 8)<br>(68026,)</pre><pre><em><br>#Splitting the data</em><br>x_train, x_test, y_train, y_test <strong>=</strong> train_test_split(x_bal, y_bal, test_size<strong>=</strong>0.2, train_size<strong>=</strong>0.8, random_state<strong>=</strong>123)</pre><p>LOGISTIC REGRESSION MODEL</p><pre><em>#Logistic regression using statsmodel</em><br><strong>import</strong> statsmodels.api <strong>as</strong> sm<br>log_m <strong>=</strong> sm<strong>.</strong>Logit(y_bal, x_bal)<br>log_f <strong>=</strong> log_m<strong>.</strong>fit()<br>print(log_f<strong>.</strong>summary())</pre><pre>Result:</pre><pre>Optimization terminated successfully.<br>         Current function value: 0.600276<br>         Iterations 5<br>                           Logit Regression Results                           <br>==============================================================================<br>Dep. Variable:                  &lt;=50K   No. Observations:                68026<br>Model:                          Logit   Df Residuals:                    68018<br>Method:                           MLE   Df Model:                            7<br>Date:                Tue, 31 May 2022   Pseudo R-squ.:                  0.1340<br>Time:                        21:00:39   Log-Likelihood:                -40834.<br>converged:                       True   LL-Null:                       -47152.<br>Covariance Type:            nonrobust   LLR p-value:                     0.000<br>=================================================================================<br>                    coef    std err          z      P&gt;|z|      [0.025      0.975]<br>---------------------------------------------------------------------------------<br>39                0.5014      0.010     50.777      0.000       0.482       0.521<br>State-gov        -0.0409      0.008     -4.970      0.000      -0.057      -0.025<br>77516             0.0187      0.009      2.168      0.030       0.002       0.036<br>Bachelors         0.2356      0.009     24.953      0.000       0.217       0.254<br>Never-married    -0.3632      0.010    -37.810      0.000      -0.382      -0.344<br>Adm-clerical      0.0998      0.009     11.663      0.000       0.083       0.117<br>Not-in-family    -0.2334      0.011    -20.723      0.000      -0.255      -0.211<br>Male              0.3347      0.012     27.862      0.000       0.311       0.358<br>=================================================================================</pre><pre><strong>import</strong> time<br><em>#Logistic regression</em><br>start <strong>=</strong> time<strong>.</strong>time()<br>log_reg <strong>=</strong> LogisticRegression(solver<strong>=</strong>&#39;liblinear&#39;, random_state<strong>=</strong>123)<br>model <strong>=</strong> log_reg<strong>.</strong>fit(x_train, y_train)<br>y_pred <strong>=</strong> model<strong>.</strong>predict(x_test) <br>end <strong>=</strong> time<strong>.</strong>time()<br>print(&#39;Runtime: &#39;, end<strong>-</strong>start)</pre><pre>Runtime:  0.11228513717651367</pre><pre><em>#Classification Report</em><br>print(classification_report(y_test, y_pred))<br>print(confusion_matrix(y_test, y_pred))</pre><pre>precision    recall  f1-score   support<br><br>           0       0.74      0.64      0.69      6790<br>           1       0.68      0.78      0.73      6816<br><br>    accuracy                           0.71     13606<br>   macro avg       0.71      0.71      0.71     13606<br>weighted avg       0.71      0.71      0.71     13606<br><br>[[4334 2456]<br> [1509 5307]]</pre><pre><em>#Feature Importance of Logistic Regression</em><br><em>#Coeffecients of All Attributes</em><br>importance_1 <strong>=</strong> model<strong>.</strong>coef_[0]<br><br><strong>for</strong> n,i <strong>in</strong> enumerate(importance_1):<br>    print(&#39;Feature: &#39;,x_test<strong>.</strong>columns[n], &#39; Score: &#39;, i)</pre><pre>Feature:  39  Score:  0.5291012518339663<br>Feature:  State-gov  Score:  -0.04589171948875622<br>Feature:  77516  Score:  0.022173663180167707<br>Feature:  Bachelors  Score:  0.25917106147983693<br>Feature:  Never-married  Score:  -0.39914588633042186<br>Feature:  Adm-clerical  Score:  0.10694764463157944<br>Feature:  Not-in-family  Score:  -0.24794343034039235<br>Feature:  Male  Score:  0.3652113897030761<br></pre><pre><em>#Barplot of Coeffecients</em><br>plt<strong>.</strong>bar([x <strong>for</strong> x <strong>in</strong> range(len(importance_1))], importance_1)<br>plt<strong>.</strong>show()</pre><p>RANDOM FOREST CLASSIFICATION</p><pre><em>#Random Forest Classifier</em><br>start_1 <strong>=</strong> time<strong>.</strong>time() <br>rfclass<strong>=</strong>RandomForestClassifier(n_estimators<strong>=</strong>20,random_state<strong>=</strong>123)<br>rfclass<strong>.</strong>fit(x_train,y_train)<br>rfypred<strong>=</strong>rfclass<strong>.</strong>predict(x_test)<br>end_1 <strong>=</strong> time<strong>.</strong>time()<br>print(&#39;Runtime: &#39;, end_1<strong>-</strong>start_1)</pre><pre>Runtime:  0.9390671253204346</pre><pre><em>#Classifiaction Report</em><br>print(classification_report(y_test, rfypred))<br>print(confusion_matrix(y_test, rfypred))</pre><pre>precision    recall  f1-score   support<br><br>           0       0.88      0.87      0.87      6790<br>           1       0.87      0.88      0.87      6816<br><br>    accuracy                           0.87     13606<br>   macro avg       0.87      0.87      0.87     13606<br>weighted avg       0.87      0.87      0.87     13606<br><br>[[5881  909]<br> [ 833 5983]]</pre><pre><em>#Feature Importance of Random Forest</em><br><em>#Coeffecients of All Attributes</em><br>importance_rf <strong>=</strong> rfclass<strong>.</strong>feature_importances_<br><br><strong>for</strong> n,i <strong>in</strong> enumerate(importance_rf):<br>    print(&#39;Feature: &#39;,x_test<strong>.</strong>columns[n], &#39; Score: &#39;, i)<br>    <br><em>#Barplot of Coeffecients</em><br>plt<strong>.</strong>bar([x <strong>for</strong> x <strong>in</strong> range(len(importance_rf))], importance_rf)<br>plt<strong>.</strong>show()</pre><pre>Feature:  39  Score:  0.23252958694666437<br>Feature:  State-gov  Score:  0.035090693158292205<br>Feature:  77516  Score:  0.214990931061341<br>Feature:  Bachelors  Score:  0.12095213445001962<br>Feature:  Never-married  Score:  0.11164378953389734<br>Feature:  Adm-clerical  Score:  0.12123871823194628<br>Feature:  Not-in-family  Score:  0.1493058126123146<br>Feature:  Male  Score:  0.014248334005524669</pre><p>DECISION TREE MODEL</p><pre><em>#DecisionTree Classifier</em><br>start_2 <strong>=</strong> time<strong>.</strong>time()<br>treemodel <strong>=</strong> DecisionTreeClassifier(max_depth<strong>=</strong>3,random_state<strong>=</strong>123)<br>treemodel<strong>.</strong>fit(x_train,y_train)<br>y_pred_tree <strong>=</strong> treemodel<strong>.</strong>predict(x_test)<br>end_2 <strong>=</strong> time<strong>.</strong>time()<br>print(&#39;Runtime: &#39;, end_2<strong>-</strong>start_2)</pre><pre>Runtime:  0.09654927253723145</pre><pre><em>#Plot of decision tree levels</em><br><strong>from</strong> sklearn <strong>import</strong> tree<br>plt<strong>.</strong>figure(figsize<strong>=</strong>(25,10))<br>plot<strong>=</strong>tree<strong>.</strong>plot_tree(treemodel,feature_names<strong>=</strong>x_test<strong>.</strong>columns<strong>.</strong>values<strong>.</strong>tolist(),class_names<strong>=</strong>[&#39;0&#39;,&#39;1&#39;],filled<strong>=True</strong>,rounded<strong>=True</strong>,fontsize<strong>=</strong>14)</pre><pre><em>#Classifiaction Report</em><br>print(classification_report(y_test, y_pred_tree))<br>print(confusion_matrix(y_test, y_pred_tree))</pre><pre>precision    recall  f1-score   support<br><br>           0       0.79      0.77      0.78      6790<br>           1       0.78      0.80      0.79      6816<br><br>    accuracy                           0.78     13606<br>   macro avg       0.78      0.78      0.78     13606<br>weighted avg       0.78      0.78      0.78     13606<br><br>[[5233 1557]<br> [1381 5435]]</pre><p>GRADIENT BOOSTING</p><pre><em>#Gradient Boosting Ensemble Method</em><br><strong>from</strong> sklearn.ensemble <strong>import</strong> GradientBoostingClassifier<br><br>start_time <strong>=</strong> time<strong>.</strong>time()<br>gbclass<strong>=</strong>GradientBoostingClassifier(random_state<strong>=</strong>0, learning_rate<strong>=</strong>0.2)<br>gbclass<strong>.</strong>fit(x_train,y_train)<br>gbypred<strong>=</strong>gbclass<strong>.</strong>predict(x_test)<br>print(&#39;speed:&#39;, time<strong>.</strong>time() <strong>-</strong> start_time)</pre><pre>speed: 4.09557318687439</pre><pre><em>#Classifiaction Report</em><br>print(classification_report(y_test, gbypred))<br>print(confusion_matrix(y_test, gbypred))</pre><pre>precision    recall  f1-score   support<br><br>           0       0.88      0.82      0.85      6790<br>           1       0.84      0.89      0.86      6816<br><br>    accuracy                           0.86     13606<br>   macro avg       0.86      0.86      0.86     13606<br>weighted avg       0.86      0.86      0.86     13606<br><br>[[5600 1190]<br> [ 741 6075]]</pre><pre><em>#Feature Importance of Gradient Boosting</em><br><em>#Coeffecients of All Attributes</em><br>importance_gb <strong>=</strong> gbclass<strong>.</strong>feature_importances_<br><br><strong>for</strong> n,i <strong>in</strong> enumerate(importance_gb):<br>    print(&#39;Feature: &#39;,x_test<strong>.</strong>columns[n], &#39; Score: &#39;, i) <br>    <br><em>#Barplot of Coeffecients</em><br>plt<strong>.</strong>bar([x <strong>for</strong> x <strong>in</strong> range(len(importance_gb))], importance_gb)<br>plt<strong>.</strong>show()</pre><pre>Feature:  39  Score:  0.15563794918970322<br>Feature:  State-gov  Score:  0.013562336314173518<br>Feature:  77516  Score:  0.0037708005574846213<br>Feature:  Bachelors  Score:  0.188559793993124<br>Feature:  Never-married  Score:  0.05461825940446137<br>Feature:  Adm-clerical  Score:  0.13400114713364292<br>Feature:  Not-in-family  Score:  0.44380694349479366<br>Feature:  Male  Score:  0.006042769912616739</pre><p>K-NEAREST CLASSIFICATION MODEL</p><pre><em># Import necessary modules</em><br><strong>from</strong> sklearn.neighbors <strong>import</strong> KNeighborsClassifier<br>knn <strong>=</strong> KNeighborsClassifier(n_neighbors<strong>=</strong>8)</pre><p>knn = KNeighborsClassifier(n_neighbors=8)</p><pre>knn<strong>.</strong>fit(x_train, y_train)<br> <br><em># Calculate the accuracy of the model</em><br>print(knn<strong>.</strong>score(x_test, y_test))</pre><pre>0.8273555784212847</pre><pre>neighbors <strong>=</strong> np<strong>.</strong>arange(1, 9)<br>train_accuracy <strong>=</strong> np<strong>.</strong>empty(len(neighbors))<br>test_accuracy <strong>=</strong> np<strong>.</strong>empty(len(neighbors))</pre><pre><em># Loop over K values</em><br><strong>for</strong> i, k <strong>in</strong> enumerate(neighbors):<br>    knn <strong>=</strong> KNeighborsClassifier(n_neighbors<strong>=</strong>k)<br>    knn<strong>.</strong>fit(x_train, y_train)<br>     <br>    <em># Compute training and test data accuracy</em><br>    train_accuracy[i] <strong>=</strong> knn<strong>.</strong>score(x_train, y_train)<br>    test_accuracy[i] <strong>=</strong> knn<strong>.</strong>score(x_test, y_test)</pre><pre><em># Generate plot</em><br>plt<strong>.</strong>plot(neighbors, test_accuracy, label <strong>=</strong> &#39;Testing dataset Accuracy&#39;)<br>plt<strong>.</strong>plot(neighbors, train_accuracy, label <strong>=</strong> &#39;Training dataset Accuracy&#39;)<br> <br>plt<strong>.</strong>legend()<br>plt<strong>.</strong>xlabel(&#39;n_neighbors&#39;)<br>plt<strong>.</strong>ylabel(&#39;Accuracy&#39;)<br>plt<strong>.</strong>show()</pre><p><strong>References</strong></p><p><em>Notebook on viewer</em>. Jupyter Notebook Viewer. (n.d.). Retrieved May 31, 2022, from <a href="https://nbviewer.org/github/fonnesbeck/Bios8366/blob/master/notebooks/Section2_1-Introduction-to-Pandas.ipynb">https://nbviewer.org/github/fonnesbeck/Bios8366/blob/master/notebooks/Section2_1-Introduction-to-Pandas.ipynb</a></p><p>Brownlee, J. (2020, October 26). <em>Imbalanced classification with the Adult Income Dataset</em>. Machine Learning Mastery. Retrieved May 31, 2022, from <a href="https://machinelearningmastery.com/imbalanced-classification-with-the-adult-income-dataset/">https://machinelearningmastery.com/imbalanced-classification-with-the-adult-income-dataset/</a></p><p><strong>Appendix</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*GgOsKaqW-6dWRPfhYsWDxA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*Z-uf9r4wCz_86IuZmrjN3Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/1*r1KHqtsQ_nmXriVE8RkUFQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*mv_v8NM6nAyvrYH-zx4MnA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d13793603d8b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Natural Language Processing (NLP) Implementation in Python]]></title>
            <link>https://medium.com/@khankishiyeva99/natural-language-processing-nlp-implementation-in-python-59f8433ea2e9?source=rss-13466bf5eb1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/59f8433ea2e9</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[big-data]]></category>
            <dc:creator><![CDATA[Aytaj Khankishiyeva]]></dc:creator>
            <pubDate>Sat, 07 May 2022 21:55:45 GMT</pubDate>
            <atom:updated>2022-06-01T16:03:46.184Z</atom:updated>
            <content:encoded><![CDATA[<h3>Natural Language Process Implementation in Python</h3><p>This project is worked on the Amazon Fine Food Reviews Dataset. The purpose of this project using text analysis technique to create a topic model that allows us to find a theme across reviews and find hidden topics. Topic modeling is trying to classify huge amount of unlabeled text to find connected words with familiar meanings and differ between uses of words with multiple meanings. In this project, I specially target ‘Good Reviews’ on Amazon in which score equal 3, 4 and 5. Rest of score (1 and 2) are labeled as ‘Bad Reviews’. Project’s business question is which group(s) have gained ‘Good Reviews’</p><p>From the part of summary of data set, I identified that Reviews data contains 568454 observations with 10 variables, they are Id, ProductId, UserId, ProfileName, HelpfulnessNumerator, HelpfulnessDenominator, Score, Time, Summary and Text. These reviews comprise more than 10 years period from October 1999 until October 2012, and they are commonly about product and user information, ratings and a plain text reviews and all other Amazon categories as well as. There are included more than 568 thousand reviews, 256 thousand users, 74 thousand products and 260 users with 50 reviews.</p><p>Dataset have equal quantitative and qualitative variables. When I checked missing values of data set, I defined 16 null values from Profile Name, and 27 null values from Summary variable. These missing values doesn’t take 1% of data set, thus there is no need to clean these missing values as they don’t have powerful impact on output.</p><p>It is clearly seen that data contains tremendous observations and it is so tough to manage for my home computer. Thereby, I just used 15000 reviews with 3, 4 and 5 Scored values. Now my dataset contains 2734 observations with same 10 variable.</p><p>Before starting topic modeling, I should remove some junk words which aren’t useful in model, and they won’t allow to get idea about groups. I selected some nouns as stop words such as ‘like’, ‘im’, ‘know’, ‘just’, ‘dont’, ‘thats’, ‘right’, ‘people, ‘youre’, ‘got’, ‘gonna’, ‘time’, ‘think’, ‘yeah’, ‘said’, ‘br’, ‘www’,’http’, ‘com’ to drop from Text column to make clearer.</p><p>Before staring modeling data, I wanted to get idea about Reviews from, I created some graphs such as histograms and word clouds. My histogram shows us the number of characters existed in each sentence of Text attribute. The result of this histogram, I learned that length of ‘Text’ which contains Reviews is ranged from 0 until 8000, and about 12000 characters’ length in each sentence of Reviews are approximately between 0 and 1000; however there are some variable with above 1000 and even between 2000 and 4000 lengths. From the second histogram I acquired that the number of words appearing in each Amazon Reviews are about 180 with 11500 Reviews and maximum number of words is observed like about 600. Having a lot number of words in Reviews might be helpful in some case, but also cause difficult to define groups of Reviews in topic modeling. The third histogram provided average word length in each sentence of Text attribute (Review), and as result of this histogram, I am informed that average length in each sentence of Review is ranged between 3 and 10, and approximately 6000 word’s average length equal to 4 and 5. This result indicates we will get values in length of 4 and 6 in model.</p><p>Lastly, before observing group(s) which gained Good Reviews, I build word cloud with ‘Text’ variable to observe mostly viewed words in Reviews by help of generated Word cloud plot. From the observation of this Word cloud, I saw ‘coffee’, ‘taste’, ‘good’, ‘great’, flavor’, ‘br’, ‘product’, ‘dog’, ‘food’ and other clearly viewed words. Additionally, I created Word cloud for Summary attribute to observe mostly given words. From the observation, I viewed ‘Great’, ‘Good’, ‘Best’, love’, ‘coffee’, ‘product’, ‘taste’, ‘Delicious’, and ‘yummy’ words in Summary attribute. Thereby, it makes sense that I actually chose Good scored reviews.</p><p>After preparing data to build model, I specified two special parameters which show the number of topics and the number of passes, and I can adjust my model by modifying these parameters. My first table contains two topics and 10 numbers of iterations. Second and third table contains three and four topics, respectively, at same numbers of iterations. When evaluated table 1 , table 2 and table 3, I saw that I have 9 topic models with three tables. Now I have to define which group makes more sense? Out of the 9 examined topic tables, nouns only, table 3 with 4 topics mostly sense. I observed that four distinct groups here: 1st topic is about ‘snack’, 2nd topic is about ‘beverages’, 3rd topic is about ‘cookie’, and 4th topic looks like ‘pet items’. As observed before in histograms and word cloud, now we can be sure that topic words’ length (snack, cookie) are between 4 and 6, mostly observed values are coffee, food, dog, product which I saw these words in my preferred model.</p><p>Furthermore, I checked third model with 3 topics and increasing number of iterations from 10 to 80 to get clearest distinction within model. From these model, I gained 1st topic is about ‘cookie and snacks ’, 2nd topic related to ‘drinkings’, and 3rd topic is about ‘pet items’.</p><p>From these models’ results, it is obviously seen that most of ‘Good reviews’ come from ‘Cookie and snacks’, ‘beverages’ and ‘pet items’ food categories. It indicates that these mentioned categories gained 3, 4 or 5 score from customers (users). Now Amazon is informed that Cookie or snacks, beverages and pet items food products are loved by its customers and customers generally provide good feedback for these categories. Now Amazon doesn’t need to be in panic for improving these categories in its sales. In other word, Amazon should focus on other categories that they haven’t been included in Good Reviewed products. From the topic model, I can recommend for company to keep ‘tea’ and ‘coffee’ as beverage, ‘cookie’ and ‘chocolate’ as cookie, ‘cracker’ and ‘chips’ as snacks in good quality which take the most important place by satisfied customers. Furthermore, which food products I didn’t observe in models, Amazon should pay more attention these food products to gain Good reviews from users.</p><p>Appendix:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*jbWL1l24tryfjtYWW0TPiQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*721iZaKAKhGGqhkY-F3mmQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*Kd7JLBeodwKaaPVJRcHVCg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*3O-nVY2yoUs0WN5USX0wgQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*ZoPLuagBORwafrYQdbxU8g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*PjAPsecDVnx_caX0R9kZsg.png" /></figure><p><strong>References</strong></p><p>Project, S. N. A. (2017, May 1). <em>Amazon Fine Food Reviews</em>. Kaggle. Retrieved February 14, 2022, from <a href="https://www.kaggle.com/snap/amazon-fine-food-reviews">https://www.kaggle.com/snap/amazon-fine-food-reviews</a></p><p>Gokce, E. (2020, July 7). <em>Topic modeling with NLP on Amazon Reviews: An application of latent Dirichlet allocation (LDA)</em>. Medium. Retrieved February 14, 2022, from <a href="https://towardsdatascience.com/topic-modeling-with-nlp-on-amazon-reviews-an-application-of-latent-dirichlet-allocation-lda-ae42a4c8b369">https://towardsdatascience.com/topic-modeling-with-nlp-on-amazon-reviews-an-application-of-latent-dirichlet-allocation-lda-ae42a4c8b369</a></p><p>Shahul ES Data scientist with strong acquaintance in the fields of Machine Learning, ES, S., Data scientist with strong acquaintance in the fields of Machine Learning, &amp; on, F. me. (2022, January 4). <em>Exploratory Data Analysis for Natural Language Processing: A Complete Guide to Python Tools</em>. neptune.ai. Retrieved February 14, 2022, from <a href="https://neptune.ai/blog/exploratory-data-analysis-natural-language-processing-tools">https://neptune.ai/blog/exploratory-data-analysis-natural-language-processing-tools</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59f8433ea2e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>