<?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 Alamsyah Hanza on Medium]]></title>
        <description><![CDATA[Stories by Alamsyah Hanza on Medium]]></description>
        <link>https://medium.com/@alamhanz?source=rss-c5465db64060------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*Gf62Za4HZx29OLAp51ZvSg.jpeg</url>
            <title>Stories by Alamsyah Hanza on Medium</title>
            <link>https://medium.com/@alamhanz?source=rss-c5465db64060------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 04:36:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alamhanz/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[Data Science Documentation]]></title>
            <link>https://alamhanz.medium.com/data-science-documentation-6ae09aad5e2d?source=rss-c5465db64060------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ae09aad5e2d</guid>
            <category><![CDATA[documentation]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[writing]]></category>
            <dc:creator><![CDATA[Alamsyah Hanza]]></dc:creator>
            <pubDate>Mon, 23 Jan 2023 14:34:06 GMT</pubDate>
            <atom:updated>2023-01-23T14:34:06.370Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Saz8YlWzGPLBPNOSMUlbHg.jpeg" /><figcaption>Documentation Creation (<a href="https://www.pexels.com/photo/blue-retractable-pen-574070/">source</a>)</figcaption></figure><p>Data scientists are not working alone. They work to solve problems that need another team&#39;s support to generate and implement the solutions. However, other teams would not have all the time in the world to discuss everything with the Data Science team. Hence, good communication through a document will be the best way to speed things up.</p><blockquote>Disclaimer: The Documentation type and communication line here based on the writer experiences.</blockquote><h3>Background</h3><p>Data scientists usually use machine learning or other mathematical methods to solve stakeholders’ problems. They must have the bandwidth to share the result with stakeholders orally or written. The data scientist must also communicate the result to the engineering team to implement the solutions. Moreover, they also sometimes must share the knowledge with the other team to showcase or increase utilization of the result. These communication lines have a widespread impact on the organization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*Hx2ZsGLAHWpV0usmFJ3NWA.png" /><figcaption>Data Science Communication</figcaption></figure><p>Hence, well-organized documentation would have a significant contribution to the organization’s success. It means the data scientist must have, not only one but, several docs which depend on the purposes and the audience target. Based on the target, the data science documentation could be divided into 2 categories: <em>Specs documents</em> and <em>Technical documents</em>.</p><h3>Specs Document</h3><h4>Product Requirements Document</h4><p>In general, the Data Science team is creating a “product” from the data using machine learning or other algorithms. This document is the first document detailing some components of the product such as :</p><ul><li>Overview / Background</li><li>Main Objective of the product — Problem Statement</li><li>Stakeholders who relate to the product</li><li>Milestones of the product — Relate to versioning</li><li>Related Documents/Dashboard</li><li>Important Tables</li><li>Feature Set</li></ul><p>This Product Requirement Document (PRD) would be the root of all documentation related to the project. PRD is a high-level explanation of the whole process related to the product. It will explain the urgency and the current state of the product. Because of those purposes, PRD would be good for new joiners, other Product Managers, or Board members. <a href="https://docs.google.com/document/d/1DhsZeeTkSeBkE8YDLTKMAEt-8Bn9j5uXvJHkokYH1XM/edit">Here</a> is the example template of the PRD.</p><h4>Feature Spec/Changes Docs</h4><p>Along with PRD, Feature Specs detailing how the product is being developed and deployed across teams. This doc is being used as notes for any inputs or questions during development. It should contain</p><ul><li>Roadmaps</li><li>Plan Discussion</li><li>Timeline</li><li>PIC of each part</li><li>Questions from related teams</li><li>Minutes of Meeting</li></ul><p>The feature spec usually explains all steps of the product journey within one particular version. So, if there is a plan for changes or a whole new version of the product, then there would be a new feature spec. It means, one product could have multiple <a href="https://docs.google.com/document/d/1wodKz65pt3LsjuR6JBJ6Rtdz0G0nUkx_4ecNf7kLAFc/edit?usp=share_link">feature specs</a>.</p><h3>Technical Document</h3><h4>Model Governance</h4><p>This document consists step by step on how the data science team generates the model or solutions. It is useful for internal teams to learn from the case so they may implement it in another problem. The <a href="https://docs.google.com/document/d/1NT157_CMow0_Sisfu8Nd_AlQgTyacEqtMHXmcR6_Ld8/edit?usp=share_link">Model Governance</a> document is also advantageous for stakeholders to discuss deeper how actually the model works and which feature is the most important in their case. Here are some elements in the docs :</p><ul><li>Problem Statement</li><li>Data Preparation</li><li>Modeling and Evaluation</li><li>Business Impact</li></ul><h4>Experimentation Document</h4><p>The document will consist of the plan and the results of the experiment which relate to a particular model version. It helps to record how the experiment is being conducted, the sample calculations, and also the monitored metrics. These are the sections in <a href="https://docs.google.com/document/d/1K9c7DEVWV5DlJM9ixe4ojTOK0ZsVDldOCFd-w4tjntg/edit?usp=share_link">the experiment docs</a> :</p><ul><li>Experiment Design</li><li>Hypothesis</li><li>Sample Size</li><li>Impact analysis</li><li>Insight and Next Steps</li></ul><h4>Deployment Docs and Load Test Docs</h4><p>This doc is mostly for communication with Backend Engineers about the flow or API contract regarding the model. Usually, it informs about differences between the current version and the new version. Moreover, <a href="https://docs.google.com/document/d/1B-4-g0Vf8nW1F-kWIsOPzKdLEgzfS5Vo4LsW8-vIiHU/edit?usp=share_link">the Deployment doc</a> must record the load test if an API call involves. Here are possible sections for the doc :</p><ul><li>Changes from the previous version</li><li>API Contract</li><li>Load Test</li></ul><h4>Root cause analysis</h4><p>Last but not least, <a href="https://docs.google.com/document/d/1_1gpiUlDIgw2z9ESCuZFW-4pny3tYiBltVYqgshoiSM/edit?usp=share_link">the RCA document</a> detailing any incident that happens to the model. The docs are regularly updated until the incident is solved. It consists of the reason for incidents and all possible ways to solve the problem. The docs will help us, especially Backend Engineers and Data Scientists to prevent the same problem in the future or solve the same incident in the future faster.</p><h3>Conclusion</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*oKkgbRriw3besMfbKuN6Vg.jpeg" /><figcaption>Documentation hierarchy</figcaption></figure><p>Structured documentation will not only help a data scientist explain a model or solution to stakeholders but also support the team to trace solution versions and reproduce them. Documentation also explains the technical solution and the impact detail on the product and business. With good communication skills on the doc, the data scientist&#39;s impact should be well known in the organization or company. In conclusion, start to write the docs now.</p><h3>Reference</h3><p><a href="https://www.datascience-pm.com/documentation-best-practices/">https://www.datascience-pm.com/documentation-best-practices/</a></p><p><a href="https://drive.google.com/drive/folders/1R78Rs3hlfPp2ngTocKcgKVtbrrji9aG-?usp=share_link">https://drive.google.com/drive/folders/1R78Rs3hlfPp2ngTocKcgKVtbrrji9aG-?usp=share_link</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ae09aad5e2d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Favorite Pastry during Holiday]]></title>
            <link>https://medium.com/data-folks-indonesia/favorite-pastry-during-holiday-804403b5b829?source=rss-c5465db64060------2</link>
            <guid isPermaLink="false">https://medium.com/p/804403b5b829</guid>
            <category><![CDATA[design-thinking]]></category>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Alamsyah Hanza]]></dc:creator>
            <pubDate>Wed, 11 May 2022 15:06:08 GMT</pubDate>
            <atom:updated>2022-05-17T01:17:59.029Z</atom:updated>
            <content:encoded><![CDATA[<p>Analytics exercise to get the best pastry during Lebaran Holiday.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wiX_o8GrMF0AjqUevO_K1A.jpeg" /><figcaption>My Mother’s Pastries</figcaption></figure><p>I just celebrate <a href="https://en.wikipedia.org/wiki/Lebaran">Lebaran</a> a week ago (2022–05–02) after Ramadhan fasting. As Indonesian, we celebrate it by visiting our families around town or back to our hometown to meet our parents. In my case, I back to my mother&#39;s house and waited for my uncle, aunt, cousin, or other visitors to come. My mother had prepared so much food to welcome them like <a href="https://en.wikipedia.org/wiki/Ketupat">Ketupat</a>, <a href="https://en.wikipedia.org/wiki/Rendang">Rendang</a>, and mostly pastries.</p><p>There are several types of pastries in Indonesia which is served specifically during Lebaran. For example <em>Kastengel, Nastar</em>, and <em>Kue Sagu</em>. Some people don&#39;t like a specific types of pastries like “too much cheese” or “too sweet”. Even one pastry type could have a different taste that makes people who love it doesn&#39;t want to eat it. I’m wondering, what is the favorite pastry of our guest based on what my mother has served?</p><h3><strong>The Leftover</strong></h3><p>In the morning one day after Lebaran, I saw pastries leftover in the guest room. Let&#39;s say we have 5 types of pastries here. The condition is more or less like in the picture below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*G4JcTQygJhu0P2zpqDinQA.png" /></figure><p>Type A much lesser than the others, and type E still fulfills the jar. Immediately I conclude that<strong> type A is the favorite pastry of our guests.</strong> Right? Not entirely wrong at least.</p><p>But consider this,</p><ol><li>My mother could refill pastry type E before I see it. But, why only type E? Maybe my mom just has type E left in the kitchen.</li><li>Type A has never been full from the beginning perhaps. I’m not saying every jar starts full.</li><li>There might be another pastry type called Type F that has run out on Leabaran day and my mother fill the jar with Type C.</li></ol><p>So, the leftover is <em>not really telling me anything</em> about our guest&#39;s favorite pastries. The prompt conclusion is still biased since there are many assumptions to be satisfied.</p><p>Supposedly my mother has never done a refill and every jar is full from the start. My conclusion should’ve been less biased and I could give my mom a recommendation to buy type A much more for next year. So that we might reduce the overflow.</p><p>Then, I remember, there was one of my cousins who took over pastry A jar and eat it up the night before by himself. So, we come back to our board.</p><h3>The other Point of View</h3><p>The favorite pastry must represent most of our guests. If we just look at the leftover that is caused by my cousin, then<strong> it is better to have another jar just for him</strong> and reconsider our favorite pastry. He is the outlier in our case here.</p><p>On the other hand, my cousin could be an influencer who can influence others to eat his favorite pastry. Or he could be a person who can represent many people somehow. Unfortunately, he does not satisfy both cases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*vPghZXjxib7t2t9BIK7qeA.png" /><figcaption>Eater Counter</figcaption></figure><p>Because of that bias, we could redefine our definition of favorite pastry as a pastry with a high unique number of eaters. The more eaters, the higher chances the pastry is the favorite. In that case, it would be difficult, since I don&#39;t have the technology to track the number of eaters at my mother&#39;s house. But, presume we have the number, then Type B is the favorite.</p><p>Regrettably, I must say that the new definition is still not strong enough. Remember, one eater may eat more than one type of pastry, and Type B may be a new type of pastry so everyone tries to eat at least one.</p><h3>The Objective</h3><p>As I have elaborated, <strong>a favorite pastry</strong> can be defined in many different ways. We can calculate the number of items has been eaten by the guest or calculate the unique guest who has eaten each type. It all <strong>depends on the purpose of knowing this favorite pastry</strong>.</p><p>For example, suppose we have a goal to satisfy our family members rather than our guest in terms of pastry. Then, we can define the favorite pastry as a pastry that has the highest “family score”. I can formulate a simple family score as follow, with an alpha between 0.55 and 1:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*TAXVhpUUWTyi6lKTxYiMwQ.png" /><figcaption>The basic family score for pastry x</figcaption></figure><p>Where <em>n</em> is the number of people who eat pastry x and <em>q </em>is the number of the pastry x that are eaten by them. Meanwhile, <em>f</em> means “Family” and <em>o</em> is “Other”. As you can see, it basically calculates the “number of people per pastry” with alpha as the weight. The higher the alpha, the more we consider our family.</p><p>The other example, if we want to reduce our expenses for next year&#39;s Lebaran without reducing our guest satisfaction then we must define the favorite pastry based on the pastry price. Here is an example formula :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*9jTycs4oO_CnsrhXPVHvdg.png" /><figcaption>Favorite Pastry formula with amt is the price and P is a set of pastries</figcaption></figure><h3>End of Exercise</h3><p>In short, the first intuitive answer to certain problems may not give an optimal solution. <strong>We must exercise and rethink the solution</strong>. On the other hand, sometimes the problem itself is not clear enough from the beginning.</p><p>This “Favorite Pastry” problem, for example, doesn’t have a clear goal of what we want to achieve at the start. We are even not clear enough to define what “Favorite” means. In return, we have so many directions to go and the analysis becomes wide open instead of converging to solutions.</p><p>In that situation, the analyst must obtain more information about the problem so that they have a solid problem statement. After some time, there may still be not enough information which leads the analyst to construct assumptions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=804403b5b829" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-folks-indonesia/favorite-pastry-during-holiday-804403b5b829">Favorite Pastry during Holiday</a> was originally published in <a href="https://medium.com/data-folks-indonesia">Data Folks Indonesia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How We Estimate Food Debarkation Time With ‘Tensoba’]]></title>
            <link>https://medium.com/gojekengineering/how-we-estimate-food-debarkation-time-with-tensoba-da05674cb758?source=rss-c5465db64060------2</link>
            <guid isPermaLink="false">https://medium.com/p/da05674cb758</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[food-delivery]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[gojek]]></category>
            <dc:creator><![CDATA[Alamsyah Hanza]]></dc:creator>
            <pubDate>Tue, 01 Feb 2022 05:51:34 GMT</pubDate>
            <atom:updated>2022-02-01T05:51:34.999Z</atom:updated>
            <content:encoded><![CDATA[<h4>GoFood, our food delivery product has millions of customers. Overall waiting time plays a huge role in customer satisfaction. Here’s how Tensoba helps.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zxba3FzU8E3_km7tRU4CBA.png" /></figure><p><strong><em>Authors: Alamsyah Koto Hanza, Mathangi Sri, Hareesh Gujja, Mayank Khera, Aditya Datta, Abhinav Tiwary, Sruti Rallapalli</em></strong></p><p>GoFood serves millions of customers every day in Indonesia. We believe reliability is one of the keys to making the customer return to the product.</p><blockquote>Based on our research, one of the most influential factors to customer satisfaction is overall waiting time.</blockquote><p>Obviously, the faster food is served, the higher the customer satisfaction. Therefore, reducing the GoFood delivery time is imperative to increase customer satisfaction. However, there are limited levers to reduce food delivery time and hence we focus our attention on setting expectations.</p><p>Customers want to understand certain parameters at a merchant level before deciding to order. Delivery time is one of the key influencing factors of conversion rates. Historically, we have seen lower Estimation Time Arrival (ETAs) have higher conversion rates — it shows with a negative correlation factor of 53% between ETA and conversion rates. It means if the ETA is far higher than Actual Time Arrival (ATA), then the odds of customers making the order will reduce. Meanwhile, if the ETA is far lower than ATA, then the customer will not trust GoFood in the future.</p><p>As part of the solution for this reliability problem, GoFood intends to increase customer confidence in ETA in the application. The confidence will make the customer trust the ETA and choose orders with the most convenient ETA for them.</p><blockquote>Consequently, ETA must have a nearly small error to the ATA for all the orders, and <strong>Tensoba</strong> is created to achieve that target.</blockquote><p>It produces estimation time between Gofood drivers accepting an order and the actual time of arrival to the customer.</p><h3>ETA on GoFood</h3><p>In GoFood, there are two types of ETAs: the ETA that is shown before the checkout page called <strong><em>ETA Discovery</em></strong> and ETA on the checkout page called <strong><em>ETA Checkout</em></strong>.</p><p>ETA Discovery is useful for customers to compare which customer will serve food generally faster than the other. It will depend on the type of food and how far the restaurant usually serves customers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FpKGfcarFcl9Odg99fedgA.png" /><figcaption>ETA Discovery Placement</figcaption></figure><p>Meanwhile, ETA Checkout will give information to customers about exactly how long they will get the food since they start to order. It depends on the cart of the order, the distance of customer location to the restaurant, and when the customer does the orders.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-2N3-D9YlPbwtPPZONfl2g.png" /><figcaption>ETA Checkout Placement</figcaption></figure><h3>Framing the problem</h3><p>This ETA problem in GoFood has the main goal to predict how long the food will arrive since the order creation in minutes or seconds. Since the target is seconds or minutes, which is a numerical target, this problem can be framed as a Regression problem. Here are the flows to framing this problem into a machine learning regression problem :</p><p>Firstly, Predicting time arrival from a particular merchant can be done by tracking the trend of time arrival from previous orders. As shown on the plot ATA from 3 different merchants below,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MUukzbkj5Nre1g2n" /><figcaption>Actual time arrival of 3 different merchants over time</figcaption></figure><p>Different merchants will have different trends, meanwhile, within the merchant, the ATA of orders is always within a certain range. Therefore, the problem can be framed as a time series problem for each merchant. This approach, however, will not be an optimal solution since GoFood has over 300.000 merchants nationwide.</p><p>Secondly, we transform every merchant into a vector that contains the past movement of its ATA. It means for every merchant we can calculate its average of ATA for the past weeks or months. Not only average but also the standard deviation or percentile. <em>Unlike a time series problem, which is mostly impacted by the historic series of data, ETA is impacted by order-level features, for instance, traffic, distance, or type of food ordered</em>. Therefore, for each order, there will be merchant level features and order level features as predictors. These features can be used as predictors for ETA for each order. Furthermore, the ETA problem can be approached as a Machine Learning regression problem instead of a time series problem.</p><h3>Metric performance</h3><p>There are several metrics that need to be considered in building the Tensoba Model. We divide the metrics into offline and online metrics. Offline metrics are the metrics for evaluating the model accuracy, meanwhile, we are using online metrics to see the impact of the model on the product which is usually measured once the model is deployed.</p><h4>Offline metrics</h4><p>There are 3 metrics for checking the Tensoba accuracy to the actual time of arrival: RMSE, MAE, and MAPE. Firstly, RMSE or Root Mean Squared Error is an interpretable metric that gives more weight to the higher error. It means RMSE is sensitive to high error. This is the formula of RMSE,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/0*V7q0G6gP-9BcCin8" /><figcaption>Metrics formula: RMSE</figcaption></figure><p>Secondly, MAE or Mean Absolute Error is a metric with an absolute error of the model and averages it instead of rooting the error square. It means, there is no weighting among errors while all the errors are being treated the same. So, if <strong>the higher error will NOT give a higher risk on the prediction</strong>, then use MAE. This is the formula of the MAE,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/0*PW17kQC5dGr5Pz5m" /><figcaption>Metrics formula: MAE</figcaption></figure><p>Lastly, MAPE or Mean Absolute Percentage Error metrics is the same as MAE but it’s normalized by the true value which will give information about how many percent far the prediction is to the true value. Also, because the metric uses “mean”, it is highly influenced by extreme values. MAPE can’t be used if the true values contain zero. Therefore, as long as the true <strong>value is NOT zero and the normalized value of the error is desired </strong>then use MAPE. Here is the formula:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/0*ErmCj2moWDgU65-T" /><figcaption>Metrics formula: MAPE</figcaption></figure><h4>Online metrics</h4><p>We measure Tensoba using 2 metrics in production: its compliance and conversion. Compliance is about how the eta will comply with the actual time of arrival, it means that when the customer expects the arrival time then it should not exceed the actual. In other words, the <strong>Tensoba must have a small underpredict and tends to overpredict</strong>. We assume that if the customer is not happy with our compliance they won’t trust our ETA or our service in general.</p><p>On the other hand, too high ETA will make customers anxious which leads to not converting to the booking after discovery on our platform. Therefore, the second online metric that we need to monitor is the conversion of our sessions. It calculates <strong>how many percent of sessions end up with a booking</strong>.</p><h3>Benchmark ETA</h3><p>Our first attempt of displaying the ETA to the customer involved an approach based on averages. The time arrival is estimated using a simple average of Actual Time Arrival for the past 2 months of each restaurant. Here is the performance of our first approach:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*ctAusQ1wI8r0QbeaRnsBfQ.png" /></figure><p>The evaluations show that on average, the ETA error plus-minus 6.4 minutes with MAPE almost 32%. The next model should beat the error of this estimation.</p><h3>ATA Components</h3><p>There are two approaches to do this modeling:</p><ol><li>Use the total ATA from the data on order level as the model target. It is called <em>wholesome prediction.</em></li><li>Divide the ATA into 3 different phases and predict it independently, then combine the result. The ATA can be divided into 3 different components,</li></ol><ul><li>The time between booking order to driver arrival to restaurant denotes as <strong>T1 </strong>(In Minutes)</li><li>The time between driver arrival to driver pickup, basically the time of driver waiting time on restaurants like queue or parking until pickup denotes as <strong>T2 </strong>(In Minutes)</li><li>The time between driver pickup to closing time or arrival time denotes as <strong>T3 </strong>(In Minutes)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RKAMBPC5Z59uI9lO" /><figcaption>Time Arrival Components</figcaption></figure><p>Because of this, the <strong>Tensoba project </strong>will have 2 models (Discovery and Checkout) for wholesome prediction or 6 models (T1, T2, T3 for each Discovery and Checkout).</p><h3>Model features and training</h3><p>Tensoba models are using the XGBoost model with three weeks of data. Most of the features in Tensoba to predict T1, T2 and T3 is the summary of those targets on different levels. For example,</p><ul><li>The Average of T1 on Merchant Level within X last days → to predict T1</li><li>The Percentile 75 of T2 on Item Type within X last weeks → to predict T2</li><li>The Median of T3 on Distance Group Level within X last hours → to predict T3</li><li>Etc</li></ul><p>However, there are other features that need to be collected in real-time like :</p><ul><li>Value of the orders</li><li>Number of items</li><li>Route Distance between Customer and Drivers</li></ul><p>Those real-time features are most likely being used on the checkout page since the information can’t be collected during Discovery.</p><h3>Model Performance</h3><p>The prediction of time arrival (ETA) will be the wholesome prediction or the total of the prediction of T1, T2, and T3. This is the best result (in Minutes) after several iterations:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O3plj9vnwOBLSbEP4kir0w.png" /></figure><p>The table shows that the performance of separated Tensoba is better on Discovery and Checkout than Benchmark ETA and wholesome prediction. It reduces the MAPE from 31% to 23%, which means that the Tensoba ETA error is only 23% far from the actual time of arrival.</p><h3>Feature Importance</h3><p>Based on the XGboost model, here are the top 3 features to predict each component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mPNYXB3xDQ9QhXXrV45pAA.png" /></figure><p>The table shows that T1 and T2 discovery is really reliable with the hourly, last 3 days, or weekly summary within the merchants. This fact kinda makes sense which states that the next T1 or T2 won’t be so much different from the previous T1 or T2 at the same hour and merchant. Meanwhile, the T3 discovery has a high dependency on the distance class. This result is in correspondence with the reality where the higher distance will lead to a longer time.</p><p>On the Checkout, T2 depends on the GMV order which shows that expensive orders generally will take a longer time to prepare. Also, as expected, the T3 checkout still has distance as the predictor. However, the p75 of T3 on the s2id level 13 is the best predictor so far which shows that for different areas T3 has different trends.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7jlXp6wES_mzp_G7" /></figure><h3>Implementation</h3><p>Tensoba Discovery implementation is not the same as the checkout. The implementation will depend on the level of the features. The smallest features level on T1 and T2 is “last 1 hour on specific merchant” features which can run every hour. Also, there are no features of Customer Location for these two cases, so the model will be the same for each customer and merchant on a specific hour. This makes it possible to run T1 and T2 hourly in a batch for each merchant.</p><p>Meanwhile, for T3, the smallest features level is “last 1 week data on specific distance groups in merchants” which can be updated daily. Therefore the T3 model in Discovery updates daily at 12 am in a batch that predicts all merchants T3 at all distance groups.</p><p>Technology at Gojek, such as <a href="https://www.gojek.io/blog/reliable-ml-pipelines-with-clockwork">Clockwork</a> and <a href="https://www.gojek.io/blog/merlin-making-ml-model-deployments-magical">Merlin</a> from the Data Sciences Platform team helps orchestrate the implementation of different schedule batch predictions like above. Clockwork supports the scheduling, meanwhile, Merlin makes it easy to do batch prediction in such a short time. The hourly prediction is stored in Redis, then the application will search the time arrival prediction through it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kes0rxgLbe2AkwJ5" /></figure><p>On the other hand, Tensoba checkout is a real-time prediction that uses information from the user’s order like route distance and order value. The model is deployed to Merlin using our Transformer which gets features from Feast in real-time. Merlin will release an API that can be used by applications to get the time arrival prediction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zIhlbw2U4ghTaQk3" /></figure><h3>Future improvements</h3><p>Tensoba has decreased the error of estimation time by almost 23%, however, this model can still be modified to make better results. Here are some future plans of improvement:</p><ul><li>Implement a retraining schema to always get fresh data to the model.</li><li>Adding features about how crowded the restaurant is or the way to get to the customer&#39;s destination.</li><li>Add information about how likely the driver will accept the order.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IPWwoozDxeKoXMtXEyrtLw.png" /></figure><p>Check out more stories from the vault <a href="https://www.gojek.io/blog">here</a>.</p><p>Oh, and we’re hiring:</p><figure><a href="https://bit.ly/gojekjobsblogs2022"><img alt="" src="https://cdn-images-1.medium.com/max/700/1*c2_eIvR2WDUWnP6YmzcGpQ.jpeg" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da05674cb758" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gojekengineering/how-we-estimate-food-debarkation-time-with-tensoba-da05674cb758">How We Estimate Food Debarkation Time With ‘Tensoba’</a> was originally published in <a href="https://medium.com/gojekengineering">Gojek Product + Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Education at the Beginning of Pandemic]]></title>
            <link>https://alamhanz.medium.com/education-at-the-beginning-of-pandemic-7e1a96012eea?source=rss-c5465db64060------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e1a96012eea</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[education]]></category>
            <dc:creator><![CDATA[Alamsyah Hanza]]></dc:creator>
            <pubDate>Fri, 07 Jan 2022 13:30:42 GMT</pubDate>
            <atom:updated>2022-01-07T13:32:15.244Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*saUWOn4P1VHQVdC6.jpg" /><figcaption><a href="https://www.marsdd.com/news/how-the-pandemic-changed-has-changed-education-forever/">source</a></figcaption></figure><p>The covid-19 pandemic impact has always been a topic since 2020. It causes many disruptions in many different fields due to this pandemic. Education is not excluded from these disruptions in all countries.</p><p>The pandemic pushes many students to start learning at home, many teachers learn how to use tools for teaching, and many parents guide their children in this process. Therefore, many institutes create their rules then put everything online. It is not an easy process since learning should be more effective in an offline manner.</p><p>Looking into <a href="https://www.kaggle.com/c/learnplatform-covid19-impact-on-digital-learning/data">this competition</a> in Kaggle, I would like to go through what had happened in 2020 when the changes in Online Learning happen in the US. This analysis is a good start to making Public Policy in terms of Online Learning, especially for cities with low bandwidth.</p><h4>The Description</h4><p>This online learning analysis uses a data source that contains 22 million rows of online learning activity on 8647 learning products within a year. The data is collected from 233 unique districts of 15 areas which are dominated by ‘Connecticut’, ‘Utah’, ‘Massachusetts’, ‘Illinois’. The data source contains 2 main metrics :</p><pre>1. Pct Accees :  Percentage of students in the district have at least one page-load event of a given product and on a given day<br>2. Engagement :  Total page-load events per one thousand students of a given product and on a given day</pre><p>The data definitely not complete, here are some notes to be remembered about the data source :</p><pre>1. There are 57 district doesnt show anything about the state, locale, pct_black. <br>2. There are 20 Learning Product doesnt have Sectors<br>3. Many null engagment index which relate to zero or null pct access. <br>4. In districts data only, the &#39;county_connections_ratio&#39; is not really informative since the columns mostly contains `[0.18, 1[`.<br>5. There are 8647 products on the engagement list, however the details only have 372 (mostly comes from Google). <br>6. Fortunately, those 372 products with details covers half of engagement details.<br>7. Most of the products is under sector PreK-12 with functions LC.</pre><p>Therefore, external data is needed to get this information. Also, from non-null data, the Majority of the district (65.9%) has [0, 0.2[ pct_black/Hispanic. However, there is still a small engagement for pct_access = 0 which means the zero value is just round down for small access.</p><h4>The Adaptation</h4><p>Firstly, I try to picture digital connectivity and engagement of 2020 online learning in the US. The picture here is done by comparing Engagement with Covid Cases in one plot and dividing it into 4 periods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mdAWsYwch9lkdvprmId2Dg.png" /><figcaption>Self-Generated Trends</figcaption></figure><p>Those 4 different periods or phases in 2020 are based on the Covid Cases from <a href="http://www.openicpsr.org/">www.openicpsr.org</a>. The orange line shows the total covid cases for all areas in the US, meanwhile, the blue line shows the total covid cases of areas on Data Source. The areas that contribute to blue lines denote as Blue Areas. Here is a detailed chronology story from the plot:</p><p><strong><em>Phase 1 (before 2020–02–10)</em></strong>: It&#39;s Pre Covid for Blue Areas. The online engagement during this phase is still stable with low engagement during the weekend and high during weekdays. This phase shows the small covid cases is not make online learning increase or decrease significantly. In addition, lockdown hadn&#39;t been implemented during this phase on Blue Areas.</p><p><strong><em>Phase 2 (2020–02–10; 2020–06–14)</em></strong>: First high wave starts to happen around April but the Online Learning engagement changes drastically around February 2020. It is probably an intervention from the State to make schools start thinking about the alternatives of offline learning. The highest median of engagement happens around the beginning of high covid cases. After the peak around the middle of April, the cases on Blue areas starts decreasing along with online learning engagement.</p><p><strong><em>Phase 3 (2020–06–14; 2020–09–07)</em></strong>: After reaching the lowest covid cases in June 2020, the case on Blue Areas slowly increased (not significantly like other areas). Interestingly, the learning engagement keeps decreasing even lower than phase one despite covid cases movement. The hypothesis for this phenomenon is that Online learning engagement does not really correlate with covid cases, but is more impacted by states rule. Also, since it had been 2 or 3 months without offline learning, many districts optimally use this offline learning period by decreasing online activity.</p><p><strong><em>Phase 4 (after 2020–09–07)</em></strong>: In the last phase, the second wave of covid 19 has started and the school begins to do engagement online (maybe State’s policies). However, there is no panic from most of the schools since the engagement is not as higher as engagement during Phase 2. It could show 2 things: the school is not following lockdown policies properly OR the school can handle the online learning calmly. It means the school is adapting, it is more ready to do Online learning in terms of tools/applications and how to communicate everything to parents and students.</p><h4>The Groups</h4><p>The second analysis is about the relationship between student engagement with online learning platforms and different locale types (Rural, Suburb, town, etc), demographic race, and <a href="https://worldpopulationreview.com/state-rankings/average-internet-speed-by-state">internet speed</a>. One simple way to present this relation is by clustering 233 areas based on student engagement with online learning platforms. Three is an optimal number cluster with three features: number of active days, engagement, and unique product. <em>However, there may be some information loss using this technique and bias towards outliers.</em></p><p>Based on the features, we can describe those clusters as follow :</p><ul><li>0 → high active days, high product (the Explorer) → 150 areas</li><li>1 → high active days, low product (the Loyal) → 59 areas</li><li>2 → low active days, low engagement (the Rookie) → 24 areas</li></ul><p>Since the locale types, internet speed, and demographic race are nominal columns, then we use the <a href="https://en.wikipedia.org/wiki/Uncertainty_coefficient">Theils-u</a> score to get the degree association between the two nominal variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QGl6PFFXJsvWqN8MCwGwlg.png" /><figcaption>Relation Clusters with internet speed and locale type</figcaption></figure><p>Firstly, the correlation clusters with the internet speed group (grp0 is the lowest). The Theil U score shows low relation, but the graph describes how cluster 0 relatively has low speed, meanwhile cluster 1 otherwise. The hypothesis is that because of the low internet speed, areas in cluster 0 always try alternatives so that students can follow the class.</p><p>Additionally, the locale type on cluster 1 is dominated by Rural areas. It indicates that with low population density, the areas are most likely to be loyal to certain products which are not necessarily good for them. there are two possibilities :</p><ol><li>These rural areas have learned and compared from other Cities or Towns about other products before do a decision. OR</li><li>These rural areas just pick several products from limited options and it works fine for students and parents.</li></ol><p>Either way, Rural areas must have better guidance to select the best product for their areas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*JSjaOeUBCZ5BwMtNtnNBGQ.png" /><figcaption>Relation Clusters with demographic race</figcaption></figure><p>On the other hand, cluster 2 mainly has an unknown locale type with a relatively high percentage of Black/Hispanic and relatively low internet speed. This cluster has a lower active day and engagement. Largely, this cluster has increased in engagement in the second and third weeks of August 2020 (week 33/34). There are two scenarios :</p><ol><li>These areas were just hit by the second wave of covid 19, so high engagement just happen in August 2020. OR</li><li>These areas don’t have enough support or guidance in the first wave.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UUR2WB2BggCqc9tQyRskFA.png" /><figcaption>cluster 2 engagement</figcaption></figure><p>As a note, cluster 2 relatively has lower bandwidth than cluster 0. It may affect product options of these areas to explore.</p><h4>The Conclusion</h4><p>As we see in the Adaptation, the beginning is always harder than later. The decision which tools should be used, the adaptation of students and parents, also how the teacher adapts this into their curriculum. After several cases, trial and error, in the end, the school was disrupted. They have decided the best application for them and are more ready to do online learning.</p><p>In the process, however, some schools have limitations. Starts with internet bandwidth and a lack of information about online learning applications. This is obviously slowing down the adaptation process from offline to online learning.</p><p>In a simple sentence, disruption of the education field is hard. Not only on the school’s side, but parents must also understand the disruption. The government must provide better technology and communication within countries so there are no students left behind.</p><h3>References</h3><p><a href="https://github.com/alamhanz/education-pandemic">https://github.com/alamhanz/education-pandemic</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e1a96012eea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sekedar Kue-Kue]]></title>
            <link>https://medium.com/data-science-indo/sekedar-kue-kue-3a56857d8830?source=rss-c5465db64060------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a56857d8830</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[image-classification]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[modelling]]></category>
            <dc:creator><![CDATA[Alamsyah Hanza]]></dc:creator>
            <pubDate>Sat, 08 May 2021 17:02:21 GMT</pubDate>
            <atom:updated>2021-10-22T13:30:04.022Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Story of Image Classification in Bahasa</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*zxn2nPgv1GXEIi1QTZfM6g.jpeg" /><figcaption>source : <a href="https://teguhanggi.my.id/2018/11/23/aneka-kue-tradisional-indonesia/">teguh-anggi</a></figcaption></figure><blockquote><strong>tak.jil . </strong><em>n </em>makanan untuk berbuka puasa (KBBI)</blockquote><p>Ramadhan merupakan salah satu masa yang sangat sibuk bagi umat muslim di Indonesia. Tidak hanya membicarakan ibadah ataupun pulang kampung, makanan menjadi topik paling hangat di bulan suci ini. Salah satunya adalah <em>Takjil</em>, sebutan makanan kecil yang dimakan saat berbuka puasa. Pada umumnya, <em>Takjil </em>di Indonesia merupakan kue-kue kecil tradisional yang bentuk dan warnanya berbeda-beda disetiap daerah. Contohnya, kue serabi, lemper, pukis, bika ambon, dan masih banyak lagi [<a href="http://blog.sayurbox.com/kue-takjil-khas-indonesia/">sumber</a>].</p><p>Karena bentuk dan warnanya yang bervariasi, memperkenalkan visual dari kue-kue kecil ini kepada <em>machine </em>akan menjadi tantangan tersendiri. Ada beberapa kue yang bentuk dan warna-nya hampir sama namun memiliki cita rasa yang begitu berbeda (contohnya : kue bingka dan kue lumpur). Artikel ini akan fokus pada <strong>cerita eksperimentasi</strong> pada klasifikasi gambar kue-kue kecil ini menggunakan <a href="https://www.tensorflow.org/tutorials/images/cnn">CNN</a> pada keras di python.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZpjC763UmjlmQUrg7LQiaw.png" /><figcaption>kue binka (kanan) vs kue lumpur (kiri) [<a href="https://www.idntimes.com/food/dining-guide/ken-kirana/serupa-tapi-beda-nama-5-kue-tradisional-yang-mirip-di-indonesia-c1c2/full/5">source</a>]</figcaption></figure><h3>Dataset Kue-Kue</h3><p>Tidak mudah untuk mendapatkan dataset gambar kue-kue nusantara yang siap pakai untuk di-<em>training</em> dalam <em>Machine Learning</em>. Cara paling mudah untuk mengumpulkan daset-nya adalah dengan search nama kue yang diinginkan dan <em>scrap</em> semua gambar yang bisa disave dari <em>google search</em>.</p><p>Untungnya, setelah dicari-cari, ditemui satu <a href="https://atapdata.ai/">website</a> yang menyediakan sebuah dataset menarik yang berisi gambar-gambar <strong>8 jenis kue tradisional</strong> dari Indonesia.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EF5PJJfF0O1PuFHUOGYY-A.png" /><figcaption>Kue — Kue Part One</figcaption></figure><p>Didatasetnya terdapat hampir <strong>200 gambar</strong> <em>training </em>(data-nya seimbang), 20 gambar v<em>alidation</em> dan 20 gambar <em>testing </em>di masing-masing jenis:</p><ul><li>Kue Dadar Gulung [Label 0] : Kue Manis yang biasanya berisi kelapa, berbentuk <strong>lonjong dan biasanya hijau.</strong></li><li>Kue Kastengel [Label 1] : Kue Keju untuk lebaran, berbentuk <strong>lonjong dan kekuningan.</strong></li><li>Kue Klepon [Label 2] : Kue berisi gula merah cair, berbentuk <strong>bola dan biasanya hijau.</strong></li><li>Kue Lapis [Label 3] : Kue dari tepung beras yang berlapis-lapis, bentuknya <strong>kotak dan berwarna warni.</strong></li><li>Kue Lumpur [Label 4] : Kue manis dari terigu, berbentuk <strong>bulat berwarna kuning.</strong></li><li>Kue Putri Salju [Label 5] : Kue dari tepung kanji dan dibubuhi gula halus, biasanya berbentuk <strong>bulan sabit dan berwarna putih.</strong></li><li>Kue Risoles [Label 6] : satu satunya kue yang tidak manis didataset ini, lumpia yang <strong>biasanya lonjong berwarna keemasan.</strong></li><li>Kue serabi [Label 7] : Kue dari tepung beras dan dikasih kuah gula, berbentuk <strong>bulat dan berwarna putih.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u7F6e3CC6-tU6nGD2CxtBg.png" /><figcaption>Kue-Kue Part Two</figcaption></figure><p>Deskripsi diatas menunjukan bahwa ada kue-kue yang bentuknya mirip-mirip seperti <strong>serabi dan kue lumpur </strong>atau <strong>Kastengel dan Risoles</strong>. Sementara kue lapis bisa menjadi kandidat yang memiliki akurasi tinggi karena paling mudah dibedakan dari yang lain.</p><h3>Model Klasifikasi Gambar</h3><p>Generik Model yang pasti digunakan untuk multiclass problem seperti ini, pastinya adalah <em>Convolutional Neural Network</em>. Model ini dijalankan diatas Keras di versi 2.4.3 dengan Tensorflow 2.4.1 di python 3.7 dan semua gambar di resize sesuai kebutuhan dan <a href="https://www.linkedin.com/pulse/keras-image-preprocessing-scaling-pixels-training-adwin-jahn/">di<em>scale</em> dengan 1/255</a>. Lebih detailnya bisa cek <a href="https://github.com/alamhanz/just-cake">disini</a>.</p><p><a href="https://github.com/alamhanz/just-cake/blob/main/notebooks/1-Model_train1-CPU.ipynb"><strong>Percobaan pertama</strong></a> yang dilakukan untuk problem ini adalah menggunakan 2 layer CNN, <em>input size</em> 128 x 128 dan banyak <a href="https://machinelearningmastery.com/pooling-layers-for-convolutional-neural-networks/">Maxpooling</a> (ini hanya eksperiment awal).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0FUZDMzjmD_SiaEgko3UqQ.png" /><figcaption>Eksperimen 0</figcaption></figure><p>Hasilnya sangat tidak memuaskan (dan tidak usah ditunjukan). Permasalahan yang muncul bukan hanya masalah hasilnya, <strong>namun juga waktu <em>training</em></strong> yang memakan rata-rata 64 detik per <em>epoch</em>. <em>Training</em> ini dilakukan hanya menggunakan CPU i3. Lalu, dicoba menggunakan GPU lokal yang membantu mengurangi waktu rata-rata per epochnya menjadi 45 detik (ini <a href="https://www.notebookcheck.net/NVIDIA-GeForce-930M.139035.0.html">GPU 930M</a>).</p><p>Untuk yang ingin menggunakan GPU Lokalnya, mungkin bisa mengikuti langkah2 <a href="https://medium.com/analytics-vidhya/how-to-install-tensorflow-cuda-toolkit-and-cudnn-on-windows-10-9efa075b448c">disini</a> dan <a href="https://medium.com/lsc-psd/tensorflow-2-1-doesnt-seem-to-see-my-gpu-even-though-cuda-10-1-with-solution-7b44297843a">disini</a>. Namun semakin cepat <em>training-</em>nya, bukan berarti akan semakin bagus performanya.</p><p><a href="https://github.com/alamhanz/just-cake/blob/main/notebooks/4-Model_train4_colab.ipynb"><strong>Percobaan kedua</strong></a><strong> </strong>(setelah beberapa iterasi)<strong>, </strong>dicoba menggunakan CNN lebih banyak — 6 layer CNN, <em>input size</em> 128 x 128 dan menggunakan <a href="https://colab.research.google.com/">google colab</a> untuk <em>training</em> yg lebih cepat. Struktur yang dipakai seperti berikut, dimana menggunakan <a href="https://keras.io/api/optimizers/adam/">Adam</a> sebagai oprimizernya dengan Learning rate .00001 dengan sekitar 25 epoch,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x60CBFDk5mp_hlyKqKx30Q.png" /><figcaption>Eksperimen 4</figcaption></figure><p>Hasilnya masih kurang memuaskan, evaluasi validasinya tidak melebihi 70% akurasinya. Kue kastangel dan lumpur menjadi 2 label yang paling jelek F1-scorenya.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wBMICo0kuBzgGYiUngJeiA.png" /><figcaption>Hasil eksperimen 4</figcaption></figure><p><a href="https://github.com/alamhanz/just-cake/blob/main/notebooks/4-Model_train4_3_colab.ipynb"><strong>Percobaan Ketiga</strong></a>, dengan menggunakan <a href="https://machinelearningmastery.com/how-to-use-transfer-learning-when-developing-convolutional-neural-network-models/"><em>transfer learning</em></a><em> </em>dari model sebelumnya, model di training lanjut menggunakan augmentasi gambar dari <a href="https://www.pyimagesearch.com/2019/07/08/keras-imagedatagenerator-and-data-augmentation/"><em>ImageDataGenerator</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*rJTaVWABfdbUVGtAEAYRxw.png" /><figcaption>Eksperimen 4.3</figcaption></figure><p>Penjelasan lebih lanjut mengenai <em>rotation, height_shift_range</em>, atau <em>shear_range</em>, bisa dilihat <a href="https://machinelearningmastery.com/how-to-configure-image-data-augmentation-when-training-deep-learning-neural-networks/">disini</a>. <strong>Augmentasi ini membantu mengurangi <em>variance</em></strong> yang akan membuat kemungkinan adanya <em>overfitting</em> mengecil. Mudahnya, augmentasi ini mengajarkan model untuk melihat gambar dari sisi yang berbeda.</p><p>Adapun hasil augmentasi seperti dibawah ini. Evaluasi menunjukan adanya peningkatan di F1-score secara keseluruhan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cHw0ipJXFj6ZV9YWtlbg_g.png" /><figcaption>Hasil eksperimen 4.3</figcaption></figure><h3>Akhirnya …</h3><p><a href="https://github.com/alamhanz/just-cake/blob/main/notebooks/6-Model_train6_2_colab.ipynb"><strong>Percobaan Terakhir</strong></a><strong>, </strong>dimana pada percobaan terakhir ini model yang digunakan adalah<a href="https://towardsdatascience.com/how-do-pretrained-models-work-11fe2f64eaa2"> <em>pretrained model</em> </a>— VGG16 (~13 CNN Layers). Karena memang pada dasarnya banyak struktur CNN yang siap pakai dan sudah dilakukan <em>pretrained</em> sebelumnya menggunakan dataset yang lebih banyak dan beragam. Biasanya <em>pretrained model </em>akan lebih cepat converge ke loss yang minimum dan hasilnya memuaskan. <strong>Tapi memang tidak semua kasus bisa diselesaikan dengan <em>pretrained model</em> ini</strong>. Selain VGG16, dalam keras terdapat <em>restnet, inception, mobilenet</em> dan lainnya (daftar lengkap <a href="https://keras.io/api/applications/">disini</a>).</p><p>Percobaan terakhir ini menggunakan input 224x224 dengan satu dense layer 8 nodes diakhir karena akan prediksi 8 kelas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0k0ZddBoiWudiePsKhfwxg.png" /><figcaption>Eksperimen 6: VGG 16</figcaption></figure><p>Model 6 ini di training 2 kali :</p><ol><li>Menggunakan augmentasi rotation range = 75 → Early stopping di 22 Epoch (42 detik per epoch di Google Colab).</li><li>Lanjut Training (transfer learning dari sebelumnya), dengan augmentasi rotation range = 90 dan horizontal_flip=True. → Early stopping juga di 22 Epoch (42 detik per epoch di Google Colab).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ozQ6MRYZFHzRZQgy_hNOA.png" /><figcaption>Perbandingan hasil Model 6</figcaption></figure><p>Hasil diatas menunjukan augmentasi bisa berperan penting dalam meningkatkan akurasi model. Namun di kasus ini, augmentasi sepertinya sangat berpengaruh pada dataset validation. <strong>Disini terlihat bahwa dataset validasi dan test tidak terlalu memiliki sifat yang sama</strong>, yang mana seharusnya validasi bisa menjadi tolak ukur evaluasi test.</p><p>Prediksi VGG16 disini lebih baik dari model-model sebelumnya juga karena inputnya yg lebih besar (224 x 224) dan layer CNN-nya yang lebih tebal. Berikut <em>Classification Report</em> untuk <em>Test</em> menggunakan VGG16 ini :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*VDdjQYT8vI2vCPH9mCxdPQ.png" /><figcaption>Classification Report test VGG16</figcaption></figure><h3>Evaluasi lebih mendalam</h3><p>Kurang rasanya jika Classification tanpa <a href="https://www.dataschool.io/simple-guide-to-confusion-matrix-terminology/"><em>Confusion Matrix</em></a>. Berikut adalah <em>confusion matrix</em> dari hasil prediksi untuk data test yang pastinya belum dilihat oleh model sebelumnya — dengan akurasi 94%. Ada 10 gambar yang missclass dari 160 gambar yang ada di data test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GISBaBMFyuyusAWEupnrhg.png" /><figcaption>Confusion Matrix: Test Dataset</figcaption></figure><p>Seperti yang di duga diawal, model <strong>masih terbolak balik antara kue lumpur (label 4) dan serabi (label 7)</strong>. Disini ada 3 gambar serabi yang di duga sebagai kue lumpur. Ditambah lagi False Positive dari kue lumpur (label 4) juga cukup tinggi yang membuat label ini memiliki Precision terendah dari yang lain — bisa dilihat di<em> Classification Report</em> diatas. Bagusnya, <em>missclassification</em> di kasus ini terkadang masih bisa diindikasi dengan tingkat kepercayaan (<em>Confidence Level</em>) yang rendah.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tR29DQDQMcSFyeNusWdPaw.png" /><figcaption>missclass: kue serabi vs kue lumpur</figcaption></figure><p>Hasil lain yang sesuai dengan dugaan diawal adalah <strong>kue lapis (label 3) menjadi label yang nilai evaluasinya paling bagus</strong>. Terlihat dari confusion matrixnya, tidak ada satupun False Negative atau False Positive dari kue ini (akurasi, precision dan recall 100% — lihat di <em>Classification Report</em> diatas). Hal ini terjadi karena memang bentuk <strong>kue lapis ini yang paling unik dari kue-kue lainnya</strong>. Selanjutnya, kue Klepon (label 2) memiliki tingkat akurasi terbaik kedua karena memang bentuknya yg selalu hijau dan bulat.</p><p>Analisa terakhir yang bisa dilihat adalah Tingkat Kepercayaan (<em>Confidence Level</em>) dari prediksi si Model. Pada kasus <em>missclasification</em> diatas ditunjukan <strong>beberapa prediksi mempunyai kepercayaan yang rendah</strong>. Artinya, jika sebuah prediksi tidak melebihi suatu Batas (<em>treshold</em>) biasanya prediksinya kurang memuaskan dan <strong>bisa di label sebagai “<em>undefined</em>”</strong>. Terkadang, Tingkat Kepercayaan ini menjadi rendah dikarenakan adanya <em>noise </em>digambar. Contohnya adanya tulisan atau warna yang agak blur, di kasus ini contohnya adalah <em>Dadar Gulung Polkadot</em> dibawah yang memiliki Tingkat Kepercayaan 0.883.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5_ks9rBH-4ZviUTtEWXg5w.png" /><figcaption>Good Classification Results</figcaption></figure><h3>Catatan Akhir</h3><p>Klasifikasi Gambar dengan kelas yang banyak memang penuh tantangan, karena <strong>harus bisa mengetahui secara garis besar karakteristik setiap kelasnya</strong>. Ditambah lagi terkadang ada kelas-kelas yang punya performa kurang baik dari yang lainnya, karena ada kelas yang mirip-mirip seperti kasus kue-kue diatas. Berikut beberapa poin yang bisa jadi perhatian saat melakukan pemodelan ini :</p><ol><li>Selalu mulai dengan struktur CNN yang kecil.</li><li>Percobaan pertama tidak selalu akan baik.</li><li>Jangan Takut menggunakan Google Colab untuk eksperimentasi. Karena <em>training </em>gambar memang membutuhkan <em>resource</em> cukup besar.</li><li>Untuk Gambar, coba lakukan augmentasi.</li><li>Usahakan Data Test dan Data Validation memiliki sifat yang sama.</li><li><em>Deepdive</em> ke deskripsi setiap kelasnya dan evaluasi lebih dalam untuk yang missclassification.</li><li>Pemodelan Tidak selalu mulai dari nol. Ada <em>pretrained model</em> yang bisa digunakan.</li><li>Disarankan untuk ada kelas <strong><em>“Undefined”</em></strong> atau <strong>“bukan kue” </strong>agar model belajar lebih baik lagi.</li></ol><h3>Reference</h3><ul><li><a href="https://github.com/alamhanz/just-cake">Repositori Just Cake</a></li><li><a href="https://towardsdatascience.com/a-simple-cnn-multi-image-classifier-31c463324fa">Simple CNN</a></li><li><a href="https://analyticsindiamag.com/transfer-learning-for-multi-class-image-classification-using-deep-convolutional-neural-network/">Transfer Learning</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a56857d8830" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science-indo/sekedar-kue-kue-3a56857d8830">Sekedar Kue-Kue</a> was originally published in <a href="https://medium.com/data-science-indo">Data Science Indonesia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[F.R.I.E.N.D.S: Character Classification Perspective]]></title>
            <link>https://alamhanz.medium.com/f-r-i-e-n-d-s-character-classification-perspective-37558ac12725?source=rss-c5465db64060------2</link>
            <guid isPermaLink="false">https://medium.com/p/37558ac12725</guid>
            <category><![CDATA[exploratory-data-analysis]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[modeling]]></category>
            <dc:creator><![CDATA[Alamsyah Hanza]]></dc:creator>
            <pubDate>Sat, 23 Jan 2021 18:08:29 GMT</pubDate>
            <atom:updated>2021-01-23T18:08:29.059Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5CoZ_ROycG9UGNwc.jpg" /><figcaption><a href="https://static01.nyt.com/images/2019/09/08/arts/08friends-wesley2/08friends-wesley2-jumbo.jpg">source</a></figcaption></figure><p><em>Friends</em> is one of the famous series which runs for 10 seasons (1994–2004). The series talks about the life of people in their late 20s which contains six main characters: Monica, Ross, Rachel, Joey, Phoebe, and Chandler. Even though the series has finished more than 15 years ago, it still becomes a favorite for the streaming audience.</p><p>The data analysis about this particular series also has spread online from a different angle, like <a href="https://medium.com/@liztersahakyan/the-one-with-the-data-scientist-a-closer-look-at-the-friends-of-friends-d3530d1902af">The One With The Data Scientist</a>, <a href="https://medium.com/analytics-vidhya/data-analysis-using-python-f-r-i-e-n-d-s-4fb3ac51717">F.R.I.E.N.D.S — Data Analysis</a>, or <a href="https://brightside.me/wonder-films/a-data-scientist-found-out-who-the-real-lead-character-was-on-friends-735060/">Who the Real Lead Character Was on “Friends”</a>. Those articles mostly talk about the deep analysis of the characters, runtime, sentiment, and relationship from the dialogue script they have, and it has really good visualization about it.</p><p>However, quite different from previous articles, one thing that interesting is how the scripts of dialogue can describe the character itself. The big question here is: can a model predict which character talks given a particular scene of the script?</p><h3>The one with Data</h3><p>This article uses the data source from <a href="https://fangj.github.io/friends/">here</a>, and there is some engineering work that has been done which makes the data look like below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IsySs87ZcDLW9HTqhOT6rg.png" /><figcaption>the complete dialogue</figcaption></figure><p>As usual, the data needs to be split into two. In this case, there will be seen_data and unseen_data . The seen_data is all dialogue <strong><em>from season 1 to season 8 which will be used for training the model</em></strong>. Meanwhile, the unseen data is the rest of the season to check the model works well.</p><p>The data consist of the episode, the character (and its label), the scene (and its label), and the dialogue (the raw and the clean one). Cleaning the dialogue quite tricky since it also contains the act of the characters, which will be ruled out for this analysis.</p><h3>The one when you realize</h3><p>The feature to generate the “scene” to predict character obviously the dialogue itself. By ruled out another character other than the six main characters as “others”, this is the quick observation of the dialogue with a length less than 5.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SBfK_WWYf3KQRU1kecx7Jw.png" /><figcaption>word cloud of length 5 or less dialogue</figcaption></figure><p>The word cloud shows most of the words between characters almost the same. Thus the words like ‘yeah’, ’okay’, ’hey’, etc are removed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cyR-0o8JSyMpCIKhU5uRKQ.png" /><figcaption>word cloud clean</figcaption></figure><p>The analysis focus on 5 or fewer length since the p50 of dialogue length is 7 words. It is just a simple exploration to remove the noise factor that can’t distinct the character. This removal emphasizes words like “honey” in Monica, and “pheebs” in Joey.</p><p>After the text cleansing, here are the latest dataset looks like,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*0V1GVRAIQd02QDLPj-ZOOg.png" /><figcaption>first dataset</figcaption></figure><p>where the label mapping like this (ignores “others”) :</p><pre>{0: &#39;rachel&#39;, 1: &#39;ross&#39;, 2: &#39;monica&#39;, 3: &#39;chandler&#39;, 4: &#39;joey&#39;, 5: &#39;phoebe&#39;}</pre><p>The proportion of the label also almost the same :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*9sFfCICyiz9dNZv_ukcaow.png" /><figcaption>label proportion</figcaption></figure><p>After getting the data, the LSTM model is trained by certain parameters with MAX_LEN = 20 and EMBED = 128, here is the result of the unseen data prediction (season 9 and 10) :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*D3lyMaO14M0osiPvVEB-mQ.png" /><figcaption>first model prediction</figcaption></figure><p>The macro avg of the f1 score is 0.21 which not really good. Most of the prediction falls on Rachel or Monica which seems that most of the words that used by other character are used by them.</p><p>This shows the lines are not enough to predict the character, it needs more context. In a scene, the lines are not just generated by the characters but appear to respond to the interlocutors. Therefore the second dataset is generated :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y1U-7m6F6DRRmUj1iHbdUw.png" /><figcaption>second dataset</figcaption></figure><p>text1 is the line of interlocutors and text2 is the line of predicted character. Using 2 input of LSTM, here are the results of the unseen data prediction :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*4T0LjpGcCv3wmLaP2OpZpQ.png" /><figcaption>second model prediction</figcaption></figure><p>The result is better, but not significantly better. The model still ignored chandler, joey, and phoebe. One hypothesis is these characters don’t have unique terms. It is really hard for the model to distinguish the characters. However, as a note, the model here hasn’t really built optimally which could be one of the factors.</p><h3>The one where lines are not enough</h3><p>Clearly, even though with the optimal text cleansing and model, text data will not really enough to predict character. Since the premise indicate that the input of the model must “scene of the script”, we can use the place and the interlocutors on the scene.</p><p>There are many places on the script, it even has different names for the same place. Like “Monica and Rachel&#39;s apartment” and “Monica and Chandler’s apartment” which is the same place in the series. The manually labeled of the place generates 13 different places. This is the simple exploration between characters and the places :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W5vWd7BoSXoXjEFIjJL-ag.png" /><figcaption>Characters vs Places</figcaption></figure><p>The table shows the percentage of the place becomes the scene location by each character. For example, 41.08% of place label 4 (which is Ross’s apartment) becomes Ross&#39;s scene location. A further example, Chandler and Joey dominate place label 3 (Chandler and Joey’s apartment).</p><p>Not only the places, but the interaction between character also become quite important:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hfgkaz6quS96UaZfXmfsyw.png" /><figcaption>Characters Relationship each season</figcaption></figure><p>One significant changes happen after season 4, there are intense Chandler-Monica interaction. It happens after the “london” accident which really change the proportion interaction there. Also, Interaction between Joey and Rachel also increase since they are become roommate on season 7. Based on this analysis, we can have hypothesis that the early seasons will not relevant anymore to predict character on season 9 and 10.</p><p>Consider the above exploration, here is the data if we add the person who the characters interact with (label_prev) and the places of the scene.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5LCXCy35fukTEpkleOMEmA.png" /><figcaption>third dataset</figcaption></figure><p>After that, the third dataset is devided into “All season dataset” and “After 3rd seasons datasets” (remove first, second and third season) to test the hypothesis. Use the same keras structure, the below confusion matrix shows the evaluation between “All dataset” (Confusion matrix 3) and “After 3rd seasons datasets” (Confusion matrix 4).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*52T7sh4g8v81XsJ1U_jTcQ.png" /><figcaption>Model 3 and 4 evaluations</figcaption></figure><p>It tells us that the new feature make significant improvement, some characters even have recall almost 50%. Moreover,removing seasons 1 to 3 also gives quite improvements to predict Rachel, Ross, Monica, and Chandler. Meanwhile, Joey has decreased accuracy and the model really can’t distinguish him with Rachel, Ross and Monica. Also, Phoebe seems almost the same as Ross.</p><h3>The one which still needs an answer</h3><p>The model of characters predictions given a scene still needs <a href="https://github.com/alamhanz/the-one-with-friends">improvements</a>. The trained model above hasn’t been optimized and maybe there are some unexplored aspect of “the scene” that may improve the model.</p><p>In conclusion, a modelling is not only talk about the algorithm, but also the features, which needs the understanding of the cases. In this case, the model still can’t predict the characters well but it gets improvement (in terms of macro avg) from 0.24 to 0.37 because we do more exploration on the features. Sometimes, it is fine to not really success to build a model in the beginning, since the modeller also need to have done several iteration to learn the cases and gets the best model in the end.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37558ac12725" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PCA: beyond a features reduction]]></title>
            <link>https://medium.com/data-science-indo/pca-beyond-a-features-reduction-579d908d6267?source=rss-c5465db64060------2</link>
            <guid isPermaLink="false">https://medium.com/p/579d908d6267</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[correlation]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Alamsyah Hanza]]></dc:creator>
            <pubDate>Thu, 28 May 2020 13:58:19 GMT</pubDate>
            <atom:updated>2020-05-28T14:04:51.702Z</atom:updated>
            <content:encoded><![CDATA[<p><em>The Article for Indonesia’s Audience or people who understand Bahasa</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wJZ9iNx09u2J7ADR.jpg" /><figcaption><a href="https://en.wikipedia.org/wiki/Darts">source</a></figcaption></figure><p>Menulis itu kadang melelahkan, ini bukan curhat, tapi memang butuh kemauan yang besar (mencoba menaikan niat diri sendiri untuk menulis ini). Di masa-masa PSBB seperti sekarang ini, merupakan saat yang tepat untuk memulai kembali apa yang sudah tertunda sejak awal tahun. Berbagi bahan pikiran dan menunggu <em>feedback </em>dari yang membacanya. Tulisan ini masih jauh dari kesempurnaan, apalagi untuk masalah kebakuannya.</p><p>Pada kesempatan kali ini, ditulisan ini akan dibahas mengenai PCA (<em>Principle Component Analysis</em>) yang sudah biasa digunakan oleh para praktisi Data. Mungkin sedikit berbeda dengan penjelasan yang sudah ada sebelumnya <a href="https://towardsdatascience.com/a-one-stop-shop-for-principal-component-analysis-5582fb7e0a9c">disini</a>, <a href="https://setosa.io/ev/principal-component-analysis/">disini</a>, dan <a href="https://medium.com/@raghavan99o/principal-component-analysis-pca-explained-and-implemented-eeab7cb73b72">disini</a>. Tulisan ini akan bahas sedikit lebih dalam mengenai apa yang bisa dilakukan praktisi Data dengan PCA selain mengurangi dimensi data. Di sini juga akan dibahas mengenai efek yang akan terjadi dengan hasil PCA jika tidak ada <em>preprocessing </em>diawal. (<a href="https://github.com/alamhanz/pca-dataanalysis"><em>related github</em></a>)</p><h3>Data Description</h3><p>Untuk mempermudah visualisasi dan penjelasan, penulis akan menggunakan data sample yang tersedia di database penulis. Data ini sepertinya sudah tersimpan lama dan penulis sudah tidak terlalu mengingat dapat dari mana data ini. Tapi untuk diingat, <strong>segala efek dan penjelasan yang akan disebutkan disini sangat tergantung dengan data yang digunakan</strong>. Sehingga mungkin masih butuh penjelasan yang lebih umum dan ilmiah untuk ditarik kesimpulan yang benar. Namun, hasil tulisan ini mungkin masih bisa digunakan untuk <strong><em>quick reference only</em></strong><em>.</em></p><p>Data yang akan digunakan adalah Data Wine, yang setiap barisnya menunjukan merk Wine yang berbeda. Kolom-kolom data ini berisi deskripsi dari Wine tersebut dengan kolom paling terakhir menunjukan bagaimana tingkatan kualitas Wine tersebut.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*myu17pjs7Rd8iMCfOyeF3w.png" /><figcaption>Wine Quality Data</figcaption></figure><p>Data terdiri dari 1599 Wine berbeda (asumsi) dengan 11 kolom deskripsi dari Wine yang terkait. Mulai dari tingkat keasaman, kandungan gula dan kandungan sulfur (somehow). Penulis juga tidak yakin dengan satuan dari setiap kolom tersebut, namun kualitas data cukup baik sehingga bisa digunakan sebagai contoh ditulisan ini. Berikut ini deskripsi dari data diatas,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pnQkxFDasZ8X4wD7NRmf2A.png" /><figcaption>Wine Quality Data Description</figcaption></figure><p>Deskripsi diatas menunjukan bahwa,</p><ol><li>Tidak ada <em>Missing Value </em>(<em>count</em>-nya sama semua)</li><li>Ada beberapa kolom yang mempunyai pencilan (<em>outlier</em>), bisa diliat ada yang nilai maksimum-nya sangat jauh dari persentil 75 ke maksimumnya.</li></ol><h3>Plain PCA</h3><p>Pertama-tama akan ditunjukan hasil PCA tanpa <em>pre-processing </em>dan apa saja yang bisa didapatkan dari PCA tersebut. Menggunakan data <em>Wine Quality </em>diatas didapatkan hasil PCA sebagai berikut (input-nya adalah semua kolom kecuali <em>quality</em>),</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2aIv14C3cFMB2nvDJ5VFdw.png" /><figcaption>Plain PCA</figcaption></figure><p>Hasil PCA adalah data dengan nilai baru dengan dimensi yang sama dengan dimensi data input, dimana nilai baru ini tidak bisa diinterpertasikan. Data baru ini juga memiliki nilai variansi informasi yang sudah diurutkan, dimana dimensi pertama (p_1) lebih “informatif” dibanding yang kedua (p_2) dan seterusnya. Sehingga, kolom yang paling terakhir atau beberapa kolom dibagian akhir bisa di hilangkan karena kurang “informatif” (disini <em>dimension reduction </em>terjadi). Berikut ini adalah <em>cumulative sum </em>dari variansi informasi yang diduga ada di setiap kolom. Bisa dilihat bahwa setelah p_2 variansi informasi tidak bertambah secara signifikan lagi (dan sudah mencapai lebih dari 0.99), maka dari itu, kolom setelah p_2 bisa diabaikan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BURQGQEIueHYsTnjXwaQ5g.png" /><figcaption>Variance Contribution Cumsum</figcaption></figure><p>Di artikel ini tidak akan dijelaskan bagaimana nilai itu bisa dibuat dari input (untuk lebih detailnya bisa dilihat <a href="https://towardsdatascience.com/a-one-stop-shop-for-principal-component-analysis-5582fb7e0a9c">disini</a>), namun artikel ini akan lebih mencoba menjelaskan output lain didapat selain data baru tersebut. Setelah menelusuri beberapa teori disini dan disini, didapat bahwa PCA bisa menghasilkan <em>circle of correlation </em>seperti contoh dibawah ini.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YfRltIpZeaLSFoqOlwC3Lw.png" /><figcaption>First CoC</figcaption></figure><p>Di dalam grafik tersebut, setiap garis mewakili satu kolom dari data input. Jarak garis tersebut dari <em>origin </em>menunjukan <strong>seberapa besar variansi informasi dari kolom yang berhubungan dengan garis tersebut</strong>. Garis-garis yang mengarah ke arah yang sama/hampir sama menunjukan bahwa kolom-kolom dari garis-garis tersebut <strong>memiliki korelasi positif yang tinggi</strong>. Sedangkan garis-garis yang berlawanan arah artinya <strong>kolom-kolom dari garis-garis tersebut berkorelasi negatif</strong>. Sementara itu garis-garis seperti <em>free_sulfur_dioxide </em>dan <em>total_sulfur_dioxide</em>, yang memiliki sudut hampir 90 derajat, memiliki arti bahwa <strong>kolom-kolom dari garis-garis tersebut tidak saling berkorelasi</strong>.</p><h3>Standardized PCA</h3><p>Grafik CoC diatas terlihat begitu meyakinkan bahwa <em>free_sulfur_dioxide </em>dan <em>total_sulfur_dioxide </em>memiliki kontribusi besar dalam variansi informasi. Namun, bisa dilihat dari deskripsi data bahwa nilai kedua kolom tersebut memiliki rata2 yang tinggi dari yang lain. Ini menenjukaan bahwa kolom-kolom dari data contoh disini memiliki satuan yang berbeda. Sehingga grafik CoC diatas tidak valid dan <em>bias. </em>Untuk itu harus dilakukan <a href="https://towardsdatascience.com/normalization-vs-standardization-quantitative-analysis-a91e8a79cebf">standarisasi</a> dengan StandardScaler di sklearn.</p><p>Grafik berikut adalah <em>cumulative sum </em>dari variansi informasi untuk data yang di standarisasi. Disini komponen p_7 baru bisa mencapai kontribusi lebih dari 90, sangat berbeda dari data yang tidak di standarisasi.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XddfFXGDUyFUJKG6-heKVA.png" /><figcaption>Standardized Variance Contribution Cumsum</figcaption></figure><p>Hasil CoC-nya pun berbeda antara <em>standardized</em> dan <em>non-standardized</em>. Berikut adalah CoC dari top 7 kolom yang memiliki kontribusi paling besar untuk variansi informasi.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bfSM-wkj_yWgItG1nHZCcQ.png" /><figcaption>Standardized CoC</figcaption></figure><p>Sedikit berbeda dengan Plot CoC sebelumnya, Plot CoC ini menunjukan <em>total_sulfur_dioxide </em>dan <em>free_sulfur_dioxide </em>memiliki kontribusi tinggi namun korelasinya tinggi (karena searah). Sementara itu, Kolom <em>citric_acid </em>dan <em>fixed_acidity </em>berbanding lurus dan berkorelasi tinggi ditambah kedua kolom tersebut berbanding terbalik (karena berlawanan arah) dengan <em>pH. Insight</em> yang didapat itu sangat sesuai dengan <em>nature</em> bahwa semakin rendah pH semakin tinggi tingkat keasaman.</p><p>Karena penjelasan-penjelasan tersebut bisa langsung terlihat dari CoC, maka CoC bisa membantu dalam <strong>optimisasi banyaknya kolom untuk <em>clustering</em></strong><em>. </em>Berdasarkan CoC tersebut, <em>total_sulfur_dioxide, chlorides </em>dan <em>fixed_acidity </em>adalah kolom-kolom yang cukup untuk melakukan <em>clustering. </em><strong>Kolom-kolom ini dipilih karena tidak saling berkorelasi dan memiliki kontribusi informasi variansi yang tinggi diantara kolom-kolom yang berkorelasi dengannya</strong>.</p><h3>Remove Outliers Standardized PCA</h3><p>Masalah lainnya yang belum diselesaikan adalah masalah pencilan (<em>outliers</em>). Berdasarkan distribusi data yang distandarisasi dibawah ini, kolom <em>chlorides </em>memiliki nilai yang sangat tinggi. Dipastikan akan ada pencilan yang sangat dipengaruhi oleh kolom ini.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5HLddgdynR-40rsXhBNcPA.png" /><figcaption>Standardized data Distributions</figcaption></figure><p>Untuk itu pencilan ini harus di <em>remove </em>dari data, pembersihan pencilan ini dilakukan dengan menggunakan metode <a href="https://towardsdatascience.com/anomaly-detection-with-isolation-forest-visualization-23cd75c281e2"><em>isolation forest</em></a>. Setelah pembersihan data dari pencilan, ada perubahan besar dari CoC plot sebelumnya.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xyH76F28uAErYHHeYF6JDQ.png" /><figcaption>Non-Outlier CoC</figcaption></figure><p>Perubahan signifikan yang terjadi adalah <em>chlorides </em>dan <em>free_sulfur_dioxide </em>tidak lagi masuk ke top 7 kolom yang memiliki kontribusi besar. Ditambah juga korelasi <em>citric_acid </em>dan <em>fixed_acidity </em>berkurang (karena saling menjauh). Melalui CoC ini bisa ditentukan bahwa <em>total_sulfur_dioxide, density </em>dan <em>fixed_acidity </em>adalah kolom-kolom yang optimal untuk <em>clustering.</em></p><h3>Conclusion</h3><p>PCA secara alaminya mengumpulkan variansi informasi dan mendistribusikan variansi tersebut menjadi komponen-komponen utama. Dimana komponen pertama memiliki variansi informasi paling banyak dibanding komponen setelahnya. Hal ini yang membuat hasil PCA bisa memberikan informasi kolom mana yang memiliki variansi informasi paling banyak. <em>Insight </em>ini bisa di visualisasikan dengan <em>Circle of Correlation,</em> yang mana langsung memberikan informasi mengenai kolom mana yang <em>matter, </em>kolom mana yang bisa diabaikan.</p><p>Namun perlu diingat, <strong>segala transformasi yang dilakukan melalui PCA ada baiknya dilakukan setelah <em>data cleansing </em>dan standarisasi</strong><em>. </em>Pembersihan data ini mencakup data yang hilang atau data yang terlalu berbeda dengan lainnya (pencilan). Ada baiknya dilakukan standarisasi juga sehingga satuan dari setiap kolom akan sama.</p><h3>Further Reading</h3><p><a href="https://ncss-wpengine.netdna-ssl.com/wp-content/themes/ncss/pdf/Procedures/NCSS/Circular_Data_Correlation.pdf">Circular Data Correlation</a></p><p><a href="https://github.com/alamhanz/pca-dataanalysis">Related Github</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=579d908d6267" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science-indo/pca-beyond-a-features-reduction-579d908d6267">PCA: beyond a features reduction</a> was originally published in <a href="https://medium.com/data-science-indo">Data Science Indonesia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Voronoi Method: Zoning School System Proposal]]></title>
            <link>https://medium.com/data-science/voronoi-method-zoning-school-system-proposal-8ea333e9ece1?source=rss-c5465db64060------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ea333e9ece1</guid>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[spatial-analysis]]></category>
            <category><![CDATA[voronoi]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Alamsyah Hanza]]></dc:creator>
            <pubDate>Sun, 24 Nov 2019 05:47:55 GMT</pubDate>
            <atom:updated>2022-07-26T22:50:59.670Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yNNsoS3nv3ywF-r4TG9hRg.jpeg" /><figcaption>source : <a href="https://unsplash.com/photos/J17gyn1adEM">unplash.com</a></figcaption></figure><p>Maybe it is kinda too late for me to discuss this matter now. Because of the Zoning School System is not a <em>thing</em> right now, but it is a big deal in Indonesia around May and June 2019.</p><p>Indonesia has this a new rule (followed by another rule) to create some kind like “Zoning System” where a future student can’t choose the next level school outside their Zone. However, to be honest, I do not really understand the rule pretty much. So, here is an article in Bahasa about the rule and the reason why the government issuing the regulations.</p><ul><li><a href="https://tirto.id/memahami-sistem-zonasi-sekolah-di-ppdb-2019-ecEz">Memahami Sistem Zonasi Sekolah di PPDB 2019 - Tirto.ID</a></li><li><a href="https://edukasi.kompas.com/read/2019/06/20/11111981/9-poin-buka-bukaan-mendikbud-soal-sistem-zonasi-dan-ppdb-2019?page=all">9 Poin Buka-bukaan Mendikbud Soal Sistem Zonasi dan PPDB 2019</a></li></ul><p>All the rules there creates many viral negative feedbacks from the public as follows,</p><ol><li>Some students can’t go to school because they can only choose one school (The Radius Rule) that already full.</li><li>Some schools can’t get enough students because their area is not that dense enough.</li><li>Imbalance quality inter-zone.</li></ol><p><a href="https://www.kompasiana.com/muhamad27970/5d0257d43ba7f74e4e772572/dilema-zona-2-ppdb-online-sistem-yang-kurang-berkeadilan?page=all">Click here</a> for some details about the problem.</p><p>I won&#39;t talk about the rules and how that rule makes a big impact on future students in Indonesia. Also, I won’t blame the rule itself, because I’m not sure how Indonesia’s Government comes up with the rule. However, in this blog, I want to propose some kind of method to do this “Zoning Problem” that <em>probably </em>can minimize the negative impact. I will show how I do the analysis and end up with the methods.</p><h3>Defining the Problem</h3><p>Every analysis must start with the problem definition which has the Northstar as the real goal. In this blog, I have a goal to do make a zoning school system with a minimum of the first negative impact above. I limit the problem to just minimize the first problem because I have limited data to work on. The second problem probably can be solved with density population data, meanwhile, the third problem should use the standardized quality of all schools.</p><p>So, based on my goal there, my problem statement is</p><p><em>“How to create the Zoning School system, so that the future students have at least 3 schools to choose?”</em></p><h3>Data Collection</h3><p>After we have the problem statement, the next to do is to get the data that is suitable for the problem. I need the location of all the schools in Indonesia in terms of longitude and latitude so I can define the zone. I get the data from this <a href="http://dapo.dikdasmen.kemdikbud.go.id/sp">source</a> which I think is open for anyone (at least in Indonesia). So, I crawl all the possible school that is listed there with its information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5ozxZrAKWPriEp8-GjdrCg.png" /><figcaption>Get the Longitude and Latitude</figcaption></figure><p>It takes me about 2 days to get the right data and I get around 200.000 schools in Indonesia from all levels: elementary schools (SD), Junior High School (SMP) and Senior High School (SMA/SMK). I am not sure about the quality of the data, but when I try to plot all the Longitude and Latitude from the website here is the result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qc5xFss6c4yMhnxsOkTujw.png" /><figcaption>Probably All School Location in Indonesia</figcaption></figure><p>It shows the map of Indonesia, so the plot can confirm the data’s quality is good enough. To compare with the real map, I use python to read the shapefile of Indonesia’s map on the city level from this <a href="https://gadm.org/download_country_v3.html">source</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e-n8sI7Mkvi1DxMDBb4Y5Q.png" /><figcaption>Indonesia’s Map</figcaption></figure><p>Even with almost the same shape, after checking the data, there almost 2% of points are not exactly within the city polygon. The points outside polygon will be removed from the methods analysis. Here is an example from `Surabaya` which has points outside the polygon (red dots).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xp7Nn8ntnM4oSM6uYkytvQ.png" /><figcaption>Surabaya All School Location’s</figcaption></figure><p>For a simple exploration, this is the heatmap of a total number of schools that are officially registered on the website in every city in Indonesia. The red area is a missing value because of the different name conventions of shapefile and scrapped data. The map shows there is more school is developed on Java island (the big island with yellow color in the south) than another island. Also, other than Java island, <strong><em>the number of schools is not spatially correlated</em></strong>. Sumatera for example (the big island on West), it has a yellow area which surrounded by green area.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vmDMjxlN3a5qd1eQGcQcjw.png" /><figcaption>Total School in Every City of Indonesia</figcaption></figure><h3>Overview of Radius Principal</h3><p>Before proposing the method, let&#39;s take a look at Zoning System using Radius Principal. The method is not that complex, <em>Future Student School Zone</em> is within radius <em>X</em> kilometers from the house.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*67TbF4Yh2mU7kl_57zjHGg.png" /><figcaption>Radius Principal</figcaption></figure><p>So, the student can’t choose a school that really far from their house (red area). This principal probably will work if it is guaranteed there will be schools within the zone. Let’s simulate this approach using Indonesia school location data.</p><p>The simulation is easy, just pick many random points on the polygon of a particular city and do iteration for different radius from schools (it easier to change radius from school point than random points, the result will the same). The random points are assumed to be the student house, this assumption can be fulfilled if the city is dense enough. Because we don&#39;t want the random points to end up in the middle of the forest or abandoned lake. Thus, based on certain references, the simulation is done on <em>DKI Jakarta, Kota Surabaya, Kota Medan, Kota Bandung, Kota Makassar, and Kota Palembang</em>. As a note, <strong>the simulation using Senior High School (SMA)</strong> data location only.</p><p>This is the simulation example on <em>Surabaya </em>where the color shows the number of school choices that every random point will get for a particular radius. The red dot is the SMA location in Surabaya.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*1gN-ma1gZwJ_URMyU9zYmg.gif" /></figure><p>The simulation overall dense cities show that, for a different area, the probability of all students to get a minimum of 3 schools to choose is different. The graph below tells the probability — in percentage — of students to get a minimum of 3 school options (y-axis) with a certain radius from their house (x-axis) for many different cities (distinct by colors). So, it is expected that the higher of the x-axis, the closest of the line to 100.</p><p>The graph describes that even with radius <em>X=</em>4 km, there is a certain area like <em>Palembang </em>which still has probability under 80%. Even a city called <em>Bandung Barat </em>can’t reach 60% with a radius <em>X</em>=5 km.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bnQtpdPCXCU0fvupu6m27w.png" /></figure><p>The probability that means students need to travel with a minimum of 5 km to get at least 3 school choices with probability 60% to get all the schools in <em>Bandung Barat. </em>Moreover, the radius here using Euclidian distance, so the true distance in real life could farther than 5 km.</p><p>In summary, the Radius Principle is better to be used for a city with a high population density. However, if the methods must be implemented for all cities with different density, then the<strong><em> radius distance should be different for a different area</em></strong> depends on the population density. Even the city could be divided into certain smaller areas and adopt different radius for those areas. Not only that but, developing new schools is also necessary for certain areas who really have a small number of schools. So, students will have different schools to choose and they should not spend their time on the road.</p><h3>The Proposed Methods</h3><p>A zoning system is really challenging, especially the area that is full of small islands like Indonesia. The radius principal above has a lack of variety and it needs more exploration to determine the right radius for the right city. It also has a disadvantage if the student comes from a different island like <em>Makassar</em>. If the island distance to the closest school is more than the radius, the possibility of all students on that island to get to school is almost zero.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pvyalvyXJv3NbBbs3g-_aQ.png" /><figcaption>Makassar has many smalls island</figcaption></figure><p>Therefore the new method called Voronoi is proposed to minimize the time-consuming exploration to determine the radius. Voronoi is a method to make a partition of a plane into regions close to each of a given set of objects. Imagine we have a plane and there are some points on the plane, Voronoi&#39;s objective is to make regions where every region is closer to a particular point than the other points.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/0*FC-nX3jbnJeXmh71" /><figcaption>Voronoi diagram example (<a href="https://thatsmaths.com/2017/02/02/voronoi-diagrams-simple-but-powerful/">source</a>)</figcaption></figure><p>Let say we have a map and all location of schools, the Voronoi will automatically create the region for every school such that every student in that region is closer to that school than the other schools. However, it means every student only has <strong>one school option</strong> to choose if they must enter the closest school. Thus, the school clustering is proposed to create a larger area where students can have 3 schools minimum options. For now, I proposed <a href="https://towardsdatascience.com/understanding-k-means-clustering-in-machine-learning-6a6e67336aa1">KMeans</a> to cluster the schools in every city (its better use the HDBSCAN for future reference), which leads us to another problem to choose the cluster number. For that case, the cluster number can be evaluated using a <a href="https://medium.com/@jyotiyadav99111/selecting-optimal-number-of-clusters-in-kmeans-algorithm-silhouette-score-c0d9ebb11308">silhouette score</a> where we will choose the cluster number with the highest score. It must keep in mind that <strong><em>all schools here are assumed has the same quality </em></strong>to prevent the cluster from all bad schools.</p><p>In summary, this is the algorithm of the proposed method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xnc8p8nfhvc7S28haLJ6tg.png" /><figcaption>Pseudocode of the Algorithm</figcaption></figure><p>This is the result of the algorithm for <em>Makassar </em>and <em>Bandung Barat.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ucwhbw9jNcZHJ5yzijaxRQ.png" /><figcaption>Senior High School (SMA) Proposed Zoning System</figcaption></figure><p>The Voronoi method will ensure every student in the city will have a minimum of 3 option schools, it solves the “60% problem” on Bandung Barat before. The Voronoi also helps students on the far island to have a chance to get to school.</p><p>However, for some zone like the brown area on Bandung Barat (bottom left), the <strong><em>students must travel quite longer in averages </em></strong>because of the zone is quite big with only 3 options of schools. It probably shows that the Voronoi method will not solve the “All School is already full in this region” problem. This problem also shown in <em>Palembang </em>on the green zone (top left) and <em>Surabaya </em>on the violet zone (top left).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5UlhjQ2bhYlO-KcBlJtGgw.png" /><figcaption>Surabaya and Palembang Proposed Zoning School for SMA</figcaption></figure><h3>Conclusion and Recommendation</h3><p>The Zoning system is built to equalize the quality of education such that there will be no higher or lower class region in terms of education. Even with the good intention, the poor Zoning system and the not standardized quality of schools will make the education system seems bad and reduce the right many students to get to a school.</p><p><strong><em>The Radius Principle</em></strong> is one example of a deficient method to do Zoning system, especially for huge countries with a different population density all over the city. As the simulation shows, for Indonesia, with the same radius, the probability of students to get a minimum 3 schools option is variant. In <em>Jakarta</em>, the probability could reach almost 100% within a 2 km radius, but with the same radius, the probability is roughly 50% in <em>Palembang. </em>Thus, the<strong><em> </em></strong>radius distance should be different for a different area.</p><p><strong><em>Voronoi with KMeans clustering</em></strong> is another method that quite better than Radius Principle which can cover the Radius Problem. The Voronoi could make an optimal region for every school so that there is no region that will not have a school option more than 3. However, the problems happen if one school is covering a really large area because of the low number of schools in the neighborhood area.</p><p>Therefore, to make more optimal solutions here some action that can be done</p><ol><li>Built more schools around school that has a large Voronoi area. Or Expand the school which has a large Voronoi area.</li><li>Do more analysis on the quality of schools and make a standard quality for all cities in Indonesia. The quality here in terms of Facilities, number of teachers and class. So that we can do zoning with clustering where the total quality inter-cluster is the same.</li><li>Also, for the short term solution, increase public transportation for students so that they can reach the distant school instead of restricting their choice by doing the Radius Principle.</li></ol><h3><strong>Reference</strong></h3><ul><li><a href="https://github.com/alamhanz/education_zone/tree/master">alamhanz/education_zone</a></li><li><a href="http://comet.lehman.cuny.edu/owen/teaching/datasci/voronoiLab.html">Voronoi Diagrams Lab</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ea333e9ece1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/voronoi-method-zoning-school-system-proposal-8ea333e9ece1">Voronoi Method: Zoning School System Proposal</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Comparison of Multiverse Words Space]]></title>
            <link>https://alamhanz.medium.com/the-comparison-of-multiverse-words-space-fdc241c8966c?source=rss-c5465db64060------2</link>
            <guid isPermaLink="false">https://medium.com/p/fdc241c8966c</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Alamsyah Hanza]]></dc:creator>
            <pubDate>Mon, 12 Aug 2019 13:48:58 GMT</pubDate>
            <atom:updated>2019-08-12T13:48:58.781Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*iqjDv4yzpyVEdou8ejXzNA.png" /><figcaption>The same object at a different universe (<a href="https://matthiasgiesen.wordpress.com/tag/parallel-universe/">source</a>)</figcaption></figure><p>Machine learning has been trying to not only learning about numerical data but its also trying to figure what is happening on string data for decades. Such as text labeling, spam detector, sentiment analysis, document classification, etc. This type of machine learning, which has data string as a part of the predictor, is not literally using “string” type as part of the calculation behind it. Computers would not understand how to add “apple” and “blender” into “juice”. Therefore, <strong>word embedding </strong>comes to play to converting data string into numerical data which mostly transform words or documents becomes vectors. Not only acting as a converter but word embedding as a whole is a dictionary of documents that contain a number of words, word relation, etc.</p><p>This word transformation has various formats such as Count Vector, TF-IDF Vector, Co-Occurrence Vector, Skip Gram, Common Bag Of Words, etc. Every format can create its own universe of words, so that word “apple” in one universe would be totally different on the other universe. Therefore the result of prediction could be distinct for a different format in the same machine learning. But, how much the differences? which one is more effective?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*xz22UdISgurCuatKcgGeRg.png" /><figcaption>Two Kind of “apple” Vector Representative</figcaption></figure><h4><strong>Space of Word</strong></h4><p>In mathematics, vector space is a collection of objects called <strong>vectors</strong>, which may be added together and multiplied (or scaled) by particular numbers, called scalars (<a href="https://en.wikipedia.org/wiki/Vector_space">Wikipedia</a>). Thus, Word Space is like a room full of words that are represented as vectors which can be scaled and added each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GZLDx_zpFAtK-R4W.png" /><figcaption>Example of Word Space (<a href="http://wiki.fast.ai/index.php/Lesson_5_Notes">source</a>)</figcaption></figure><p>The above picture is an example of transforming words into a 2-dimensional vector (which mostly describe as a point). In Word Space, the vector is a finite <em>n</em>-dimensional vector where <em>n</em> is a <a href="https://en.wikipedia.org/wiki/Natural_number">natural number</a> more than zero. These <em>n</em>-dimensional vectors contain an <em>n</em> real number, therefore these vectors can be added or subtracted each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/0*aZyIDb5K4kOFBQV1.png" /><figcaption>King — Man + Woman = Queen (<a href="https://blogs.mathworks.com/loren/2017/09/21/math-with-words-word-embeddings-with-matlab-and-text-analytics-toolbox/">source</a>)</figcaption></figure><p>However, not every Word Space could create such an astonishing result like on the picture.</p><h4><strong>Work in a Multiverse of Word</strong></h4><p>As mentioned before, one word can be represented as a different vector based on the technique and the corpus of the word coming from. Corpus is a collection of texts such as a collection of articles, a collection of books or even a book itself is a corpus. So that, even if using the same technique, a word “leaf” in a corpus of biology books and “leaf” in a corpus of a one-year newspaper will have a different vector representation. In terms of machine learning, a corpus can come from anywhere as long as its general corpus and contain all the words on data training. But sometimes the corpus is all data text on data training.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*oMyuoqLgMCzjeiBKksYz3g.png" /><figcaption>word — document — corpus hierarchy when the text data training is the corpus in Machine Learning</figcaption></figure><p>After the corpus is ready, its time to use some methods for converting the word or documents on the corpus to vectors. Here is a quick explanation of some method to convert words or documents into vectors.</p><p><strong>A. <em>n-</em>count vector (documents to vectors)</strong></p><p>This method allows converting documents (imagine one long sentence) into an <em>n-</em>dimensional vector where the entity of the vector shows the stats of the influential word (count or percentage) on the corpus of the documents. Usually, the influential word is the highest number count of the word in the corpus.</p><p>For example, there is a corpus/corpora with 3 documents as follows,</p><p>corpora :</p><ul><li>I Love you and your cat and dog and all</li><li>Love Love you and my dog now</li><li>my cat loves me and my dog</li></ul><p>These are the word count of the corpora,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*hBnX3h1kjD5Pc0m_b_GrPA.png" /><figcaption>Word Count of Corpora</figcaption></figure><p>Use the table above as reference to create an <em>n</em>-count vector for every document. The first thing to do is to define the most influential word, where, in this case, is the word with count number more than 1. Therefore, the documents will be transformed into a 6-count vector.</p><p>The infamous example of transformation is a 6-count vector with entities describing the count of the influential word on documents.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*sGDvavUkQNKNtPviXsxX5A.png" /><figcaption>Usual n-count vector</figcaption></figure><p>Another example is a 6-count vector which contains the percentage of the influential word on documents.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*pV2rkktBNfAvp-IObVXXJQ.png" /><figcaption>Percentage on n-count vector</figcaption></figure><p>The last variation is the boolean 6-count vector where 1 means the documents contain the influential word, otherwise is 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*V1AVnrTB3sESS56lNNK3Wg.png" /><figcaption>Boolean n-count vector</figcaption></figure><p><strong>B. <em>n-</em></strong> <strong>TF IDF vector (documents to vectors)</strong></p><p>The next method is TF-idF or Term Frequency Inverse Document Frequency. This embedding method is transforming every word based on the following formula,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zHh81pI_XjJ2o0vZpA6CzQ.png" /><figcaption>TF-idF Formula (<a href="https://www.freecodecamp.org/news/how-to-process-textual-data-using-tf-idf-in-python-cd2bbc0a94a3/">source</a>)</figcaption></figure><p>The formula tries to evaluate how important a word is to a document in the corpora by interpreting it as weight. Therefore, the weight of a word will be different in every document (that explain why the weight has two indexes). Here the example of TF-idF vector of the corpora above with the most influential word,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*CbXcXmxQD1eg5p1U04PJYw.png" /><figcaption>Tf-idF vector example</figcaption></figure><p><strong>C. <em>n-</em>Word2Vec (words to vectors)</strong></p><p>The last method that will be discussed is Word2Vec method. Unlike the tfidf method, the idea of the method is to transform words into vectors which have contextual meaning. The contextual meaning brings distance of two synonym words or correlated words shorter and the antonym is the opposite. It makes the computer understand that the word ‘fruit’ is correlated with ‘apple’, ‘orange’, etc. However, contextual insight will be different for different corpus.</p><p>The process to produce this kind of transformation is quite different from the previous, because it includes a deep learning process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BsaqUr4AFprzWfcD.png" /><figcaption>Word2Vec Training in Deep Learning (<a href="https://towardsdatascience.com/word2vec-skip-gram-model-part-1-intuition-78614e4d6e0b">source</a>)</figcaption></figure><p>In general, the practical way to do word2vec is by collecting the corpus and train the corpus on existed word2vec model like <a href="https://pypi.org/project/gensim/">gensim</a> for python or <a href="http://www.rpubs.com/mukul13/rword2vec">rword2vec</a> for R. After the training, the model can transform a word into an n-dimensional vector.</p><h4>Pre-trained Universe</h4><p>Internet is a mysterious place, there are many different pre-trained models (which means the model that is already trained with specific corpus, usually big amount of corpus) that can be found and easily downloaded free. The model sometimes is provided with different vector length and usually, have size more than 1 gigabytes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uiA7ECBwgYs9dmZVdmLIqg.png" /><figcaption>Many sources of the pre-trained model (<a href="https://github.com/3Top/word2vec-api#where-to-get-a-pretrained-models">source</a>)</figcaption></figure><h4>The Best Universe</h4><p>In short, like the <a href="https://en.wikipedia.org/wiki/No_free_lunch_theorem">no free lunch theorem</a> state, there is no single best model or technique to transform a word into a vector. It really depends on the cases, the corpus and importantly the objective of the usage.</p><p>For example, the general context model or pre-trained model can’t be used directly for a specific case like medical terms. There must be some words that have a different meaning in general and medical. Also, there must be words in medical that hasn’t been trained in the model.</p><p>Another example, the word2vec method can’t be used if there is a possibility of many new words in data that is not included in the corpus. On that case, the n-count vector is more reliable to transform the word.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F9RWcytIJi3uYo%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fboards-turner-9RWcytIJi3uYo&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F9RWcytIJi3uYo%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="355" frameborder="0" scrolling="no"><a href="https://medium.com/media/c441e56a2c4f8d0b727189acec0586f8/href">https://medium.com/media/c441e56a2c4f8d0b727189acec0586f8/href</a></iframe><h4>Conclusion</h4><p>The embedding process is one important process to do analysis or machine learning with string data. There are multiple techniques in the word embedding which creates some kind like word multiverse. Those multiverses have different characteristics and usage, some of it has contextual insight and some of it can’t be used on the specific use case. Therefore, the learning technique on the deeper context is necessary on how the embedding can be utilized in the analysis. It also the consequence of the no free lunch theorem we talk about previously.</p><p><strong>Reference</strong></p><ul><li><a href="https://towardsdatascience.com/introduction-to-word-embedding-and-word2vec-652d0c2060fa">Introduction to Word Embedding and Word2Vec</a></li><li><a href="https://skymind.ai/wiki/word2vec">A Beginner&#39;s Guide to Word2Vec and Neural Word Embeddings</a></li><li><a href="https://medium.com/explore-artificial-intelligence/word2vec-a-baby-step-in-deep-learning-but-a-giant-leap-towards-natural-language-processing-40fe4e8602ba">Word2Vec — a baby step in Deep Learning but a giant leap towards Natural Language Processing</a></li><li><a href="https://wikipedia2vec.github.io/wikipedia2vec/pretrained/">Pretrained Embeddings - Wikipedia2Vec</a></li><li><a href="https://machinelearningmastery.com/prepare-text-data-deep-learning-keras/">How to Prepare Text Data for Deep Learning with Keras - Machine Learning Mastery</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fdc241c8966c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Azab FTV: the other point of view]]></title>
            <link>https://medium.com/data-science-indo/data-azab-ftv-the-other-point-of-view-c4bac66abf75?source=rss-c5465db64060------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4bac66abf75</guid>
            <category><![CDATA[text-mining]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[bahasa-indonesia]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Alamsyah Hanza]]></dc:creator>
            <pubDate>Sat, 27 Oct 2018 05:03:11 GMT</pubDate>
            <atom:updated>2019-12-05T23:43:58.804Z</atom:updated>
            <content:encoded><![CDATA[<p><em>*the content will be written in Bahasa</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*sx644bMTJwIfoAFef11mQQ.png" /><figcaption>Punishment From God</figcaption></figure><blockquote><strong>azab</strong> <em>n</em> siksa Tuhan yang diganjarkan kepada manusia yang melanggar larangan agama: <em>dia takut akan — Allah;</em></blockquote><blockquote><strong>— sengsara</strong> segala macam penderitaan (kesengsaraan)</blockquote><p>Pada 24 Oktober lalu, <a href="https://kumparan.com/@kumparannews/pedagang-dan-pengangguran-paling-banyak-tertimpa-azab-di-ftv-1540365461559351076?fbclid=IwAR0YCp3kCL_kEHOnnxuz8Dxw6QjpM4R3ib7SiE-8Go2l2ccn64U2zo3Cq7k">Kumparan</a> merilis satu analisa dari data judul-judul ftv religi yang sedang menjadi topik hangat dalam beberapa minggu terakhir. Dalam tulisannya, kumparan menyatakan bahwa data tersebut menyebutkan bagaimana Pedagang dan Pengangguran Paling Banyak tertimpa azab disebut dalam judul-judul tersebut. Tak hanya azab menurut profesi, kumparan juga melakukan analisa sederhana dari azab menurut gender.</p><p>Disebabkan oleh artikel tersebut dan ketersediaanya <a href="# https://www.slideshare.net/rizkinolimit/daftar-194-judul-ftv-azab">data</a>, tulisan ini pun dibuat untuk melihat aspek lain yang bisa di dapat dari data 194 judul ftv tersebut. Dimulai dari bagaimana menyiapkan datanya, merumuskan tujuan analisa, dan menentukan teknik sederhana yang akan dilakukan menggunakan python. (keselurahan script bisa didapat di <a href="https://github.com/alamhanz/azab_data_analysis">sini</a>)</p><h3><strong>Data Extraction</strong></h3><p>Link data diatas menyediakan semua 194 judul ftv yang digunakan kumparan dalam analisisnya, namun terlihat tidak serapi yang diperkirakan (bayangannya sudah rapi aja).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PxFPIE_7cFAf2N_qrCOlsQ.png" /><figcaption>Judul film-film ftv</figcaption></figure><p>Dalam link tersebut data text yang tersedia belum dalam bentuk tabular, namun teks-teks tersebut terlihat ada polanya dimana setelah angka pasti diikuti dengan judul filmnya dan kata sebelum angka adalah stasiun TV yang menyiarkannya. Teks tersebut dapat diextract menjadi tabular dengan simple script di python (3.6.5) seperti di bawah ini (dengan semua teks di link tersebut dicopy dan disimpan dalam “raw_data.txt”).</p><p>PS: Hati-hati dengan judul yang mengandung angka. Untungnya hanya ada 1 judul yang mengandung angka. <strong><em>Jenazah 3 Bersaudara Mati Dempet, Dikuburkan Dekat Galian Sampah</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mc4xTAusQPFFxO_FHB9JQA.png" /><figcaption>script sederhana extract datanya</figcaption></figure><p>Script diatas menghasilkan tabular data dengan 194 baris dan 2 kolom sebagai berikut (yang selanjutnya akan disebut sebagai “Data Azab”).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*YnSYm6hxJO65DTpmJJj0NQ.png" /><figcaption>Tabular Data Azab</figcaption></figure><h3>Data Text Cleaning</h3><p>Data Azab ini terbilang cukup bersih dan bisa langsung dilakukan analisa, yang harus diperhatikan adalah hanya stopwords dan punctuation . Jika ingin dilakukan analisa lebih juga bisa dilakukan stemmer yang artinya mengubah kata-kata dalam teks menjadi kata dasar (untuk python bisa menggunakan <a href="https://pypi.org/project/Sastrawi/">Sastrawi</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o0QbSnOIzzlNG1UUCVdQsg.png" /><figcaption>Pembersihan data teks dari tanda baca dan mengubah ke kata dasar</figcaption></figure><p>Karena dalam koteks judul-judul ini (dan analisa kita selanjutnya) kata “Ibu” penting, walaupun cuma disebut 9 kali, sehingga kata “ibu” tidak dimasukan ke stopwords . Kata “dzolim” atau “dzalim” serta “orang tua” juga penting sehingga perlu dilakukan perilaku khusus pada saat stemming yang dimana sastrawi belum bisa mengubahnya menjadi kata dasar (dimana kata yang benar adalah “Zalim” berdasarkan KBBI).</p><blockquote><strong>zalim</strong><em>/za·lim/</em> <em>a</em> bengis; tidak menaruh belas kasihan; tidak adil; kejam;</blockquote><p>Berikut hasil stemming dan pembersihan punctuation ditabular data,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*43GfrJGjqLycAD4T4bXpng.png" /><figcaption>kolom baru hasil <strong>stemming</strong> dan <strong>punctuation clearence</strong></figcaption></figure><h3>Tingkatan “Azab”</h3><p>Pada umumnya data teks cukup sulit untuk dianalisa dikarenakan banyak kata yang berbeda dengan makna yang sama, serta bahkan bisadibutuhkan <a href="https://machinelearningmastery.com/what-are-word-embeddings/"><em>embedding process</em></a><em>. </em>Namun, untuk kasus Data Azab ini, dikarenakan rata2 panjang teks relative sedang (10 kata tiap judul dalam rata-rata) serta variasi kata yang begitu banyak (seperti ‘adukan’, ‘terjebur’, ‘tawon’, ‘ribuan’, ‘formalin’, ‘timah’, ‘ternak’), <em>embedding process</em> tidak akan membantu banyak hal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TajNPmsB8s-RvXCpetc4nw.png" /></figure><p>Hal yang menarik dari Data Azab ini (setelah dilakukan skimming) adalah pola yang muncul di hampir semua Judul. Secara garis besar, setiap judul FTV ini pasti mengandung entitas <strong>Pelaku Dosa</strong> dan <strong>Azab</strong> yang diberikan, ditambah juga elemen <strong>Dosa</strong> yang dilakukan pelaku yang sering muncul didalam entitas <strong>Pelaku Dosa,</strong> sebagai contoh</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N39QZ4QnFcDRgiCxY09moA.png" /><figcaption>Entitas Judul FTV</figcaption></figure><p>Namun, <strong>Azab</strong> memiliki tingkatan yang berbeda untuk setiap satu <strong>Pelaku Dosa</strong> yang sama. Hal ini terjadi jelas bergantung pada <strong>Dosa</strong> apa yang dilakukannya. Berdasarkan skimming dan konteks dari semua judul pada Data Azab ini, entitas <strong>Azab </strong>memiliki beberapa tingkatan :</p><ol><li><em>Penderitaan</em> : Pada tingkatan ini Azab tidak menyebabkan kematian pada Pelaku dosa. Seperti menjadi sakit-sakitan atau harta menghilang.</li><li><em>Kematian</em> : Azab yang diberikan adalah suatu kejadian yang begitu dahsyat yang menyebabkan kematian pada Pelaku dosa. Seperti tersengat listrik, tertimpa panggung, atau mati karena lintah di rawa.</li><li><em>Jenazah : </em>Pelaku dosa mendapatkan Azab setelah kematiannya, seperti jenazah menghilang, bumi menolak jenazah atau janazah dipatok puluhan ular.</li><li><em>Keranda : </em>Hampir sama dengan sebelumnya, namun Azab ini terjadi secara spesifik di keranda <em>si </em>Pelaku Dosa. Sebagai contoh, keranda tertimpa atap, atau tertancap bambu.</li><li><em>Kuburan : </em>Tingkat ini juga sama dengan sebelumnya, yang berbeda hanya tempatnya dimana Azab terjadi di kuburannya. Bisa setelah dikuburkan atau saat sebelum dikuburkan. Contohnya, kuburan mengecil, kuburannya bau atau kuburannya tak bisa digali.</li></ol><p>Untuk satu judul FTV tidak menutup kemungkinan terdapat <em>multiple </em>tingkatan<em> </em>Azab, seperti FTV berjudul <strong><em>Akibat Tamak Suamiku Tenggelam dalam Gentong Minyak dan Makamnya Jatuh Ke Jurang</em></strong>, atau <strong><em>Jenazah Penebang Kayu Liar Mati Dengan Kulit Bersisik Pohon Dan Kerandanya Tetimpa Pohon Sampai Terbakar.</em></strong></p><p>Untuk mengekstrak tingkatan Azab ini disetiap judul FTV bisa dilakukan dengan <em>rule based </em>sederhana untuk setiap tingkatannya. Misalkan jika judul mengandung kata “Jenazah”, “Mayat” atau “Jasad” maka judul ini memiliki tingkatan <em>Jenazah.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sRRZZlPQETfGHWo2O9XYFQ.png" /><figcaption>Mengekstrak Tingkatan Azab</figcaption></figure><p><em>Rule Based </em>ini tidak memberikan keakuratan yang tinggi contohnya <strong><em>Anakku Ditolak Bumi Karena Hidup penuh Dosa</em></strong> harusnya memiliki tingkatan <em>Kuburan </em>namun judul ini masuk tingkatan <em>Penderitaan </em>karena tidak eksplisit menyebut “kuburan” di dalam judulnya. Walaupun keakuratannya masih kurang, <em>Rule based</em> ini cukup untuk menggambarkan bagaimana proporsi tingkatan Azab di semua Data Azab ini.</p><p>Selanjutnya, setelah mendapatkan tingkatan Azab di setiap judul, bisa dilakukan perhitungan proporsi tingakatn Azab di setiap Saluran TV.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P7WHe3pH9vGPiVw-hdZlWg.png" /><figcaption>Proporsi Tingkatan disetiap Saluran TV</figcaption></figure><p>Terlihat bahwa proporsi tingkat <em>Kematian </em>di MNC TV lebih banyak secara signifikan dibandingkan di Indosiar. Sebaliknya, tingkat <em>Keranda </em>lebih banyak terjadi di Indosiar. Namun, untuk tingkatan lainnya, tidak ada perbedaan yang besar, yang menandakan judul yang diberikan di MNC dan Indosiar tidak memiliki variasi yang berbeda berdasarkan tingkatan Azabnya hanya saja MNC TV lebih sering melakukan <em>multiple</em> Azab dengan menambahkan fenomena kematiannya si Pelaku Dosa di Judulnya.</p><h3>Durhaka</h3><p>Tingkatan Azab diatas, seperti juga sudah dibahas, sebenernya juga mungkin bergantung pada bentuk dosanya. Untuk melihat hubungan dosa dan azabnya bisa diambil beberapa contoh dosanya seperti dosa yang berhubungan dengan <strong>harta</strong> dan <strong>dosa durhaka</strong>. (Karena keterbatasan waktu dan teknik yang digunakan, dosa yang dipilih hanya dua dosa tersebut).</p><p>Dosa pertama untuk diekstrak adalah dosa durhaka dimana dosa durhaka bisa ada dua jenis, Durhaka antara Orangtua-Anak dan Durhaka Suami-Istri. Menggunakan <em>rule based </em>yang hampir sama, bisa didapat matrix correlation sebagai berikut,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K_R8OrPhAdH5LET8KKiMRg.png" /><figcaption>Matrix Korelasi Dosa Durhaka</figcaption></figure><p>Matrix korelasi ini (nilai negatif menunjukan hubungan yang sangat lemah) menunjukan bahwa untuk kedua saluran TV lebih sering melakukan judul dengan durhaka antara Orangtua-Anak dibandingkan durhaka Suami-Istri. Sebagai tambahan, hubungan Anak dengan Ibu lebih sering dibahas dibandingan Anak dengan Ayah. Untuk selanjutnya, Durhaka akan menunjuk ke Durhaka Orangtua-Anak.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aR8PT0ITOmejkbM2bHAG1Q.png" /><figcaption>Script mengekstrak Dosa Durhaka dan Dosa Harta</figcaption></figure><p>Menggunakan perhitungan korelasi yang sama, didapat tabel pivot seperti berikut,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*E9Un7JlU94bqKAzkZQD1yA.png" /><figcaption>Korelasi dosa dan tingkatan azabnya</figcaption></figure><p>Matrix korelasi dosa-azab diatas memberikan beberapa informasi menarik dimana</p><ul><li>MNC TV lebih sering menghubungkan Durhaka Orangtua-Anak dengan Dosa harta dibanding Indosiar.</li><li>Untuk Pendosa Harta ataupun Durhaka, Indosiar seringnya memberikan judul dengan azab ditingkatan <em>Jenazah. </em>Namun, Durhaka Ortu sedikit variatif dengan adanya tingkatan <em>Kematian.</em></li><li>Sedangkan untuk kedua dosa di MNC TV lebih sering diberikan judul dengan tingkat <em>Kuburan. </em>Sama dengan Indosiar, Durhaka Ortu jauh lebih variatif dengan adanya tingkatan <em>Keranda.</em></li></ul><p>Dua Informasi terakhir diatas menunjukan bahwa Dosa Ortu-Anak lebih banyak dapat perhatian dibandingkan Dosa Harta. Hal ini terjadi kemungkinan karena adat ketimuran yang masih sangat erat dengan menghormati orang tua.</p><h3><strong>Most Word Bias</strong></h3><p>Walaupun dengan teknik diatas telah memberikan informasi yang bagus, namun ada kemungkinan informasi tersebut adalah informasi bias, contohnya informasi tingkatan azab <em>Jenazah </em>di Indosiar untuk pedosa Durhaka. Informasi ini ada kemungkinan bias karena sebagian besar judul di Indosiar mengandung kata “Jenazah”. Untuk itu perlu di lakukan <a href="https://www.graphpad.com/guides/prism/7/statistics/stat_interpreting_one-sample_t_test.htm?toc=0&amp;printWindow"><em>statistical testing</em></a> terlebih dahulu apakah informasi yang didapat hanya kebetulan belaka atau bisa digeneralisir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PMlFLQUVSe9STgu1MwLJpg.png" /><figcaption>Most Word di setiap saluran TV</figcaption></figure><h3>Konklusi</h3><p>Data Teks merupakan salah satu bentuk data yang menarik untuk dianalisa karena bisa dilihat dari berbagai <em>point of view</em> sesuai konteks dari setiap kalimat di dalam teksnya. Beberapa diantaranya yang bisa dilakukan adalah <a href="https://robots.thoughtbot.com/named-entity-recognition">NER</a> (<em>Named Entity Recognition</em>), yang mana untuk kasus ini ada Entitas baru yang unik yaitu <strong>Pelaku Dosa</strong> dan <strong>Azab, </strong>dan korelasi sederhana diantara kata dalam teks yang bisa memiliki banyak arti serta interpretasi.</p><p>Terakhir, janganlah durhaka dengan orang tua karena ada banyak variasi azab yang akan diterima dikemudian hari.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4bac66abf75" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science-indo/data-azab-ftv-the-other-point-of-view-c4bac66abf75">Data Azab FTV: the other point of view</a> was originally published in <a href="https://medium.com/data-science-indo">Data Science Indonesia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>