<?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 Thuy Trinh on Medium]]></title>
        <description><![CDATA[Stories by Thuy Trinh on Medium]]></description>
        <link>https://medium.com/@thuytrinht4?source=rss-28ab9c908275------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*EORs9IX-8780mTdE</url>
            <title>Stories by Thuy Trinh on Medium</title>
            <link>https://medium.com/@thuytrinht4?source=rss-28ab9c908275------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 02:55:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thuytrinht4/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[Customer Segmentation for Arvato Financial Services]]></title>
            <link>https://medium.com/@thuytrinht4/customer-segmentation-for-arvato-financial-services-4cec6745a20d?source=rss-28ab9c908275------2</link>
            <guid isPermaLink="false">https://medium.com/p/4cec6745a20d</guid>
            <dc:creator><![CDATA[Thuy Trinh]]></dc:creator>
            <pubDate>Thu, 04 Nov 2021 12:30:14 GMT</pubDate>
            <atom:updated>2021-11-04T23:24:49.253Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*8QlwE6MHCgVk17Ag_RjwYw.jpeg" /></figure><h3>Project Definition</h3><h3>Project Overview</h3><p>In this project, supervised and unsupervised machine learning algorithms are used to analyze demographical datasets of a general population as well as of customers of a German mail-order company.</p><p>This is one of Udacity’s capstone project for the Data Science Nanodegree program. The data is provided by Bertelsmann Arvato Analytics.</p><h3>Problem Statement</h3><p>The project has two major steps: the customer segmentation report, the supervised learning model, and the Kaggle Competition.</p><ol><li><strong>Customer Segmentation Report</strong>: use unsupervised learning methods to analyze attributes of established customers and the general population in order to create customer segments.</li><li><strong>Supervised Learning Model</strong>: use dataset with attributes from targets of a mail order campaign and the previous segmentation analysis to build a machine learning model that predicts whether or not each individual will respond to the campaign.</li><li><strong>Kaggle Competition</strong>: use the developed supervised model to make predictions on the campaign data as part of a <a href="https://www.kaggle.com/c/udacity-arvato-identify-customers">Kaggle Competition</a>.</li></ol><h3>Metrics</h3><p>The evaluation metric for this competition is <a href="https://en.wikipedia.org/wiki/Receiver_operating_characteristic#Area_under_the_curve">AUC for the ROC curve</a>, relative to the detection of customers from the mail campaign. A ROC, or receiver operating characteristic, is a graphic used to plot the true positive rate (TPR, proportion of actual customers that are labeled as so) against the false positive rate (FPR, proportion of non-customers labeled as customers).</p><p>In a ROC curve, a higher X-axis value indicates a higher number of False positives than True negatives. While a higher Y-axis value indicates a higher number of True positives than False negatives. So, the choice of the threshold depends on the ability to balance between False positives and False negatives.</p><p>The reason for choosing AUC for the ROC curve is because, as it can be seen later in <em>Fig2: Supervised learning: Training data</em>, our dataset is a very imbalanced dataset which the class customers is very little, compared to the class general population. Therefore, using ROC curves help us in finding a classification threshold that suits our specific problem.</p><h3>Analysis</h3><h3>Data Exploration</h3><p>There are four data files used in this project:</p><ul><li>Udacity_AZDIAS_052018.csv: data for the general population of Germany, 891 211 persons (rows) x 366 features (columns).</li><li>Udacity_CUSTOMERS_052018.csv: data for customers of the company, 191 652 persons (rows) x 369 features (columns)</li><li>Udacity_MAILOUT_052018_TRAIN.csv: data for individuals who were targets of a marketing campaign, 42 982 persons (rows) x 367 (columns)</li><li>Udacity_MAILOUT_052018_TEST.csv: data for individuals who were targets of a marketing campaign, 42 833 persons (rows) x 366 (columns)</li></ul><p>Each row of the demographics files represents a single person, but also includes information outside of individuals, including information about their household, building, and neighborhood.</p><p>The “CUSTOMERS” file contains three extra columns (‘CUSTOMER_GROUP’, ‘ONLINE_PURCHASE’, and ‘PRODUCT_GROUP’), which provide broad information about the customers depicted in the file. The original “MAILOUT” file included one additional column, “RESPONSE”, which indicated whether or not each recipient became a customer of the company. For the “TRAIN” subset, this column has been retained, but in the “TEST” subset it has been removed. Otherwise, all of the remaining columns are the same between the three data files.</p><h3>Data Visualization</h3><p><strong>Data for Customer Segmentation</strong></p><p>Udacity_AZDIAS_052018.csv and Udacity_CUSTOMERS_052018.csv</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gaPQPj_5RlzcjQCYfKmoLg.png" /><figcaption>Fig1: Customer Segmentation Data</figcaption></figure><p><strong>Data for Supervised Learning Model</strong></p><p>Udacity_MAILOUT_052018_TRAIN.csv and Udacity_MAILOUT_052018_TEST.csv</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AxtyOP-qs17Jh_Fv4Z_pCg.png" /><figcaption>Fig2: Supervised learning: Training data</figcaption></figure><p>Fig1 and Fig2 show that we have imbalanced datasets for both studies, where the class of customers are significantly less than class of general population, specifically:</p><ul><li>In Customer Segmentation study, customers class accounts for 18% of the total records.</li><li>In Supervised Learning study, customers class accounts for only 1% of the total records.</li></ul><h3>Methodology</h3><h3>Customer Segmentation</h3><h3><strong>Data Preprocessing</strong></h3><ol><li><strong>Parse missing or unknown string values</strong></li></ol><ul><li>Columns (18,19) have mixed types, we’ll fixed it by replacing the string value of ‘X’ and ‘XX’ as missing value, and set datatype as float</li><li>Check for the missing values according to the dictionary which contains encodings for unknown values and if such exists it will be replaced with numpy.nan.</li></ul><p><strong>2. Missing values</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GV0M6TVId5i4WOUhgemTZw.png" /><figcaption>Fig3: Missing values of Customer Segmentation data</figcaption></figure><ul><li>Most columns (96%) have 20% or less values missing.</li><li>Most rows (81%) have 25 or less attributes missing.</li></ul><p><strong>3. Identifier or Attributes of low variance</strong></p><ul><li>Column LNR is identifier, since it has 100.0% values are unique</li><li>Nine columns have too low variance where more than 95% of values belong to 1 value.</li></ul><p><strong>4. Deal with attributes with values as string</strong></p><ul><li>Deal with datetime value: ‘EINGEFUEGT_AM’</li><li>Drop categorical columns with too many categorical values.</li></ul><p><strong>5. Impute, transform, and standardize features</strong></p><p>Imputation should be based on the type of attribute:</p><ul><li><strong>Binary:</strong> Some attributes only take 2 (non-missing) values. Missing values should be imputed based on the most common value.</li><li><strong>Categorical:</strong> These will be one-hot encoded first and then imputed like binary attributes (most common value).</li><li><strong>Numerical:</strong> Missing values of numerical attributes will be imputed based on the median value.</li></ul><h3>Implementation</h3><h3>Feature Reduction using Principal Component Analysis (PCA)</h3><p>For the customer segmentation task, a clustering algorithm will be used and they run very slowly with large numbers of features. The cleaned and transformed dataset has 319 different features. The feature range can be reduced by applying Principal Component Analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dsKaI6rbm6uEouBm-o7ENg.png" /><figcaption>Fig4: PCA Visualisations</figcaption></figure><p>From 319 components, 164 components explain 90% of variance in the dataset. The dataset can be reduced to almost half of its feature range while only losing 10% of variance.</p><p>The first three components explain 18.2% of variance, of which:</p><ul><li>Component 1 explains 8.1% total variance, determined by the mobility (MOBI_REGIO)<strong> </strong>and social status of the person (LP_STATUS_FEIN).</li><li>Component 2 explains 5.5% total variance, determined by the car a person owns (KBA13_HERST_BMW_BENZ and KBA13_MERCEDES).</li><li>Component 3 explains 4.6% total variance, determined by dominating movement in the person’s youth (CJT_TYP_1), the person’s financial behaviour (FINANZ_SPARER), and , online affinity (ONLINE_AFFINITAET).</li></ul><h3>Clustering Datasets using k-means Clustering</h3><p>Next step is to using k-means++ clustering to find out clusters in the population and customers dataset to see which group best represents the company’s customer base. To determine the optimal number of clusters, the elbow method was used. Elbow curve plots the number of cluster k against the sum of squared error (sse). The optimal number of clusters is determined where sse is no longer drop significantly by adding more clusters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u9ulzSPBVs2QnZ-JK_4IiA.png" /><figcaption>Fig5: Elbow curve</figcaption></figure><h3>Refinement</h3><p>There is no clear elbow in the plot. The inertia or sum of squared distances drops significantly until around 9 clusters and then basically flattens out, so 10 clusters are chosen as final number.</p><p>The final PCA and KMean parameters are:</p><ul><li>pca_components = 164</li><li>kmean_clusters = 10</li></ul><h3>Cluster Analysis</h3><p>Using the clustered model, we can cluster of each of the records into 10 cluters from their 164 PCA components. To analyse the difference in distributions of each clusters from the customers and general population, we create a plot of how clusters are distributed across both datasets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zzMjVXe1mcl6pwMvhIVVXg.png" /><figcaption>Fig6: Share of persons in every cluster for each dataset</figcaption></figure><p>The plot shows how clusters are distributed across both datasets. Clusters are equally spread across the general population and show only small differences in size. This can be expected from dataset that represents the general population very well.</p><p>In contrast, the customers dataset exhibits a large imbalance across clusters. Cluster 2, 4, 5, and 6 are the biggest clusters. More than 85% of customers are mapped to these four clusters.</p><h3>Clustering Mailout Marketing Data</h3><p>The clustering model developed in the previous section was applied to the mailout data. Below is the plot distribution of clusters, by RESPONSE.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MkCxjvDo6bDrXj0-fu4cMg.png" /><figcaption>Fig7: Mailout Cluster distribution</figcaption></figure><h3><strong>Mailout Marketing Prediction using Supervised Learning</strong></h3><p>Now that we’ve found which parts of the population are more likely to be customers of the mail-order company, it’s time to build a prediction model. The purpose of the model is to forecast a customer response variable (0/1) that states whether or not a person becomes a customer of the company following the campaign.</p><h3>Methodology</h3><h4><strong>Classifier selection</strong></h4><p>Several supervised machine learning classifiers can be considered for forecasting model. The following algorithms were evaluated:</p><ul><li>Random Forest Classifier</li><li>Adaptive Boosting (AdaBoost) Classifier</li><li>Gradient Boosting Classifier</li></ul><p><strong>Classifier evaluation</strong></p><p>As can be seen from Fig2, training dataset is a very imbalanced dataset which the class customers is very little, compared to the class general population. Therefore, to prevent over-fitting, the evaluation metric being used here is <a href="https://en.wikipedia.org/wiki/Receiver_operating_characteristic">Receiver operating characteristic</a> Area Under Curve (ROC AUC), together with cross-validation method when training.</p><h3>Implementation</h3><p>Fig8 below shows learning curve of each of the three chosen classifiers. A learning curve shows the validation and training score of an estimator for varying numbers of training samples 10%-100% of training data. Each sample is 5-fold cross validated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NF0AFYpJ0qy0u31QTVYvHw.png" /><figcaption>Fig8: Learning curves for selected ML classifiers</figcaption></figure><p>The <strong>Random Forest Classifier</strong> does not only show the lowest mean validation score but also a consisently high train score, implying high model bias. In other words, the model is strongly overfitted on the training data and provides a bad predictor for unseen data.</p><p>The <strong>AdaBoost Classifier </strong>and <strong>Gradient Boosting Classifier </strong>on the other hand show better performance. They demonstrate a decrease of model bias with increasing sample size. While AdaBoost curves already converged after ~80% of the sample is fed to the algorithm, learning curves for the Gradient Boosting Classifier keep converging with more data. In addition to that, Gradient Boosting provides the highest mean validation score, making it our choise of estimator for the forecasting model.</p><h3>Refinement</h3><p>Finally, the parameters for the Gradient Boosting Classifiers are hypertuned using grid-search.</p><p>Particularly, there are four hyper parameters that are tuned:</p><ul><li>learning_rate</li><li>n_estimators</li><li>max_depth</li><li>min_samples_split</li></ul><p>The valued used to search over for each of the hyper parameters are:</p><blockquote><em>parameters = {‘gbc__learning_rate’: [0.1, 0.2], ‘gbc__n_estimators’: [100],<br> ‘gbc__max_depth’: [3, 5], ‘gbc__min_samples_split’: [2,4]}</em></blockquote><p>The best classifier has the following parameters:</p><blockquote><em>parameters = {‘gbc__learning_rate’: 0.1, ‘gbc__n_estimators’: 100, ‘gbc__max_depth’: 3, ‘gbc__min_samples_split’: 4}</em></blockquote><p>After tuning, the model improve AUC score from 0.74 to 0.76.</p><h3>Mailout Marketing Prediction — Results</h3><h3>Model Evaluation and Validation</h3><p><strong>Kaggle Competition</strong></p><p>Scores were obtained after uploading submissions to the <a href="https://www.kaggle.com/c/udacity-arvato-identify-customers/leaderboard">Kaggle competition</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*u88oNDioMsRXIqriGUc_dw.png" /><figcaption>Fig10: Kaggle Leaderboard</figcaption></figure><p><strong>Justification</strong></p><p>All of the models scored results that are either equal or slightly higher on Kaggle test set, compared to the Local score, meaning that our trained models are not over-fitted and that the chosen methodology and implementation are reliable.</p><p>Specifically, both AdaBoost and Gradient Boost are performing better than Random Forest on Kaggle. The reason might be because although all three are tree-based classifiers, AdaBoost and Gradient Boost are known to be simpler and require smaller number of trees. And since we have reduced a lot of noise, as well as number of features in the dataset through data cleaning and clustering process, AdaBoost and Gradient Boost classifiers will less likely to overfit and subsequently result in better score on test set.</p><h3>Conclusion</h3><p><strong>Reflection</strong></p><p>The Bertelsmann/Arvato Project proved to be a comprehensive and challenging exercise in the Data Science Nanodegree program. It requires a wide range of technical knowledge in both supervised as well as un-supervised learning. Finding a suitable and robust methodology and implementation pipeline is one of the biggest challenges for me, which I would like to give special thanks to <a href="https://medium.com/@mei.eisenbach">Mei Eisenbach</a> for a great <a href="https://github.com/mkeisenbach/arvato">Github repository</a> in this respect. Additionally, handling the data with relatively big number of records and features of different datatypes was also another challenges in this project.</p><p>Customers and general population were clustered into 10 groups, of which 4 showed to hold over 85% of the company’s customers. These four majour groups had specific characteristics: customers of this company are well-earning couples or families with a certain affinity for online purchases.</p><p>To forecast customer responses, the Gradient Boosting Classifiers proved to be the best-performing estimator. The Kaggle submission results shows that there is still room for improvement though.</p><p><strong>Improvement</strong></p><p>The following changes to my approach could be considered to optimize project outcomes:</p><ul><li>Use sampling techniques (like upsample, or downsample) to deal with imbalanced issue in the training set.</li><li>Test different approaches to standardize and scale features, like using Min-Max-Scaler instead of Standard Scaler.</li><li>Drop fewer or more data points when preparing the datasets.</li></ul><h3>References</h3><p>Arvato Bertelsmann Customer Analysis (<a href="https://medium.com/@mei.eisenbach/arvato-bertelsmann-customer-analysis-ae1aac59a1ef">https://medium.com/@mei.eisenbach/arvato-bertelsmann-customer-analysis-ae1aac59a1ef</a>)</p><p>Customer Segmentation for Arvato Financial Services (<a href="https://medium.com/@matthias_h2609/customer-segmentation-for-arvato-financial-services-ffb089f2017f">https://medium.com/@matthias_h2609/customer-segmentation-for-arvato-financial-services-ffb089f2017f</a>)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cec6745a20d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AirBnB listings in Boston and Seattle]]></title>
            <link>https://medium.com/@thuytrinht4/airbnb-listings-in-boston-and-seattle-8e4f7029bb63?source=rss-28ab9c908275------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e4f7029bb63</guid>
            <dc:creator><![CDATA[Thuy Trinh]]></dc:creator>
            <pubDate>Sat, 09 Oct 2021 13:42:08 GMT</pubDate>
            <atom:updated>2021-10-09T13:42:08.110Z</atom:updated>
            <content:encoded><![CDATA[<h4>Homes rentals post COVID-19: availability, room types and pricing.</h4><p><strong>Introduction</strong></p><p>It’s beginning of October 2021, and we have just reached the “new normal” state post COVID-19. It marks recovery phase of many industries, including tourism and home rental. One of the heavily impacted service is AirBnB, an online apps for lease or rent short-term lodging.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uz7IAgLvQ5DslvB2QJcSyA.jpeg" /></figure><p>In this post, we will take a closer look at the listings associated with Seattle and Boston as of September 2021. Specifically, we will be using listings.csv file downloaded from <a href="http://insideairbnb.com/get-the-data.html">Inside AirBnB</a> to draw insights on the latest rental market in Boston and Seattle.</p><ol><li><strong>What is the total number of rooms available for rent listed in AirBNB at the time of data collection?</strong></li></ol><pre>As of 2021-09-19, there are 3123 rooms in Boston listed for rent in AirBNB.<br>As of 2021-09-25, there are 4249 rooms in Seattle listed for rent in AirBNB<br>There are 1126 (36.0%) more listings in Seattle than in Boston</pre><p>Generally speaking, there are 36% more rooms listed in Seattle than in Boston in September 2021. Knowing that these two cities are roughly equal in size, based on the number of rooms supply available in the 2 city, we can draw an initial guess that prices in Seattle could be 30% lower than prices in Boston.<br>Let check this hypothesis.</p><p><strong>2. What type of rooms are offered? Which types are most popular? What are the average rental rate for each type?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*0KrSA6Gkw00WhhtCeK1y1A.png" /></figure><p>In September 2021, in both Seattle and Boston, there are 4 types of rooms offered on AirBnB: <strong><em>Entire home/apt</em></strong>, <strong><em>Private room</em></strong>, <strong><em>Shared room</em></strong> and <strong><em>Hotel</em></strong>. The majority of the rentals are of the class <strong><em>Entire home/apt</em></strong> with around 63% of total rents in Boston and 82% of total rents in Seattle. In costrast, there are not a lot of <strong><em>Shared room</em></strong> and <strong><em>Hotel </em></strong>available for rent in both cities. There are 25 hotels and 12 shared room can be found in AirBNB Boston and in Seattle, there are only 3 hotels and 42 shared rooms listed on AirBNB.</p><p>Now, let look at the price of those listings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*xCyANfhKojPGsfrzbe2Z4Q.png" /></figure><p>Rental price in Boston are higher than in Seattle in general. An average house with 2 bedrooms in Boston will cost $241/night, while it is only $180/night in Seattle, which is 34% higher. This coincides with the first guess for difference in rental rate based on total number of listings. On the other hand, price gap for <strong><em>Private Room</em></strong> between the two cities are low, which is $96 in Boston and $84 in Seattle.<br>Price for <strong><em>Hotel Room</em></strong> is missing and price of <strong><em>Shared room</em></strong> are rather too low, this is due to because of missing data for these type of listings in Seattle.</p><p><strong>3. What are the areas where most rooms are listed for rent in each city?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qVvAEifvTFrJCob4pY5jZw.png" /></figure><p>The listings are more concentrated in Boston, where nearly 25% of the total listings are in the Top2 neighborhoods Dorchester and Downtown. While listings are less concentrated in Seattle, where Top2 neighbors Belltown and Broadway only accounts for 12% of total listings.</p><p><strong>Conclusion</strong></p><p>In this article, we have looked through the general statistics on the most updated rental listings on AirBnB for the month of September 2021. There are more than 3,000 listings in Boston and over 4,000 listings in Seatle now. This suggests that renting is back to normal now. It seems that local renting for Entire house and Private Rooms are back to normal, while Hotel listings are still limited in the two cities.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e4f7029bb63" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>