<?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 Jesús Caballero Medrano on Medium]]></title>
        <description><![CDATA[Stories by Jesús Caballero Medrano on Medium]]></description>
        <link>https://medium.com/@CodingDuckMx?source=rss-1a51b80e0d33------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*xKxS6bMaEYf4UsO4</url>
            <title>Stories by Jesús Caballero Medrano on Medium</title>
            <link>https://medium.com/@CodingDuckMx?source=rss-1a51b80e0d33------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 00:10:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@CodingDuckMx/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[Predicting Kindle books’ reviews]]></title>
            <link>https://medium.com/@CodingDuckMx/predicting-kindle-books-reviews-3be74232e5d7?source=rss-1a51b80e0d33------2</link>
            <guid isPermaLink="false">https://medium.com/p/3be74232e5d7</guid>
            <category><![CDATA[amazon]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[kindle]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[npl]]></category>
            <dc:creator><![CDATA[Jesús Caballero Medrano]]></dc:creator>
            <pubDate>Fri, 06 Mar 2020 03:50:55 GMT</pubDate>
            <atom:updated>2020-03-06T03:50:55.166Z</atom:updated>
            <content:encoded><![CDATA[<p>In 2018 Amazon hit the one trillion dollars milestone, duplicating its value in a year. This milestone is making it more valuable than Walmart, Samsung, Netflix, and even Disney, all put together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TiwnB1ZvwDsSLmdfySOHVQ.jpeg" /></figure><p>But, why? Amazon, who controls 49% of the eCommerce, process a lot of data of their customers and also who are not one yet. In offline stores, you have to become a member of any rewards club to be identified, so your purchases. On the other hand, online activity analysis comes so much easy. When you enter to its site, you become the perfect customer: every move, every click in the webpage store is an opportunity to learn from you; even the device you use and how many time you spend seeing a product!</p><p>Another strategy it has for maximizing profit is analyze popular products bought but that the customers don’t care about the brand, like knives and batteries among others. Processing the return and review data, they can choose which product to manufacture on its own in a cheaper way. Here is where the reviews come important to the business.</p><p>In addition, Amazon loses money when selling some of its own-branded products, like the Kindle, a series of e-readers designated to enable users to browse, buy, download, and read e-books, newspapers, magazines and other digital media via wireless networking to the Kindle Store. But it is just one other strategy only because it has been shown that Kindle owners are likely to expend more than people that don’t. That’s why Kindle books’ reviews are such important for the company.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FegyXjaS4UmCmByyQltRKg.jpeg" /></figure><p>I got a data set of Kindle books’ reviews from 2008 to 2018. The written reviews come together with:</p><ul><li>Reviewer ID</li><li>Verification of the purchase.</li><li>The Amazon Standard Identification Number (ASIN) of the Kindle book.</li><li>A short summary, commonly used as a title for the review.</li><li>The time when the review was made.</li><li>Any votes from other costumers that agree to the reviewer’s post.</li><li>And a photo, if the reviewer decided to post one.</li></ul><p>First I look for the proportion of scores. These come from 1 to 5, and I got the share of the score:</p><ul><li>Score 5: 60.53%</li><li>Score 4 25.29%</li><li>Score 3: 8.93%</li><li>Score 2: 3.07%</li><li>Score 1: 2.16%</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*P8YGAgZsLhtKccjrl5MXfA.png" /><figcaption>The score 5 is the most popular among reviews.</figcaption></figure><p>Because of the limitations of my computational resources, I had to take a random sample of 10% of the data, which contains 2 million reviews, verifying I keep the same proportion of the scores in the sample.</p><p>Next, I engineered some of the features: like mark on which season of the year the review was made, or if the reviewer is in the top 50 most active reviewers, the length of the summary and the review text itself, and measured the subjectivity and polarity of the summary and the review text as well.<br>What is this? Subjectivity and polarity are part of the Sentimental Analysis that can be made to a text by AI. Sentimental Analysis relies on the importance of the order of words. “great” is a positive sentence, while “not great” is not. I used a tool developed by Tom De Smedt who assigned a value for each word.</p><p>I got an interesting plot about the correlation between the subjectivity and the polarity, it seems to more subjectivity implies more polarity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*kHdKhO6zG0MOMXgI0CNeuA.png" /><figcaption>Subjectivity vs Polarity</figcaption></figure><p>Another technique I used is splitting the review text, so I can relate the used words with the score. But all words are not the same in importance than the others. For example, the word &lt;&lt;the&gt;&gt; is the most used word in English, with about 6%+ of share, the second is &lt;&lt;of&gt;&gt; and the third is &lt;&lt;and&gt;&gt;. We can not leave this to affect the prediction. So I used a technique called Term Frequency-Inverse Document Frequency (TF-IDF) which weights words in order of importance. But how this importance is calculated? The importance increases by the number of times it is mentioned in the review. But, it is offset by the global times mentioned in all the reviews of a specific score.</p><p>Luckily, this method pulls out all the most common words in English that might not be relevant in the context, these words are known as Stop Words. Usually are prepositions, articles, and numbers. Then we have our data set ready to go.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*1ATTSwQRj8un0tHuAH7CQA.png" /><figcaption>Frequency of words in English.</figcaption></figure><p>I run a RandomForestClassifier to predict the score of a bunch of reviews, and some interesting results I got. The first I would like to point is the complexity of trying to get a model. I tried some other models and all I tried become better scoring 5 when the review is also 5, but for the other, it comes not too good.</p><p>(Picture)</p><p>Why? One possible cause I thought we, as customers are more likely to use words from a “bag of words” more specific when we are happy with the purchase, rather when we are not. For example, if I am satisfied with the product I purchased, I hit the 5 star bottom and write: Great, Good, Excellent. But when it turns to a bad experience, we want to let the world know we have had a bad experience, emphasizing with more distinct words our disappointment. This thought can be supported by the next plot. It shows the mean weight of the words in all reviews.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*Z3oQGbhbOWmGo0xA_RrWSg.png" /><figcaption>Most relevant words in the reviews.</figcaption></figure><p>Another thing I would like to pop up of this model are some of the most important features: the polarity of the review text, the length of the review, followed by the subjectivity of the review text. A disclaimer must be said. Due the limitations of my resources, I have to took out some of what I called: so uncommon words, that have less than 0.01% of weight in the score. That reduced significantly my set of words form the 20 thousands to the two hundreds. I would really like to have the opportunity to run the model with all the variables at least, and if possible, with all reviews.</p><p>In conclusion, this is just a step towards predicting scores in reviews. The most important conclusion might be: get a good computer or server to get thru it first!</p><p>Some other the visualizations I got from the data that are worth to share:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*jMejUb3dR1mvS_DeyHdtKA.png" /><figcaption>Number of words of the review among years.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*ML1BSYxuEnFT-uBVW08gcA.png" /><figcaption>Number of votes a review had received, sorted by its verification status.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*mE3vvgUscQJuHNbEhpT3yA.png" /><figcaption>Top 50 features for the RandomForestClassifier.</figcaption></figure><p>Credits of the data set: Jianmo Ni, Jiacheng Li, Julian McAuley<br> <em>Empirical Methods in Natural Language Processing (EMNLP)</em>, 2019</p><p><a href="https://nijianmo.github.io/amazon/">https://nijianmo.github.io/amazon/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3be74232e5d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Is there a relation between LGBT rights and GDP per capita in the countries?]]></title>
            <link>https://medium.com/@CodingDuckMx/is-there-a-relation-between-lgbt-rights-and-gdp-per-capita-in-the-countries-efba6e7dcc64?source=rss-1a51b80e0d33------2</link>
            <guid isPermaLink="false">https://medium.com/p/efba6e7dcc64</guid>
            <category><![CDATA[lgbt-rights]]></category>
            <category><![CDATA[human-capital]]></category>
            <category><![CDATA[lgb]]></category>
            <category><![CDATA[gdp]]></category>
            <category><![CDATA[gdp-per-capita]]></category>
            <dc:creator><![CDATA[Jesús Caballero Medrano]]></dc:creator>
            <pubDate>Fri, 07 Feb 2020 05:32:07 GMT</pubDate>
            <atom:updated>2020-02-07T05:48:01.775Z</atom:updated>
            <content:encoded><![CDATA[<p>The World Bank, among other global and local institutions, has been working to accomplish one of its main goals: reduce poverty in the world. This could be reached out by caring about the human capital, which includes: skills, ability, knowledge, and health attributes. All of those factors shape an individual’s productivity and influence the overall economic output.</p><p>Nowadays, discrimination based on Sexual Orientation (SO) has become more relevant. President Trump Administration has urged the Equal Employment Opportunity Commission (EEOC) to reverse the Obama-era policy. President Obama’s policy provided workplace protections for Lesbian-Gay-Bisexual-Transexual-Transgender (LGBT) Americans. As a result, LGBT Americans’ job opportunities are threatened by the government, but also by non-government institutions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*KG3UcCtQwbmgvlFZo_u3ww.jpeg" /><figcaption>LGBT rights turned into the Supreme court of the United States.</figcaption></figure><p>When a person is denied to fully participate in society, their rights are being limited causing repercussions in his or her emotional stability and development, affecting the country’s economic results. A study from 2013 showed that sexual minorities were about twice as likely as their respective heterosexual counterparts to have been unemployed and uninsured. On the other hand, the unemployment rate of trans Americans turns to 15%, three times higher than the unemployment rate in the U.S. population at the time of the survey (5%). Consequently, a survey from the National Center for Transgender Equality in 2015 showed up that around 29% of American trans people were living in poverty compared to 12% in the U.S. population.</p><p>Many studies have been done about the inclusion of certain minorities and their rights into society, but I chose to dig into the possible relation of Lesbian-Gay-Bisexual (LGB) rights and the countries’ richness. Due to the fact that I chose the International Lesbian, Gay, Bisexual, Trans and Intersex Association (ILGA) as a reliable source for the legal rights of the LGB community among the recent years, I had to drop the T of LGBT. The data does not contain information about Trans policies in the countries.</p><p>When talking about the countries’ richness, I considered The World Bank as my trustworthy source; taking the Gross Domestic Product (GDP) per capita as a measurement. The most recent year information I got was from 2017. Therefore I decided to work with it, as is the most recent global information available.</p><p>ILGA has been collecting so many interesting variables for each country about LGB rights as:</p><ul><li>Legal status of Same-Sex (SS) acts.</li><li>Age of consent for SS acts.</li><li>Are SS acts legal for both genders?</li><li>How the penalizing is described and where: legal or moral documents.</li><li>How long is the sentence or is the death itself?</li><li>Has there been any arrest in the last three years?</li><li>Are Non-Government Organizations banned?</li><li>If a National Human Rights Institution exists, is SO inclusive?</li><li>Does the country’s constitution protect LGB against discrimination?</li><li>Is discrimination at work illegal?</li><li>Is discrimination illegal in other ways?</li><li>Is in the legislation the option of Hate Crime?</li><li>Is incitement to hatred based on SO prohibited?</li><li>Are Conversion Therapy banned?</li><li>Does the State recognize the civil union of SS couples?</li><li>Do SS couples can jointly adopt?</li><li>Is 2nd parent adoption a possibility?</li><li>Same-sex Marriage.</li></ul><p>How can we compare these variables with the GDP per capita of each country? Kees Waaldjik proposed a quantitative indicator summarizing the most important rights for the LGBT community. In his search paper, “The relationship between LGBT inclusion and economic development: Macro-level evidence” (<a href="https://doi.org/10.1016/j.worlddev.2019.03.011">https://doi.org/10.1016/j.worlddev.2019.03.011</a>), he named such indicator as to the “Global Index on Legal Recognition of Homosexual Orientation” (GILRHO). Based on such index, I considered the following variables as the more representatives for the ILGA dataset:</p><ul><li>Legal status of Same-Sex acts.</li><li>Age of consent for Same-Sex acts.</li><li>Is discrimination at work illegal?</li><li>Is discrimination illegal in other ways?</li><li>Does the State recognize the civil union of Same-Sex couples?</li><li>Do Same-Sex couples can jointly adopt?</li><li>Is 2nd parent adoption a possibility?</li><li>Same-sex Marriage.</li></ul><p>Here are some results I got from the data set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/1*J8pip_0t27JUzrb3sTArvA.png" /><figcaption>Share of total of countries with LGBT favorable legislation.</figcaption></figure><ul><li>SS Acts are still illegal in 36.41% of the countries.</li><li>In the countries where SS acts are legal, 12.90% of them have different age limits for SS consensual acts, where countries like Canada, Chile and Paraguay pop up.</li><li>Only in 37.43% of the countries have protection towards discrimination based on SO in employment and 32.82% based on regarding goods and/or services.</li><li>14.35% of countries recognize civil unions of SS couples.</li><li>Almost the same proportion of countries approve the possibility of joint adoption or 2nd parent adoption; Israel, Malta, Brazil and Mexico are the countries with no joint adoption possibility.</li><li>Just 11.28% on countries of the world recognize Same-Sex marriage.</li></ul><p>In order to measure the situation of the LGB rights in the countries, I build a score like the GILRHO, assigning a full point to the score if the country has granted the right to the community and zero if not; in the case of adoption, half-point is given for each option. The minimum score is zero and the maximum is 7.0. Only six countries got seven points: Uruguay, Netherlands, France, UK, Colombia and New Zealand. Then, Brazil and Mexico got 6.5 points. Finally, 65 countries got zero points.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ormZcTS7_2f2n2BaiYPsg.png" /><figcaption>The lighter the color indicates more LGB rights.</figcaption></figure><p>A map has been drawn to visualize the scores around the world, where we can see Africa has the most critical situation for LGB rights, followed by Southwest Asia. The rest of Asia has upper scores, but still below four points. Oceania is divided, we have Australia and New Zealand with two of the highest scores in the world; however, some of the lowest scores are found in New Guinea and part of Indonesia. The Americas has mixed results, mostly oriented to equal rights. Finally, Europe is divided into two regions: the west being more progressive and the east is not so.</p><p>Moving towards the richness of the countries, I used the GDP per capita. However, taking the year 2017 only would be biased, because the result of a particular year might be influenced by some other temporal variables. That is why for this purpose I considered the average of the GDP per capita of the period from 2007 to 2017. I ranked the countries by their result and drew a map to compare possible similarities with the first map.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HCUof1aVzu_wduFak3zNfQ.png" /><figcaption>The darker the color is, the lower average GDP per capita between 2007 and 2017.</figcaption></figure><p>As shown in the map, there are zones with low average drawn with the darker colours and zones with greater richness represented with lighter colours. Once again we have Africa and the Southwest Asia of the same colour; similar colour between the countries of the rest of the Asian continent. For Oceania, it splits up into three colours pointing to Australia and New Zealand to be the richest of the zone, compared with the rest of the continent, which are darker. Europe is also divided by East and West. The Americas has similar colours for Latin America, contrasting the colours drawn at the United States and Canada. Latin America is where we could point the difference between the maps. Most countries sharing colours with Europe, Canada or the US in the first map, does not share the same colour in the second map.</p><p>Next, I divided the GDP per capita results by 15 bins and normalized to compare the results with the LGBT rights scores normalized as well. The relation looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*XZNQ_yeFZE-Z4dSBE0qQQg.png" /><figcaption>Relation between LGB rights score vs Average GDP per capita.</figcaption></figure><p>The visualization suggested that the Chi-Square test could be done to know about the possible correlation. My results are: we reject the hypothesis of independence with a confidence of 95%, with a p-value of almost zero (4.9799x10^-12) and a statistics of 228.28. After considering the results, we might be able to say that there is no independence between the score on the LGBT rights rank and the average of the GDP per capita in the years between 2007 and 2017.</p><p>In conclusion to this matter, this is the first approach. Many other variables may be and should be considered in upcoming studies. Although the result showed that we may consider no-independence, there are other possible causes like international pressure to modify the legislation. The result does not show correlation, i.e., is LGB rights a factor for country development or is the country development itself the cause to move the legislation towards a respectful environment toward the LBGT community?</p><p><strong><em>Despite these observations, everybody deserves happiness!</em></strong></p><p>The Github work can be founded here: <a href="https://github.com/CodingDuckmx/LGBT-studies">https://github.com/CodingDuckmx/LGBT-studies</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=efba6e7dcc64" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>