<?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 Barış Cengiz on Medium]]></title>
        <description><![CDATA[Stories by Barış Cengiz on Medium]]></description>
        <link>https://medium.com/@bariscengiz?source=rss-e84e1c1b0a4f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*HdNGhr8hb3ZjscpFz0s_cA.jpeg</url>
            <title>Stories by Barış Cengiz on Medium</title>
            <link>https://medium.com/@bariscengiz?source=rss-e84e1c1b0a4f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 13:25:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bariscengiz/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[Evaluating Classification Models, Confusion Matrix]]></title>
            <link>https://medium.com/codex/evaluating-classification-models-confusion-matrix-47f498d93d4a?source=rss-e84e1c1b0a4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/47f498d93d4a</guid>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[confusion-matrix]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[classification-metrics]]></category>
            <dc:creator><![CDATA[Barış Cengiz]]></dc:creator>
            <pubDate>Sun, 24 Apr 2022 14:54:23 GMT</pubDate>
            <atom:updated>2022-04-25T12:25:33.772Z</atom:updated>
            <content:encoded><![CDATA[<p>In classification problems, accuracy of a model can be the main performance indicator in many cases. But there are some cases accuracy is not enough to evaluate the performance of a model.</p><p>When the data you are working with is unbalanced, accuracy score can be misguiding. Confusion Matrix is useful in these cases.</p><p><strong>Confusion Matrix</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*XhPhfOJBtTgz4quvnNEDjQ.png" /><figcaption>Confusion Matrix</figcaption></figure><p>Confusion Matrix displays 4 cases; TP, FP, FN and TN.</p><p>True Positive (T.P): Correctly predicted Positive values.</p><p>False Positive (F.P): Negative (0) values predicted as Positive (1)</p><p>False Negative (F.N): Positive (1) values predicted as Negative (0)</p><p>True Negative (T.N): Correctly predicted Negative values.</p><p>As it can be seen, there are two types of mistakes in classification: False Positive and False Negative.</p><p><strong>False Positive</strong>: Type-I Error, not so critical. For example: Model predicted a transaction as Fraud but it’s not fraud. A simple apology should suffice in this case.</p><p><strong>False Negative: </strong>Type-II error, critical. For example: Model predicted a transaction as Not Fraud but it is actually fraud. In this case your company/bank <strong>can</strong> lose money, credibility etc.</p><p><strong>Evaluation Scores</strong></p><p><strong>Accuracy</strong>: Ratio of correctly predicted values in the data.</p><p><em>(T.P + T.N) / (T.P + T.N + F.P + F.N)</em></p><p><strong>Precision</strong>: Ratio of correct predictions in Positive-predicted values. Measures how good the model is when the prediction is positive.</p><p><em>(T.P) / (T.P + F.P)</em></p><p><strong>Recall</strong>: Ratio of correctly predicted values in the Positive Class of the data. Measures how good the model is at correctly predicting positive classes.</p><p><em>(T.P) / (T.P + F.N)</em></p><p><strong>F1-Score</strong>: Weighted Avg. of Precision and Recall scores.</p><p><em>2*(Precision*Recall) / (Precision + Recall)</em></p><p>When the data is unbalanced (Ex: 900 Negative, 50 Positive), Accuracy score can be misleading. Because the model might be good at predicting Negative values but not that good in predicting Positive values.</p><p>It is also recommended to check precision, recall and F1-scores in every classification model regardless of the data being balanced or unbalanced.</p><p><strong>Example:</strong></p><p>A dataset contains 1000 patients’ information. The goal of the model is predicting whether the patient has cancer. 990 of them don’t have cancer and 10 of the have cancer.</p><p>Let’s imagine the output looks like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*220JCwJ-YO3V_dOrMdjEwA.png" /><figcaption>Example Conf. Matrix</figcaption></figure><p>As it can bee seen above, model classified 95 of them as cancer and 905 as not cancer.</p><p>Accuracy: (5 + 900) / (1000) = 0.905</p><p>Accuracy score is pretty high. Model looks accurate but this is an unbalanced dataset. Let’s further investigate;</p><p>Precision: T.P / (T.P + F.P) = 5 / 95: 0.053</p><p>Recall: T.P / (T.P + F.N) = 5 / 10: 0.5</p><p>It looks like the model was not really good at predicting Positive values. It’s important to check all the metrics.</p><p>Thanks for reading.</p><p>Barış Cengiz</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47f498d93d4a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/evaluating-classification-models-confusion-matrix-47f498d93d4a">Evaluating Classification Models, Confusion Matrix</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Recommendation Systems, ARL]]></title>
            <link>https://medium.com/@bariscengiz/recommendation-systems-arl-3a9b940a475c?source=rss-e84e1c1b0a4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a9b940a475c</guid>
            <category><![CDATA[market-basket-analysis]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[association-rule-learning]]></category>
            <category><![CDATA[recommendation-system]]></category>
            <dc:creator><![CDATA[Barış Cengiz]]></dc:creator>
            <pubDate>Sun, 10 Apr 2022 19:26:05 GMT</pubDate>
            <atom:updated>2022-04-10T19:32:59.154Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*eouiAN1NjcjyiuiFNwPhCg.png" /></figure><p>ARL (Association Rule Learning) is a rule based ML method for discovering interesting relations between variables. It can be used as Market Basket Analysis to find the patterns between the products you are selling.</p><p>A famous example is Walmart displaying beers and baby diapers next to each other after observing that customers tend to buy both together frequently.</p><p>Apriori algorithm can be used to calculate these relationships.</p><p><strong>Apriori Algorithm:</strong></p><p>Apriori algorithm is a market basket analysis method to discover patterns between products.</p><p>Relationship between X and Y:</p><p>Support(X,Y) = Freq(X,Y) / N : Probability of X and Y to be sold together.</p><p>Confidence(X,Y) = Freq(X,Y) / Freq(X) : Probabilty of Y to be sold given X is sold.</p><p>Lift(X, Y) = Support(X,Y) / (Support(X) * Support(Y)) : Increase in probability of Y to be sold when X is sold.</p><p><strong>Implementation of the algorithm:</strong></p><ol><li>Determine a minimum support and minimum confidence value.</li><li>Calculate every item’s support value.</li><li>Drop items with lower support value than the value in the step-1.</li><li>Create and calculate the support values of the dual associations.</li><li>Drop groups with lower support value than the value in the step-1.</li><li>Create and calculate the support values of the association between groups.</li><li>Drop groups with lower support value than the value in the step-1.</li><li>Repeat until 0 or 1 group remains.</li></ol><p>Choose the groups with higher confidence value than the determined minimum value. Note that lift can also be used as a factor.</p><p>Example: Min Support &gt; 0.2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*y5TGSK_n8cbXJmIdebGTlQ.png" /><figcaption>Receipts</figcaption></figure><p>Supports Values of every item:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*B2h6ZZoMI6eF0eVECshB0g.png" /><figcaption>Support Values</figcaption></figure><p>Drop items with lower support value than the minimum:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*rIDDZTPIlgLCy7BK218yfw.png" /><figcaption>Remaining Items</figcaption></figure><p>Create and calculate the support values of the dual associations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*g6b1cKjwlhRrpjdI-yo8Ww.png" /><figcaption>Support table of the groups</figcaption></figure><p>Drop groups with low support value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*UxmpW-2Pm40ZNB-f87MjmA.png" /><figcaption>Remaining Groups</figcaption></figure><p>Create the new list and the support values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*Hwvl_fWzkMjMKTxLkfj4Fg.png" /><figcaption>New Groups</figcaption></figure><p>Drop groups with low support value.</p><p>As it can be seen, only Eggs, Tea and Coke remains with a support value of 0.4.</p><p>Create the final table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P4WKn4uFLRmbTRPrXE6FyA.png" /><figcaption>Final Table</figcaption></figure><p>Now it can be evaluated what item to recommend to a person buying an item or which two items can be displayed together to raise the sales.</p><p>Thank you for reading.</p><p>Barış Cengiz</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a9b940a475c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CRM Analytics, RFM Analysis]]></title>
            <link>https://medium.com/codex/crm-analytics-rfm-analysis-90aa2ae55fbc?source=rss-e84e1c1b0a4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/90aa2ae55fbc</guid>
            <category><![CDATA[crm]]></category>
            <category><![CDATA[rfm-analysis]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[rfm]]></category>
            <dc:creator><![CDATA[Barış Cengiz]]></dc:creator>
            <pubDate>Thu, 31 Mar 2022 15:41:35 GMT</pubDate>
            <atom:updated>2022-04-05T12:40:09.367Z</atom:updated>
            <content:encoded><![CDATA[<p>After learning and completing a <a href="https://medium.com/@bariscengiz/calculating-potential-customer-return-using-rule-based-classification-152610c4d945">project about rule based classification</a>, this week’s subject is CRM analytics.</p><p>CRM means Customer Relationship Management. There are 3 types of CRM: <strong>collaborative, analytical, and operational</strong>. As a data scientist, the most important approach is -as you can guess- the analytical approach.</p><p>Most companies have large and valuable customer databases and it would be a shame to not use the data in them. To make better business decisions, companies can use RFM analysis and segmentize their customers. It would be too hard/impossible to provide different approaches to each customer. By segmentizing, companies can approach customer group(s) more strategically.</p><h3>RFM Analysis</h3><p>RFM stands for Recency, Frequency, Monetary.</p><p><strong>Recency</strong>: Time between the last transaction made and the analysis date.</p><p><strong>Frequency: </strong>Number of transactions.</p><p><strong>Monetary: </strong>Total price of the transactions.</p><p>RFM is a data driven, rule based segmentation technique.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/1*_a3em3x0NxQDQk49-XBfVA.png" /><figcaption>Table-1 Example RFM Table</figcaption></figure><p>In table-1, we can observe customers’ RFM information and try to compare them but values need to be standardized to evaluate and segmentize each customer. Without transforming these values it is not possible to decide whether a customer’s R, F and M values are high or not. For example, C3’s recency is 46 days, this looks bad compared to C1 or C2 but it is possible that there are some customers with 300+ days recency. This standardization can be done by scoring each metric in a 1–5 rating system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*t_mrXhPV9dUqvk2R4IJFYg.png" /><figcaption>Table-2 RFM Scores</figcaption></figure><p>Now we can clearly see, C3’s recency score is bad as 1 is the lowest score possible. After creating the score table, Each customer’s RFM score can be determined in a couple ways like calculating the mean of the RFM values or labeling with the RFM values. Let’s use labeling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*Oq0614L8hpq2m9q_cEQp7A.png" /><figcaption>Table-3 RFM Label</figcaption></figure><p>Still it can be seen that there are too many RFM scores. (111,112,…,555) 5³ = 125 values to be exact. For this we can use the 2-axis RF Grid to segmentize.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*oUKMc3gk53hccFX4YNeu1g.png" /><figcaption>Image-1 RF-Grid</figcaption></figure><p>Notice that M score is not used. This is because our goal is to reduce the number of groups in a logical way and monetary is not the most important metric. As, a high monetary score can be gained with one big purchase or a lot of small purchases.</p><p>Lots of the times keeping existing customers is far more efficient than gaining new customers. So companies might focus on the groups with high frequency and low recency scores like “Can’t loose them”, “at risk”. This customers were “champions” or “loyal customers” at some point and it would be beneficial to win them back. Note that different approaches should be taken in different fields and industries.</p><p>This process should be done periodically to update customers’ scores and to evaluate the performance of the strategies applied to the customers since the last segmentation process.</p><p>Thank you for reading.</p><p>Barış Cengiz</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90aa2ae55fbc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/crm-analytics-rfm-analysis-90aa2ae55fbc">CRM Analytics, RFM Analysis</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Calculating Potential Customer Revenue Using Rule Based Classification]]></title>
            <link>https://medium.com/@bariscengiz/calculating-potential-customer-return-using-rule-based-classification-152610c4d945?source=rss-e84e1c1b0a4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/152610c4d945</guid>
            <category><![CDATA[data-preprocessing]]></category>
            <category><![CDATA[rule-based-classification]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Barış Cengiz]]></dc:creator>
            <pubDate>Sun, 13 Mar 2022 13:03:27 GMT</pubDate>
            <atom:updated>2022-03-13T16:49:36.289Z</atom:updated>
            <content:encoded><![CDATA[<p>In this project the main goal is to calculate potential customer revenue <em>without</em> using any machine learning libraries or pre-built functions/methods.</p><h3>The Data</h3><p>First, let’s examine the data in the Persona dataset. This dataset contains customer data from a variety of countries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*zbAnDXYh8qrGILagJb4wrQ.png" /><figcaption>Image-1 Persona DataFrame Info</figcaption></figure><p>As it can be seen in Image-1, Persona Dataset has 5 columns with 5000 entries. Clearly this is a clean dataset with no missing values. Price and age are the numerical features. Source, sex and country are the categorical features. All features are self explanatory except SOURCE. Source feature is the information of customers’ smart-phone operating system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*oOC1L0MGFbkx0uNse10D3g.png" /><figcaption>Image-2 df.head()</figcaption></figure><p>Source feature has 2 unique values: <em>ios</em> and <em>android</em> as it is shown in Image-3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*2J66gHP-0zEkz7PPQAo3ow.png" /><figcaption>Image-3 Unique Values of Source Feature</figcaption></figure><p>Investigate the data further:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*XRMBhrmisQLFW4rGsRkAXQ.png" /><figcaption>Image-4 Average Customer Spending by Country</figcaption></figure><p>Customers are from 6 different countries. Average spending by country can be seen in Image-4.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*GN---WuKO-uaESC04oqRJQ.png" /><figcaption>Image-5 Average Customer Spending by Source</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*XbVULT8j8NqtzyKlS0eqxQ.png" /><figcaption>Image-6 Average Customer Spending by Country-Source</figcaption></figure><h3>Pre-Processing the Data</h3><p>To make the data a bit more clear, aggregate the data as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vdOR94K5qF7F45A3UBxtpA.png" /><figcaption>Image-7 Agg.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*osr2BLJEmGg4Dj3K6HR1Sg.png" /><figcaption>Image-8 agg_df First Five Entries</figcaption></figure><p>Now one way to continue is adding age categories to the dataset. This will help us predict a new customers revenue. Age intervals can be defined as followed:</p><p>0–18: Underaged,</p><p>19–23: College students (Possibly),</p><p>24–30: Young adults,</p><p>31–40: Possibly young parents</p><p>40–66: 66 being the oldest age in the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*qL2L78Cn_qlx042xD5DJ2w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*1H4SeYIxHrVhFqBIJriEuw.png" /><figcaption>Image-9 First 5 entries with the age_cat feature</figcaption></figure><p>Now it’s time to add the persona feature to the dataset.</p><p><em>Ex. Persona</em>: “BRA_ANDROID_MALE_41_66”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wzY9JWRxEFP8RWs6wp5Ukg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*4A9ltBzklUjmiKCMaYh9HQ.png" /><figcaption>Image-10 First 5 entries of the persona_df</figcaption></figure><p>Essentially we have grouped customers by country, source, gender and age interval then calculated average spending for each group.</p><p>Next step is creating segments for average spendings. Let’s divide the average spending into 4 segments: A,B,C,D (Descending)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*zKHnJrZx1cs9dw4VzsGOAQ.png" /><figcaption>Mean, max and sum values for each segment</figcaption></figure><p>Our dataset is ready to use for predicting revenues of new customers.</p><h3>Prediction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yqXwz18denczJE2JO_gMNw.png" /><figcaption>Function to predict the revenue of a new customer</figcaption></figure><p>pred_price function takes DataFrame, country, source, sex and age inputs to return predicted segment and price for a new customer.</p><p>Examples:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*6x94wz58VK79eD5j7jqSbQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*b1mlAalw2g5uwhjcYUqjRA.png" /></figure><p>So we can expect a potential 41.8 revenue value from a 33 year-old Turkish female android user and a potential of 32.8 revenue value from a 35 year-old French ios user.</p><p>Thanks for reading.</p><p>Barış Cengiz</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=152610c4d945" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>