<?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 Emeka Onu on Medium]]></title>
        <description><![CDATA[Stories by Emeka Onu on Medium]]></description>
        <link>https://medium.com/@emekaonu?source=rss-f37c71828921------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DNryxBCr2ODXnOL183uaYQ.jpeg</url>
            <title>Stories by Emeka Onu on Medium</title>
            <link>https://medium.com/@emekaonu?source=rss-f37c71828921------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 10:41:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@emekaonu/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[PYTHON 3.6 — IN-DEPT LOOK]]></title>
            <link>https://emekaonu.medium.com/python-3-6-in-dept-look-3c5838ba0627?source=rss-f37c71828921------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c5838ba0627</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Emeka Onu]]></dc:creator>
            <pubDate>Thu, 02 Feb 2017 09:21:49 GMT</pubDate>
            <atom:updated>2017-02-02T09:21:49.990Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://docs.python.org/3.6/whatsnew/3.6.html">Python 3.6</a> was released on 23 Dec 2016, and so many people have not yet started using or learning about the awesome features it has. I wrote this article to give a highlight of the new features I found the most interesting.</p><p>Python 3.6 was shipped with 16 <em>Python Enhancement Proposals (PEP)</em>. If you don’t know what PEP is, A Python Enhancement Proposals (PEP) is a design document to propose a fundamental change of language such as syntax or really key APIs. The PEP provides a concise technical specification of the feature and a rationale for the feature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-VTIAW51hTMoVMMFOpYT_w.png" /></figure><h4>PEP 468: Preserving Keyword Argument Order</h4><p>If you have ever used **kwargs, you may have noticed that it’s just a dictionary and if you specify keyword arguments, they will come back in a random order because dictionaries are ordered.</p><p>Python 3.6 keeps the order of the arguments passed into the function call.</p><pre># Type the following in your command line</pre><pre>&gt;&gt;&gt; def PEP468(**kwargs):<br>...     print(list(kwargs.keys())) <br>...  <br>&gt;&gt;&gt; PEP468(a=1, b=2, c=3, d=4) <br>[&#39;a&#39;, &#39;b&#39;, &#39;c&#39;, &#39;d&#39;] <br>&gt;&gt;&gt;</pre><p>a, b, c, and d is keyword arguments that will return a mapping whose iterable on keys and values and whatever you want to keep that order of a, b, c, and d.</p><h4>PEP 487: Simpler customization of class creation</h4><p>If you have tried to write a meta-class, you will agree with me that it’s not easy. It’s really complicated and there’s little subtleties to it.</p><pre># Type the following in your command line</pre><pre>&gt;&gt;&gt; class PEP487:<br>...     def __init_subclass__(cls, whom, **kwargs): <br>...         super().__init_subclass__(**kwargs) <br>...         cls.hello=lambda: print(f&quot;hello, {whom}&quot;) <br>...  <br>&gt;&gt;&gt; class Helloworld(PEP487, whom = &quot;world&quot;): <br>...     pass <br>...  <br>&gt;&gt;&gt; Helloworld.hello() <br>hello, world <br>&gt;&gt;&gt;</pre><p>It is now possible to customize subclass creation without using a meta-class. The new <strong>_init_subclass</strong> class method will be called on the base class whenever a new subclass is created.</p><p>Another hook is <strong>__set_owner__</strong>, a hook in descriptors which gets called once the class the descriptor is part of is created.</p><h4>PEP 495: Local Time Disambiguation</h4><p>In most world locations, there have been and will be times when local clocks are moved back. In those times, intervals are introduced in which local clocks show the same time twice in the same day. In these situations, the information displayed on a local clock (or stored in a Python datetime instance) is insufficient to identify a particular moment in time.</p><pre># Type the following in your command line</pre><pre>&gt;&gt;&gt; dt = datetime.datetime(2017, 11, 1, 1, 30)<br>&gt;&gt;&gt; pdt = dt.astimezone()<br>&gt;&gt;&gt; pst = dt.replace(fold=1).astimezone()<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; pdt.strftime(&#39;%Y-%m-%d %T %Z%z&#39;) <br>&#39;2016-11-06 01:30:00 WAT+0100&#39; <br>&gt;&gt;&gt; pst.strftime(&#39;%Y-%m-%d %T %Z%z&#39;) <br>&#39;2016-11-06 01:30:00 WAT+0100&#39;</pre><p>PEP 495 adds the new fold attribute to instances of datetime.datetime and datetime.time classes to differentiate between two moments in time for which local times are the same.</p><h4>PEP 498: Formatted string literals</h4><p>Also known as <strong>String interpolation,</strong> <strong>PEP498</strong> basically added a concept called formatted strings or “f” strings. It’s totally obvious to notice from the example code below that there’s an ‘f’ prefixing the strings. These strings contain replacement field, which is expression delimited by curly braces {}. While other string literals always have a constant value, formatted strings are really expressions evaluated at run time.</p><pre># Type the following in your command line</pre><pre>&gt;&gt;&gt; name = &quot;Emeka Onu&quot; <br>&gt;&gt;&gt; print (f&quot;My name is {name}&quot;) <br>My name is Emeka Onu <br>&gt;&gt;&gt;</pre><h4>PEP 506/524 — Adding A Secrets Module To The Standard Library</h4><p>In Python 3.5.2, os.urandom which is the best way to get a cryptographic secure random bits up blocked if there was not enough randomness in the operating system. This isn’t a problem if you are just using your desktop but if u are using a container that starts up instantaneously or you are using a little IoT device that doesn’t have a lot of input that could be a problem because your system would halt to crawl until enough input that randomly was coming to the system initialize the entropy for the last kernal to actually give you this cryptographically secure bits.</p><p>In python 3.6, os.urandom() blocks until there’s enough entropy in the system (a potential problem for containers)</p><p>The new os.getrandom() raises an exception if it would block</p><p>The main purpose of the new secrets module is to provide an obvious way to reliably generate cryptographically strong pseudo-random values suitable for managing secrets, such as account authentication, tokens, and similar.</p><ul><li>Use the secrets module for anything security or crypto-related</li><li>Use random for modeling and simulation</li></ul><h4>PEP 509 — Add a private version to dict</h4><p>Dictionaries now have a version ID that’s only accessible from C code — Meant as a monitor to detect when namespaces have mutated — Helpful for catching e.g global and built-in namespace lookup.</p><h4>PEP 515 — Underscores in Numeric Literals</h4><p>This basically gives you the ability to write long numbers with underscores where the comma normally would be. In other words, 1000000 can now be written as 1_000_000. this update came at the right time for me.</p><p>The ability to use underscores in numeric literals for improved readability. Anytime I put more than 20 zeros in a row I had to start counting zeros to make sure I get it right.</p><p>Let’s take a look at some simple examples:</p><pre># Type the following in your command line</pre><pre>&gt;&gt;&gt; 1_000_000 <br>1000000  <br>&gt;&gt;&gt; 0x_FF_FF_FF_FF <br>4294967295</pre><p>The Python documentation and the PEP also mention that you can use the underscores after any base specifier. Here are a couple of examples taken from the PEP and the documentation:</p><pre># Type the following in your command line</pre><pre>&gt;&gt;&gt; flags = 0b_0011_1111_0100_1110 <br>&gt;&gt;&gt; flags <br>16206 <br>&gt;&gt;&gt; 0x_FF_FF_FF_FF <br>4294967295 <br>&gt;&gt;&gt;</pre><p>There are some notes about the underscore that need to be mentioned:</p><ul><li>You can only use one consecutive underscore and it has to be between digits and after any base specifier</li><li>Leading and trailing underscores are not allowed</li></ul><p>You can learn more about this change in…</p><p><a href="https://www.python.org/dev/peps/pep-0515/">PEP 515 -- Underscores in Numeric Literals</a></p><h4>PEP 519: Adding a file system path protocol</h4><p>You can’t in anyway escape from dealing with paths, whether in CLI tools or in web applications.</p><p>File system paths have historically been represented as str or bytes objects. This has led to people who write code which operate on file system paths to assume that such objects are only one of those two types (an int representing a file descriptor does not count as that is not a file path). Unfortunately that assumption prevents alternative object representations of file system paths like pathlib from working with pre-existing code, including Python’s standard library.</p><p>Here are some examples of how the new interface allows for pathlib.Path to be used more easily and transparently with pre-existing code:</p><pre>&gt;&gt;&gt; import pathlib <br>&gt;&gt;&gt; with open(pathlib.Path(&quot;README&quot;)) as f: <br>...     contents = f.read() <br>... <br>&gt;&gt;&gt; import os.path <br>&gt;&gt;&gt; os.path.splitext(pathlib.Path(&quot;some_file.txt&quot;)) (&#39;some_file&#39;, &#39;.txt&#39;) <br>&gt;&gt;&gt; os.path.join(&quot;/a/b&quot;, pathlib.Path(&quot;c&quot;)) &#39;/a/b/c&#39; <br>&gt;&gt;&gt; import os <br>&gt;&gt;&gt; os.fspath(pathlib.Path(&quot;some_file.txt&quot;)) &#39;some_file.txt&#39;</pre><h4>PEP 520 — Preserving class attribute definition order</h4><p>Attributes in a class definition body have a natural ordering: the same order in which the names appear in the source. This order is now preserved in the new class’s <strong>dict</strong> attribute.</p><pre>&gt;&gt;&gt; class OrderPreserved: <br>...     a = 1 <br>...     b = 2 <br>...     def meth(self): <br>...         pass <br>...  <br>&gt;&gt;&gt; list(OrderPreserved.__dict__.keys()) <br>[&#39;__module__&#39;, &#39;a&#39;, &#39;b&#39;, &#39;meth&#39;, &#39;__dict__&#39;, &#39;__weakref__&#39;, &#39;__doc__&#39;] <br>&gt;&gt;&gt;</pre><h4>PEP 523 — Adding a frame evaluation API to CPython</h4><p>While Python provides extensive support to customize how code executes, one place it has not done so is in the evaluation of frame objects. If you wanted some way to intercept frame evaluation in Python there really wasn’t any way without directly manipulating function pointers for defined functions.</p><p>In PEP 523 there is now a CAPI that allows for specifying an alternative frame evaluation function.</p><h4>PEP 525/530 — Asynchronous generators and comprehensions</h4><p>IF you have been using python 3.5, you’ve probably discovered a async and await. That is fantastic but asynch and await can’t be used everywhere. That’s frustrating!</p><p>Time to get rid of the frustration! Async and await keywords can now be used as neccessary in generators.</p><h4>PEP 528/529: Windows default encoding</h4><ul><li>REPL now uses UTF-8</li><li>Bytes-based paths are now accepted on windows</li></ul><h4>PEP 526 — Syntax for variable annotations</h4><p>The basic premise of this PEP is take the idea of Type Hinting (PEP 484) to its next logical step, which is basically adding option type definitions to Python variables, including class variables and instance variables. Please note that adding these annotations or definitions does not suddenly make Python a statically typed language. The interpreter still doesn’t care what type the variable is. However, a Python IDE or other utility like pylint could have an annotation checker added to them that could highlight when you use a variable that you have annotated as one type and then used incorrectly by changing its type mid-function.</p><p>Example of how this works:</p><pre># annotate.py</pre><pre>name: str = &#39;Emeka&#39;</pre><p>What we have here is a Python file that we have named annotate.py. In it, we have created a variable, name, and annotated it to indicate it is a string. This is done by adding a colon after the variable name and then specifying what type it should be. You don’t have to assign anything to the variable if you don’t want to. The following is just as valid:</p><pre># annotate.py <br>name: str</pre><p>When you annotate a variable, it will get added to the module’s or class’s <strong>annotations</strong> attribute. Let’s try importing the first version of our annotate module and access that attribute:</p><pre>&gt;&gt;&gt; import annotate <br>&gt;&gt;&gt; annotate.__annotations__ <br>{&#39;name&#39;: &lt;class &#39;str&#39;&gt;} <br>&gt;&gt;&gt; annotate.name <br>&#39;Emeka&#39;</pre><p>As you can see, the <strong>annotations</strong> attribute returns a Python dict with the variable name as the key and the type as the value. Let’s add a couple of other annotations to our module and see how the <strong>annotations</strong> attribute updates.</p><pre># annotatetwo.py</pre><pre>name: str = &#39;Emeka&#39;   <br>ages: list = [12, 20, 32]   <br>class Car:     <br>    variable: dict</pre><p>In this code, we add an annotated list variable and a class with an annotated class variable. Now let’s import our new version of the annotate module and check out its <strong>annotations</strong> attribute:</p><pre>&gt;&gt;&gt; import annotate <br>&gt;&gt;&gt; annotate.__annotations__ <br>{&#39;name&#39;: &lt;class &#39;str&#39;&gt;, &#39;ages&#39;: &lt;class &#39;list&#39;&gt;} <br>&gt;&gt;&gt; annotate.Car.__annotations__ <br>{&#39;variable&#39;: &lt;class &#39;dict&#39;&gt;} <br>&gt;&gt;&gt; car = annotate.Car()<br>&gt;&gt;&gt; car.__annotations__ <br>{&#39;variable&#39;: &lt;class &#39;dict&#39;&gt;}</pre><p>This time around, we see that the annotations dictionary contains two items. You will note that the module level <strong>annotations</strong> attribute does not contain the annotated class variable. To get access to that, we need to access the Car class directly or create a Car instance and access the attribute that way.</p><p>I am convinced that Python 3.6 is an interesting release. There are many more interesting additions and improvements that are worth checking out. You can learn more about them by reading the <a href="https://docs.python.org/3.6/whatsnew/3.6.html">official “What’s New In Python 3.6” announcement</a>.</p><p><a href="https://docs.python.org/3.6/whatsnew/3.6.html">What&#39;s New In Python 3.6 - Python 3.6.0 documentation</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c5838ba0627" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python for Data Science: Why?]]></title>
            <link>https://emekaonu.medium.com/python-for-data-science-why-ff713e9bca5d?source=rss-f37c71828921------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff713e9bca5d</guid>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Emeka Onu]]></dc:creator>
            <pubDate>Fri, 27 Jan 2017 20:04:16 GMT</pubDate>
            <atom:updated>2017-02-02T09:26:58.463Z</atom:updated>
            <content:encoded><![CDATA[<p>I’m not here to tell you why you should build your next big data project in Python because I have no idea what your next project is and whether or not Python would be a good fit for it.</p><p>Instead, my goal is to relate to you as a data scientist. I’m going to share some personal stories from my career as a data scientist and hope that you’ll see parts of yourself in them.</p><p>If you stick around and read through the rest of this article, I think you’ll come to the same conclusion I did — <strong><em>Python is going to make an impact on your future, whether you realize it or not. So why not learn it?</em></strong></p><h3>Data Science Enthusiast?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EaJ7JR-8AiFpoI00M1oGyw.png" /></figure><p>When I graduated from college, I decided to really pursue a career as a data scientist. Having used Java and several web development tools, my hunt for other useful tools was ON! Fortunately, it didn’t take me long to decide, Python was my appetizer.</p><p><strong>Why not other programming languages?</strong></p><p>The Python programming language is currently fueling scientific programming, but this wasn’t always the case.</p><p>For years academic scholars and private researchers were using the MATLAB language for scientific research.</p><p>That all started to change with the release of Python numerical computation engines such as: <a href="http://www.numpy.org/">numpy</a> and <a href="https://www.scipy.org/">scipy</a></p><p>These tools allowing complex calculations to be done by a single “import” statement followed by a function call.</p><p>Slowly but surely, Python started to take over as the preferred language for computer science research.</p><p>These days I spend much more time writing computational Python code than I do anything else, so I’m clearly biased, but I can tell you this:</p><p><strong><em>Python is a multi purpose language</em></strong></p><p>Python brings people with different backgrounds together. As a common, easy to understand language that is known by programmers and that can easily be learnt by statisticians, you can build a single tool that integrates with every part of your workflow.</p><p><strong><em>Python is the future of Artificial Intelligence.</em></strong></p><p>Given the flexibility of the language, its speed, and the machine learning functionality delivered by libraries such as: <a href="http://scikit-learn.org/stable/">scikit-learn</a>, <a href="https://keras.io/">keras</a> and t<a href="http://www.tensorflow.org/">ensorFlow</a>.</p><p>We’ll continue to see Python dominate the machine learning landscape.</p><p>Working with Python has always been a good experience for me. Not just because of its easy code syntax, but due to its phenomenal community support. I must admit that Python has always surprised me with its extended industry use.</p><h3>Trying to Stay Focused.</h3><p>I love tinkering with new tools, but I don’t switch to new tools because of what people are saying about it. I try to spend my limited free time to educate myself more in terms of broader concepts (machine learning theory, statistics, etc.), since tools are just manifestations of these. If I have a problem to solve, I would first formulate the number of steps. Then, I would consider tools I already know that can help me implement these tasks. If these tools are not sufficient, I will consider alternative tools.</p><p>Though, picking up new tools is worthwhile, but the day has only 24 hours.</p><h3><strong>Want to become a data scientist?</strong></h3><p>How would you feel if you woke up tomorrow with perfect knowledge, given your background and education, for how to become a data scientist as fast as possible?</p><p>Get started today because you will save time, money, and frustration.</p><p><a href="https://datascience.ng/">Data Science ng</a></p><p><em>If you found value in this, it would mean a lot to me for you to scroll down and hit the </em><strong><em>recommend</em></strong><em> button. Thanks so much for reading!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff713e9bca5d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Harnessing Data For Active Business Insights — Case Study of hotels.ng]]></title>
            <link>https://emekaonu.medium.com/harnessing-data-for-active-business-insights-case-study-of-hotels-ng-7f1df2ae508a?source=rss-f37c71828921------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f1df2ae508a</guid>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[review]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Emeka Onu]]></dc:creator>
            <pubDate>Sat, 27 Aug 2016 15:28:48 GMT</pubDate>
            <atom:updated>2016-08-28T10:51:24.640Z</atom:updated>
            <content:encoded><![CDATA[<p>Last week, at the third <a href="https://twitter.com/forLoopNigeria">forLoop</a> event in Lagos Nigeria, I prepared a slide on Harnessing Data For Active Business Insight. Although I was unable to attend the event, this post walks through the analytical process behind building the machine learning model behind the hotel performance ranking.</p><p>Head over to <a href="https://github.com/dacyst/hotels.ng-reviews">GitHub</a> if you want to check out the script immediately, and feel free to suggest improvements as it’s under continuous development.</p><h3>Why business Insights</h3><p>One of the major challenges in the African tech space is the alignment of theory and practice. The practical application of technical solutions in addressing real world business problems. Data driven solutions, as a technical field, techniques must be applied in a way that is profitable to businesses.</p><p><a href="https://hotels.ng/">hotels.ng</a> made for an easy business scenario for this little project on the subject matter.</p><h3>Business Case</h3><p><em>Lagos hotel customers are used to calling in and complaining of large fees being paid for recommended hotels and eventually getting not so good services. Using a data driven approach, create a good performance measurement system for hotels in Lagos. The goal is to improve customer recommendation by providing a better measurement of hotel performance.</em></p><h3>Current Classification System</h3><p>The total number of user likes is currently being used as a rank for hotels in Nigeria. This is a binary representation as the user is confined to either ‘like’ or ‘keep-moving’. We may get deeper insights by analyzing various aspects of hotel performance e.g cleanliness, security etc and/or measure customer satisfaction from customer reviews.</p><h2>Let’s get started!</h2><p><strong>This is a summary of the entire analysis process.</strong></p><ol><li>We need to get all reviews from each hotel on hotels.ng</li><li>Run analysis to get the degree of positivity or negativity of each review</li><li>Using a document term matrix, cluster reviews using KNN.</li><li>Based on the degree of positivity and negativity in each cluster, assign a cluster score to each cluster.</li><li>This matrix or KNN model can be used to cluster any new review from any old or new hotel listed.</li><li>We rank hotels simply based on their aggregate [sentiments score * cluster score]</li><li>Lastly, we derive compare our new performance score to cost per night for each hotel.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/0*2g5JUuVLdedNmhcw." /></figure><p>The first task was to grab all reviews and calculate the polarity figure for each review and each hotel. A mapper and a reducer was used to get the hotel listings from<a href="https://hotels.ng/"> hotels.ng</a> and another mapper and reducer pair to get the reviews from each hotel listing from <a href="https://hotels.ng/">hotels.ng</a>.</p><p>Finally we used a standalone script (analyse.py) to calculates the polarity of each review in out output data set.</p><p>A total 4 python scripts were used in this phase. Each script was made executable and piped on the command line.</p><p>BASH</p><pre>chmod +x ./hotels/mapper.py</pre><pre>chmod +x ./hotels/reducer.py</pre><pre>chmod +x ./reviews/mapper.py</pre><pre>chmod +x ./reviews/reducer.py</pre><pre>./hotels/mapper.py | ./hotels/reducer.py | ./reviews/mapper.py | ./reviews/reducer.py | ./analyse.py &gt; polarity.csv</pre><h3>MAP-REDUCE</h3><p>MapReduce is a programming construct where a big data problem is split into smaller pieces. The mapper usually does the same things for each line or iteration of a script and the reducer takes its input from the mapper output and performs the final analytical task. For example in the case of hotels.ng, a mapper would create a GET request to hotels.ng and grab the html page of each hotel listing and print out the value. The reducer takes this html page and extracts the specific content (hotel listings) from the page.</p><p>With the polarity.csv output, we can perform our analysis by building a document term matrix with our reviews. A document term matrix is a matrix of word frequency across all reviews. It takes a wordlist of all words appearing in all reviews and counts the amount of times each word appears in each review. With the document term matrix we can cluster our reviews, aggregate sentiments within each cluster and assign that cluster score to each review.</p><p>A document term matrix is a matrix of word frequency across all reviews. It takes a word-list of all words appearing in all reviews and counts the amount of times each word appears in each review. With the document term matrix we can cluster our reviews, aggregate sentiments within each cluster and assign that cluster score to each review.</p><p><strong>Kmeans</strong> clustering is a cluster analysis method, here observations are grouped by similarities between features. So here reviews with similar words would be clustered together. K is the number of clusters or groups to group reviews into.</p><p><strong>Analytical Process 2: NLP &amp; K-Means Clustering. Unsupervised Learning</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*UtWxD3A2sB3jMkUu." /></figure><p><strong>DOCUMENT-TERM MATRIX</strong></p><p>Given a group of documents, create an <em>N X M</em> matrix with the number of times each word in all documents occur in each document. SO: N = Number of text files (in this case reviews) and M = Number of individual words across all documents. Normalize Matrix: [x-mean(x)] / Standard Deviation (x) Cluster document based on word frequency occurrence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/0*t89U-9y-GegXJmaq." /></figure><p><strong>Goal: </strong>Minimize the amount of dis-similarities between observations within each cluster, but not so much that they become singular. For this, we observe a sample of 2 to 50 clusters and plot the within cluster dissimilarities.</p><p>Above is a plot of within cluster dissimilarities for each number of cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/0*l1cDG0IKOumJ5zpP." /></figure><p>Using our new model and passing each hotel review through this model, we are able to get a performance measure for each hotel based on how customers experienced their stay. We can also compare this performance measure to cost for effective spending. Take a look below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*1hZoPizmoSHJXU1vDKIWnA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f1df2ae508a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>