<?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 Muhammad Risqi Firdaus on Medium]]></title>
        <description><![CDATA[Stories by Muhammad Risqi Firdaus on Medium]]></description>
        <link>https://medium.com/@mrfirdauss?source=rss-3c1b4e4eafc9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fi_Az7gulF8HtT2JCik_uw.jpeg</url>
            <title>Stories by Muhammad Risqi Firdaus on Medium</title>
            <link>https://medium.com/@mrfirdauss?source=rss-3c1b4e4eafc9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 16:34:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mrfirdauss/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[Hidup Kok Gitu Amat, Apasih yang Dikejar?]]></title>
            <link>https://mrfirdauss.medium.com/hidup-kok-gitu-amat-apasih-yang-dikejar-11ff37595eb5?source=rss-3c1b4e4eafc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/11ff37595eb5</guid>
            <category><![CDATA[islam]]></category>
            <category><![CDATA[self-awareness]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[life]]></category>
            <dc:creator><![CDATA[Muhammad Risqi Firdaus]]></dc:creator>
            <pubDate>Sun, 08 Dec 2024 08:13:50 GMT</pubDate>
            <atom:updated>2024-12-08T08:13:50.727Z</atom:updated>
            <content:encoded><![CDATA[<p>Pertanyaan ini sering banget muncul dipikiran (atau bahkan ditanyakan teman) belakangan ini. Kenapa si, kayanya orang-orang pada <em>hustle</em> banget, memang apasih yang dicari?</p><p>Pertanyaan ini membuatku kembali membuka materi mata kuliah Motivasi Berprestasi (iya, mata kuliah yang diambil secara tak sengaja wkwk). Salah satu materi yang sering diulang di mata kuliah tersebut adalah Hierarki Kebutuhan Maslow atau yang sering disebut Piramida Maslow (Maslow, 1943).</p><h3>Teori Kebutuhan Maslow</h3><p>Teori ini menjabarkan bahwa, untuk memenuhi kebutuhan di tingkat tertinggi, manusia harus memenuhi kebutuhan-kebutuhan di bawahnya terlebih dahulu. Secara terurut, terdapat lima tingkatan yang perlu dipenuhi: fisiologi, rasa aman, kasih sayang, penghargaan dan aktualisasi diri.</p><p>Berkaitan dengan pertanyaan pada tulisan ini, Piramida Maslow menggambarkan bahwa sejatinya apa yang dicari manusia adalah pemenuhan atas kebutuhannya. Berdasarkan tingkat yang belum terpenuhi, manusia akan memenuhi kebutuhannya dari yang paling fundamental atau dasar piramida.</p><p>Ketika seseorang belum dapat memenuhi kebutuhan perutnya, maka yang ia cari hanya akan sampai pada tingkatan “makan apa”. Sebaliknya ketika dia sudah selesai dengan kebutuhan lain hingga pada tingkat tidak membutuhkan lagi penghargaan atau pujian, maka ia akan mencari cara untuk terus mengembangkan dirinya. Dia akan berlepas dari segala ketergantungan yang tidak seharusnya ia lakukan.</p><h3>Aktualisasi Diri Sebagai Tujuan Puncak</h3><p>Dari sini, kita akan sadar bahwa sejatinya tujuan puncak manusia adalah mengaktualisasi diri. Secara bahasa aktualisasi diri berarti menjadikan seseorang sosok dirinya sepenuhnya. Menurut Erikson, aktualisasi diri berarti berhubungan dengan makna ideal dari kehidupan untuk mengembangkan diri dan memaksimalkan semua potensi untuk berusaha menjadi manusia seideal mungkin.</p><p>Menjadi pribadi yang mengejar aktualisasi diri berarti melepaskan kebutuhan akan pujian orang lain serta penerimaan orang lain atas hal-hal yang kita lakukan. Dengan begitu, apa-apa yang kita usahakan akan jadi lebih bermakna disamping manfaat yang diberikan oleh usaha kita. Kita menjadi tidak bergantung pada timbal-balik atas usaha yang kita lakukan.</p><p>Konsep ini sebenarnya mirip dengan teori altruisme. Yang mana kita berbuat kebaikan tanpa memandang apakah kita akan mendapatkan timbal-balik atau tidak.</p><h3>Tujuan Hidup dalam Pandangan Agama (Islam)</h3><p>Setelah memahami bahwa, tujuan puncak manusia secara psikologis adalah aktualisasi diri, sebagai muslim, kita perlu mengetahui bentuk-bentuk aktualisasi diri. Hal ini nantinya yang akan menjadi panduan agar yang kita lakukan tidak hanya baik, tetapi juga sesuai dengan anjuran agama.</p><p><strong>Menjadi Khalifah di Muka Bumi</strong></p><p>Tentu, teman-teman sudah tidak asing dengan surat al-baqarah ayat 30, terkait penciptaan manusia. Ayat ini menerangkan bahwa tujuan Allah SWT menciptakan manusia sejatinya sebagai pemimpin atau khalifah di muka bumi.</p><p>Menjadi khalifah artinya menjadi pengatur keberjalanan alam semesta ini, bukan justru menjadi perusak. Dalam surat yang sama, dijelaskan bahwa akan ada manusia yang mengatakan bahwa dirinya berbuat kebenaran padahal sejatinya mereka lah yang berbuat kerusakan di Dunia.</p><p>Menjadi khalifah bukan berarti harus menjadi Presiden. Kita bisa memulai menjadi khalifah atau pemimpin pada lingkup yang lebih kecil atau bidang yang lebih spesifik. Dimulai dari menjadi pelajar yang baik, yang belajar dengan sungguh-sungguh, atau lebih lagi mungkin menjadi direksi perusahaan bidang pembangunan di masa depan.</p><p><strong>Memberi Manfaat Bagi Seluruh Alam</strong></p><p>Kita sering mendengar bahwa tujuan agama islam serta para nabi adalah menjadi agama rahmat lil-alamin, atau bentuk kasih sayang kepada seluruh alam. Pertanyaannya sekarang, bagaimana kita bisa menjadi bentuk kasih sayang Allah pada seluruh alam?</p><p>Salah satu yang utama adalah dengan menjadi manusia yang bermanfaat. Dalam hadits riwayat Thabrani dijelaskan bahwa sebaik-baik kita adalah yang bermanfaat bagi orang lain. Kemudian dalam hadits riwayat Bukhari Muslim disebutkan bahwa “Barang siapa yang membantu saudaranya, maka Allah penuhi kebutuhannya”. Dalam hadits riawayat Bukhari no. 5027 disebutkan juga bahwa “Sebaik-baik kalian adalah yang belajar al-quran dan mengajarkannya”. Selain itu, terdapat pula dalam hadist lain bahwa sebaik-baik kalian adalah yang tidak ingkar dalam hutang, paling baik akhlaknya dan belajar, memberi makanan, serta masih banyak hadist lain.</p><p>Dari sini dapat ditarik kesimpulan bahwa untuk bisa menjadi rahmat kita bisa mulai dengan beberapa tindakan berikut.</p><ol><li>Melaksanakan kewajiban kita sebaik mungkin</li><li>Membantu kebutuhan orang lain (berdampak)</li><li>Belajar dan mengajarkan al-quran</li></ol><p>Dari dua aksi di atas, sudahkah kita mengukur seberapa jauh diri kita bermanfaat? Padahal tiga poin di atas barulah dasar dari menjadi rahmat bagi seluruh alam.</p><p><strong>Beribadah Kepada Allah</strong></p><p>Meskipun poin ini ditulis di paling akhir, bukan berarti poin ini adalah poin yang tidak penting. Poin ini justru yang menjadi poin pamungkas, poin yang ditulis sejara <em>jahr</em> mengenai tujuan pencipataan manusia. Dalam surat adz-dzariyat ayat 56 disebutkan bahwa “Dan tidaklah Aku ciptakan jin dan manusia, melainkan untuk beribadah kepadaku”.</p><p>Poin ini sekaligus menjadi poin perangkum bahwa tindakan kita untuk menjadi khalifah serta rahmat harus didasari atas ibadaha kepada Allah. Dari poin ini juga dikunci bahwa tujuan manusia hidup itu tidak hanya bersifat koneksi horizontal dengan manusia lain, tetapi juga vertikal dengan sang Pencipta.</p><h3>Rangkuman</h3><p>Berdasarkan semua narasi di atas, dapat kita simpulkan bahwa sejatinya pekerjaan kita, belajar kita serta semua aktivitas kita bertujuan untuk memenuhi kebutuhan hidup kita. Sedangkan, kebutuhan hidup utama kita ialah mengaktulisasi diri. Aktualisasi diri yang sesuai dengan ajaran Agama tidak hanya bersifat kepada sesama, tetapi juga bersifat spiritual. Oleh karena itu, jangan lupa untuk terus memaksimalkan potensi dan meniatkan ini semua kepada Allah, agar apa yang kita usahakan menjadi berkah.</p><p><strong>Citation</strong></p><p>Ahmad Zainuddin, Lc. (2021, April 27). <em>Apakah Anda Termasuk Sebaik-Baik Manusia?</em>. Muslim.or.id. <a href="https://muslim.or.id/8144-apakah-anda-termasuk-sebaik-baik-manusia.html">https://muslim.or.id/8144-apakah-anda-termasuk-sebaik-baik-manusia.html</a></p><p>Al-Quran</p><p>Maslow, A. H. (1943). A theory of human motivation. <em>Psychological Review, 50</em>(4), 370–396. <a href="https://psycnet.apa.org/doi/10.1037/h0054346">https://doi.org/10.1037/h0054346</a></p><p>Sussex Publishers. (n.d.). <em>The theory of self-actualization</em>. Psychology Today. <a href="https://www.psychologytoday.com/intl/blog/theory-and-psychopathology/201308/the-theory-self-actualization">https://www.psychologytoday.com/intl/blog/theory-and-psychopathology/201308/the-theory-self-actualization</a></p><p>Terima kasih kepada teman-teman yang memberi masukan baik secara langsung, maupun tidak langsung sebagai bahan tulisan ini, baik dalam bentuk materi maupun saran.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11ff37595eb5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Art of Choosing The Right Metric in Machine Learning (1)]]></title>
            <link>https://mrfirdauss.medium.com/the-art-of-choosing-the-right-metric-in-machine-learning-1-2ecc30a95e7e?source=rss-3c1b4e4eafc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ecc30a95e7e</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[business]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Muhammad Risqi Firdaus]]></dc:creator>
            <pubDate>Sat, 11 May 2024 10:01:58 GMT</pubDate>
            <atom:updated>2024-05-13T02:35:39.977Z</atom:updated>
            <content:encoded><![CDATA[<p>Performance metric is an important metric to measure impact and successfulness. In term of machine learning development, the performance metric is essential in measuring and evaluating the readiness of the machine learning model. In this passage we would discuss the performance metric in classification task.</p><p>There are so many performance metric that could be used. We choose the metric based on task of the model. In classification, accuracy is the most common metric. We often use accuracy for any classification model. However, using accuracy as silver bullet could impact our business, since the cost of false positive (FP) and false negative (FP) is different.</p><p>In several case, having false positive is more desirable than having false negative. For example, in churn modeling, we could tolerate recontacting the retain user, than letting the churn users were being not detected. In short, for this case, we cannot apply accuracy as our main metric. Now, let’s take a look onto the list of performance metric and it’s case.</p><h3>Accuracy</h3><p><strong>definition</strong></p><p>As I mentioned before, accuracy is the most common metric. Accuracy have most intuitive measurement than the others. Accuracy measure the percentage of correct prediction of all prediction. In short, we can measure accuracy by dividing the number of correct prediction by all prediction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*4ZkfsEYswuEMkkenWVLnHw.png" /><figcaption>formula of accuracy</figcaption></figure><p><strong>when to use</strong></p><p>The use case of accuracy is kinda tricky. We could use accuracy when the label class is balanced. For example, you have 100 news text to analyze, 50 of them are having negative sentiment, and the rest are positive. You want to measure how is your model performance. If the model could predict 90 out of 100 news text, we can take 90/100 as our model accuracy.</p><p>In another case, when the label is imbalanced, the usage of accuracy, could bring us into failure. For example, we want to measure our fraud detection model. The data consist of 990 not fraud and 10 fraud label. The model successfully predict all not fraud data, but none fraud data could be detected. If we use accuracy, our model performance is 99 percent. By only looking in to this number, our model performed outstanding. However, this model could harm our company if they can’t detect any fraud. This will bring us into a big loss.</p><h3>Precision</h3><p><strong>definition</strong></p><p>Precision measure the number of positive prediction that was correct. To calculate precision, you need to divide the number of TP (true possitive) by the total number of all positive prediction (TP+FP), where FP is false positive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*VxBqWi7K0TA2B8ihDVSy7Q.png" /><figcaption>formula of precision</figcaption></figure><p><strong>when to use</strong></p><p>You can use precision when you have to avoid false positive, but can deal with false negative. For example, in spam detector, We have 100 email, 90 of them are non-spam and 10 of them are spam. If the model classify 3 non-spam as spam and 8 spam email as spam, the precision would be 8/11. By this calculation, we can see that this metric is resistant from imbalanced label.</p><p>In this case, we can deal if the model classify spam email as non-spam, but there is no tolerant if the model put non-spam email in spam box. Imagine, if the non-spam that been classify as spam is an important email, we could possibly receive a massive loss.</p><h3>Recall</h3><p><strong>definition</strong></p><p>Recall is the opposite of precision. Recall measure the number of positive class that could be predicted as positive class. We can calculate recall by dividing the number of true positive (TP) prediction per total number of all positive class (TP+FN), where FN is the false negative.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*7MnJ-plvvNYd7mYq_ou_kg.png" /><figcaption>formula of recall</figcaption></figure><p><strong>when to use</strong></p><p>If we want to maximize the number correct positive prediction, we can use recall. For example, in fraud detection, if we can not detect the real fraud, we could cost our company. It could possibly produce loss from the fraud that we were unable to detect.</p><p>Suppose we have 900 non fraud data and 100 fraud data. Our model predict 90 fraud as fraud and 10 as non-fraud. The recall for our model is 90/100. In this paragraph we can conclude that recall can deal with imbalanced label, because we only concern about the positive class.</p><h3>F1-Score</h3><p><strong>definition</strong></p><p>F1-score is defined as harmonic mean of precision and recall. For multi class classification, there are three type of f1 score, those are weighted, macro and micro. In this passage, we would only discuss about macro f1-score. Macro F1-score measure the mean of f1-=score between class.</p><p>For binary classification, we can calculate f1-score by calculating 2 per sum of 1 per recall plus 1 per precision. In the other hand, for multi class, we can measure f1-score by calculating the average of f1-score per class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*vCmjxMLQRKInseKdG-qlTg.png" /><figcaption>formula f1-score</figcaption></figure><p><strong>when to use</strong></p><p>If we have to deal with our imbalanced data to measure unbiased prediction and we want to measure our model performance as if our label is balanced, we can use this metric.</p><p>For example, we have 900 AI generated text and 100 human written text. Our model classify 100 AI generated text as human written, and 40 human written as AI generated text. We can calculate f1-score as below.</p><p><strong>AI Class</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*fvyNqsZUuCt667-TaWo8bQ.png" /><figcaption>calculation f1score for AI class</figcaption></figure><p><strong>Human Class</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*U68Ws1HcXScke-htmhmELA.png" /><figcaption>calculation f1score for human written class</figcaption></figure><p><strong>Macro</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*9VQuXicpTws1QC_sNGCimw.png" /><figcaption>macro f1-score</figcaption></figure><h3>Key Takeaways</h3><p>After understanding performance metric for classification task, we can adjust our model to align with the business objective. This will lead us into a better impact on business metric. For example, you can adjust the classification threshold to adjust model based on precision and recall.</p><p>Now, my question is, in fraud detection, for fraud prediction. In order to avoid loss from undetected fraud, what we need to do? increase or decrease our classification threshold?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ecc30a95e7e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hidup itu pilihan, maka memilihlah]]></title>
            <link>https://mrfirdauss.medium.com/hidup-itu-pilihan-maka-memilihlah-19b57459726f?source=rss-3c1b4e4eafc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/19b57459726f</guid>
            <category><![CDATA[life]]></category>
            <category><![CDATA[choices]]></category>
            <category><![CDATA[quarter-life-crisis]]></category>
            <dc:creator><![CDATA[Muhammad Risqi Firdaus]]></dc:creator>
            <pubDate>Wed, 14 Feb 2024 02:32:07 GMT</pubDate>
            <atom:updated>2024-02-14T02:32:07.667Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T20rMvSe5-9tkbBjAEIeeA.jpeg" /><figcaption>source: linkedin</figcaption></figure><p>Pasti frasa “Hidup itu pilihan” mungkin sudah tidak asing lagi di telinga kita. Aku pun menyetujui frasa tersebut. Nyatanya memang begitu kan, hidup adalah agregasi dari pilihan-pilihan yang kita ambil. Meskipun, memang pilihan yang kita ambil, tidak selalu membawa kita pada hal yang kita inginkan.</p><p>Ketika kita coba menengok ke belakang, kita mungkin akan berpikir, jikalau dulu mengambil jalan yang berbeda, kita tidak akan sampai di sini. Pun kita juga jadi sadar, jalan yang kita ambil sekarang memberikan begitu banyak kemungkinan buat masa depan kita.</p><h3>Manusia itu terbatas</h3><p>Kita perlu sadar, bahwa kita tidak selalu bisa mengambil semua yang kita inginkan. Kadang kala, kita perlu merelakan sebuah suatu jalan, untuk jalan lain yang menurut kita lebih sesuai bagi kita. Itulah hakikat dari memilih.</p><p>Contoh gampangnya adalah memilih kesibukan. Mungkin bagi sebagian kita, punya banyak kesibukan, prestasi di mana-mana, dengan segala kegiatannya membuat kita terlihat keren. Namun, pernah kah kita mencoba merefleksikan, apakah dengan segala kesibukan yang kita ambil, kita bisa berkontribusi secara maksimal di semua kegiatannya? Ketika berbagai kepentingan bertabrakan, kepentingan mana yang akhirnya kia ambil?</p><h3>Mulai untuk fokus dan berani mengambil pilihan</h3><p>Setelah kita sadar akan keterbatasan yang kita miliki, maka kita akan menjadi lebih memperhatikan jalan yang diambil. Keterbatasan itulah yang membuat kita memilih apa-apa saja jalan yang kita ambil. Ketika telah memantapkan hati atas suatu jalan, bukan tidak mungkin distraksi itu muncul.</p><p>Distraksi yang membuat kita berpikir, apakah pilihan yang kita ambil sudah yang terbaik? Bagaimana jika ernata jalan lain lebih baik? Wjar kok, namanya juga manusia, kadang memang diuji dengan komitmen kita. Namun, kembali lagi, jika memang kita telah memilih dengan pertimbangan yang mendalam, konsisten pada jalan yang diambil akan menjadikan pilihan kia bernilai. Ketika sebuah jalan telah diambil, artinya kita harus konsekuen dengan segala kemungkinan yang terjadi di masa depan.</p><p>Maka kawan, beranikan diri untuk mengambil pilihan. Pegang teguh jalan terjal yang kau ambil itu. Mantapkan hatimu, karena Tuhan tidak akan mengubah nasib suatu bangsa, kecuali bangsa itu sendiri memilih untuk bergerak mengubahnya.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19b57459726f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to e-Commerce Data Analysis Using SQL]]></title>
            <link>https://mrfirdauss.medium.com/introduction-to-e-commerce-data-analysis-using-sql-902667b4804f?source=rss-3c1b4e4eafc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/902667b4804f</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Muhammad Risqi Firdaus]]></dc:creator>
            <pubDate>Sat, 06 Jan 2024 10:00:56 GMT</pubDate>
            <atom:updated>2024-01-06T10:02:07.791Z</atom:updated>
            <content:encoded><![CDATA[<p>Pada kesempatan kali ini, gw coba akan ngasi beberapa contoh query-query analisis data penjualan ecommerce pakai SQL. Oh ya, data yang gue pake formatnya tu .csv, nah supaya ga perlu export-export-an gw bakal nge-query pake Deepnote. Di sana, lu bisa jadiin sebuah file .csv as table di RDB.</p><p>Di Deepnote, kita ga perlu buat export data ke SQL, soalnya kita bisa langsung nge-query dari file CSV di kernelnya. Berikut adalah tautan buat sumber dataset yang gw pake <a href="https://www.kaggle.com/datasets/olistbr/brazilian-ecommerce">https://www.kaggle.com/datasets/olistbr/brazilian-ecommerce</a>. Dataset ini adalah dataset ecommerce Brazil.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aXTlOcs3-l0L4Bi_pyiADA.png" /><figcaption>Source: Kaggle</figcaption></figure><p>Di sesi kali ini, gw bakal bahas empat soal dan coba ngasi query dan hasilnya. Cakupan query pada sesi kali ini adalah</p><ol><li>Select</li><li>Join Table</li><li>Group By</li><li>Window Function (Partition)</li></ol><p>Tenang, gw ga bakal bikin query yang logicnya ribet, would very beginner friendly. Oke, langsung aja kita ke studi kasusnya.</p><h3>Count the number of orders per year and month.</h3><p>Buat solve kasus ini, kita cuman butuh <strong>satu tabel </strong>(olist_orders_dataset). Kita cuman perlu mecah timestampnya jadi year dan month, terus kita group by kedua entitas tersebut. Kalo mau, bisa juga diapply sorting year dan month, pake <em>order by</em>, biar lebih gampang liat trennya.</p><pre>SELECT  <br>    EXTRACT(YEAR FROM order_purchase_timestamp) as year,<br>    EXTRACT(MONTH FROM order_purchase_timestamp) as month,    <br>    count(order_id) count_ourder  <br>FROM &#39;olist_orders_dataset.csv&#39;  <br>GROUP BY year, month;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*iqYJ7T_lGdZNksc2-5V8vg.png" /></figure><h3>Top 20 product categories based on total revenue and total order (only for delivered orders).</h3><p>Inti dari pertanyaan ini adalah dapetin revenue (total pendapatan) dan jumlah order per kategori produk, dari pesenan (order) yang udah delivered. Nah ini rada kompleks, kita perlu join beberapa table<em> (‘olist_order_items_dataset.csv’, ‘olist_products_dataset.csv’ dan ‘olist_orders_dataset.csv’) </em>terus kita perlu filter yang statusnya “deliverd”. Nah abis tu, baru kita group per kategori produk dan kita urutin deh dari total revenue. Total revenue, didapat dari total biaya dari semua transaksi.</p><pre>select   <br>    sum(price) as total_revenue,   <br>    count(oi.order_id) as number_order,   <br>    p.product_category_name  <br>from &#39;olist_order_items_dataset.csv&#39; oi  <br>join &#39;olist_products_dataset.csv&#39; p on oi.product_id = p.product_id  <br>join &#39;olist_orders_dataset.csv&#39; o on o.order_id = oi.order_id  <br>where o.order_status = &#39;delivered&#39; <br>group by p.product_category_name  <br>order by  <br>    total_revenue desc,   <br>    number_order desc <br>limit 20;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*SyDoo6eq2Sacgk49gKNLtA.png" /></figure><h3>The number of orders which are delivered late from the estimated time per year and month.</h3><p>Ini rada mirip sama query pertama, kita cuman perlu nge-count dari tabel orderlist berapa order yang deliverynya late. Nah buat ngefilter delivery yang late itu gimana, kita bisa make “where order_delivered_customer_date &gt; order_estimated_delivery_date” yang maknanya timestamp deliverednya lebih dari estimated timenya.</p><pre>select <br>    EXTRACT(YEAR FROM order_purchase_timestamp) as year, <br>    EXTRACT(MONTH FROM order_purchase_timestamp) as month, <br>    count(order_id) count_ourder <br>from &#39;olist_orders_dataset.csv&#39; o<br>where <br>    order_delivered_customer_date &gt; order_estimated_delivery_date<br>GROUP BY year, month<br>order by year, month;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*q8yWmSAs4ttgf-0vRcbOAA.png" /></figure><h3>The top 3 customers per year and per month based on total spending.</h3><p>Ini bakal jadi query terasik, karena kita bakal make window function. Kalo lu belum familiar window function tu apa, intinya dia adalah salah satu fungsi di SQL buat ngelakuin hal kompleks dengan melakukan pengerjaannya pake bikin jendela-jendela (pembagian) berdasarkan kolom yang ditentuin. Ciri dari query ini adalah kata “OVER”.</p><p>Bedanya dengan group by apa? Kalo group by semua hasilnya bakal cuman dikumpulin jadi satu per group yang dibikin, sedangkan window function ini coba buat mertahanin baris aslinya. Buat kamu yang pengen bikin perangkingan, fungsi ini cocok banget.</p><p>Di kasus ini, yang bakal kita jadiin window atau pengelompokan fungsi adalah tahun dan bulan baut dapetin customer dengan rank 1–3 per bulan per tahunnya. Nah kaya query awal, kita ekstrak dulu tuh timestmap-nya. Abis tu, kita generate spending pake jumlah harga + biaya pengiriman. Dari sana bakal kita pake buat window funcitonnya.</p><p>Terakhir kita bakal group per bulan dan per tahun baut dapetin spendingnnya, dari spending yang didapetin itu, kemudian kita rank per customer. Dari sini bakal keliatan nih rank 1–3 per tahun per bulannya.</p><pre>select *<br>from<br>    (select <br>        EXTRACT(YEAR FROM order_purchase_timestamp) as year, <br>        EXTRACT(MONTH FROM order_purchase_timestamp) as month, <br>        sum(oi.price + oi.freight_value) spending,<br>        RANK() OVER(PARTITION BY year, month ORDER BY spending DESC) AS spending_rank,<br>        customer_id<br>    from &#39;olist_orders_dataset.csv&#39; as o<br>    join &#39;olist_order_items_dataset.csv&#39; as oi on o.order_id = oi.order_id<br>    GROUP BY year, month, customer_id<br>    order by 1,2 asc)<br>where <br>    spending_rank &lt;= 3;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*VOA52tZpM1YTaqCHi2E4Ag.png" /><figcaption>Ini lanjutannya masi banyak, cman gw cut di sini yagesya</figcaption></figure><p>Coba kita bandingin kalo make query group by aja berikut,</p><pre>select <br>    EXTRACT(YEAR FROM order_purchase_timestamp) as year, <br>    EXTRACT(MONTH FROM order_purchase_timestamp) as month, <br>    sum(oi.price + oi.freight_value) spending,<br>    customer_id<br>from &#39;olist_orders_dataset.csv&#39; as o<br>join &#39;olist_order_items_dataset.csv&#39; as oi on o.order_id = oi.order_id<br>GROUP BY year, month, customer_id<br>order by 3 desc<br>limit 3</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*jS4rT7G5BwbeQcx_911Pxg.png" /></figure><p>Kita jadi ga bisa dapetin rank per bulannya, cuman customer dengan spending pada sebuah bulan terbesar yang muncul.</p><h3>Conclusion</h3><p>Gue yakin, introduction yang gue buat ini sangat banyak <em>missing knowledge-</em>nya. Nah, buat itu, lu bisa nih buat eksplor lebih lagi, dan nyoba-nyoba buat bikin soal sendiri. Harapannya dari adanya artikel ini, bisa jadi pemantik buat eksplor lebih jauh.</p><p>By the way, kalo bingung, lu bisa coba DM gw atau prompt ke ChatGPT, they smart enough for simple query. Thank you!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=902667b4804f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pemuda: Antara Ego dan Idealisme]]></title>
            <link>https://mrfirdauss.medium.com/pemuda-antara-ego-dan-idealisme-74a0b1b24f33?source=rss-3c1b4e4eafc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/74a0b1b24f33</guid>
            <category><![CDATA[patience]]></category>
            <category><![CDATA[idealism]]></category>
            <category><![CDATA[sumpah-pemuda]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[kepemimpinan]]></category>
            <dc:creator><![CDATA[Muhammad Risqi Firdaus]]></dc:creator>
            <pubDate>Fri, 10 Nov 2023 16:02:50 GMT</pubDate>
            <atom:updated>2023-11-10T16:02:50.519Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Always start everything with Mega-Thinking.</blockquote><p>Itu adalah quotes yang disampaikan oleh mentor kami, AVP HCComm Telkom, Mas Rama saat Town Hall Sobatlit bulan lalu, 28 Oktober. Kalo kamu bingung apa makna itu, tenang, aku juga pernah mengalaminya.</p><p>Mega-thinking adalah konsep berpikir secara helicopter view, mengenai apa yang kita lakukan. Mega-thinking menitik beratkan pemikiran kita pada apa si dampak yang ingin dibawa dari kegiatan yang kita jalani.</p><p>Konsep ini mungkin mirip dengan konsep <em>end-mind</em> yang dibawa oleh Steven Covey pada Habits of Highly Effect People, atau podcast yang lagi naik daun, End Game by Gita Wirjawan. Terus apa hubungan pemuda, sama pemikiran ini?</p><p>Sebelum jauh, coba jawab pertanyaan ini. Pernah ga si, kalian merasa ada yang salah sama society yang kalian jalani? contoh simple mungkin, solat di mesjid yang diimamin kakek-kakek yang bacaan quran-nya ala kadarnya. Terus, apa yang kalian lakuin jika ada di kondisi itu? malah jadi males solat di mesjid? atau malah masbuk di rokaat terakhir?</p><p>Aku ga nyalahin jalan apapun yang kalian pilih. Pun, kalo malah jadi makmumnya, bisa jadi solat kita ga sah kan? Nah tapi, pernah ga si, kali coba buat “pdkt” ke kakek-kakek takmir masjid ini? Coba buat dateng awal waktu, bantu rapiin tempat solat setelah jumatan. Bayangin, misal dengan begitu, kalian bisa dapet <em>respect </em>dari si Kakek, dan malah ditawarin jadi imam.</p><p>Sekarang, coba tanya pada diri sendiri. Sebenarnya yang mendorong kita selama ini, itu ego atau idealisme kita?</p><p>Terus gimana kita mengalahkan ego kita? Sejatinya, ego itu akan terus muncul. Wajar sekali seorang anak adam memiliki ego dalam hidupnya. Kita hanya bisa mengelola ego. Ego hanya bisa dikelola, kapan dia sebaiknya didorong, kapan dia sebaiknya ditahan. Pada konteks pengelolaan ego yang baik, justru ego itu bisa menjadi pendorong kita, untuk terus bertahan mewujudkan keidealan yang kita dambakan.</p><p>Kembali ke persoalan mega-thinking. Dengan menggap idealisme adalah mega-thinking yang kita coba kejar. Kita akan tersadar akan realita, bahwa dunia ini masih jauh dari keadaan idealnya. Dari sana akan muncul peluang bagi mereka yang mau membuka mata.</p><p>Memang tidak selalu mudah. Kadang kala, rasanya, apa yang kita usahakan tak kunjung membuahkan hasil. Rasanya apa yang kita kerjakan tidak memberi manfaat pada diri sendiri, apalagi lingkungan sekitar. Namun, cobalah untuk menarik nafas, dan refleksikan sejauh mana kita telah berjalan.</p><p>Releksi ini muncul ketika evaluasi SobatLIT kemarin. Jujur saja, aku tipe yang slalu meng-underestimate dampak dari sebuah kegiatan. Namun, evaluasi kemarin membuka mata, bahwa kegiatan-kegiatan kecil yang kita galakkan ternyata manfaatnya bisa sebegitu bermakna.</p><p>Sesimple bootcamp yang coba kita rancang. Yang awalnya hanya menargetkan 40–80 perserta, tiba-tiba pendaftarnya melonjak 6x lipat dalam 1 malam, dari 30 orang menjadi lebih dari 200 orang. Tidak cukup di sana, antusiasme pesertanya pun di luar dugaan.</p><p>Ambil kisah lain, kemarin salah satu divisi di bawah departemen yang aku pimpin melakukan company goes to campus. Mungkin rasanya biasa saja, secara, perusahaan datang ke kampus dan melakukan promosi adalah hal yang biasa. Namun, malam kemarin, ada sebuah pesan di grup yang menarik perhatian. Yak, salah satu pesertanya sudah diterima di perusahaan yang kami undang.</p><p>Apakah semuanya langsung menghasilkan dalam sekejap mata? tentu tidak. Kadang, biji yang kita tanam baru muncul ke tanah setelah beberapa hari kita siram. Mungkin, kita sudah sampai berfikir, ah paling juga tidak tumbuh. Namun, itulah yang membedakan pemuda dengan orang yang jiwanya tua. Idealismenya lah yang justru mendorongnya untuk terus berusaha.</p><p>Ingatlah, 95 tahun yang lalu, para pemuda itu begitu visioner. Apakah setelah mereka bersumpah, Indonesia menyatu begitu saja? Tentu tidak, panjang masih perjalanan mereka. Makin sukar mungkin, interferensi dari berbagai arah. Namun, nyatanya, usaha itu tidak sia-sia, berawal dari organisasi pemuda, menyatu dan bersumpah bersama, terwujudlah persatuan. Maka bersabarlah kawan dalam perjuanganmu!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74a0b1b24f33" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Belajar Leadership dari Great Leader]]></title>
            <link>https://mrfirdauss.medium.com/pembangunan-indonesia-ke-depan-4a14cbb68e59?source=rss-3c1b4e4eafc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a14cbb68e59</guid>
            <category><![CDATA[knowledge-sharing]]></category>
            <category><![CDATA[lnl]]></category>
            <category><![CDATA[rumah-kepemimpinan]]></category>
            <dc:creator><![CDATA[Muhammad Risqi Firdaus]]></dc:creator>
            <pubDate>Wed, 11 Oct 2023 23:26:34 GMT</pubDate>
            <atom:updated>2023-10-12T02:25:30.166Z</atom:updated>
            <content:encoded><![CDATA[<p>Kita menyadari bahwa Nabi Muhammad SAW meruapakn nabi terakhir, nabi yang membawa ajaran yang paling sempurna. Bila ditelisik lebih dalam, cara nabi Muhammad membawakan ajaran ini pun luar biasa cerdas. Mari kita breakdown perjalanan dakwah nabi menjadi beberapa fase.</p><h3>Fase Mekah</h3><p>Pada fase ini pendekatan dimulai dengan intelektualitas dan kultural. Untuk menyentuh hati masyarakat, sebelumnya Nabi telah memperelok diri dengan sifat yang luar biasa mulia. Sifat ini lah yang menyentuh sisi intelektualitas dan kultural masyarakat sehingga mau menerima ajaran yang saat itu sangat asing.</p><p>Output dari Fase ini ialah SDM strategis yang terdepan dalam intelektualitas, mulia dalam akhlak dan kuat dalam tauhid. Tercermin dari pribadi para sahabat di awal perkembangan islam yang cerdas, berkarakter dan memiliki ketauhidan yang kuat.</p><h3>Fase Madinah</h3><p>Pada fase ini, mulai dilakukan pendekatan bermasyarakat secara luas. Umat islam tidak lagi hidup di bawah tekanan Kaum Quraisy, melainkan berdampingan dengan Kaum lain di madinah. Pendekatan yang dibangun adalah pendekatan yang moderat, dengan pembangunan masyarakat yang struktural, yang mengedepankan kepentingan bersama melalui struktur pemerintahan yang baku.</p><p>Output dari fase ini ialah masyarakat yang beradab. Masyarakat yang dapat berbaur dengan siapa saja. Fase yang masyarakatnya menjadi rujukan kemajuan pada masa-masa kedepannya.</p><h3>Fase Madani pada Organisasi</h3><p>Fase selanjutnya atau fase terakhir ialah fase di mana kita yang perlu mengilhami apa yang sudah diajarkan oleh Rasulullah. Bagaimana beliau telah dapat membawa masyaraakt yang awalnya terbelenggu kejahilan menjadi masyarakat yang berkembang dengan pesat.</p><p>Sadar tidak sadar, strategi yang diterapkan Rasulullah dalam mentransformasi serta mendisrupsi peradaban pada masa itu sangat efektif. Ini tercermin sebagaimana kompetensi pemimpin besar yang sesuai dengan buku kepemimpinan masa kini yakni, Great Leadership karya Antony Bell.</p><h3>Tipe Kompetensi Pemimpinan dan Aplikasinya</h3><p>Dalam buku tersebut, terdapat 4 positioning pemimpin. Keempat fase ini diperlukan untuk menghandle berbagai jenis pengikut karena tiap level pengikut harus di-handle dengan cara yang berbeda. Keempat kompetensi pemimpin tersebut ialah</p><h3><strong>Instructor</strong></h3><p>Inilah kompetensi yang cocok disampaikan pada pengikut yang yang masih belum berpengalaman, masih baru, masih belum sadar seberapa tidak tahu pengikut itu. Dalam memimpin fase ini hendaknya seorang pemimpin menerapkan fokus dan explorasi pada pengikutnya agar pengikutnya segera sadar akan kekurangannya.</p><h3>Coach</h3><p>Seiring waktu, pengikut tersebut akan mulai sadar akan kekurangannya, akan muncul sedikit kegelisahan akan seberapa tidak kapabel pengikut-pengikut itu. Dari sana harus terus didorong rasa keinginan untuk berkembang dan belajar. Oleh karena itu, tipe yang cocok diterapkan as a leader ialah tipe yagn membangun dan mengembangkan anggotanya.</p><h3>Fasilitator</h3><p>Di fase ini, mereka mulai mampu untuk belajar dengan mandiri. Mlai berpengalaman akan pergerakan yang dilakukan. Sayangnya, kadang masih ditemukan ketidakpedean dalam diri pengikut. Maka sangat cocok diterapkan tipe pemimpin yang mengfasiltiasi dan emnguatkan kepribadian dari pengikutnya</p><h3>Consultant</h3><p>Ketika pengikut telah sampai pada level ini, mereka telah menjadi pengikut yang berpengalaman dan percaya diri. Seorang pemimpin harus dapat memosisikan diri melalui empowerment dan membiarkan pengikutnya. Agar pengikutnya atau anggotanya berkembang dengan leluasa.</p><p>Terakhir salah satu hal terpenting yang dapat dihiglight pada tulisan ini atas seorang pemimpin ialah kemauan untuk terus, belajar, beradaptasi dan berempati dengan orang lain. Semoga tulisan ini bermanfaat terima kasih.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a14cbb68e59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Time Series Kehidupan: Sebuah Modal untuk Connecting The Dots]]></title>
            <link>https://mrfirdauss.medium.com/time-series-kehidupan-sebuah-modal-untuk-connecting-the-dots-e02fa1f07690?source=rss-3c1b4e4eafc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/e02fa1f07690</guid>
            <category><![CDATA[quarter-life-crisis]]></category>
            <category><![CDATA[kehidupan]]></category>
            <category><![CDATA[management]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[timeseries]]></category>
            <dc:creator><![CDATA[Muhammad Risqi Firdaus]]></dc:creator>
            <pubDate>Mon, 18 Sep 2023 07:35:35 GMT</pubDate>
            <atom:updated>2023-09-18T07:35:35.810Z</atom:updated>
            <content:encoded><![CDATA[<p>Karena malas menulis hal teknis, mari kita padukan teknis dan hikmah kehidupan wkwk.</p><p>Buat yang pernah handle data timeseries, mesti ga asing lagi dengan istilah tren dan seasonality. Nah di artikel kali ini, aku bakal coba bahas makna tren dan seasonality di kehidupan kita.</p><p>Pada time series kita mengenal value sebagai sumbu-y dan waktu sebagai sumbu-x. Nah, sebagai manusia biasa, tentunya kadang kita merasa value kita naik turun seiring berjalannya waktu. Itu terjadi di segala sendi kehidupan kita, baik semangat menjalani hidup atau-bahkan keimanan. Ternyata, di dunia data, kenaikan dan penurunan data pada waktu singkat juga marak terjadi. Perhatikan grafik berikut</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*a79nYT6GyTESNo6Yntqjtg.png" /><figcaption>Grafik I</figcaption></figure><p>Jika dilihat terjadi penurunan dan penaikan yang sangat inkonsisten, terkesan tidak membentuk pola. Itu sejatinya adalah sebuah graf yang sedang diperbesar. Sekarang perhatikan graf berikut.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*5jr-R9QIRhrqdMy7cfLlwA.png" /><figcaption>Grafik II</figcaption></figure><p>Kalo kalian sadar, grafik II ini adalah versi zoom out dari grafik I. Mungkin, sebagian dari kita mulai dapat menangkap terbentuknya tren di sana. Meskipun, tren yang terbentuk belum menghasilkan pola yang signifikan. Sekarang perhatikan grafik III.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*OOmekfQckF4-2wwrilfjaA.png" /><figcaption>Grafik III</figcaption></figure><p>Ketika kita melihat data dari sisi yang kurang granular atau timeseries yang lebih panjang, sebenarnya kita sedang berproses. Terlihat tren dari data yang terus meningkat, meskipun terbentuk seasonality pada waktu tertentu, yakni terjadi naik turun.</p><p>Dalam dunia data, seasonality atau naik turun value itu adalah hal yang wajar. Bisa jadi memang ada kejadian yang membuat kita sedikit turun, atau mungkin justru membuat kita naik. Contoh berikut adalah data timeseries rerata kecepatan kendaraan pada suatu ruas jalan di London, Inggris (Mohon abaikan legenda grafik).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/465/1*P0VVCy79wtJ_iEtANzwaTQ.png" /><figcaption>Grafik IV</figcaption></figure><p>Terlihat puncak perlambatan hanya terjadi pada jam-jam tertentu. Pada waktu non-rush hour terlihat kecepatan atau nilai dari sumbu-y bahkan bisa mencapai hampir 2 kali lipat waktu macet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*PeoLbwKkO27kjKMdR7HNbg.png" /><figcaption>Grafik V</figcaption></figure><p>Selain itu jam, kemacetan juga dapat dipantau trennya berdasarkan hari. Terlihat pada hari minggu, 2 Februari 2020, tren terendahnya masi jauh lebih tinggi dibandingkan hari kerja.</p><p>Okeh, sekarang kembali ke laptop. Terlihat bahwa data timeseries yang terlalu granular, tidak cocok untuk mengambil kebijakan strategis. Pola atau tren pada data yang terlalu granular masih sangat kabur. Sebagai mana pemgembangan diri kita. Bisa jadi pada data detail kita merasa kita kurang berkembang, padahal jika ditarik lebih jauh, pada time frame satu tahun misalnya, telah banyak peningkatan yang kita lalui</p><p>Sekarang kita bahas soal data dan strategi dari sudut pandang pemangku kebijakan. Pada Piramida di samping, terlihat bahwa level granularitas data pada tiap level pemangku kebijakan berbeda.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-5Xz1iH9_OfQOGYz.png" /><figcaption>Piramida data dan managemen</figcaption></figure><p>Pada level operasional, data yang digunakan sangat detail, bahkan bisa sedetail data lengkap per transaksi. Sedangkan pada level eksekutif, data yang dipakai bersifat aggregasi atau <em>summarize</em> baik dalam level quarter year atau bahkan YoY.</p><p>Hal ini dapat diilhami dengan, pada operasional (keseharian kita) kita perlu terus mengevaluasi nilai kita berdasarkan tiap peristiwa yang kita lalui. Namun, jangan mudah mengambil keputusan besar, hanya berdasarkan data peristiwa. Bisa jadi meskipun value kita sedang turun, kita masih terus berprogres lebih baik.</p><p>Oleh karena itu, dalam pengambilan keputusan strategis atau yang amat berpengaruh dari hidup hendaknya kita melihat jauh kebelakang. Tetapi jangan juga menjadi terlalu santai, karena data atau nilai kita dalam setahun adalah akumulasi dari perilaku kita sehari-hari.</p><p>Itulah sedikit tulisan random di siang ini. Yang sejatinya ingin ditulis dari lama, cuman terhalang rasa malas. Semoga bermanfaat, dan jangan lupa menyebarkan wkwk. :v</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e02fa1f07690" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Aggregation, Join Table ala MongoDB: Sebuah Studi Kasus]]></title>
            <link>https://medium.com/digistarclub/aggregation-join-table-ala-mongodb-sebuah-studi-kasus-213b61d92d8a?source=rss-3c1b4e4eafc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/213b61d92d8a</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[nosql]]></category>
            <dc:creator><![CDATA[Muhammad Risqi Firdaus]]></dc:creator>
            <pubDate>Fri, 16 Jun 2023 11:34:04 GMT</pubDate>
            <atom:updated>2023-06-16T11:34:04.069Z</atom:updated>
            <content:encoded><![CDATA[<p>Bagi mereka yang sudah lihai menggunakan SQL, pasti tidak asing dengan query “JOIN” yang digunakan untuk menggabungkan 2 atau lebih tabel. Pertanyannya, apakah hal ini juga mungkin dilakukan pada collection NoSQL?</p><p>Pada kasus ini, kita akan menggunakan MongoDB salah satu Document Based NoSQL. Pada Document Based NoSQL, <em>instance </em>data disimpan dalam object yang tertata pada collection atau document database. Untuk menggabungkan 2 atau lebih collection, pada NoSQL, khususnya pada mongoDB, terdapat sebuah fitur yang disebut aggregation.</p><p>Sebagaimana yang telah dijelaskan dalam artikelku sebelumnya, ada beberapa fungsi <em>aggregation</em> yang dapat digunakan sebagai pengganti <em>join table</em> di MongoDB. Untuk lebih lengkapnya, kamu bisa baca dulu <a href="https://medium.com/@mrfirdauss/mongodb-aggregation-can-we-join-a-collection-on-a-no-sql-database-ede56ca519af">di sini</a>.</p><p>Pada studi kasus kali ini, kita akan menggunakan database yang dirancang untuk aplikasi pengingat tugas. Sebelum lebih jauh, temen-temen perlu memahami dahulu seperti apa arsitektur database yang kita gunakan. Berikut adalah arsitektur database yang digunakan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7GyCHCRcz2jPS01QrsjwSA.png" /><figcaption>Arsitektur Database Latihan</figcaption></figure><h3>Daftar Grup yang Diikuti User</h3><p>Kita akan menampilkan daftar dan informasi grup yang diikuti user, baik sebagai owner, maintainer, maupun member. Untuk melakukan hal ini pipeline yang kita miliki hanya perlu melakukan lookup melalui group_list yang dimiliki user.</p><pre>[<br>  {<br>    $match:<br>      {<br>        _id: ObjectId(&quot;6401d6c7d6b91267a5712bd1&quot;),<br>      },<br>  },<br>  {<br>    $lookup:<br>      {<br>        from: &quot;group&quot;,<br>        localField: &quot;group_list&quot;,<br>        foreignField: &quot;_id&quot;,<br>        as: &quot;data&quot;,<br>      },<br>  }<br>]</pre><p>Sebenarnya sampai sini, kamu sudah akan mendapatkan hasil berupa daftar tugas yang masih aktif. Namun, untuk mengekstrak hal tersebut, kamu harus masuk ke dalam child dari child respon yang diterima. Untuk mempermudah komunikasi kamu dapat menambah script berikut pada pipeline. Agar response untuk client side dapat diperindah, dan menurunkan komputasi di sisi client.</p><pre>[<br>  {<br>    $unwind:<br>      {<br>        path: &quot;$data&quot;,<br>        includeArrayIndex: &quot;string&quot;,<br>        preserveNullAndEmptyArrays: false,<br>      },<br>  },<br>  {<br>    $replaceRoot:<br>      {<br>        newRoot: &quot;$data&quot;,<br>      },<br>  },<br>]</pre><h3>Daftar Tugas User yang Masih Aktif</h3><p>untuk mendapatkan daftar ini, gunakan <em>user collection</em> sebagai basis pencarian. Kemudian lakukan filter untuk memilih user mana yang datanya ingin diekstraksi. Untuk mendapatkan tugas yang diinginkan maka kita akan menggunakan dua fungsi agregasi: match, lookup dengan pipeline.</p><pre>[<br>  {<br>    $lookup: {<br>      from: &quot;group&quot;,<br>      localField: &quot;group_list&quot;,<br>      foreignField: &quot;_id&quot;,<br>      pipeline: [<br>        {<br>          $lookup: {<br>            from: &quot;class&quot;,<br>            localField: &quot;classes&quot;,<br>            foreignField: &quot;_id&quot;,<br>            as: &quot;class&quot;,<br>          },<br>        },<br>        {<br>          $lookup: {<br>            from: &quot;task&quot;,<br>            localField: &quot;class.active_task_list&quot;,<br>            foreignField: &quot;_id&quot;,<br>            pipeline: [<br>              {<br>                $lookup: {<br>                  from: &quot;tags&quot;,<br>                  localField: &quot;tags&quot;,<br>                  foreignField: &quot;_id&quot;,<br>                  as: &quot;tags&quot;,<br>                },<br>              },<br>              {<br>                $match: {<br>                  date_due: {<br>                    $gte: Date(),<br>                  },<br>                },<br>              },<br>            ],<br>            as: &quot;tasks&quot;,<br>          },<br>        },<br>      ],<br>      as: &quot;data&quot;,<br>    },<br>  }<br>]</pre><p>Sebagaimana pada kasus pertama, kita dapat melakukan unwind dan replace root untuk memperbaiki format response untuk client.</p><pre>[<br>{<br>    $unwind:<br>      {<br>        path: &quot;$data&quot;,<br>        includeArrayIndex: &quot;string&quot;,<br>        preserveNullAndEmptyArrays: false,<br>      },<br>  },<br>  {<br>    $unwind:<br><br>      {<br>        path: &quot;$data.tasks&quot;,<br>        includeArrayIndex: &quot;string&quot;,<br>        preserveNullAndEmptyArrays: false,<br>      },<br>  },<br>  {<br>    $replaceRoot:<br>      {<br>        newRoot: &quot;$data.tasks&quot;,<br>      },<br>  }<br>]</pre><h3>End of the story, Editors Note</h3><p>Sebagaimana <em>join operation</em> pada SQL. Operasi tunggal kadang tidak cukup untuk menyelesaikan persoalan di dunia nyata. Untuk mengatasi hal tersebut, mongoDB menyediakan pipeline yang dapat kita rekayasa dengan menaruhnya dalam <em>lookup </em>untuk meniru operasi nested join yang ada pada SQL.</p><p>Dibalik kefleksibelan strukturnya, NoSQL database menyimpan kerumitan dalam operasi kompleks serta statistikal. Oleh sebab itu, MongoDB cocok digunakan pada tahap pengembangan. Jika telah menemukan struktur yang pas, pada program dengan database yang complex menggunakan SQl dengan berbagai jenis tuning diyakini dapat meningkatkan performa pemanggilan data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=213b61d92d8a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/digistarclub/aggregation-join-table-ala-mongodb-sebuah-studi-kasus-213b61d92d8a">Aggregation, Join Table ala MongoDB: Sebuah Studi Kasus</a> was originally published in <a href="https://medium.com/digistarclub">Digistar Club by Telkom Indonesia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MongoDB Aggregation: Can We Join a Collection on A No-SQL Database?]]></title>
            <link>https://medium.com/digistarclub/mongodb-aggregation-can-we-join-a-collection-on-a-no-sql-database-ede56ca519af?source=rss-3c1b4e4eafc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/ede56ca519af</guid>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[nosql]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Muhammad Risqi Firdaus]]></dc:creator>
            <pubDate>Thu, 27 Apr 2023 01:45:10 GMT</pubDate>
            <atom:updated>2023-04-27T01:58:58.071Z</atom:updated>
            <content:encoded><![CDATA[<p>For those who ever knew about the database, it is not strange to hear about no-SQL. MongoDB, as the famous no-SQL document-oriented database, has been massively used by the developer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/0*aT_RkxbqhVeECfci.png" /><figcaption>source: fool.com</figcaption></figure><p>MongoDB preserves a user-friendly database through Ad-hoc queries, aggregation, capped collection, file storage, indexing, load balancing, replication, and server-side JavaScript execution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/357/1*DOJj4Hevg8JFQdDvM64rYg.png" /></figure><p>However, only a few of the users whose a clear understanding of MongoDB’s features. On several occasions, when I was reviewing a backend code that used MongoDB as the database, I found several dirty codes. The common mistake of the MongoDB developer is manually joining the collection in the server program.</p><h3><strong>Aggregation</strong></h3><p>Aggregation is a hidden gem feature that is preserved by MongoDB. Aggregation serves as a manipulation query like in MongoDB collection as in SQL database.</p><p>Aggregation process a large number of data in a collection by passing them through different stages(pipeline). Here, I will explain to you several aggregation operations that you can use on your program.</p><h3><strong>The Pipeline</strong></h3><p>MongoDB aggregation works in the form of a data operation pipeline. A pipeline consists of one or more stages of operation that process the document. Each phase could be a filter, join, or unwind operation.</p><p>Thus, the pipeline is an array of operations that allows developers to combine any other operations in MongoDB so the developers can get the desired result. You will learn the kind of the operation later.</p><pre>[<br>   // Stage 1: Filter pizza order documents by pizza size<br>   {<br>      $match: { size: &quot;medium&quot; }<br>   },<br>   // Stage 2: Group remaining documents by pizza name and calculate total quantity<br>   {<br>      $group: { _id: &quot;$name&quot;, totalQuantity: { $sum: &quot;$quantity&quot; } }<br>   }<br>]</pre><h3><strong>Look Up</strong></h3><p>Joining the table plays a significant role in database optimization. Lookup operation preserves the left outer join to a collection in the same database.</p><pre>{<br>   $lookup:<br>     {<br>       from: &lt;collection to join&gt;,<br>       localField: &lt;field from the input documents&gt;,<br>       foreignField: &lt;field from the documents of the &quot;from&quot; collection&gt;,<br>       as: &lt;output array field&gt;<br>     }<br>}</pre><p>The operation is equal to the query below.</p><pre>SELECT *, &lt;output array field&gt;<br>FROM collection<br>WHERE &lt;output array field&gt; IN (<br>   SELECT *<br>   FROM &lt;collection to join&gt;<br>   WHERE &lt;foreignField&gt; = &lt;collection.localField&gt;<br>);</pre><p>If you are willing to do a nested query or subqueries on your operation you can use a pipeline such as below. You can fill the pipeline with another query (operation).</p><pre>{<br>   $lookup:<br>      {<br>         from: &lt;joined collection&gt;,<br>         let: { &lt;var_1&gt;: &lt;expression&gt;, …, &lt;var_n&gt;: &lt;expression&gt; },<br>         pipeline: [ &lt;pipeline to run on joined collection&gt; ],<br>         as: &lt;output array field&gt;<br>      }<br>}</pre><pre>SELECT *, &lt;output array field&gt;<br>FROM collection<br>WHERE &lt;output array field&gt; IN (<br>   SELECT &lt;documents as determined from the pipeline&gt;<br>   FROM &lt;collection to join&gt;<br>   WHERE &lt;pipeline&gt;<br>);</pre><h3><strong>Match</strong></h3><p>One of the optimization keys in database queries is filtering the data. You could only choose the specified document that matches the condition through <strong>$match</strong> operation.</p><pre>{ $match: { &lt;query&gt; } }</pre><p>You can specify the filter using query expressions such as <strong>$gt</strong> (greater than) and any other expression.</p><pre>{ $match: { $expr: { &lt;aggregation expression&gt; } } }</pre><h3>Deconstructing The Object Document</h3><p>The problem with a document-oriented database is the form of return value that is strict on the document form itself. Using <strong>$unwind</strong> you can deconstructs an array field from a document object, and output it as an array of each element.</p><pre>{ $unwind: &lt;field path&gt; }</pre><p>Suppose you have an object below. An object that has an array as one of the object child values.</p><pre>{ <br>  &quot;_id&quot; : 1, <br>  &quot;item&quot; : &quot;Shirt&quot;, <br>  &quot;sizes&quot;: [ &quot;S&quot;, &quot;M&quot;, &quot;L&quot;] <br>}</pre><p>If you want to deconstruct the child into an array of objects like below. You can use <strong>$unwind</strong> operation.</p><pre>[<br>{ _id: 1, item: &#39;Shirt&#39;, sizes: &#39;S&#39; },<br>{ _id: 1, item: &#39;Shirt&#39;, sizes: &#39;M&#39; },<br>{ _id: 1, item: &#39;Shirt&#39;, sizes: &#39;L&#39; }<br>]</pre><p>using operation below.</p><pre> { $unwind: { path: &quot;$sizes&quot; } } </pre><h3>Replacing The Root</h3><p>As we join the collection, the document goes deep, as the tree of the data structure of an object. It makes us harder to get the value of the result if what we desire is only the leaf of the object. In order to handle this problem, MongoDB preserves the <strong>$replaceRoot</strong> operation.</p><p><strong>$replaceRoot</strong> operation allows us to replace the root of the existing document with the desired output. You can promote the leaf or the object child of the document as the root value of the object through this operation. <strong>$replaceRoot</strong> has the following form.</p><pre>{ $replaceRoot: { newRoot: &lt;replacementDocument&gt; } }</pre><p>Suppose we have data below.</p><pre>[<br>  { &quot;_id&quot; : 1, &quot;name&quot; : &quot;Arlene&quot;, &quot;age&quot; : 34, &quot;pets&quot; : { &quot;dogs&quot; : 2, &quot;cats&quot; : 1 } }<br>  { &quot;_id&quot; : 2, &quot;name&quot; : &quot;Sam&quot;, &quot;age&quot; : 41, &quot;pets&quot; : { &quot;cats&quot; : 1, &quot;fish&quot; : 3 } }<br>  { &quot;_id&quot; : 3, &quot;name&quot; : &quot;Maria&quot;, &quot;age&quot; : 25 }<br>]</pre><p>By implementing the following operation, we can get the following result below.</p><pre>{ $replaceRoot: { newRoot: { $mergeObjects:  [ { dogs: 0, cats: 0, birds: 0, fish: 0 }, &quot;$pets&quot; ] }} }  </pre><pre>[<br>  { &quot;dogs&quot; : 2, &quot;cats&quot; : 1, &quot;birds&quot; : 0, &quot;fish&quot; : 0 }<br>  { &quot;dogs&quot; : 0, &quot;cats&quot; : 1, &quot;birds&quot; : 0, &quot;fish&quot; : 3 }<br>  { &quot;dogs&quot; : 0, &quot;cats&quot; : 0, &quot;birds&quot; : 0, &quot;fish&quot; : 0 }<br>]</pre><p>We can also use it for nested document array, by combinint <strong>$replaceRoot</strong> with <strong>$unwind</strong> operation.</p><h3>Grouping The Data</h3><p>Somehow, we need to populate the document according to a specific key. If you want to do that operation, you can use <strong>$group</strong> operation. <strong>$group</strong> operation preserves the output of the document that has been populated by the specific key.</p><p>Furthermore, you can also use statistical operations on the document that has been populated before. As in SQL, may you have familiar with GROUP BY query. Here is the syntax of the operation.</p><pre>{<br>  $group:<br>    {<br>      _id: &lt;expression&gt;, // Group key<br>      &lt;field1&gt;: { &lt;accumulator1&gt; : &lt;expression1&gt; },<br>      ...<br>    }<br> }</pre><p>In the triple dots, you can input statistical operation as mentioned before. The form of the operation could be count, sum, and any other operation that you can see in <a href="https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/">the documentation page</a>.</p><p>Suppose you have data below.</p><pre>[<br>  { &quot;_id&quot; : 1, &quot;item&quot; : &quot;abc&quot;, &quot;price&quot; : NumberDecimal(&quot;10&quot;), &quot;quantity&quot; : NumberInt(&quot;2&quot;), &quot;date&quot; : ISODate(&quot;2014-03-01T08:00:00Z&quot;) },<br>  { &quot;_id&quot; : 2, &quot;item&quot; : &quot;jkl&quot;, &quot;price&quot; : NumberDecimal(&quot;20&quot;), &quot;quantity&quot; : NumberInt(&quot;1&quot;), &quot;date&quot; : ISODate(&quot;2014-03-01T09:00:00Z&quot;) },<br>  { &quot;_id&quot; : 3, &quot;item&quot; : &quot;xyz&quot;, &quot;price&quot; : NumberDecimal(&quot;5&quot;), &quot;quantity&quot; : NumberInt( &quot;10&quot;), &quot;date&quot; : ISODate(&quot;2014-03-15T09:00:00Z&quot;) },<br>  { &quot;_id&quot; : 4, &quot;item&quot; : &quot;xyz&quot;, &quot;price&quot; : NumberDecimal(&quot;5&quot;), &quot;quantity&quot; :  NumberInt(&quot;20&quot;) , &quot;date&quot; : ISODate(&quot;2014-04-04T11:21:39.736Z&quot;) },<br>  { &quot;_id&quot; : 5, &quot;item&quot; : &quot;abc&quot;, &quot;price&quot; : NumberDecimal(&quot;10&quot;), &quot;quantity&quot; : NumberInt(&quot;10&quot;) , &quot;date&quot; : ISODate(&quot;2014-04-04T21:23:13.331Z&quot;) },<br>  { &quot;_id&quot; : 6, &quot;item&quot; : &quot;def&quot;, &quot;price&quot; : NumberDecimal(&quot;7.5&quot;), &quot;quantity&quot;: NumberInt(&quot;5&quot; ) , &quot;date&quot; : ISODate(&quot;2015-06-04T05:08:13Z&quot;) },<br>  { &quot;_id&quot; : 7, &quot;item&quot; : &quot;def&quot;, &quot;price&quot; : NumberDecimal(&quot;7.5&quot;), &quot;quantity&quot;: NumberInt(&quot;10&quot;) , &quot;date&quot; : ISODate(&quot;2015-09-10T08:43:00Z&quot;) },<br>  { &quot;_id&quot; : 8, &quot;item&quot; : &quot;abc&quot;, &quot;price&quot; : NumberDecimal(&quot;10&quot;), &quot;quantity&quot; : NumberInt(&quot;5&quot; ) , &quot;date&quot; : ISODate(&quot;2016-02-06T20:20:13Z&quot;) },<br>]</pre><p>If you apply following operation, you can get the result as mentioned below.</p><pre>{<br>    $group: {<br>       _id: null,<br>       count: { $count: { } }<br>    }<br>  }</pre><pre>{ &quot;_id&quot; : null, &quot;count&quot; : 8 }</pre><h3>Sort The Return Value</h3><p>It is more optimum if you can sort the array before sending it to the client. But, will be difficult, if you sort it manually on your server. You can optimize the sort operation, by asking the MongoDB to sort on the structure that they have through <strong>$sort</strong> operation. This operation is equal to order by query in SQL.</p><p>Here is the syntax of the <strong>$sort </strong>operation. You can fill the value of sort order object by -1 for descending order and 1 for ascending order. The limit of the operation is at maximum of 32 order keys.</p><pre>{ $sort: { &lt;field1&gt;: &lt;sort order&gt;, &lt;field2&gt;: &lt;sort order&gt; ... } }</pre><h3>At The End</h3><p>It is important to have a clear understanding of the stack that is used. Here is only a short introduction to aggregation operation in MongoDB. For more specific information, you can read the documentation <a href="https://www.mongodb.com/docs/manual/aggregation/">here</a>. You can use <strong>aggregation section </strong>in MongoDB DBMS to visualize the <strong>aggregation pipeline</strong>. The feature is located beside the collection of the data.</p><p>If you curious about one of pipeline that i made, here is the example.</p><pre>[<br>  {<br>    $match: {<br>      _id: ObjectId(&quot;6401aec4c409219093cb18b7&quot;),<br>    },<br>  },<br>  {<br>    $lookup: {<br>      from: &quot;group&quot;,<br>      localField: &quot;group_list&quot;,<br>      foreignField: &quot;_id&quot;,<br>      pipeline: [<br>        {<br>          $lookup: {<br>            from: &quot;class&quot;,<br>            localField: &quot;classes&quot;,<br>            foreignField: &quot;_id&quot;,<br>            pipeline: [<br>              {<br>                $lookup: {<br>                  from: &quot;task&quot;,<br>                  localField: &quot;active_task_list&quot;,<br>                  foreignField: &quot;_id&quot;,<br>                  pipeline: [<br>                    {<br>                      $lookup: {<br>                        from: &quot;tags&quot;,<br>                        localField: &quot;tags&quot;,<br>                        foreignField: &quot;_id&quot;,<br>                        as: &quot;tags&quot;,<br>                      },<br>                    },<br>                    {<br>                      $match:{<br>                        date_due: {<br>                          $gt: Date()<br>                        }<br>                      }<br>                    }<br>                  ],<br>                  as: &quot;task&quot;,<br>                },<br>              },<br>            ],<br>            as: &quot;classes&quot;,<br>          },<br>        },<br>      ],<br>      as: &quot;group_list&quot;,<br>    },<br>  },<br>  {<br>    $unwind: {<br>      path: &quot;$group_list&quot;,<br>      includeArrayIndex: &quot;string&quot;,<br>      preserveNullAndEmptyArrays: false,<br>    },<br>  },<br>  {<br>    $unwind: {<br>      path: &quot;$group_list.classes&quot;,<br>      includeArrayIndex: &quot;string&quot;,<br>      preserveNullAndEmptyArrays: false,<br>    },<br>  },<br>  {<br>    $unwind: {<br>      path: &quot;$group_list.classes.task&quot;,<br>      includeArrayIndex: &quot;string&quot;,<br>      preserveNullAndEmptyArrays: false,<br>    },<br>  },<br>  {<br>    $replaceRoot:<br>      {<br>        newRoot: {<br>          $mergeObjects:[<br>            {name: &quot;$group_list.classes.name&quot;},<br>            &quot;$group_list.classes.task&quot;<br>          ],<br>        },<br>      },<br>  },<br>]</pre><p>This query is made for getting active task of a user that joined into a group. Each group have a class, and each class is storing the task. I also tried to get the tag object for each task.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ede56ca519af" width="1" height="1" alt=""><hr><p><a href="https://medium.com/digistarclub/mongodb-aggregation-can-we-join-a-collection-on-a-no-sql-database-ede56ca519af">MongoDB Aggregation: Can We Join a Collection on A No-SQL Database?</a> was originally published in <a href="https://medium.com/digistarclub">Digistar Club by Telkom Indonesia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploratory Data Analysis: a Case Study Example on Classification Task]]></title>
            <link>https://mrfirdauss.medium.com/exploratory-data-analysis-a-case-study-example-on-classification-task-ece1a65b5302?source=rss-3c1b4e4eafc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/ece1a65b5302</guid>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[eda]]></category>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Muhammad Risqi Firdaus]]></dc:creator>
            <pubDate>Wed, 26 Apr 2023 05:21:58 GMT</pubDate>
            <atom:updated>2023-04-26T10:13:08.903Z</atom:updated>
            <content:encoded><![CDATA[<p>Exploratory data analysis (EDA) plays the main role on building a machine learning model. Everything you do on your data would based on your EDA results. I once wrote about some EDA on my old blog post, you can read it <a href="http://coretgabut.blogspot.com/2021/01/">here</a>.</p><p>I will give you some tutorial about finding the edge of the data. Maybe itis not the best tutorial you read, the task that i cover will be only for <strong>classification</strong> task. If you have timeseries data or regression task, you can looking for other tutorial.</p><h3>About The Data</h3><p>In thise article, I use <a href="https://www.kaggle.com/competitions/spaceship-titanic/data?select=train.csv">spaceship titanic data</a> from kaggle. As shown on the kaggle page, the data contain train, test and sample submission data. This is a good data for you to start your exploration. The data that i use have been modified to give a better learning experience for you.</p><p>As you may know, to start EDA, after loading the data, you can get the snapshot of the data through method <em>.head()</em>.</p><pre>df.head()</pre><p>The notebook will return <strong>top five</strong> data based on the id. You can change the amount of the snapshot data (row) by giving number of row you want on method parameter.</p><pre>df.head(10)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*dzMMLo10ERXNTohtbqWBtg.png" /></figure><p>This method is important for you. Before analyzing or doing any step forward you need to get a small figure of your data. By the screenshot that i give, you can see there are some <strong>odd values</strong> on the feature “FoodCourt”. With the general knowledge like that, you can do a specific step such get the unique value of the data.</p><h3>Getting The General Information</h3><p>After you get the snapshot of the data, you can get the general information from the data through method <em>.info()</em>. This method will return the type of the data, the count of non-nullable features, and the feature name obviously wkwk.</p><pre>df.info()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*75qR8pp5pVMtiBFOJrrA0w.png" /></figure><p>By the figure shown, you can see that most of the feature is in object (categorical) type. You can see that the non-null count for each feature has different value, which means that you have null data.</p><h3>Get Rid The Duplicate Data Off</h3><p>Somehow, our data may be consist of duplicate data, you should check and drop it before further step. Pandas has adrop_duplicates() method that can easily drop the duplicate instances of your data. In this case, we don’t have any duplicate data, so we can move forward to the next step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*N-sgYJbXm4jaV3RNf6MSEg.png" /></figure><h3>Finding The Null Value</h3><p>Exploring the null value of each feature can lead you to the cleaning process. If the null data percentage is too big, you can use imputer, or maybe choose the least null percentage feature as the drop baseline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aSmtwT-MFJ1rgHf6fSu3cw.png" /></figure><p>As we can see, the percentage for each feature on our data is very low, so we can drop the row based on the highest null feature. However, in the first phase you can see that the amount of training data was scrimp, so maybe you can arrange an experiment by comparing two types of training experiments: data with/without null.</p><h3>Figuring The Unique Value</h3><p>To realize there are some odd values on your data, you can start by figuring out the unique value of your feature. Getting the count of the unique value is taking the main role.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/122/1*wn2pX19VevITKG4tvZ42QA.png" /></figure><p>Furthermore, checking each feature could be needed. You can use method <em>.unique() </em>for each feature series.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*Io48XUS6ujeiS4u418kgsA.png" /></figure><p>By checking particular features, maybe we can get some odd value, like “one” inside numerical value. Do you think it is possible for having age 0? The question maybe would be answered as you explore your data.</p><p>By the statement before, we can replace the age data above and convert the type to integer.</p><h3>Exploring The Data Distribution</h3><p>In classification, it is important to know and adjust the <strong>distribution</strong> of the data, especially on target data. The figure below shows you the distribution of target data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*n7d984BnC4vksnQPYM0mVw.png" /><figcaption>df.Transported.value_counts().plot.bar()</figcaption></figure><p>We can see that there is no significant difference in data (target) distribution. We can continue our investigation on feature correlation.</p><p>For numerical data, you can investigate the distribution of the data through histogram or line plot. If you are handling categorical data, besides heatmap for each class, you can use bar plot to investigate the distribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*GVj_sx2G5nWNeBmunA1OpQ.png" /><figcaption>comparing hsitogram vs barplot</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*nW7TUnOGBNAzAdbWgD2_dg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*cTsPVT8ZO9SpK7mmoV_3ZQ.png" /></figure><p>We can see that if the passanger comes from “Earth” the passanger is <strong>most likely</strong> to be transported, in contrast with other value that the HomePlanet value will lead the passanger not to be transported. By the graph, we could also conclude that the most of the <strong>data distribution</strong> is having “Earth” category, which can lead to bias.</p><p>Which one is the best plot? no one knows, there is no silver bull on it. The best fit plot is depending on your data. However, if we want to encode more precious, we can investigate the correlation of each category based on its class</p><h3>Is It Enough?</h3><p>The answer is, no one knows. If you have numeric interval data, maybe you can investigate the existence of the outlier. It could be done by plotting your numerical data using boxplot. Before going too far, we have to deal with the same definition of an <strong><em>outlier</em></strong><em> term</em>.</p><p>In this context, an outlier defined as the value that is beyond the inner fence of the data (beyond 1.5 IQR, you can google it later). The boxplot shows the outlier of the data by a locating the points outside the long projection of the plot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*imAYwmFJethmGDS45nm2tQ.png" /></figure><h3>Is Your Feature Correlated Well?</h3><p>First thing first, you have to understand that correlation doesn’t imply causality. If you see a correlation between unrelated data, you can check the causality first.</p><p>Checking the correlation of categorical data can be kinda tricky. If you are using pearson correlation, you will only get the correlation of numerical data. Furthermore, if you want to investigate correlation on non-numerical data, you can use <strong><em>phi_k</em></strong> correlation (you can google it later).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*V6cZLYwpvU1zB4KKMYVT2g.png" /></figure><p>If you are curious about the exact value of the correlation, you can turn the annotation of the plot on. Determining the correlation of the feature to the target feature could lead us to <strong>feature selection.</strong></p><h3>The Most Important Feature</h3><p>If you want to look for the feature’s importance, you need to <strong>build a base model first</strong>. With the changes in your encoding, model, maybe your <strong>feature’s importance</strong> also <strong>can be changed</strong>. In this case, i use the most simple base model, decision tree on non null data to identify the feature importance of my initial data. <em>To be noted: i have separated the column Cabin into three columns and encoded it before training the base model.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*hQGhUs9Zfv1pltZCiFv6Qw.png" /></figure><h3>To Sum Up</h3><p>You have learned some methods for EDA in classification task. By the time, you will learn, that the method for EDA in other tasks may be a little bit different. On another article maybe i will explain feature engineering, data cleaning or maybe EDA on another task. Hopefully this article will be benefical for you. See ya later!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ece1a65b5302" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>