<?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 Muhamad Salim Alwan on Medium]]></title>
        <description><![CDATA[Stories by Muhamad Salim Alwan on Medium]]></description>
        <link>https://medium.com/@muhamadsalimalwan10?source=rss-a1f1cd4bfa39------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*kYFH0blF1xyiB-vijr9krw.jpeg</url>
            <title>Stories by Muhamad Salim Alwan on Medium</title>
            <link>https://medium.com/@muhamadsalimalwan10?source=rss-a1f1cd4bfa39------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 18 May 2026 11:40:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@muhamadsalimalwan10/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[Credit Card Customer Segmentation: Unsupervised Machine Learning K-Means Clustering]]></title>
            <link>https://medium.com/@muhamadsalimalwan10/credit-card-customer-segmentation-unsupervised-machine-learning-k-means-clustering-fb4677461408?source=rss-a1f1cd4bfa39------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb4677461408</guid>
            <category><![CDATA[banking]]></category>
            <category><![CDATA[clustering]]></category>
            <category><![CDATA[segmentation]]></category>
            <category><![CDATA[unsupervised-learning]]></category>
            <category><![CDATA[credit-cards]]></category>
            <dc:creator><![CDATA[Muhamad Salim Alwan]]></dc:creator>
            <pubDate>Sat, 23 Aug 2025 17:20:29 GMT</pubDate>
            <atom:updated>2025-08-23T17:20:29.942Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7VnJq47hR1Rw_8Ak" /><figcaption>Photo by <a href="https://unsplash.com/@gagliardiphotography?utm_source=medium&amp;utm_medium=referral">Giovanni Gagliardi</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><a href="https://www.investopedia.com/terms/c/creditcard.asp"><strong>Credit cards</strong></a> are typically issued by banks or financial services companies, allowing cardholders to borrow funds to pay for goods and services at merchants that accept card payments. However, credit cards require cardholders to repay the borrowed funds in the future, plus applicable interest and agreed-upon additional fees, either in full on the billing date or over time.</p><p>Based on this, we will carry out clustering by looking at the behavior of credit card customers. We will use a dataset provided by Kaggle titled <strong>“Credit Card Data- Intermediate Dataset”</strong>. The dataset provides insight into the usage patterns of credit card users within a bank. With detailed information on credit card transactions and customer behavior, this dataset enables researchers and analysts to uncover meaningful segments and trends. However, this time we will focus only on customer segmentation. But, before we dive into the data, it would be a good idea to check out the dataset <a href="https://www.kaggle.com/datasets/samira1992/credit-card-data-intermediate-dataset/data">here</a>.</p><p>We will divide our work into the following steps:<br>1. Data preprocessing: handling missing values and exploratory data analysis<br>2. Filtering and normalize data<br>3. Find the optimal number for clustering<br>4. Implementing K-Means Clustering<br>5. Analyzing segments<br>6. Implementing clusters result into data</p><p>Awesome, let’s import the required libraries and learn the dataset first by observing what features it has.</p><pre>import pandas as pd<br>import numpy as np<br>import seaborn as sns<br>import matplotlib.pyplot as plt<br>from sklearn.preprocessing import StandardScaler<br>from sklearn.cluster import KMeans<br>from sklearn.decomposition import PCA<br><br>import warnings<br>warnings.filterwarnings(&#39;ignore&#39;)<br>sns.set_palette(&#39;pastel&#39;, 5)<br><br>df = pd.read_csv(&#39;Customer_Data.csv&#39;)<br>df.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NBdXcunxcyDguFalTHzoTw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ubrlsiiHOP58lftR2DMtqg.png" /></figure><ul><li>BALANCE: The balance is the total amount a customer owes you or you owe to a vendor. Customer and vendor balances can be.<br>- BALANCE_FREQUENCY: How frequently the Balance is updated, score between 0 and 1 (1 = frequently updated, 0 = not frequently updated) PURCHASES : Amount of purchases made from account.<br>- PURCHASES: Consumer purchase data is the information about consumer purchases, including the product or service, time of purchase, and the amount spent. This data indicates purchase history, customer buying patterns, and other relevant details, such as stock availability and product appearance.<br>- ONEOFF_PURCHASES: Maximum purchase amount done in one-go.<br>- INSTALLMENTS_PURCHASES: Amount of purchase done in installment.<br>- CASH_ADVANCE: Cash in advance given by the user.<br>- PURCHASES_FREQUENCY: How frequently the Purchases are being made, score between 0 and 1 (1 = frequently purchased, 0 = not frequently purchased).<br>- ONEOFF_PURCHASES_FREQUENCY: A column that shows how often customers buy things that are not part of a regular plan. It can help businesses group customers based on their buying habits and offer them suitable products. There are different ways to do this using machine learning and data analysis.<br>- PURCHASES_INSTALLMENTS_FREQUENCY: A column that measures how often customers make purchases in installments, as a percentage of months with at least one installment purchase in the last 12 months. It can help businesses understand the payment preferences and behaviors of different customer segments.<br>- CASH_ADVANCE_FREQUENCY: A column that indicates how often customers take cash in advance from their credit card, as a fraction of months with at least one cash advance transaction in the last 12 months. It can help businesses understand the borrowing and repayment patterns of different customer segments.<br>- CASH_ADVANCE_TRX: A column that counts the number of times customers take cash in advance from their credit card in the last 12 months. It can help businesses identify the customers who rely on cash advances more often.<br>- PURCHASES_TRX: A column that counts the number of purchase transactions made by customers in the last 12 months. It can help businesses understand the purchase frequency and volume of different customer segments.<br>- CREDIT_LIMIT: A column that shows the maximum amount of money that customers can borrow from their credit card. It can help businesses understand the spending power and credit risk of different customer segments.<br>- PAYMENTS: A column that shows the total amount of money that customers paid to their credit card in the last 12 months. It can help businesses measure the repayment ability and creditworthiness of different customer segments.<br>- MINIMUM_PAYMENTS: A column that shows the minimum amount of money that customers have to pay to their credit card in the last 12 months. It can help businesses evaluate the repayment ability and creditworthiness of different customer segments.<br>- PRC_FULL_PAYMENT: A column that shows the percentage of months with full payment of the due statement balance in the last 12 months. It can help businesses assess the repayment ability and creditworthiness of different customer segments.<br>- TENURE: A column that shows how long customers have been using their credit card, in months. It can help businesses</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*d4erphR_X28Yrbq5gBNdag.png" /></figure><p>Oh no! We found missing values ​​in the data in the columns ‘CREDIT_LIMIT’ and ‘MINIMUM_PAYMENTS’. So, we need to handle them first. For column ‘MINIMUM_PAYMENTS’, we’ll fill the missing values ​​with zeros. But for column ‘CREDIT_LIMIT’, we’ll delete the entire row. Why we don’t fill it with zeros as well? Of course, because the credit limit must have a certain minimum value and cannot be zero. And also we can’t fill it with the <a href="https://www.geeksforgeeks.org/maths/mean-median-mode/">mean</a>, <a href="https://www.geeksforgeeks.org/maths/mean-median-mode/">median</a>, or even <a href="https://www.geeksforgeeks.org/maths/mean-median-mode/">mode</a>, as that would make the results unrepresentative. Furthermore, since we’re only deleting one row, it won’t be a significant issue.</p><pre>df[&#39;MINIMUM_PAYMENTS&#39;] = df[&#39;MINIMUM_PAYMENTS&#39;].fillna(0)<br>df.dropna(inplace=True)</pre><p><em>Voilà</em>, we have successfully doing data preprocessing. And next, we will first look at the correlation between features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t8DYOG2R04a-DkUO3d_GrQ.png" /></figure><p>From the heatmap graph above, the column that has the highest correlation is column ‘PURCHASES’ and ‘ONEOFF_PURCHASES’ with a value of 0.92, and so on. It should be noted that <a href="https://www.statology.org/correlation-does-not-imply-causation-examples/"><strong>correlation is not causation</strong></a>. This means that the columns do have a relationship, but that does’nt mean that the columns have cause and effect.</p><p>Perfect, we will continue to filtering and normalize the data now. And of course, after that we also should find the optimal number of cluster before implementing the K-Means Clustering.</p><pre>Q1 = df[&#39;PURCHASES&#39;].quantile(0.25)<br>Q3 = df[&#39;PURCHASES&#39;].quantile(0.75)<br>IQR = Q3-Q1<br><br>lower_bound = Q1 - (0.75 * IQR)<br>upper_bound = Q3 + (0.75 * IQR)<br><br>filtered_df = df[(df[&#39;PURCHASES&#39;] &gt;= lower_bound) &amp;<br>                 (df[&#39;PURCHASES&#39;] &lt;= upper_bound)]<br><br>filtered_df = df.drop(columns=&#39;CUST_ID&#39;, index=1)<br>scaled_df = StandardScaler().fit_transform(filtered_df)<br><br>pca = PCA(n_components=2)<br>pca_components = pca.fit_transform(scaled_df)<br>pca_df = pd.DataFrame(pca_components, columns=[&#39;PCA1&#39;, &#39;PCA2&#39;])</pre><p>The filtering we do aims to reduce outliers in the data. StandardScaler() is needed to scale different features to be equal. For each feature, its value is changed to have a mean = 0 and a standard deviation = 1. PCA is used to reduce the dimensionality of features. This reduced-dimensional dataset is, in some ways, ‘good enough’ to encode the most important relationships between points, despite reducing the number of data features by 50%, the overall relationships between data points are largely preserved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*M3zvLE_fg1eFqPQfyc7HtQ.jpeg" /></figure><p>To find the optimal value of the cluster, we use the Elbow Method. The Elbow Method is a popular technique used for K-Means clustering. The best value for a cluster is when the graph starts to slope or forms an elbow. The graph shows that as the cluster passes 3, the inertia value decreases gradually. Therefore, the optimal value for the cluster is 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2bjhr6UqLqylHeu8qLDQ4g.png" /></figure><p>Finally, we get the results after applying K-Means Clustering. Here, we have three clusters: 0, 1, and 2. Each cluster behaves differently based on its features. We can analyze them as follows:</p><p><strong># CLUSTER 0</strong></p><ul><li>Have a small balance</li><li>Balance is not updated very often</li><li>Purchases are quite low</li><li>Make very small lump-sum purchases</li><li>Make installment purchases are quite low</li><li>Down payment is very low</li><li>Purchase frequency is quite low</li><li>Single-purchase frequency is low</li><li>Installment payment frequency is low</li><li>Cash advance withdrawals are very rare</li><li>Cash advance withdrawals are low in the last 12 months</li><li>Transaction numbers are rare in the last 12 months</li><li>Have a small credit limit</li><li>Credit card payments in the last 12 months are very low</li><li>Minimum credit card payment amount is quite low</li><li>Full payment percentage of balances due in the last 12 months is quite high</li><li>Customers are relatively new to using their credit cards</li></ul><p><em>“It could be said that this segment contains fairly passive customers. This could be because their financial capacity is not very high, so they cannot bear an excessively high credit burden. Companies can promote other products/services such as savings, deposits, and so on that are more suited to this customer profile.”</em></p><p><strong># CLUSTER 1</strong></p><ul><li>Very large debt balance</li><li>Frequent balance renewals</li><li>Very low purchases</li><li>Very low one-time purchases</li><li>Very low installment purchases</li><li>Very high down payment</li><li>Very low purchase frequency</li><li>Low one-time purchase frequency</li><li>Very low installment purchase frequency</li><li>Frequent cash advances from credit cards</li><li>Very frequent cash advance withdrawals in the last 12 months</li><li>Very infrequent purchase transactions in the last 12 months</li><li>Fairly high credit limit</li><li>Quite large amount paid to credit card</li><li>Very high minimum payment</li><li>Very low percentage of full payments due</li><li>Not long used a credit card</li></ul><p><em>“This segment has relatively high financial capacity, but rarely uses it. Their financial responsibilities can be quite high. This cluster is not very active in making purchases, but their single payments can be quite large, perhaps for luxury items. Furthermore, this cluster tends not to wait for their bills to come due. Companies can offer promotions or discounts for each purchase or installment to encourage more purchases by this segment.”</em></p><p><strong># CLUSTER 2</strong></p><ul><li>Quite large balance</li><li>Frequently renewed balance</li><li>Very high purchases</li><li>Very high one-time purchases</li><li>Very high installment purchases</li><li>Low down payment</li><li>Very high purchase frequency</li><li>Very high one-time purchase frequency</li><li>Very high installment purchase frequency</li><li>Very rare cash advance withdrawals from credit card</li><li>Small number of cash advance withdrawals in the last 12 months</li><li>Very frequent purchase transactions in the last 12 months</li><li>High credit limit</li><li>Very large amount paid to credit card</li><li>Fairly high minimum payment</li><li>Very high percentage of full payment of balance due</li><li>Long-term credit card users</li></ul><p><em>“This segment is highly consumptive. And they are loyal customers. However, companies need to be careful about their very high past-due bills due to their high purchasing/installment patterns. To reward their loyalty, companies can offer them certain discounts.”</em></p><pre>final_df = df[[&#39;CUST_ID&#39;]].join(filtered_df)<br>final_df.to_csv(&quot;Customers Clusters.csv&quot;, index=False)</pre><p>Our final step will be to input the clustering results into a dataframe and save it in a file named “Customers Clusters.csv”. This file can be used in the future to practice supervised machine learning, such as prediction and classification tasks.<br>To see the complete documentation, you can visit my profiles on <a href="https://github.com/salim23-png/Customer-Segmentation-Using-K-Means-Clustering"><strong>GitHub</strong></a> and <a href="https://www.kaggle.com/code/muhamadsalimalwan/customer-segmentation-k-means-clustering"><strong>Kaggle</strong></a>. Thank you for reading until the end. Please comment and like if you enjoyed. <br><strong><em>~Have a nice coding day!</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb4677461408" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kepribadian Ekstrovert vs Introvert: Analisa Machine Learning]]></title>
            <link>https://medium.com/@muhamadsalimalwan10/kepribadian-ekstrovert-vs-introvert-analisa-machine-learning-dde19d20ed30?source=rss-a1f1cd4bfa39------2</link>
            <guid isPermaLink="false">https://medium.com/p/dde19d20ed30</guid>
            <category><![CDATA[support-vector-machine]]></category>
            <category><![CDATA[psychology]]></category>
            <category><![CDATA[personality]]></category>
            <category><![CDATA[extroverted-introvert]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Muhamad Salim Alwan]]></dc:creator>
            <pubDate>Wed, 11 Jun 2025 07:47:49 GMT</pubDate>
            <atom:updated>2025-06-11T07:52:54.511Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1j9_ZhdudWJKh1S4" /><figcaption>Photo by <a href="https://unsplash.com/@tingeyinjurylawfirm?utm_source=medium&amp;utm_medium=referral">Tingey Injury Law Firm</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Introvert dikenal sebagai kepribadian dari orang yang menyukai dan menemukan energi saat sendirian. Dan orang ekstrovert dapat dikenali dari interaksi sosial dan karakter yang mudah berbaur dengan banyak orang. Dua tipe kepribadian yang kontras ini pertama kali diperkenalkan pada tahun 1910 oleh Carl Gustav Jung.</p><p>Introvert sering digunakan untuk menggambarkan tipe kepribadian yang dicirikan oleh pilihan terhadap lingkungan yang tenang dan lebih suka introspeksi serta lebih banyak aktivitas menyendiri. Aktivitas menyendiri ini dapat mencakup membaca, berkreasi, menulis, dan terlibat dalam aktivitas sendirian. Sering kali, bagi kepribadian introvert, keterlibatan sosial dapat menyebabkan perasaan memiliki baterai sosial yang “terkuras” dan akan memerlukan waktu menyendiri untuk “mengisi ulang” baterai sosial mereka. Selain itu, orang introvert biasanya suka merenung, bisa menjadi pendengar yang baik, dan lebih suka jika dibiarkan sendiri dengan aktivitasnya.</p><p>Ekstrovert berbeda dengan kepribadian introvert, yang biasanya lebih bersifat terbuka, memperoleh energi dengan berada di sekitar orang lain, menciptakan percakapan, dan berpartisipasi dalam banyak kegiatan berkelompok. Ekstrovert memiliki energi yang tinggi dalam lingkungan sosial. Mereka mendapatkan keuntungan dari keterlibatan orang lain, berbeda dengan introvert yang membutuhkan waktu sendiri untuk mengisi ulang energi dari keterlibatan sosial.</p><p>Nah, dari sedikit penjelasan di atas, sebagai seorang <em>data scientist </em>(<em>wanna be</em>) bisakah kita menganalisa kepribadian seseorang melalui aktivitas mereka? Apakah seorang introvert tidak boleh mempunyai ciri seperti seorang ekstrovert ataupun sebaliknya?</p><p>Baik, untuk menjawab pertanyaan tersebut kita perlu menjelajahi kaggle untuk menemukan dataset yang sesuai. Kamu juga dapat melihatnya <a href="https://www.kaggle.com/datasets/rakeshkapilavai/extrovert-vs-introvert-behavior-data/data">di sini</a>. Dari dataset tersebut terdapat beberapa indikator untuk menganalisa apakah seseorang itu termasuk tipe introvert atau ekstrovert, di antaranya:</p><ol><li>Berapa banyak waktu yang dihabiskan dengan menyendiri? (0–11 jam)</li><li>Apakah sering mengalami demam panggung? (Ya/Tidak)</li><li>Berapa frekuensi acara sosial yang diikuti? (0–10)</li><li>Frekuensi pergi keluar rumah? (0–7)</li><li>Merasa terkuras setelah bersosialisasi? (Ya/Tidak)</li><li>Jumlah teman dekat? (0–15)</li><li>Berapa frekuensi posting media sosial? (0–10)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cp-s0KCa18DcoRxHefH-Cw.png" /></figure><p>Sekilas, dataset yang ada mempunyai berbagai data yang hilang yang ditandai dengan ‘NaN’ (<em>Not a Number</em>). Selain itu, beberapa fitur/kolom masih bertipe data string seperti <em>stage_fear, Drained_after_scializing, </em>dan <em>Personality. </em>Oleh karena itu, kita akan menghapus baris yang berisi data yang tidak lengkap lalu merubah semua tipe data string/teks menjadi angka. Hal ini dilakukan untuk menghindari error dan meningkatkan akurasi model.</p><pre># Menghapus baris dengan nilai NaN<br>df.dropna(inplace=True) <br><br># Melakukan iterasi untuk encoding setiap kolom bertipe teks<br>features = df[[&quot;Stage_fear&quot;, &quot;Drained_after_socializing&quot;, &quot;Personality&quot;]]<br>for col in features:<br>    le = LabelEncoder()<br>    df[col] = le.fit_transform(df[col])</pre><p>Selanjutnya, kita akan melatih data dengan membaginya menjadi data latih 80% dan data uji 20%. Dimana kolom <em>Personality </em>akan kita jadikan sebagai target atau variabel y, sedangkan sisanya akan menjadi variabel X karena dianggap bisa memengaruhi target atau variabel y.</p><pre>X = df.drop(&quot;Personality&quot;, axis=1)<br>y = df[&quot;Personality&quot;]<br><br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)</pre><p>Model yang akan kita gunakan kali ini adalah SVM (<em>Support Vector Machine</em>). Lebih tepatnya lagi adalah modul SVM untuk <em>Classification </em>yang bernama SVC. Hal ini karena kita akan melakukan tugas klasifikasi.</p><p>Klasifikasi adalah proses untuk mengelompokkan sekumpulan data berdasarkan ciri kesamaan dan perbedaannya. Seperti halnya dataset kita yang cocok untuk mengkalsifikasi atau mengelompokkan apakah termasuk ke dalam tipe introvert atau ekstrovert. Di bawah ini ialah contoh perbedaan sebelum dan sesudah dilakukan klasifikasi. Dimana sebelum dilakukan klasifikasi, masih terdapat titik data yang tidak sesuai warna/kelompoknya. Berbeda halnya dengan gambar di sebelah kanan yakni setelah dilakukan klasifikasi. Dimana setiap kelompok, yaitu 0 atau warna biru untuk ekstrovert dan 1 atau merah untuk introvert saling terpisah membentuk kelompoknya masing-masing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nlk0wYMZbxiOTwuwriZLVw.png" /></figure><p>Seusai dilakukan pengujian, model SVM menampilkan hasil yang cukup memuaskan dimana skor akurasinya mencapai 0,93. Itu artinya sebanyak 93% data berhasil diprediksi dengan benar oleh model. Seperti yang terlihat pada Confusion Matrix, hampir semua data dapat diprediksi dengan benar. Dimana data yang berhasil diprediksi dengan benar ditandai dengan warna biru.</p><pre>SVM_pipeline = Pipeline([<br>    (&#39;scaler&#39;, StandardScaler()),<br>    (&#39;model&#39;, SVC(kernel=&#39;linear&#39;))<br>])<br><br>SVM_pipeline.fit(X_train, y_train)<br><br>y_pred = SVM_pipeline.predict(X_test)<br><br>print(&quot;Accuracy Score: &quot;, accuracy_score(y_test, y_pred))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*sfFnEDUZ_IrW5If_sfgOPA.png" /></figure><p>Kita juga perlu memperhatikan korelasi atau hubungan antara setiap fitur dengan target. Hal ini untuk melihat kontribusi dari setiap fitur pada saat pemodelan. Kita bisa melihatnya melalui grafik korelasi di bawah ini. Dimana jika angka mendekati angka 1 atau semakin gelap warnanya berarti nilainya positif dan begitu pun berlaku sebaliknya. Jika diperhatikan fitur seperti <em>stage_fear </em>(demam panggung) dan <em>Drained_after_socializing </em>(merasa capek setelah bersosialisasi) punya korelasi yang paling tinggi pada <em>Personality</em> yaitu masing-masing sekitar 0,85. Sehingga bisa kita asumsikan bahwa kedua fitur ini berkorelasi kuat terhadap <em>personality </em>seseorang apakah ekstrovert atau introvert.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*ziVNyv3rUbK2lokoaE09pg.png" /></figure><p>Dan yang paling terakhir adalah kita akan coba memasukan data baru ke dalam model untuk diprediksi lalu kita akan melihat hasilnya. Namun, sebelum ke situ, aku sedikit penasaran dengan tipe kepribadian rata-rata untuk orang introvert dan ekstrovert itu seperti apa. Kenapa? karena menurutku itu bisa jadi gambaran awal atau untuk melakukan validasi sederhana nantinya. Ingat ya, setelah encoding, 0 merujuk pada ekstrovert dan 1 merujuk pada introvert. Kamu bisa melihat detailnya di bawah ini.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d-i8hAiu-vLy5c1AfLX8pg.png" /></figure><p>Oke, ini saatnya kita mencoba model yang udah dibuat tadi dengan mengujinya dengan data baru. Biar seru, kita asumsikan saja bahwa data baru ini ialah berdasarkan kebiasaan dari seseorang bernama Joni. Joni sering menghabiskan waktu sendirian paling tidak selama 8 jam. Ia tidak pernah merasakan takut saat di atas panggung. Acara sosial yang diikutinya sebanyak 5 kali dan pergi keluar sebanyak 4 kali. Ia sering merasa lelah setelah bersosialisasi. Sirkel pertemanannya hanya berkisar 10 orang dan ia hanya posting di sosmed dengan frekuensi sebanyak 3. Lalu, kira-kira apakah tipe kepribadian Joni? Yuk kita cek!</p><pre>def predict_extrovert_or_introvert(input_dict):<br>    features = [&#39;Time_spent_Alone&#39;, &#39;Stage_fear&#39;, &#39;Social_event_attendance&#39;,<br>                     &#39;Going_outside&#39;, &#39;Drained_after_socializing&#39;, &#39;Friends_circle_size&#39;, &#39;Post_frequency&#39;]<br>    <br>    # Create a list input according to the feature order and make prediction<br>    input_list = [input_dict[feature] for feature in features]<br>    prediction = SVM_pipeline.predict([input_list])[0]<br>    return &#39;Extrovert&#39; if prediction == 0 else &#39;Introvert&#39;<br><br># Input new data<br>data = {<br>    &#39;Time_spent_Alone&#39;: 8,<br>    &#39;Stage_fear&#39;: 0,<br>    &#39;Social_event_attendance&#39;: 5,<br>    &#39;Going_outside&#39;: 4,<br>    &#39;Drained_after_socializing&#39;: 1,<br>    &#39;Friends_circle_size&#39;: 10,<br>    &#39;Post_frequency&#39;: 3<br>}<br><br># Predict<br>result = predict_extrovert_or_introvert(data)<br>print(f&quot;The Personality is: {result}&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*QV4jyUWbDIOBYijlOqbk-w.png" /></figure><p>Ternyata, setelah kita cek, <em>personality </em>si Joni ini ialah Introvert. Meskipun Joni tidak merasa takut saat di atas panggung dan mempunyai teman yang cukup banyak, ia tetap termasuk orang introvert. Kenapa ya? Kalau kamu tahu jawabannya kita diskusi di kolom komentar ya!</p><p>Dan jangan lupa buat cek kode lengkapnya <a href="https://github.com/salim23-png/Personality-Predictions-Extrovert-vs-Introvert-/blob/main/README.md">di sini</a>.</p><p><strong>Referensi:</strong></p><p><a href="https://www.choosingtherapy.com/introvert-vs-extrovert/">https://www.choosingtherapy.com/introvert-vs-extrovert/</a></p><p><a href="https://www.simplypsychology.org/introvert-extrovert.html">Introvert vs. Extrovert Personality: What&#39;s The Difference?</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dde19d20ed30" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prediksi Harga Saham Menggunakan Python]]></title>
            <link>https://medium.com/@muhamadsalimalwan10/prediksi-harga-saham-menggunakan-python-33310663ed31?source=rss-a1f1cd4bfa39------2</link>
            <guid isPermaLink="false">https://medium.com/p/33310663ed31</guid>
            <category><![CDATA[saham]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[telkom]]></category>
            <category><![CDATA[predictions]]></category>
            <category><![CDATA[stock-market]]></category>
            <dc:creator><![CDATA[Muhamad Salim Alwan]]></dc:creator>
            <pubDate>Sat, 07 Jun 2025 15:33:01 GMT</pubDate>
            <atom:updated>2025-06-07T15:33:23.961Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NHlRacrMg7AYoz33" /><figcaption>Photo by <a href="https://unsplash.com/@nampoh?utm_source=medium&amp;utm_medium=referral">Maxim Hopman</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Hai semua, apa kabar? Semoga dalam keadaan sehat selalu. Tepat sehari sebelum hari raya Idul Adha 1446 H aku tulis tulisan ini. Semoga dapat membuat kita menuju ke arah yang positif dan bagi yang melaksanakan ibadah haji semoga menjadi haji yang mabrur. Aamiin.</p><p>Anyway busway, kali ini aku mau berbagi sedikit soal projek latihanku, yaitu (<em>drum beat sound) </em>prediksi harga saham. Yap, cuman kali ini aku pengen coba yang agak berbeda, aku ngga pake dataset dari kaggle, tapi aku pake dataset dari library YFinance. By the way, buat yang belum sempet donwload library bisa langsung download dulu aja dan lihat dokumentasinya <a href="https://github.com/ranaroussi/yfinance/blob/main/README.md">di sini</a> sebelum lanjut.</p><p><strong>Apa itu Library YFinance?</strong></p><p>Jadi, ini adalah library yang menggunakan API Yahoo yang tersedia untuk umum, dan ditujukan untuk tujuan penelitian dan pendidikan. Isinya berisi informasi-informasi keuangan yang ada pada Yahoo Finance, yaitu seputar pasar saham, obligasi, mata uang dan juga kripto. Di YFinance ini, kamu juga bisa menemukan emiten saham dalam negeri (Indonesia), contohnya PT Telkom Indonesia (Persero) Tbk dengan kode TLKM tapi khusus di YFinance atau juga Yahoo Finance kita harus nambahin domain .JK untuk merujuk pada wilayah Jakarta, Indonesia. Oke langsung aja kita deep into the water, baca sampai selesai ya!</p><pre>import pandas as pd<br>import numpy as np<br>import matplotlib.pyplot as plt<br>import yfinance as yf<br>import warnings<br>warnings.filterwarnings(&quot;ignore&quot;)<br><br>ticker = yf.Ticker(&quot;TLKM.JK&quot;)<br><br>try:<br>    # Attempt to fetch historical data<br>    data = ticker.history(start=&#39;2020-01-01&#39;, end=&#39;2024-12-31&#39;)<br>except Exception as e:<br>    print(&quot;An error occurred while fetching data:&quot;, e)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*oMIWh5rtIR-k-f7ctKxxsA.png" /></figure><p>Di sini kita import beberapa library dasar di python dan load data historis untuk harga saham TLKM.JK dari 2020–2024 (5 tahun). Sebelum lebih jauh, sumber kodenya kamu bisa lihat juga di profil github-ku <a href="https://github.com/salim23-png/Stock-Prediction-Analysis">di sini</a>. Sebenernya tiap kali load data akan ada beberapa fitur atau kolom yang tersedia, cuman di sini aku fokus di fitur OHLCV (Open, High, Low, Close, dan Volume) yang berguna buat analisa teknikal maupun buat prediksi nanti. Di luar itu, kaya fitur dividen dan stock splits ngga aku pakai karena terlalu banyak nilai null dan aku pikir gak akan terlalu berdampak signifikan ke hasil prediksi. Meskipun demikian, aku juga nambahin beberapa fitur yang berkaitan dengan analisis teknikal dasar saham, seperti Moving Average, RSI, dan MACD.</p><p><strong>Moving Average, RSI, dan MACD</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XHvZJem1Pz5kEemQfe1XYw.png" /></figure><p>Salah satu indikator sederhana yang dapat membantu kita dalam menganalisa pergerakan saham adalah <em>Moving Average</em>. Indikator ini menggambarkan pergerakan harga saham rata-rata dari waktu ke waktu. Seperti halnya gambar di atas terdapat beberapa indikator MA (<em>Moving Average</em>) berupa garis pada candle stick yang terdiri dari MA 5, 10, 20 dan 50 yang masing-masing merujuk pada berapa lama hari dimana harga dirata-ratakan. Tentunya hal tersebut akan memberikan sedikit perbedaan. Dimana MA 50 hari digunakan untuk analisis harga saham jangka panjang karena memberikan informasi harga rata-rata tiap 50 hari atau sekitar 2,5 bulan pasar saham (satu bulan 20 hari pasar saham). Berbeda halnya dengan MA 5, 10, dan 20 yang penggunaannya lebih cocok untuk analisa jangka pendek sampai menengah, misalnya untuk trading harian atau mingguan.</p><p>Lain halnya dengan indikator MACD dan RSI. Indikator M<em>oving Average Convergence Divergence</em> (MACD) dan <em>Relative Strength Index</em> (RSI) adalah salah dua indikator populer yang digunakan oleh analis teknis dan pedagang harian. Meskipun keduanya pun memiliki perbedaan yang terletak pada apa yang ingin diukur oleh masing-masing. MACD dihitung dengan mengurangi EMA 26 periode dari EMA 12 periode. Hasil perhitungan tersebut adalah EMA MACD selama sembilan hari yang disebut “garis sinyal” yang kemudian diplot di atas garis MACD, yang dapat berfungsi sebagai pemicu sinyal beli dan jual. Pedagang dapat membeli sekuritas saat MACD melintasi garis sinyalnya dan menjual, ataupun sebaliknya.</p><p>Sedangkan RSI bertujuan untuk menunjukkan apakah pasar dianggap overbought (kondisi terlalu banyak orang yang membeli saham sehingga harga terlalu tinggi untuk didorong naik lagi) atau oversold (kondisi terlalu banyak orang yang menjual saham atau mengalami tren penurunan) dalam kaitannya dengan level harga terkini. RSI menghitung keuntungan dan kerugian harga rata-rata selama periode waktu tertentu. Periode waktu default-nya adalah 14 periode dengan nilai yang dibatasi dari 0 hingga 100.</p><p>Buat kamu yang ingin buat visualisasi seperti di atas bisa pakai mplfinance yang kamu bisa akses <a href="https://www.slingacademy.com/article/installing-and-configuring-mplfinance-for-financial-charting/">di sini</a> buat tutor yang lengkapnya.</p><p><strong>Pemodelan Machine Learning</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Exg_NQiMZV9NJbfxv91Lg.png" /></figure><p>Model yang digunakan adalah Random Forest. Kenapa? Karena sebelum ini semua beberapa model sudah aku coba bandingkan akurasinya dengan bantuan GridSearchCV termasuk juga buat nentuin parameter terbaik yang bisa digunakan. Dan Hasilnya cukup memuaskan dari mulai R2 Score, MAE, maupun MSE. Hasil R2 Score yakni 0,96 menunjukkan bahwa akurasi model untuk menjelaskan seberapa jauh data dependen (label) dapat dijelaskan oleh data independen (fitur) dimana memiliki rentang antara 0 dan 1, sehingga hasil yang didapat dengan Random Forest bisa dibilang sangat baik. MAE atau <em>Mean Absolute Error </em>menjelaskan rata-rata dari selisih absolut antara nilai prediksi dan nilai aktual. Dimana pada model bernilai cukup rendah yaitu 74,9. Lalu MSE atau <em>Mean Squared Error MSE </em>menghitung rata-rata dari selisih kuadrat antara nilai prediksi dan nilai aktual. Dengan hasil 11.923, 3 pada model.</p><p><strong>Kesimpulan</strong></p><p>Jadi, itu dia sedikit penjelasan mengenai step dan tools penting yang aku gunakan untuk melakukan prediksi saham dengan<em> machine learning. </em>Di antaranya ada YFinance untuk menyediakan dataset historis dari harga saham dan juga mplfinance untuk visualisasi khusus bidang keuangan. Buat step lengkapnya kamu bisa liat di github aku <a href="https://github.com/salim23-png/Stock-Prediction-Analysis">di sini</a>.</p><p><em>Next step? </em>Ya, aku kira masih banyak yang perlu ditingkatkan lagi. Mungkin selanjutnya aku bakal buat <em>dashboard</em> dengan bantuan <em>back-end </em>kaya <em>Dash </em>atau mungkin <em>streamlit</em>. Aku masih nyari tools terbaik buat bikin visualisasi kaya mplfinance yang khas tapi juga bisa interaktif kaya <em>plotly</em> kalau kamu tahu. Dan juga model yang udah ada ini pengen aku terapin buat prediksi harga ke depan dan coba aku bandingin dengan harga saham aktualnya. Meskipun udah aku coba sebetulnya, tapi aku masih kurang puas dengan hasilnya. Mungkin <em>next</em> bakal aku share.Kalau kamu ada solusi buat aku atau mau diskusi <em>feel free</em> buat komen ya. See you :)</p><p><strong>Referensi</strong></p><ul><li><a href="https://www.investopedia.com/terms/m/movingaverage.asp">Moving Average (MA): Purpose, Uses, Formula, and Examples</a></li><li><a href="https://www.investopedia.com/ask/answers/122214/what-are-main-differences-between-moving-average-convergence-divergence-macd-relative-strength-index.asp">How Do the MACD and RSI Indicators Differ?</a></li><li><a href="https://blog.hsb.co.id/pengetahuan-keuangan/apa-itu-oversold-dan-overbought/">Kenali Istilah Oversold dan Overbought dalam Trading | HSB Investasi</a></li><li><a href="https://accounting.binus.ac.id/2021/08/12/memahami-r-square-koefisien-determinasi-dalam-penelitian-ilmiah/">MEMAHAMI R SQUARE (KOEFISIEN DETERMINASI) DALAM PENELITIAN ILMIAH</a></li><li><a href="https://www.trivusi.web.id/2023/03/perbedaan-mae-mse-rmse-dan-mape.html">Perbedaan MAE, MSE, RMSE, dan MAPE pada Data Science</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33310663ed31" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RFM Analysis Using Python and SQL]]></title>
            <link>https://medium.com/@muhamadsalimalwan10/rfm-analysis-using-python-and-sql-17889b42b1e4?source=rss-a1f1cd4bfa39------2</link>
            <guid isPermaLink="false">https://medium.com/p/17889b42b1e4</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[rfm-analysis]]></category>
            <category><![CDATA[pareto-principle]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Muhamad Salim Alwan]]></dc:creator>
            <pubDate>Fri, 04 Apr 2025 16:16:50 GMT</pubDate>
            <atom:updated>2025-04-05T05:03:26.147Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KieJ5sc0ZNJbD45Y" /><figcaption>Photo by <a href="https://unsplash.com/@kmuza?utm_source=medium&amp;utm_medium=referral">Carlos Muza</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Recency, frequency, and monetary (RFM) analysis is a tool for understanding and assessing consumer behavior based on purchases. RFM techniques can be used by quantitatively categorizing and classifying customers based on the total RFM of their most recent transactions. This technique has the ultimate goal of identifying and targeting the most valuable customers for the purpose of conducting targeted and focused marketing campaigns. Each consumer is given a numerical score based on these parameters, making the analysis objective and data-driven. RFM analysis is rooted in the famous marketing axiom, the Pareto Principle or 80/20 rule where 80% of the results come from 20% of the causes. This tool has three components, namely recency, frequency, and monetary.</p><blockquote><strong>Recency (R)</strong> as days since last purchase: Subtract the most recent purchase date from today to calculate recency. For example, 3 days, 5 days, etc.</blockquote><blockquote><strong>Frequency (F)</strong> as the total number of transactions: How many times did a customer purchase? For example, 7 if someone ordered 7 times in a given time period.</blockquote><blockquote><strong>Monetary (M)</strong> as the total money spent by a customer in a given currency and time period.</blockquote><p>RFM analysis can be a powerful tool for gaining insights into customer segmentation. It can help answer important questions such as:</p><ul><li>Who are our best customers?</li><li>Which customers are at risk of churning?</li><li>Who has the potential to become more valuable?</li><li>Which customers can be effectively retained?</li><li>Who are lost customers that you don’t need to pay much attention to?</li><li>Which group of customers is most likely to respond to your current campaign?</li></ul><p><strong>Preparing The Dataset</strong></p><p>In this article, we will analyze a dataset from Kaggle called “Northwind Traders”. The dataset provides various data files, such as <em>orders, categories, customers, employees, order details, products,</em> and <em>shippers</em>. However, to do RFM Analysis we only need <em>orders</em> and <em>order details</em> data. We will analyze it with RFM analysis and using a combination of Python and SQL. I use Jupiter Notebook from Google Colab to make the coding easier. You can access the dataset by clicking this link: <a href="https://www.kaggle.com/datasets/jeetahirwar/northwind-traders/data">click here</a>.</p><pre>query = &quot;SELECT * FROM orders LIMIT 5;&quot;<br>df= pd.read_sql(query, con=engine)<br>df</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*QjYKy5FECvAHjrFmYz0aJA.png" /><figcaption>Orders data from Northwind Traders dataset</figcaption></figure><pre>query = &quot;SELECT * FROM order_details LIMIT 5;&quot;<br>df= pd.read_sql(query, con=engine)<br>df</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*08BJNjJVbvfTP7Gw7Ie62A.png" /><figcaption>Order details data from Northwind Traders dataset</figcaption></figure><p>You can see all the complete code used in this article by <a href="https://github.com/salim23-png/RFM-Analysis-Using-Python-and-SQL/blob/main/Northwind_Traders_RFM_Analysis_(Python%26SQL).ipynb">clicking here</a>.</p><p><strong>Creating RFM Customer Segmentation</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iycfOrgVrea6jv2VYeYU7A.png" /></figure><p>You can see all the complete code used in this article by <a href="https://github.com/salim23-png/RFM-Analysis-Using-Python-and-SQL/blob/main/Northwind_Traders_RFM_Analysis_(Python%26SQL).ipynb">clicking here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*UaVDLBHji0TNdoHFg54m1Q.png" /></figure><p><strong>Visualizing The Result of RFM Analysis</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*hWLdv4A-of9KX4Ax1JddUA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NTNgk7jFKld6jawZRbG7Hg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*4GOrinPO0dOyyo8_Wm0V2A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*rSRLV5J_R4pnP9zBkyb2gQ.png" /><figcaption>Visualization of the result with radar chart, scatter plot, heatmap, and pie chart.</figcaption></figure><p>You can see all the complete code used in this article by <a href="https://github.com/salim23-png/RFM-Analysis-Using-Python-and-SQL/blob/main/Northwind_Traders_RFM_Analysis_(Python%26SQL).ipynb">clicking here</a>.</p><p><strong>Conclusions</strong></p><blockquote>Based on the results, there are 3 dominant segments, namely <em>loyal customers, champions,</em> and <em>potential loyalists</em>. And also these three segments have a fairly good proportion as depicted in the radar chart. This can illustrate the results of implementing a good strategy in that time period. Be it marketing performance, discount strategy, competitive pricing, better service, or other strategies. However, to increase the loyalty of these three segments, the company can sell high-value products or provide offers for new products and ask for their reviews to increase participation. In addition, the company can also offer a membership system with various benefits that they can get.</blockquote><blockquote>Although the results are very good, the company is recommended to increase attention to other segments to avoid customer churn. For example, for the <em>hibernating</em> segment and also <em>at risk </em>which is very risky to stop shopping at the company’s store. For segments like this, companies need to utilize their marketing tools, such as email marketing to continue to offer products, both new products and products with special discounts to attract customers to shop.</blockquote><blockquote>Finally, to predict future sales based on the 11 segments, we can look at the results on the heatmap and also the scatter plot. Where the heatmap shows a fairly strong correlation between <em>frequency</em> and <em>monetary</em>, which is 0.94. This means that if one of them goes up or down, the others will be the same. That way we can use the scatter plot to confirm this relationship by looking further at its effects on customer segments. Where there are several outliers in the data that need to be watched out for in the <em>champions</em> and <em>at risk</em> segments, aka moving away from the main point collection. While for the <em>loyal customers</em> segment and others are relatively stable or have adjacent points.</blockquote><blockquote>RFM analysis can be a useful tool, especially in the field of customer relationship management (CRM). However, especially in this article, further analysis is still needed. For example, the use of K-Means Clustering and also more interesting visualizations. In addition, the dataset used, namely Northwind Traders, still allows for other analyses in the future, for example lead time analysis or other analyses that allow.</blockquote><p>Any feedback is so appreciated :)</p><p><strong>References:</strong></p><ul><li><a href="https://www.putler.com/rfm-analysis/#Customer_segmentation_using_RFM_analysis">https://www.putler.com/rfm-analysis/#Customer_segmentation_using_RFM_analysis</a></li><li>Lewaaelhamd, I. (2023). Customer Segmentation Using Machine Learning Model: An Application of RFM Analysis. <em>Journal of Data Science and Intelligent Systems</em>, <em>2</em>(1), 29–36. <a href="https://doi.org/10.47852/bonviewJDSIS32021293">https://doi.org/10.47852/bonviewJDSIS32021293</a></li><li><a href="https://clevertap.com/blog/rfm-analysis/">https://clevertap.com/blog/rfm-analysis/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17889b42b1e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>