<?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 Merve ÖZKAN on Medium]]></title>
        <description><![CDATA[Stories by Merve ÖZKAN on Medium]]></description>
        <link>https://medium.com/@merveatasoy48?source=rss-a0d572db1a54------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-u_nGzm4tE_TBTSGI1P_TQ.jpeg</url>
            <title>Stories by Merve ÖZKAN on Medium</title>
            <link>https://medium.com/@merveatasoy48?source=rss-a0d572db1a54------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 07:33:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@merveatasoy48/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[Association Rule Learning with Apriori Algorithm]]></title>
            <link>https://medium.com/@merveatasoy48/association-rule-learning-with-apriori-algorithm-3557881acf35?source=rss-a0d572db1a54------2</link>
            <guid isPermaLink="false">https://medium.com/p/3557881acf35</guid>
            <category><![CDATA[apriori-algorithm]]></category>
            <category><![CDATA[arl]]></category>
            <dc:creator><![CDATA[Merve ÖZKAN]]></dc:creator>
            <pubDate>Thu, 22 Feb 2024 07:40:05 GMT</pubDate>
            <atom:updated>2024-02-22T07:44:19.759Z</atom:updated>
            <content:encoded><![CDATA[<p>It is desirable to recommend services or products to users by using some techniques. It is possible to realize this process with the co-learning rule technique. 💯</p><p>It is a rule-based machine learning technique used to find patterns (pattern, relationship, structure) in data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*Aw-cKtblzWpqYOG3zztCSw.png" /><figcaption>The customer and the products they buy</figcaption></figure><p>As a result of Associatin Rule Learning (ARL) based analysis, if it is determined that there is a purchasing relationship between one or more products, the products can be sorted close to each other in the physical market. In this case, this will increase sales.</p><h3>Apriori Algorithm</h3><p>🛒 Basket analysis method.</p><p>🛍 Used to reveal product associations.</p><p>The Apriori algorithm calculates iteratively over three metrics and gives very valuable simple statistics on product associations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*fu2RCat4qvGqZEn6it8zOw.png" /><figcaption>Three important metrics for Apriori Algorithm</figcaption></figure><p>🔦 Now let’s examine step by step how the apriori algorithm works and deepen our knowledge;</p><p>Support value was chosen as 0.2. This means; If a product or product group is observed less than 20% on the invoice or in the basket, it does not matter. Ignore this product while performing procedures.</p><p>At the end of each step, elimination processes will be carried out according to the support value determined at the beginning of the algorithm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*mz_rmf0f-gw5SbagFI3fxA.png" /><figcaption>The coefficients determined at the beginning of the study and the items included in the shopping list</figcaption></figure><p>Firstly, the support values of the products alone, then product pairs, then product triplets are calculated, and in each iteration, those that fall below the support value determined at the beginning of the study are eliminated.</p><blockquote>STEP 1:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*rWxYn8z7CWzpiI4jc6aJ0A.png" /><figcaption>List of STEP 1</figcaption></figure><p>The support value is calculated using the Support formula and then those below the threshold value of 0.2 are eliminated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*oEYnlH8eivle4zqkrlX7pg.png" /><figcaption>List of what remains after elimination in STEP 1</figcaption></figure><blockquote>STEP 2 :</blockquote><p>New mappings are created, support values are calculated and thresholding is performed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*FNOMKAuM2fJH5AOhNUeMnQ.png" /><figcaption>List of STEP 2</figcaption></figure><p>Eliminated items are Milk, Egg and Milk, Cola combinations equal to 20%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*bdhIh23sAZgYANi4_sYrjA.png" /><figcaption>List of what remains after elimination in STEP 2</figcaption></figure><blockquote>STEP 3</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*QnPdQAFt_WMtGEb9TEiS2w.png" /><figcaption>List of STEP 2</figcaption></figure><p>New mappings are made, support values are calculated and those below the 0.2 threshold are eliminated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*iBajHK-iljtNQpGlhgxAaA.png" /><figcaption>List of what remains after elimination in STEP 3</figcaption></figure><blockquote>STEP 4</blockquote><p>🚀Creation and interpretation of the final table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*edv-BCFqDn4nLCEb8LU56Q.png" /><figcaption>Creation and interpretation of the final table</figcaption></figure><p>After the thresholding process in Step 1, Step 2, Step 3, we combine the remaining elements in the last table. Then we calculate the support, confidence and lift values.</p><p>Confidence and Lift formulas were given at the beginning of the article.</p><p>💠 <strong>Support</strong> : The probability of buying product X and product Y together, <br>💠 <strong>Confidence</strong> : The frequency of buying Y because product X is bought,<br>💠 <strong>Lift :</strong> increases the probability of buying Y by lift times since product X is bought.</p><p>After interpreting the concepts in this way, let’s interpret the figures for the egg and tea row in the final table;<br>↪ Eggs and tea are observed together in 40% of all purchases.<br>↪ 67% of customers who buy eggs also buy tea.<br>↪ The sale of tea product increases 1.11 times in egg purchases.<br>I leave it to you to interpret the other lines 💫</p><p>🚄 These operations are completed in a few lines with the mlxtend library. If you wish, you can review the github codes I have shared below. Let’s not forget that what is important in real life in ARL projects is to prepare the data structure suitable for ARL.</p><p>👩‍💻 <a href="https://github.com/MRV-1/Association_Rule_Learning">Github Repo </a>⛓</p><p>🌀 You can also access another ARL project in which I used the ARMUT dataset from the link below.</p><p>👩‍💻<a href="https://www.kaggle.com/work/code">Kaggle Notebook</a> ⛓</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3557881acf35" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Recommender Systems]]></title>
            <link>https://medium.com/@merveatasoy48/recommender-systems-8ef5fe706dd9?source=rss-a0d572db1a54------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ef5fe706dd9</guid>
            <category><![CDATA[arl]]></category>
            <category><![CDATA[recommender-systems]]></category>
            <dc:creator><![CDATA[Merve ÖZKAN]]></dc:creator>
            <pubDate>Thu, 22 Feb 2024 07:17:53 GMT</pubDate>
            <atom:updated>2024-02-22T07:17:53.031Z</atom:updated>
            <content:encoded><![CDATA[<p>🚨 Recommender systems are systems that work by recommending products or services to users using some techniques.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p2q-fDxQgAIXaQaS9KL1wA.png" /><figcaption>Recommender System</figcaption></figure><p>It came to the agenda for the first time in the 1990s with the naming of digital libraries.</p><p>It is used in many systems, from radio programs to dating applications, from e-commerce sites to social media channels, in an application in many infrastructures.</p><p>⚡Critical sentence ↙</p><p>There is a lot of content related to the user’s area of interest and these need to be filtered.</p><p>🎯 Therefore, the general purpose of recommendation systems is to filter the abundant possible content, services, products, movies and similar situations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*egJ8vgMM7SdVzsTEE1Hirw.png" /><figcaption>User-movie matrix</figcaption></figure><p>🍪 For example, users have watched a movie and as a result of their ratings, a table like the one above has emerged. This is where recommendation systems come into play.</p><p>🎬 It makes score predictions for unknown user-movie pairs, according to these score predictions, the score that those who have not yet watched a movie can give to a movie is calculated, if there is a situation where they can give a high score, the recommender system recommends this movie to this person.</p><p>🌊 Simple Recomender System is grouped as Association Rule Learning, Content Based Filtering, Collaborative Filtering.</p><p>Let’s meet in my next article, Association Rule Learning 💁 👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ef5fe706dd9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AB Testing]]></title>
            <link>https://medium.com/@merveatasoy48/ab-testing-65b529266768?source=rss-a0d572db1a54------2</link>
            <guid isPermaLink="false">https://medium.com/p/65b529266768</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[compare]]></category>
            <category><![CDATA[ab-testing]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Merve ÖZKAN]]></dc:creator>
            <pubDate>Tue, 13 Feb 2024 12:28:26 GMT</pubDate>
            <atom:updated>2024-02-21T14:41:48.325Z</atom:updated>
            <content:encoded><![CDATA[<p>The A/B test is one of the most widely used methods in data science. A represents one feature or group, while B represents a different feature or group. The issue of interest is whether there is a difference between these two. 👩‍🔬</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I8m4KAUor7hHO73gME6VTQ.png" /><figcaption>A/B Testing</figcaption></figure><p>Statistical methods used to test a belief are called hypothesis tests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*G3zTcGdXzePlwOfVQPdxlA.png" /><figcaption>Forms of hypothesizing</figcaption></figure><p>Hypotheses can be constructed in three different ways as grouped in the picture.</p><p>The structure we will focus on in hypothesis testing will be group comparisons.</p><p>The main purpose of group comparisons is to see if possible differences are due to chance.</p><p>This is the key point of A/B testing.</p><p>To evaluate scientifically whether the situation that emerges is due to chance or not.</p><h3>Two-Sample Independent T-Test</h3><p>When we think of the A/B test, we are either comparing the mean of two groups or the proportions of two groups. In this article, we will be coding and interpreting the process of comparing two group averages.</p><p>Let’s get started 👨‍💻</p><p>When implementing A/B testing, we will complete it in three steps;</p><blockquote>1) Build Hypotheses</blockquote><p>🌀</p><blockquote><em>2) </em>Assumption Check</blockquote><ol><li>Assumption of Normality</li></ol><p>It is concerned with the normality of the distributions of the groups concerned.</p><p>If either of the two groups does not meet the normality assumption, the non-parametric mannwhitneyu test is used.</p><p>2. Homogeneity of Variance</p><p>It is concerned with the similarity of the distributions of the variances of two groups.</p><blockquote>3) Implementation of the Hypothesis</blockquote><p>If the assumptions are accepted, Independent two sample T Test is applied.<br>If the assumptions are not accepted, the Mann-Whitney U test is applied.</p><p>The results will be interpreted according to the p-value value obtained.</p><p><strong>H0 REJECT</strong> if p-value &lt; 0.05. ❌</p><p><strong>H0 CANNOT BE REJECTED</strong> if p-value &gt; 0.05. ✔</p><p>Now let’s examine this on the diabetes dataset with the python DataFrame structure.</p><p><strong>BELIEF : </strong>The average age of people with and without diabetes is the same.</p><p>Let’s import the dataset and take a look at the data.👁👁</p><pre>Pregnancies  Glucose  BloodPressure  SkinThickness  Insulin      BMI  DiabetesPedigreeFunction  Age  Outcome<br>0            6      148             72             35        0 33.60000                   0.62700   50        1<br>1            1       85             66             29        0 26.60000                   0.35100   31        0<br>2            8      183             64              0        0 23.30000                   0.67200   32        1<br>3            1       89             66             23       94 28.10000                   0.16700   21        0<br>4            0      137             40             35      168 43.10000                   2.28800   33        1h</pre><p>Pregnancies, Glucose, BloodPressure, SkinThickness, Insulin, BMI, DiabetesPedigreeFunction, Age, Outcome variables.</p><p>For now, we will be interested in Outcome and Age variables.</p><pre>df.groupby(&quot;Outcome&quot;).agg({&quot;Age&quot;: &quot;mean&quot;})</pre><p>With the above line of code, let’s group those with and without diabetes and find the average age.</p><pre>             Age<br>Outcome         <br>0       31.19000<br>1       37.06716</pre><p>The result came back and there seems to be a difference between the two groups.🔺 🔻</p><p>But is this difference the result of chance, let’s look at it from a scientific point of view.👩‍🔬</p><blockquote>1) Build Hypotheses</blockquote><p>H0: M1 = M2<br> → The average age of people with and without diabetes is the same.<br>H1: M1 != M2<br> → The average age of people with and without diabetes is different.</p><blockquote><em>2) </em>Assumption Check</blockquote><ol><li>Assumption of Normality</li></ol><p>Shapiro test is used to assume normality.</p><pre>test_stat, pvalue = shapiro(df.loc[df[&quot;Outcome&quot;] == 1, &quot;Age&quot;].dropna())<br>print(&#39;Test Stat = %.4f, p-value = %.4f&#39; % (test_stat, pvalue))<br><br>#Test Stat = 0.9546, p-value = 0.0000</pre><p>p-value &lt; 0.05 so, H0 is <strong>REJECT</strong></p><pre>test_stat, pvalue = shapiro(df.loc[df[&quot;Outcome&quot;] == 0, &quot;Age&quot;].dropna())<br>print(&#39;Test Stat = %.4f, p-value = %.4f&#39; % (test_stat, pvalue))<br><br>#Test Stat = 0.8012, p-value = 0.0000</pre><p>p-value &lt; 0.05 so, H0 is <strong>REJECT</strong></p><p>Normality assumption was examined and rejected. The stage of applying the hypothesis was started.</p><p>Since the assumption was rejected, the non-parametric test Mann-Whitney U will be applied.</p><blockquote>3) Implementation of the Hypothesis</blockquote><pre>test_stat, pvalue = mannwhitneyu(df.loc[df[&quot;Outcome&quot;] == 1, &quot;Age&quot;].dropna(),<br>                                 df.loc[df[&quot;Outcome&quot;] == 0, &quot;Age&quot;].dropna())<br>print(&#39;Test Stat = %.4f, p-value = %.4f&#39; % (test_stat, pvalue))<br><br>#Test Stat = 92050.0000, p-value = 0.0000</pre><p>p-value &lt; 0.05 so, H0 is <strong>REJECT</strong></p><p><strong>Conclusion :</strong> The average age of people with and without diabetes <strong>is not equal. </strong>🚀</p><p>I have shared the code fragments mentioned in the article and more in my repo below.</p><p>Have a nice review. 👋</p><p><a href="https://github.com/MRV-1/A-B_Testing">Github Repo : for A/B Testing</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65b529266768" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Review Sorting]]></title>
            <link>https://medium.com/@merveatasoy48/review-sorting-7c8c6bd77195?source=rss-a0d572db1a54------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c8c6bd77195</guid>
            <category><![CDATA[review]]></category>
            <category><![CDATA[sorting]]></category>
            <dc:creator><![CDATA[Merve ÖZKAN]]></dc:creator>
            <pubDate>Tue, 13 Feb 2024 11:54:38 GMT</pubDate>
            <atom:updated>2024-02-13T11:55:22.865Z</atom:updated>
            <content:encoded><![CDATA[<p>Review sorting have a positive impact on brand perception and demonstrate brand authority.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*mYewe498yaYcWHS1ovyAYg.png" /><figcaption>Example of customer reviews</figcaption></figure><p>When comments are analyzed by the customer in a purchasing process, the comments with the highest social proof are taken into account.</p><p>Social proof is one of the most influential reasons for a user’s purchase. The opinion of the community stands at a very important point due to the comments and scores of users about the products.</p><p>When marketplaces are analyzed; in some marketplaces, a one-star review is at the top, while in some marketplaces, a 5-star review is at the top.</p><p>Why ❓</p><p>Actually, there is no answer to this question, because marketplaces are not interested in sorting customer reviews based on whether they have a low or high score, the aim is to provide users with social proof.<br>Therefore, marketplace sortings are based on whether users find the comments useful or not.</p><p>So how should the developer create this sorting ❓</p><p>💭 Many perspectives can be developed on this issue, but here we will be discussing methods from three different perspectives. 🔈</p><pre>def score_up_down_diff(up, down):<br>    return up - down<br><br># Review 1 Score:<br>score_up_down_diff(600, 400)<br><br># Review 2 Score<br>score_up_down_diff(5500, 4500)</pre><p>Where up is the total number of users who found this comment useful and down is the total number of users who found this comment not useful.</p><blockquote>Review 1 score is <em>200. </em>Review 2 score is <em>1000.</em></blockquote><p>There is something wrong here. 🤔</p><p>However, when analyzed on a percentage basis, it is seen that review 1 is higher. 🙇‍♀️</p><p>Solution to this problem with Score Average rating let’s produce. ↙</p><h3>Score Average Rating</h3><pre>def score_average_rating(up, down):<br>    if up + down == 0:<br>        return 0<br>    return up / (up + down)<br><br>score_average_rating(600, 400)<br><br>#OUT : 0.6<br><br>score_average_rating(5500, 4500)<br><br>#OUT : 0.55</pre><p>The score_average_rating method achieved better results than the score_up_down_diff method.</p><p>But if we look at this example;</p><pre>score_average_rating(2, 0) <br>#Out: 1.0<br><br>score_average_rating(100, 1)<br>#Out: 0.9900990099009901</pre><p>When ranking is done, review 1 will be at the top, not review 1 which should normally be in the first place, this method cannot take into account the frequency value. 🌊</p><p>There should be a method that can rank according to both frequency and rating. ⚓</p><h3>Wilson Lower Bound Score</h3><p>It allows you to score items, products or reviews that contain any binary interactions.</p><p>It aims to solve all measurement problems that arise as a result of binary interactions.</p><p>It uses a Bernoulli probability distribution and aims to calculate the probability of binary events.</p><p>For example, it is used to calculate the probability of a coin toss coming up tails, or the probability of how an event with two outcomes can occur.</p><pre>def wilson_lower_bound(up, down, confidence=0.95):<br>    n = up + down<br>    if n == 0:<br>        return 0<br>    z = st.norm.ppf(1 - (1 - confidence) / 2)<br>    phat = 1.0 * up / n<br>    return (phat + z * z / (2 * n) - z * math.sqrt((phat * (1 - phat) + z * z / (4 * n)) / n)) / (1 + z * z / n)<br><br><br>wilson_lower_bound(600, 400)     #0.5693094295142663<br>wilson_lower_bound(5500, 4500)   #0.5402319557715324<br><br><br>wilson_lower_bound(2, 0)      #0.3423802275066531<br>wilson_lower_bound(100, 1)    #0.9460328420055449</pre><p>From the scores returned by the Wilson_lower_bound method, it can be seen that the frequency and ratio information is effective in the score formation in this method. 🔖</p><p>Target achieved.🚀</p><p>Let’s make scores on the data set according to the three given methods.</p><pre># score_pos_neg_diff<br>comments[&quot;score_pos_neg_diff&quot;] = comments.apply(lambda x: score_up_down_diff(x[&quot;up&quot;], x[&quot;down&quot;]), axis=1)<br><br># score_average_rating<br>comments[&quot;score_average_rating&quot;] = comments.apply(lambda x: score_average_rating(x[&quot;up&quot;], x[&quot;down&quot;]), axis=1)<br><br># wilson_lower_bound<br>comments[&quot;wilson_lower_bound&quot;] = comments.apply(lambda x: wilson_lower_bound(x[&quot;up&quot;], x[&quot;down&quot;]), axis=1)</pre><pre>comments.sort_values(&quot;wilson_lower_bound&quot;, ascending=False)</pre><pre>    up  down  score_pos_neg_diff  score_average_rating  wilson_lower_bound<br>11  147     2                 145               0.98658             0.95238<br>12   61     1                  60               0.98387             0.91413<br>1    70     2                  68               0.97222             0.90426<br>21   68     2                  66               0.97143             0.90168<br>18   54     2                  52               0.96429             0.87881<br>15   40     1                  39               0.97561             0.87405<br>13   30     1                  29               0.96774             0.83806<br>16   37     2                  35               0.94872             0.83114<br>19   18     0                  18               1.00000             0.82412<br>17   61     6                  55               0.91045             0.81807<br>0    15     0                  15               1.00000             0.79612<br>9    52     8                  44               0.86667             0.75835<br>7    37     5                  32               0.88095             0.75000<br>14   23     5                  18               0.82143             0.64409<br>2    14     2                  12               0.87500             0.63977<br>20   12     2                  10               0.85714             0.60059<br>10   28    12                  16               0.70000             0.54570<br>5     5     2                   3               0.71429             0.35893<br>8    21    23                  -2               0.47727             0.33755<br>6     8     6                   2               0.57143             0.32591<br>3     4     2                   2               0.66667             0.29999<br>4     2    15                 -13               0.11765             0.03288</pre><p>Here, considering both frequency and rating information, the wilson_lower_bound score was created, sorting was performed and a successful result was obtained compared to other methods. 📈</p><p>The sample set was analyzed by the method and the behavior of the sample was reflected in the whole population.💻</p><p>I created a github repository to share the code fragments and dataset discussed in the article. You can check it out from the link below. ⛓</p><p><a href="https://github.com/MRV-1/Review_Sorting">Github Repo : for Review Sorting</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c8c6bd77195" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Product Sorting]]></title>
            <link>https://medium.com/@merveatasoy48/product-sorting-94e9db162789?source=rss-a0d572db1a54------2</link>
            <guid isPermaLink="false">https://medium.com/p/94e9db162789</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[product-sorting]]></category>
            <dc:creator><![CDATA[Merve ÖZKAN]]></dc:creator>
            <pubDate>Tue, 13 Feb 2024 11:20:02 GMT</pubDate>
            <atom:updated>2024-02-13T11:20:02.834Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the most important factors influencing the purchase of a product is the belief in the wisdom of crowds.🗽</p><p>The wisdom of crowds is a prominent concept in purchasing and marketing processes.📈</p><p>It allows people who are in the shopping phase to be guided by the thought that so many people cannot be wrong.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*8qC_pvsATOtPIbck4Qfqtg.png" /></figure><p>I mentioned the details of the subject in my article <a href="https://medium.com/@merveatasoy48/product-rating-62cb8079090d">product rating</a> medium.</p><p>In this article, I will be discussing what kind of problems may arise when product sorting is done by developers and what solutions we should produce by looking at these problems from which angles.</p><p>🔖We will address the problems by progressing step by step with the Product sorting dataset.</p><p>Let’s read the data and look at the first 3 rows.</p><pre>                                        course_name    instructor_name  purchase_count  rating  commment_count  5_point  4_point  3_point  2_point  1_point<br>0  (50+ Saat) Python A-Z™: Veri Bilimi ve Machine...  Veri Bilimi Okulu           17380 4.80000            4621     3466      924      185       46        6<br>1  Python: Yapay Zeka ve Veri Bilimi için Python ...  Veri Bilimi Okulu           48291 4.60000            4488     2962     1122      314       45       45<br>2           5 Saatte Veri Bilimci Olun (Valla Billa)       Instructor_1           18693 4.40000            2362     1582      567      165       24       24<br>3    R ile Veri Bilimi ve Machine Learning (35 Saat)  Veri Bilimi Okulu            6626 4.60000            1027      688      257       51       10       21</pre><p>The dataset contains the variables course_name, instructor_name, purchase_count, rating, commment_count, 5_point, 4_point, 3_point, 2_point, 1_point.</p><p>Variables between 5_point and 1_point contain the distribution of points for the course.</p><p>Let’s perform descending sorting on Pandas’ DataFrames using the sort_values method.</p><pre>df.sort_values(&quot;rating&quot;, ascending=False).head(3)</pre><pre>                                         course_name    instructor_name   purchase_count  rating  commment_count  5_point  4_point  3_point  2_point  1_point<br>0   (50+ Saat) Python A-Z™: Veri Bilimi ve Machine...  Veri Bilimi Okulu           17380 4.80000            4621     3466      924      185       46        6<br>10        İleri Düzey Excel|Dashboard|Excel İp Uçları  Veri Bilimi Okulu            9554 4.80000            2266     1654      499       91       22        0<br>19                     Alıştırmalarla SQL Öğreniyorum  Veri Bilimi Okulu            3155 4.80000             235      200       31        4        0        0</pre><p>The resulting data is like this. Some problems have occurred here.</p><blockquote>1) I get irrelevant results.</blockquote><blockquote>2) Although there are courses with a higher number of purchases, they are on the bottom rows.</blockquote><p>In other words, the number of purchases and the number of comments cannot somehow override the rating. However, this is contrary to the concept of social proof. ❗</p><p>There should be a solution so that the number of purchases, comments and rating can be taken into account.</p><h3>Sorting by Rating, Comment and Purchase</h3><p>All three metrics should be standardized and then sorted at the same time.</p><p>We use the MinMaxScaler method to bring them all into the same range. When they are not in the same range, it will be seen that the one with the higher value manipulates the result.</p><pre>df[&quot;purchase_count_scaled&quot;] = MinMaxScaler(feature_range=(1, 5)). \<br>    fit(df[[&quot;purchase_count&quot;]]). \<br>    transform(df[[&quot;purchase_count&quot;]])<br><br>df[&quot;comment_count_scaled&quot;] = MinMaxScaler(feature_range=(1, 5)). \<br>    fit(df[[&quot;commment_count&quot;]]). \<br>    transform(df[[&quot;commment_count&quot;]])</pre><p>With the lines, purchase count and comment count were brought to the same range as rating.</p><pre>def weighted_sorting_score(dataframe, w1=32, w2=26, w3=42):<br>    return (dataframe[&quot;comment_count_scaled&quot;] * w1 / 100 +<br>            dataframe[&quot;purchase_count_scaled&quot;] * w2 / 100 +<br>            dataframe[&quot;rating&quot;] * w3 / 100)<br><br>df[&quot;weighted_sorting_score&quot;] = weighted_sorting_score(df)<br><br>df.sort_values(&quot;weighted_sorting_score&quot;, ascending=False).head(20)</pre><p>Here, 3 different structures were weighted and the following ranking result was obtained.</p><pre><br>                                          course_name    instructor_name  purchase_count  rating  commment_count  5_point  4_point  3_point  2_point  1_point  purchase_count_scaled  comment_count_scaled  weighted_sorting_score<br>1   Python: Yapay Zeka ve Veri Bilimi için Python ...  Veri Bilimi Okulu           48291 4.60000            4488     2962     1122      314       45       45                5.00000               4.88470                 4.79510<br>0   (50+ Saat) Python A-Z™: Veri Bilimi ve Machine...  Veri Bilimi Okulu           17380 4.80000            4621     3466      924      185       46        6                2.43801               5.00000                 4.24988<br>20                                           Course_9       Instructor_3           12946 4.50000            3371     2191      877      203       33       67                2.07051               3.91634                 3.68156<br>14                       Uçtan Uca SQL Server Eğitimi  Veri Bilimi Okulu           12893 4.70000            2425     1722      510      145       24       24                2.06612               3.09623                 3.50198<br>2            5 Saatte Veri Bilimci Olun (Valla Billa)       Instructor_1           18693 4.40000            2362     1582      567      165       24       24                2.54684               3.04161                 3.48349<br>10        İleri Düzey Excel|Dashboard|Excel İp Uçları  Veri Bilimi Okulu            9554 4.80000            2266     1654      499       91       22        0                1.78937               2.95839                 3.42792<br>15                      Uygulamalarla SQL Öğreniyorum  Veri Bilimi Okulu           11397 4.50000            2353     1435      705      165       24       24                1.94213               3.03381                 3.36577<br>4   (2020) Python ile Makine Öğrenmesi (Machine Le...  Veri Bilimi Okulu           11314 4.60000             969      717      194       38       10       10                1.93525               1.83398                 3.02204<br>11                                           Course_3       Instructor_4           24809 4.30000             250       95       87       51       12        5                3.05375               1.21066                 2.98739<br>3     R ile Veri Bilimi ve Machine Learning (35 Saat)  Veri Bilimi Okulu            6626 4.60000            1027      688      257       51       10       21                1.54669               1.88427                 2.93711<br>6                                            Course_2       Instructor_3            3171 4.70000             856      582      205       51        9        9                1.26033               1.73602                 2.85721<br>9                        Modern R Programlama Eğitimi  Veri Bilimi Okulu            6537 4.40000             901      559      252       72        9        9                1.53932               1.77503                 2.81623<br>8            A&#39;dan Z&#39;ye Apache Spark (Scala &amp; Python)  Veri Bilimi Okulu            6920 4.70000             214      154       41       13        2        4                1.57106               1.17945                 2.75990</pre><p>So, can a ranking be made by considering ratings from different angles or by focusing only on ratings ❓</p><p>Yes it is possible, we will use Bayesian Average Rating for this.</p><h3>Bayesian Average Rating Score</h3><p>bayesian_average_rating calculates a weighted probabilistic average over score distributions.🚀</p><pre>def bayesian_average_rating(n, confidence=0.95):<br>    if sum(n) == 0:<br>        return 0<br>    K = len(n)<br>    z = st.norm.ppf(1 - (1 - confidence) / 2)<br>    N = sum(n)<br>    first_part = 0.0<br>    second_part = 0.0<br>    for k, n_k in enumerate(n):<br>        first_part += (k + 1) * (n[k] + 1) / (N + K)<br>        second_part += (k + 1) * (k + 1) * (n[k] + 1) / (N + K)<br>    score = first_part - z * math.sqrt((second_part - first_part * first_part) / (N + K + 1))<br>    return score</pre><p>The bayesian_average_rating method is created above. There are some mathematical operations in the method. But we will not go into the math part of the job right now.</p><p>If you wish, you can investigate this probabilistic average calculation.</p><p>Let’s continue to discuss the processes. ↩</p><p>The star distributions in the DataFrame will be entered instead of n in the bayesian_average_rating method. The confidence interval is set as 0.95 by default.</p><p>Given these values, the function tells us that my result may have a 5% margin of error.</p><pre><br>df[&quot;bar_score&quot;] = df.apply(lambda x: bayesian_average_rating(x[[&quot;1_point&quot;,<br>                                                                &quot;2_point&quot;,<br>                                                                &quot;3_point&quot;,<br>                                                                &quot;4_point&quot;,<br>                                                                &quot;5_point&quot;]]), <br>                                                                 axis=1)<br><br>df.sort_values(&quot;bar_score&quot;, ascending=False).head(20)</pre><pre>                                          course_name    instructor_name  purchase_count  rating  commment_count  5_point  4_point  3_point  2_point  1_point  purchase_count_scaled  comment_count_scaled  weighted_sorting_score  bar_score<br>19                     Alıştırmalarla SQL Öğreniyorum  Veri Bilimi Okulu            3155 4.80000             235      200       31        4        0        0                1.25901               1.19766                 2.72659    4.72913<br>0   (50+ Saat) Python A-Z™: Veri Bilimi ve Machine...  Veri Bilimi Okulu           17380 4.80000            4621     3466      924      185       46        6                2.43801               5.00000                 4.24988    4.66586<br>10        İleri Düzey Excel|Dashboard|Excel İp Uçları  Veri Bilimi Okulu            9554 4.80000            2266     1654      499       91       22        0                1.78937               2.95839                 3.42792    4.64168<br>5                                            Course_1       Instructor_2            4601 4.80000             213      164       45        4        0        0                1.37886               1.17859                 2.75165    4.63448<br>4   (2020) Python ile Makine Öğrenmesi (Machine Le...  Veri Bilimi Okulu           11314 4.60000             969      717      194       38       10       10                1.93525               1.83398                 3.02204    4.59567<br>14                       Uçtan Uca SQL Server Eğitimi  Veri Bilimi Okulu           12893 4.70000            2425     1722      510      145       24       24                2.06612               3.09623                 3.50198    4.56816<br>1   Python: Yapay Zeka ve Veri Bilimi için Python ...  Veri Bilimi Okulu           48291 4.60000            4488     2962     1122      314       45       45                5.00000               4.88470                 4.79510    4.51604<br>2            5 Saatte Veri Bilimci Olun (Valla Billa)       Instructor_1           18693 4.40000            2362     1582      567      165       24       24                2.54684               3.04161                 3.48349    4.51521<br>6                                            Course_2       Instructor_3            3171 4.70000             856      582      205       51        9        9                1.26033               1.73602                 2.85721    4.50797<br>3     R ile Veri Bilimi ve Machine Learning (35 Saat)  Veri Bilimi Okulu            6626 4.60000            1027      688      257       51       10       21                1.54669               1.88427                 2.93711    4.48208<br>20                                           Course_9       Instructor_3           12946 4.50000            3371     2191      877      203       33       67                2.07051               3.91634                 3.68156    4.48063<br>15                      Uygulamalarla SQL Öğreniyorum  Veri Bilimi Okulu           11397 4.50000            2353     1435      705      165       24       24                1.94213               3.03381                 3.36577    4.45481<br>8            A&#39;dan Z&#39;ye Apache Spark (Scala &amp; Python)  Veri Bilimi Okulu            6920 4.70000             214      154       41       13        2        4                1.57106               1.17945                 2.75990    4.43491<br>9                        Modern R Programlama Eğitimi  Veri Bilimi Okulu            6537 4.40000             901      559      252       72        9        9                1.53932               1.77503                 2.81623    4.43153<br>22  A&#39;dan Z&#39;ye Uygulamalı Hadoop ve Büyük Veri Eği...  Veri Bilimi Okulu            3062 4.40000             169      122       29       13        2        3                1.25130               1.14044                 2.53828    4.39133<br>7   Veri Bilimi için İstatistik: Python ile İstati...  Veri Bilimi Okulu             929 4.50000             126       88       26        9        0        3                1.07451               1.10316                 2.52239    4.34219<br>12                                           Course_4       Instructor_5            1901 4.30000             376      218      113       34        8        3                1.15507               1.31990                 2.52869    4.32076<br>26                                          Course_14       Instructor_9            6027 4.00000             176      103       52       16        3        2                1.49705               1.14651                 2.43612    4.26038<br>27                                          Course_15       Instructor_1            1164 4.60000              98       65       24        6        0        3                1.09399               1.07889                 2.56168    4.25394<br>13                                           Course_5       Instructor_6            6056 4.70000             144       82       46       12        1        3                1.49945               1.11877                 2.72186    4.21854<br><br></pre><p>bar_score provides a sorting by focusing on the rating, this score, which is created by looking at the distribution of rates, is a scientifically valuable score that can be used in rating calculation.</p><p>In this case, social proofs were again overlooked (number of comments, number of purchases)🙇‍♀️</p><p>If the only focus is on the scores and we want to rank based on these scores, then the bar_score method can be used alone. <br>But if there is more than one factor to consider, then bar_score will not be valid.</p><p>We need new approaches. 😥</p><h3>Hybrid Sorting : Bar Score + Other Factors</h3><pre>def hybrid_sorting_score(dataframe, bar_w=60, wss_w=40):<br>    bar_score = dataframe.apply(lambda x: bayesian_average_rating(x[[&quot;1_point&quot;,<br>                                                                     &quot;2_point&quot;,<br>                                                                     &quot;3_point&quot;,<br>                                                                     &quot;4_point&quot;,<br>                                                                     &quot;5_point&quot;]]), axis=1)<br>    wss_score = weighted_sorting_score(dataframe)<br><br>    return bar_score*bar_w/100 + wss_score*wss_w/100<br><br><br>df[&quot;hybrid_sorting_score&quot;] = hybrid_sorting_score(df)<br><br><br>df.sort_values(&quot;hybrid_sorting_score&quot;, ascending=False).head(20)</pre><p>This solution was aligned in a way that was both business-like, scientific and gave a chance to new potential stars. 🎊</p><pre>                                          course_name    instructor_name  purchase_count  rating  commment_count  5_point  4_point  3_point  2_point  1_point  purchase_count_scaled  comment_count_scaled  weighted_sorting_score  bar_score  hybrid_sorting_score<br>1   Python: Yapay Zeka ve Veri Bilimi için Python ...  Veri Bilimi Okulu           48291 4.60000            4488     2962     1122      314       45       45                5.00000               4.88470                 4.79510    4.51604               4.62766<br>0   (50+ Saat) Python A-Z™: Veri Bilimi ve Machine...  Veri Bilimi Okulu           17380 4.80000            4621     3466      924      185       46        6                2.43801               5.00000                 4.24988    4.66586               4.49947<br>20                                           Course_9       Instructor_3           12946 4.50000            3371     2191      877      203       33       67                2.07051               3.91634                 3.68156    4.48063               4.16100<br>10        İleri Düzey Excel|Dashboard|Excel İp Uçları  Veri Bilimi Okulu            9554 4.80000            2266     1654      499       91       22        0                1.78937               2.95839                 3.42792    4.64168               4.15618<br>14                       Uçtan Uca SQL Server Eğitimi  Veri Bilimi Okulu           12893 4.70000            2425     1722      510      145       24       24                2.06612               3.09623                 3.50198    4.56816               4.14169<br>2            5 Saatte Veri Bilimci Olun (Valla Billa)       Instructor_1           18693 4.40000            2362     1582      567      165       24       24                2.54684               3.04161                 3.48349    4.51521               4.10252<br>15                      Uygulamalarla SQL Öğreniyorum  Veri Bilimi Okulu           11397 4.50000            2353     1435      705      165       24       24                1.94213               3.03381                 3.36577    4.45481               4.01920<br>4   (2020) Python ile Makine Öğrenmesi (Machine Le...  Veri Bilimi Okulu           11314 4.60000             969      717      194       38       10       10                1.93525               1.83398                 3.02204    4.59567               3.96622<br>19                     Alıştırmalarla SQL Öğreniyorum  Veri Bilimi Okulu            3155 4.80000             235      200       31        4        0        0                1.25901               1.19766                 2.72659    4.72913               3.92811<br>5                                            Course_1       Instructor_2            4601 4.80000             213      164       45        4        0        0                1.37886               1.17859                 2.75165    4.63448               3.88135<br>3     R ile Veri Bilimi ve Machine Learning (35 Saat)  Veri Bilimi Okulu            6626 4.60000            1027      688      257       51       10       21                1.54669               1.88427                 2.93711    4.48208               3.86409<br>6                                            Course_2       Instructor_3            3171 4.70000             856      582      205       51        9        9                1.26033               1.73602                 2.85721    4.50797               3.84767<br>9                        Modern R Programlama Eğitimi  Veri Bilimi Okulu            6537 4.40000             901      559      252       72        9        9                1.53932               1.77503                 2.81623    4.43153               3.78541<br>8            A&#39;dan Z&#39;ye Apache Spark (Scala &amp; Python)  Veri Bilimi Okulu            6920 4.70000             214      154       41       13        2        4                1.57106               1.17945                 2.75990    4.43491               3.76491<br>22  A&#39;dan Z&#39;ye Uygulamalı Hadoop ve Büyük Veri Eği...  Veri Bilimi Okulu            3062 4.40000             169      122       29       13        2        3                1.25130               1.14044                 2.53828    4.39133               3.65011<br>13                                           Course_5       Instructor_6            6056 4.70000             144       82       46       12        1        3                1.49945               1.11877                 2.72186    4.21854               3.61987<br>7   Veri Bilimi için İstatistik: Python ile İstati...  Veri Bilimi Okulu             929 4.50000             126       88       26        9        0        3                1.07451               1.10316                 2.52239    4.34219               3.61427<br>12                                           Course_4       Instructor_5            1901 4.30000             376      218      113       34        8        3                1.15507               1.31990                 2.52869    4.32076               3.60393<br>27                                          Course_15       Instructor_1            1164 4.60000              98       65       24        6        0        3                1.09399               1.07889                 2.56168    4.25394               3.57704<br>28                                          Course_16      Instructor_13            2362 4.50000              95       58       26        9        0        2                1.19328               1.07629                 2.54467    4.19961               3.53763</pre><p>Let’s examine the table;</p><p>Course_9’s high ranking is quite valuable, it has a significant number of reviews and a significant number of purchases. 🎊</p><p>Course_1’s position is also important, it’s a new course with a low number of reviews and purchases but a high score, so it might have potential. 🎊</p><p>Bar_score gives us the chance to move up those that are new but have potential. ✨</p><p>To summarize → 🗣</p><p>When the bar score method is considered as a factor that has weight in a hybrid ranking, it somehow brings up products that have higher potential but have not yet received sufficient social proof.</p><p>You can access the dataset and codes here.</p><p>Stay in good health. 👋</p><p><a href="https://github.com/MRV-1/Product_Sorting">Github Repo : Product Sorting</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94e9db162789" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Product Rating]]></title>
            <link>https://medium.com/@merveatasoy48/product-rating-62cb8079090d?source=rss-a0d572db1a54------2</link>
            <guid isPermaLink="false">https://medium.com/p/62cb8079090d</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[measurement-problem]]></category>
            <category><![CDATA[product-rating]]></category>
            <dc:creator><![CDATA[Merve ÖZKAN]]></dc:creator>
            <pubDate>Tue, 13 Feb 2024 10:34:05 GMT</pubDate>
            <atom:updated>2024-02-13T11:21:44.895Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone 👋, I am here with a pleasant article. ↙</p><p>When a user enters an e-commerce site to purchase a product and performs a search, a page with product information will appear in front of them. After this point, a selection process begins for the user. At this point, there are some situations that affect the user’s purchasing decisions. One of the most prominent purchasing concepts in recent years is the concept of social proof. It is one of the most influential reasons for a user to buy.</p><p>It is tried to obtain an opinion about the product related to how the society reacts to the product. The opinion of the community stands at a very important point due to the comments and scores of the users about the products. The idea that makes societies accept what is accepted is the belief in<strong> the wisdom of crowds</strong>.</p><p>📈<strong>The wisdom of crowds</strong> ↔ Purchasing is a concept that affects marketing processes.</p><p>These social proofs are credited on the basis that such a large number of people cannot be wrong.</p><p>💭Assume that the customer has resolved her indecision about price and brand in the list of products seen as a result of the search and reduced her choice to two products.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*yZuEuVzCPC5DpCI3X3xgOw.png" /><figcaption>Two different products and average product ratings</figcaption></figure><p>Based on the concept of social proof, most of us will prefer the product on the left, because it has more votes than the other one.</p><p>🔈What if the situation was like this?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*G53qxj1_UugfafaRHGC1FQ.png" /><figcaption>Average voting and number of purchases for two different products</figcaption></figure><p>In that case, most of us would prefer the product on the right. Because more people have bought it, more people have approved it.</p><p>👥The goal as a user is to get the most famous best product in terms of price and performance.</p><p>So what is the role of marketplaces ❓</p><p>🖥How a marketplace should deliver products to its users in the most accurate way.</p><p>A marketplace can put products at the top of the product listing with sponsorship. Or they may have some special products and have a specific purpose to keep this product at the top for a while.</p><p>The sensitive point here is that it is necessary to give the social proof touch points with the objectivity and in the right way. Social proof should be presented in the most accurate way to avoid manipulating the market.</p><p>When creating product scoring, some situations occur on the developer side. Now let’s consider these situations by coding them in python. ✨</p><p>Course review dataset includes Rating, Timestamp, Enrolled, Progress, Questions Asked, Questions Answered variables.</p><p>First glance to dataset 👁</p><pre>     Rating            Timestamp             Enrolled  Progress  Questions Asked  Questions Answered<br>0    5.00000  2021-02-05 07:45:55  2021-01-25 15:12:08   5.00000          0.00000             0.00000<br>1    5.00000  2021-02-04 21:05:32  2021-02-04 20:43:40   1.00000          0.00000             0.00000<br>2    4.50000  2021-02-04 20:34:03  2019-07-04 23:23:27   1.00000          0.00000             0.00000<br>3    5.00000  2021-02-04 16:56:28  2021-02-04 14:41:29  10.00000          0.00000             0.00000</pre><p>Let’s try to analyze the characteristics of the data by asking it some questions.</p><p>Distribution according to voting values.</p><pre>df[&quot;Rating&quot;].value_counts()</pre><pre>Rating<br>5.00000    3267<br>4.50000     475<br>4.00000     383<br>3.50000      96<br>3.00000      62<br>1.00000      15<br>2.00000      12<br>2.50000      11<br>1.50000       2</pre><p>What are the votes according to the questions asked ❓</p><pre>df.groupby(&quot;Questions Asked&quot;).agg({&quot;Questions Asked&quot;: &quot;count&quot;, &quot;Rating&quot;: &quot;mean&quot;})</pre><pre>                 Questions Asked  Rating<br>Questions Asked                         <br>0.00000                     3867 4.76519<br>1.00000                      276 4.74094<br>2.00000                       80 4.80625<br>3.00000                       43 4.74419<br>4.00000                       15 4.83333<br>5.00000                       13 4.65385<br>6.00000                        9 5.00000<br>7.00000                        2 4.75000<br>8.00000                        5 4.90000<br>9.00000                        3 5.00000<br>10.00000                       2 5.00000<br>11.00000                       2 5.00000<br>12.00000                       1 5.00000<br>14.00000                       2 4.50000<br>15.00000                       2 3.00000<br>22.00000                       1 5.00000</pre><p>Average score for the product →</p><pre>df[&quot;Rating&quot;].mean()</pre><pre>4.764284061993986</pre><p>When averaged in this way, we may be missing the recent trend in terms of customers for that product or training.</p><p>There may have been some problems with the product recently, so any positive or negative trends in the way the product is presented or handled will have lost their impact.</p><h3>Time-Based Weighted Average</h3><p>By dividing the periods into 30 days, 30–90 days, 90–180 days and more than 180 days and assigning weights to these values, we minimize the possibility of missing the trend.</p><pre>def time_based_weighted_average(dataframe, w1=28, w2=26, w3=24, w4=22):<br>    return dataframe.loc[df[&quot;days&quot;] &lt;= 30, &quot;Rating&quot;].mean() * w1 / 100 + \<br>           dataframe.loc[(dataframe[&quot;days&quot;] &gt; 30) &amp; (dataframe[&quot;days&quot;] &lt;= 90), &quot;Rating&quot;].mean() * w2 / 100 + \<br>           dataframe.loc[(dataframe[&quot;days&quot;] &gt; 90) &amp; (dataframe[&quot;days&quot;] &lt;= 180), &quot;Rating&quot;].mean() * w3 / 100 + \<br>           dataframe.loc[(dataframe[&quot;days&quot;] &gt; 180), &quot;Rating&quot;].mean() * w4 / 100<br><br>time_based_weighted_average(df)</pre><p>In time based weighted averaging, this function will help to solve the problem. When the rows in the function are run individually; it will be seen that there is an increase in satisfaction in recent time.</p><blockquote>So should all users have the same weight?</blockquote><p>In other words, should the rating made by someone who has just enrolled in the course and watched a 1-minute video be the same as the rating made by a person who has completed the entire course?</p><p>No, of course, in many sectors, the concept of user quality comes to the fore in this field.</p><h3>User-Based Weighted Average</h3><p>User based weighted average is one of the general methods used in order to prevent some salesmanship and deception efforts and to make the social proof presentation in the most accurate way.</p><p>The user has bought a product and made a lot of positive comments with 5 points, which misleads customers who will make a purchase.</p><pre>def user_based_weighted_average(dataframe, w1=22, w2=24, w3=26, w4=28):<br><br>    return dataframe.loc[dataframe[&quot;Progress&quot;] &lt;= 10, &quot;Rating&quot;].mean() * w1 / 100 + \<br><br>           dataframe.loc[(dataframe[&quot;Progress&quot;] &gt; 10) &amp; (dataframe[&quot;Progress&quot;] &lt;= 45), &quot;Rating&quot;].mean() * w2 / 100 + \<br><br>           dataframe.loc[(dataframe[&quot;Progress&quot;] &gt; 45) &amp; (dataframe[&quot;Progress&quot;] &lt;= 75), &quot;Rating&quot;].mean() * w3 / 100 + \<br><br>           dataframe.loc[(dataframe[&quot;Progress&quot;] &gt; 75), &quot;Rating&quot;].mean() * w4 / 100<br><br><br>user_based_weighted_average(df, 20, 24, 26, 30)</pre><p>If both of these methods are considered together, the transactions become more logical.</p><pre>def course_weighted_rating(dataframe, time_w=50, user_w=50):<br>    return time_based_weighted_average(dataframe) * time_w/100 + user_based_weighted_average(dataframe)*user_w/100<br><br><br><br>course_weighted_rating(df, time_w=40, user_w=60)</pre><p>When both values are used, product scoring is obtained. 🦋</p><p>I am leaving a link with the full code below, you can review it if you wish. 🙇‍♀️</p><p>Goodbye. 🏄‍♂️</p><p><a href="https://github.com/MRV-1/Product_Rating">Github Repo : For Product Rating</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62cb8079090d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Customer Segmentation with RFM]]></title>
            <link>https://medium.com/@merveatasoy48/customer-segmentation-with-rfm-8db8171eb6d5?source=rss-a0d572db1a54------2</link>
            <guid isPermaLink="false">https://medium.com/p/8db8171eb6d5</guid>
            <category><![CDATA[crm]]></category>
            <category><![CDATA[rfm]]></category>
            <category><![CDATA[customer-segmentation]]></category>
            <dc:creator><![CDATA[Merve ÖZKAN]]></dc:creator>
            <pubDate>Wed, 07 Feb 2024 10:45:25 GMT</pubDate>
            <atom:updated>2024-02-07T11:49:41.134Z</atom:updated>
            <content:encoded><![CDATA[<p>RFM : Recency, Frequency, Monetary consists of the initials Recency, Frequency, Monetary.</p><p>It is one of the first applications that comes to mind when it comes to customer analytics, data science, segmentation, which has been widely used in the business world for a very long time.</p><p>· RFM analysis is a technique used for customer segmentation.</p><p>· It enables customers to be divided into groups based on their purchasing habits and to develop strategies specific to these groups.</p><p>· It provides the opportunity to take action based on data in many topics for CRM studies.</p><h3>RFM Metrics</h3><p>We will create some scores based on RFM Metrics and perform segmentation on these scores.</p><blockquote><strong>Recency (Novelty)</strong>: It refers to the customer’s novelty or the last time they shopped from us.</blockquote><p>If the recency value of one customer is 1 and the other is 10; 1 is better for us. If we talk in daily terms, it means that he shopped 1 day ago.</p><blockquote><strong>Frequency : </strong>It is the total number of purchases made by the customer, in other words, the number of transactions. The frequency metric can be obtained by calculating the purchase (transaction) frequency of customers.</blockquote><blockquote><strong>Monetary (Monetary Value) :</strong> refers to the monetary value left by customers.</blockquote><p>Let’s take it with an example;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*mHs3RIxaCtzkqOKUGSnZAg.png" /><figcaption>R, F, M Values</figcaption></figure><p>We have 1000 customers and they have metrics R,F,M. This data is given in the table.</p><p>The first customer shopped 80 days ago, his shopping frequency is 250 and the total monetary value left is 5200 units.</p><p>When we look at customer number 2, the recency value is 7 (shopped 7 days ago), the shopping frequency is 560 and the total value left is 2300 units.</p><p>If we look at the recency here, which value is better for us, the smaller value is better. Customer 3 with a value of 1 is a warm customer.</p><p>In the Frequecy metric, the larger value is better for us.</p><p>In monetary value, the larger value is better for us.</p><p>Metrics have a comparison problem both within and between each other. For example, in column R, we can see the largest and smallest over 4 observation values.</p><p>The values in all columns should be comparable both within and between each other.</p><p>RFM metrics should be converted into RFM scores.</p><p>Converting these metrics into scores means expressing them all in the same genus. In fact, a kind of standardization will be done. They will all be converted into a form that is comparable both within and between each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*RY1yreDLFO-Rh4SbqSS08g.png" /><figcaption>R, F, M Scores</figcaption></figure><p>The entire audience is converted between 1 and 5. Customer 3 has a monetary value of 3. Therefore it is said that “this customer is somewhere in the average in terms of monetary value”. For example, the monetary value of 5 is at the highest level. Even if not all observation units are visible, it is understood that it has the highest value.</p><p>For us, a low Recency value is good and a high Recency value is bad. Recency parameter is different from Monetary and Frequecy. It will be seen that there will be an inverse proportion when creating the score in this parameter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*1_BSxybSuhQnSrgd-8yt7A.png" /><figcaption>RFM Scores</figcaption></figure><p>RFM scores of 555 are more valuable than those of 111. Since there will be 5 different values in each of the three columns, the RFM score can occur in many combinations.</p><p>Dealing with all the combinations means that we can’t actually segment the customers exactly as we want. There are values close to each other and not all of them can form logical segments. Therefore, a process should be done in such a way that a smaller number of score distinctions in RFM scores form segments that are logical and suitable for business knowledge.</p><p>There is a common method used in the sector for this. Segments will be created accordingly. These scores will be created over two-dimensional visuals commonly used in the sector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xlip8r2hHhaYqFlB9hvsOg.png" /><figcaption>Customer Segments</figcaption></figure><p>Above, customer segments are positioned on the R and F axes.</p><p>The person with a frequency of 5 is the most frequent shopper in the company. These people do not seem to exist recently in terms of recency. Therefore, these are the most valuable customers for us, we are about to lose them. It is categorized as you cannot lose.</p><p>In the At risk class, they have a recency value of 1-2 and a frequency value of 3-4, they have a frequency above the average, but they have been absent recently, so they are a risky group. So before I was looking at all my customers through a single pair of glasses, now it’s very simple.</p><p>Through RFM analysis I now know that there is a champion group, loyal customers, potential loyal customers. These customers can be engaged by a specific employee, but it costs more to find new customers than to keep existing ones. After segmentation of the existing customers, I have customers in classes such as you cannot lose them, risky, requiring attention, and I have their frequency.</p><p>A department sales methods can be determined according to the classes to be determined on this table.</p><p>When it is asked which class should be dealt with more on this table, the can’t lose them class is the class to be dealt with. The at risk class below it is another class that needs to be dealt with. It is necessary to give promotions, discounts and gifts to the champions class. To keep their loyalty up to date.</p><p>A score of 145 corresponds to the at risk class. Monetary was excluded and these segments are created according to R and F values.</p><p>It may seem strange to exclude monetary value, but a customer may have left a lot of money, but this transaction may have been done all at once. The value of the customer is not the money they leave but the frequency of their communication with us or the frequency of their shopping. Because a customer who communicates with us or shops frequently can continue to benefit from this customer with many different marketing approaches through cross-selling methods. Therefore, the number of frequencies is more important for us.</p><p>For this reason, there are R and F values in two dimensions. Various marketing sales approaches and communication approaches can be developed on these segmented table groups.</p><p>RFM analysis was created using pandas dataframes in Python programming language. Those who want to review it can access it from the link below.</p><p><a href="https://github.com/MRV-1/RFM">https://github.com/MRV-1/RFM</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8db8171eb6d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CRM Analytics and CLTV Calculating]]></title>
            <link>https://medium.com/@merveatasoy48/crm-analytics-and-cltv-calculating-41b2127ad957?source=rss-a0d572db1a54------2</link>
            <guid isPermaLink="false">https://medium.com/p/41b2127ad957</guid>
            <dc:creator><![CDATA[Merve ÖZKAN]]></dc:creator>
            <pubDate>Wed, 07 Feb 2024 07:59:46 GMT</pubDate>
            <atom:updated>2024-02-07T11:22:52.351Z</atom:updated>
            <content:encoded><![CDATA[<p>In its general definition, CRM provides the opportunity to realize the relationships to be established with customers from different angles with higher awareness.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*imhErafNf1mh0sKiuhRwkA.png" /><figcaption>Example CRM Stages</figcaption></figure><p>When a brand interacts with its customers, instead of considering them all the same, it can sub-segment them and communicate in a focused, efficient and beneficial way. The basis of this work includes situations such as aiming to make the transactions to be made with limited resources more useful.</p><p>Let’s imagine that a company has 1000 customers, it wants to retain these customers because it costs more to acquire customers. For retention efforts, customers should be segmented and segment-specific behaviors should be developed. Applying the same marketing strategy to every customer will not bring success.</p><p>Customer segmentation can already be done in a rule-based way using the pandas library. I leave a project for this example in the kaggle notebook below. So why are there concepts and application areas such as CRM, RFM, CRM Analytics?</p><p><a href="https://www.kaggle.com/code/merveatasoy1/kural-tabanl-s-n-fland-rma-m-teri-segmentasyonu">https://www.kaggle.com/code/merveatasoy1/kural-tabanl-s-n-fland-rma-m-teri-segmentasyonu</a></p><p>Our main effort with CRM analytics is to try to make customer relationships more efficient in a data-driven way. Customer relationships and processes are somehow handled with data science and data analytics processes and tried to be made more efficient. This effort is called CRM analytics.</p><p>Managing communication with customers based on data can sometimes contribute in terms of labor, sometimes time and sometimes profitability, and in many cases it provides the opportunity to develop strategy. Developing a strategy means more customers, more profit, and more resources with less effort.</p><h3>KPIs — Key Performance Indicators</h3><p>Companies have some KPI definitions to determine performance; for example, customer acquisiton rate is the percentage of customers acquired in a given time period, while customer churn rate is the rate at which a customer leaves the company. Using some of these KPI values, customer lifetime value is derived.</p><p>What is this so-called customer lifetime value?</p><h3><strong>Customer Life Time Value</strong></h3><p>It is the monetary value that a customer will bring to a company during the duration of its relationship-communication with that company.</p><p>If we can calculate the life-time value of our existing customers, we can unitize the costs of finding new customers, which is another concern of ours, then we will have some insight into this issue between finding new customers and existing ones, which we often hear about in theory but which can be a bit more problematic to implement in practice.</p><h3>How to Calculate Customer Lifetime Value?</h3><p>When we look at the literature, there are enough CLTV finding methods to confuse us. Calculating and estimating the CLTV value are different things. Within the scope of this topic, we will simply calculate the CLTV value.</p><figure><img alt="Formülas for CLTV Calculating Process" src="https://cdn-images-1.medium.com/max/1024/1*bNk3o618wdNx2NltcdVuTw.png" /><figcaption>Formülas for CLTV Calcualting Process</figcaption></figure><p>Above all processes are simply formulated.</p><p>Customer Value is our main focus. In Advanced CLTV, we will proceed through two terms found from this customer value equation.</p><p>Churn Rate is the customer abandonment rate and is fixed. There is a company-specific customer churn rate value. It is corrected with Customer Value and divided by it.</p><p>Profit Margin; there will be a profit amount that the company will assume in its shopping with customers.</p><p>Purchase Frequency; since this process will be done for all customers, the value of the total number of transactions is actually scaled for all customers. The effect of the whole mass is reflected by a simple division process.</p><p>Churn Rate; customer abandonment rate</p><p>The company has stated that it makes 10% profit from its sales. When this profit amount is multiplied by the total price left by each customer, the profit from the transaction will be calculated.</p><p>Let’s consider the formulas through an example;</p><p>The company has a 0.8 customer abandonment rate.</p><p>Let’s adapt it for this customer, the total number of transactions is 3. In one transaction, he made a transaction of 300 units, in another transaction 400, in another 500 br. The number of transactions is 3 and the total price paid is 1200 units.</p><p>Attention, in the detail of the transaction here, he may have bought 10 of the product of 30 units, we are not interested in this. What is important for us is the transaction. In other words, there is an invoice issuance transaction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*pK6qXt-x2Ky0AeOl8RhE9Q.png" /><figcaption>Example of CLTV Calculating</figcaption></figure><p>The CLTV value is set to 1800, once we have this value, we can sort the total prices left by each customer in descending order.</p><p>When we consider the problem in these dimensions, we obtain a value for the lifetime value of our customers, which is somewhat different from what is done in classical segmentation.</p><p>As a result, when a ranking is made according to the CLTV values to be calculated for each customer and groups are formed by dividing at certain points according to the CLTV values, our customers will be segmented.</p><p>I am sharing a github repo that contains the entire process described here. You can also examine it through the code. The code was developed in Python using pandas dataframes.</p><p><a href="https://github.com/MRV-1/CLTV">https://github.com/MRV-1/CLTV</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41b2127ad957" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Veri Biliminde NumPy]]></title>
            <link>https://medium.com/@merveatasoy48/veri-biliminde-numpy-561c9be457e2?source=rss-a0d572db1a54------2</link>
            <guid isPermaLink="false">https://medium.com/p/561c9be457e2</guid>
            <dc:creator><![CDATA[Merve ÖZKAN]]></dc:creator>
            <pubDate>Tue, 30 Jan 2024 10:33:11 GMT</pubDate>
            <atom:updated>2024-01-31T10:34:11.022Z</atom:updated>
            <content:encoded><![CDATA[<p>Numerical Python extensions (NumPy) bilimsel hesaplamalar için kullanılmaktadır. Dizi ve matrisler üzerinde yüksek performanslı çalışma imkanı sağlamaktadır. 💯</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*JpLqtfN612SO4JYFgqPqsQ.png" /></figure><p>Temelleri 1995 yılında atılmıştır. Python’un kurucusu olan Guido Van Rossum’da içinde bulunduğu grup tarafından inşa edilmiştir. Bu grubun amacı Python programlama dilini kullanarak natematiksel ya da <br>istatistiksel bazı ihtiyaçları da karşılayabilcek bir kütüphane oluşturmaktır.<br>Python’da NumPy matematik ve istatistik dendiğinde akla gelen ilk kütüphanelerden biridir. NumPy Python’da temel programlama dünyasından veri analitiği dünyasına bir yol oluşturan kütüphanedir. 🎯</p><h3>Peki neden veri biliminde NumPy’ı tercih edelim ?</h3><blockquote>Daha az çabayla daha fazla işlem için NumPy. 🚀🚀</blockquote><p>Aslında neden NumPy sorusuna 2 madde ile cevap verilebilir;</p><h4>1) Hız 🕛</h4><p>NumPy içerisinde veri tutarken fix type adını verdiği sabitlenmiş tipte veri tutma işlemi gerçekleştirerek listelere kıyasla çok daha hızlı bir şekilde işlem yapma imkanı sağlar. ✔<br>Örneğin; bir liste içerisinde 10 eleman varsa hepsi farklı tipte ise; listeler her bir elemanın tip ve boyut ve diğer bazı meta bilgilerini ayrı ayrı tutmaktadır. NumPy ise veriyi sabit bir tipte tutar. Örneğin tamamı integer olacaktır. İçerisinde sadece aynı tipte veriyi barındıracağından dolayı verimli saklama işlemi yapar. Buda NumPy array’lere hızlı olma özelliği kazandırır. 🤙</p><p>Aşağıdaki kod satırında bu hız işlemini ele alalım;</p><pre>arr = np.array([1, 2, 3, 4, 5])<br>arr[0] = 5.9</pre><p>Kodda 5 elemandan oluşan bir array’in ilk indeksine 5.9 değeri atandı. Array içerisinde elemanların veri yapısı tipi integer iken yeni atanan elemanın veri yapısı float’tır. Normalde array görüntülendiğinde çıktının;</p><pre>array([5.9, 2, 3, 4, 5])</pre><p>olmasını bekleriz ama sonuç;</p><pre>array([5, 2, 3, 4, 5])</pre><p>olacaktır. Çünkü NumPy gelen verinin yapısına baktı ve dedi ki; <em>“benim veri setimdeki veri yapısı integer değerlerde oluşmakta o zaman ben senide integer tutmalıyım ki hız kazanabileyim”</em></p><p>NumPy’ın hız sebebini örnekle ele aldık, şimdi diğer tercih sebebine geçelim. ⬇</p><h4>2) Yüksek Seviyeli Vektörel İşlemler 💎</h4><p>Diğer programlama dillerinde iç içe döngülerle çözüm bulunan işlemleri NumPy birkaç satırda sonuçlandırır. Yüksek seviyeli vektörel işlemler yapmaya olanak sağlar.</p><p>Örneğin elimizde bir array olduğunu ve 5&#39;ten küçük olanların filtrelenmesi gerektiğini varsayalım. İlk aşamada bunu klasik for döngüsü yöntemi ile gerçekleştirelim;</p><pre>ab = []<br>  for i in v:<br>     if i &lt; 3 :<br>       ab.append(i)</pre><p>Yukarıda yer alan kod parçacığı v listesindeki tüm elemanları teker teker dolaşacak ardından koşulu sağlayanları ab listesine ekleyecektir.</p><p>Şimdi birde bunu NumPy ile gerçekleştirelim;</p><pre>v[v &lt; 3]</pre><p>Tek satırda işlem çözüldü. Yüksek seviyeli işlem dediğimizde bu aslında. Daha az çaba ile çalışmayı sağladı. 🙅‍♀️</p><p>Özetle veri bilimi alanında ilerliyorsanız, Python ya da R’ tercih edeceksiniz demektir. Python’da array’ler ile high level işlemler yapabilmek için NumPy ele alınan sebeplerden dolayı tercih edilesi duruyor. 💠<br>Ayrıca NumPy ile yeni tanışanlar için temel seviye işlemlerini içerisinde barındıran ve veri biliminin temeli olan NumPy array’leri ile gerçekleştirilen kodları bir Github repo’su oluşturarak sizin için paylaştım. İncelemek isteyenler aşağıdaki linkten ulaşabilirler.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*KPCR8WyHhSuWR4Id3K2CJQ.png" /></figure><p>↪</p><p><a href="https://github.com/MRV-1/NumPy">GitHub - MRV-1/NumPy</a></p><p>Daha az çaba ile daha fazla işlem için NumPy diyoruz ve yazımızı burada sonlandırıyoruz. 👌</p><p>Sonraki yazıda buluşana kadar keyifle kalın… 🌞🤙<br>©</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=561c9be457e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Perceptron mimarisinde Python ile AND Mantık Kapısının Kodlanması]]></title>
            <link>https://medium.com/@merveatasoy48/perceptron-mimarisinde-python-ile-and-mant%C4%B1k-kap%C4%B1s%C4%B1n%C4%B1n-kodlanmas%C4%B1-562cd71ac0ce?source=rss-a0d572db1a54------2</link>
            <guid isPermaLink="false">https://medium.com/p/562cd71ac0ce</guid>
            <dc:creator><![CDATA[Merve ÖZKAN]]></dc:creator>
            <pubDate>Sun, 26 Mar 2023 13:18:14 GMT</pubDate>
            <atom:updated>2023-03-27T07:05:28.685Z</atom:updated>
            <content:encoded><![CDATA[<p>Perceptron tek katmanlı bir yapay sinir ağının temel birimidir. Eğitilebilecek tek bir sinir hücresinden meydana gelmektedir. Giriş değerleri, ağırlıklar ve sapma, ağırlıklı toplam ve aktivasyon işlemi olmak üzere 4 kısımdan meydana gelir. Hem giriş hemde çıkış değerleri ağa verilir ve sinir ağının öğrenmesi beklenir. Dolayısıyla denetimli öğrenme gerçekleştirir.</p><p>1957&#39;de Cornell Havacılık Laboratuvar’ında Amerikalı psikolog Frank Rosenblatt tarafından bulunmuştur.</p><p>Aşağıda Perceptron mimarisine ait örnek görüntüye yer verilmiştir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*RNVegfC_ilprnIxmrCXMrQ.png" /></figure><p>Dilerseniz şimdi görselde yer alan ağırlıkların, girdilerin ağa sunulması ve ağın öğrenmeyi gerçekleştirmesi işlemlerini kodlayarak öğrenelim. Ben bu yazımda AND Mantık Kapısı problemi üzerinden Percepton mimarisinde model oluşturacağım.</p><h3><strong>AND(VE) Mantık Kapısı Problemi</strong></h3><p>Hepimiz AND kapısının nasıl çalıştığını biliyoruz. X1 vektörüne ait değerler 0,0,1,1 ve X2 vektörüne ait değerler 0,1,0,1 iken beklenen çıktı değerleri 0,0,0,1 şeklinde olmalıdır. Bu bilgileri ait tabloyu aşağıda görebilirsiniz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*edB8_WVM0rgIZk5kMyL_Fg.png" /></figure><p>Perceptron modelini gerçekleyebilmek için X1 ve X2 vektörlerine ait W1 ve W2 vektörleri tanımlanmalıdır. Bu değerler mimariye ait ağırlık vektörleridir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*iaX9YRGDj0Fo5BxNKv5I_Q.png" /></figure><p>Buradaki değerler rastgele atanan girdilerdir. W1 ve W2 ağırlıkları aynı olmak zorunda değildir. Ben bu şekilde tercih ettim. Sizde linkini birazdan bırakacağım kodu indirerek üzerinde değişiklikler yapabilirsiniz.</p><h3><strong>Probleme Ait Parametrelerin Tanımlanması</strong></h3><p>Mimari içerisinde tanımlanması gereken bias ve threshold değerleri yer almaktadır.</p><p>Bias ağırlıkların güncellenmesi aşamasında kullanılması gereken değerdir. Bu değerin çok büyük seçilmesi istenen ağırlıktan bir anda çok fazla uzaklaşmaya sebep olurken, çok küçük seçilmesi hedeflenen ağırlığa ulaşmada iterasyon sayısını oldukça artıracaktır.</p><p>Fakat buradaki amaç ağırlıkların güncellenerek mimarinin ürettiği çıktıyı beklenen çıktı ile eşitleyebilmek, yani doğru sonuçları üretebilmek olduğundan çok fazla iterasyon sayısına rağmen bias katsayısının çok yüksek tutulması önerilmez.</p><p><strong>∑</strong> xi*wi formülü kullanılarak elde edilen değer bir aktivasyon fonksiyonuna girdi olarak verilir. Aktivasyon fonksiyonu olarak sigmoid sıklıkla tercih edilir. 0-1 arasında çıktı üreten ve yaygın bir şekilde kullanılan bu fonksiyonun threshold değeri AND Mantık Kapısı problemi için 1.5 olarak belirlenir.</p><p>Threshold değerinin 1.5 olarak belirlenmesi demek; toplam fonksiyonundan dönen değer 1.5&#39;ten büyük olduğunda 1, küçük olduğunda 0 değerini çıktı olarak üret demektir.</p><pre>#AND MODEL<br>x1 = [0,0,1,1]<br>x2 = [0,1,0,1]<br>waitedOutput =  [0,0,0,1]<br>w1 = [1.2,1.3,1.4,0.5]<br>w2 = [1.2,1.3,1.4,0.5]<br>threshold = 1.5 <br>bias = 0.1<br>fNET = 0</pre><h3>Ağırlıkların Hesaplanması</h3><h4><strong>∑</strong> xi*wi</h4><p>formülü ile matris çarpımı gerçekleştirilerek Transfer Fonksiyonunda FNet değeri bulunur. Aşağıdaki kod satırları bu işlemi gerçekleştirmektedir.</p><pre>def weighted_sum(i):<br>    fNET = x1[i]*w1[i]+x2[i]*w2[i];<br>    return fNET</pre><h3>Aktivasyon Fonksiyonu</h3><p>Fonksiyona gönderilen FNet değeri belirlenen eşik değerinden büyükse 1, değilse 0 çıktısını döndüren kod satırlarına aşağıda yer verilmiştir.</p><pre>def activation_func(fNET):<br>    if fNET&gt;threshold:  <br>       output=1<br>    else:<br>       output=0<br>    return output</pre><h3>Ağırlıkların Yeniden Hesaplanması</h3><p>waitedOutput parametresi ile aktivasyon fonksiyonundan dönen değer(Ç) eşit değilse o satıra ait W1 ve W2 değerlerinin güncellenmesi gerekir.</p><p>Ç ile waitedOutput döngünün i. satırında birbirine eşit ise herhangi bir işlem yapma.</p><ol><li>Elde edilen çıktı beklenen değerden büyük ise;</li></ol><p>W1 ve W2 ağırlıklarını, X vektörünün o anki değeriyle bias katsayısını çarparak çıkar. Sonuçta elde edilen çıktı değerini azaltmayı hedefle.</p><p>2. Elde edilen çıktı beklenen değerden küçük ise;</p><p>W1 ve W2 ağırlıklarını, X vektörünün o anki değeriyle bias katsayısını çarparak topla. Sonuçta elde edilen çıktı değerini artırmayı hedefle.</p><p>Python ile bahsedilen cümleleri kodlayalım.</p><pre>def agirliklari_yeniden_hesapla(Ç,i):           <br>    if( Ç != waitedOutput[i] ):<br>        if Ç &gt; waitedOutput[i]:<br>            w1[i] = w1[i] - bias * x1[i]<br>            w2[i] = w2[i] - bias * x2[i]<br>        else :<br>            w1[i] = w1[i] + bias * x1[i]<br>            w2[i] = w2[i] + bias * x2[i]<br></pre><h3>Sinir Ağının Gerçeklenmesi</h3><p>waitedOutput matrisindeki tüm değerler ile aktivasyon fonksiyonun oluşturduğu çıktı değerlerinin tamamı eşit oluncaya kadar ağırlıklar güncellenmeli, algoritma iteratif bir şekilde devam etmelidir.</p><p>Ben içe içe iki for döngüsü ile şu şekilde bu işlemi sağladım;</p><pre>for i in range(3):                                   <br>    for j in range(len(waitedOutput)):<br>        a = weighted_sum(j);                         #x1 ve x2&#39;nin sırasıyla netleri hesaplanacak<br>        Ç = activation_func(a)                      #step_func=activation_func çıktı değeri üretecek<br>        agirliklari_yeniden_hesapla(Ç,j)            #hatalı çıkışlar için ağırlıklar yeniden hesaplanacak<br></pre><p>Dışarıdaki for döngüsünde range() alanına 1 yazılırsa tüm akış 1 kere çalıştırılacak demektir. Bu durumda bias parametresi 0.1 alındığından ağırlık güncellemesi istenen değere ulaşmamış olabilir. Dolayısıyla range() alanına 4,5,6 gibi değerler yazılmalı ağırlıkların hangi döngü değerinde güncellemesi duruyorsa o rakam range()’in parametre değeri olarak atanmalıdır.</p><p>Ben burada 3 sefer tüm akışı çalıştırdığımda ulaşmak istediğim çıktı değerlerini elde ettiğimi gördüm bu sebepten range(3) olarak tune ettim.</p><h3>KODLARIN ÇALIŞTIRILMASI VE ADIM ADIM İNCELENMESİ</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KVhktkr4QzYKDCmEMPrScw.gif" /></figure><p>i=0, j=0 iterasyonunda aşağıdaki atamalar gerçekleştirilir;</p><p>Sinir ağının ağırlıklarda herhangibir güncelleme yapmadığını görürüz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*01DNB50fNDHHvhHFvW6RuQ.png" /></figure><p>i=0, j=1 iterasyonunda aşağıdaki atamalar gerçekleştirilir;</p><p>Bu aşamada da herhangi bir ağırlık güncellemesine ihtiyaç olmayacaktır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*YL72VmxZguV_hG4lbz8gPA.png" /></figure><p>i=0, j=2 iterasyonunda aşağıdaki atamalar gerçekleştirilir;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*CmcxjBEm8864DqQRZuh_KA.png" /></figure><p>i=0, j=3 iterasyonunda aşağıdaki atamalar gerçekleştirilir;</p><p>Burada durum diğerlerinden farklıdır. Sinir ağından üretmesi beklenen çıktı ile ağın ürettiği çıktı aynı değildir. Bu sebepten öğrenmeye ihtiyacı var ve ağırlıklarını güncellemelidir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*8n6W5QXYgFHsMVhGKCQIcw.png" /></figure><p>Ağırlıklarını bu aşamada güncelledi. Fakat 0.6 değeri beklenen çıktı değerinin üretilmesi için yeterli bir katsayı değildir. Bunun için dışarıdaki for döngüsünün 2 defa daha içerisindeki işlemleri yeniden gerçekleştirmeye ihtiyacı vardır.</p><p>i=1, j=3 için w1 = 0.7, w2 = 0.7</p><p>i=2, j=3 için w1=0.79, w2 = 0.79</p><p>Güncellenen bu ağırlıklarla, hatalı elde edilen çıktı değeri yerine hedeflenen değere ulaşmış bulunmaktayız.</p><p>Yukarıda bahsedilen kodların tamamına aşağıda yer alan github linkinden ulaşabilirsiniz.</p><p><a href="https://github.com/merveatasoy/Perceptron.git">GitHub - merveatasoy/Perceptron: Coding AND Logic Gate with Python in Perceptron Architecture</a></p><h3>OR(VEYA) Mantık Kapısı Problemi</h3><p>Sizde perceptron sinir ağı mimarisini kullanarak github’da linkini paylaştığım bu kod üzerinden OR Mantık Kapısı problemini modelleyebilirsiniz. Problemin girdileri ve waitedOutput parametresi aşağıdaki görseldeki gibi olmalıdır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*wtz1BgK3rZMY5InhvaXdHQ.png" /></figure><p>Ufak bir ipucu :)<br>Aktivasyon fonksiyonunda yer alan threshold parametresini bu problemde 1.5 olarak almanız hatalı sonuç üretmenize sebep olacaktır.</p><p>Bu sebepten Threshold değerini 0.5 almanızı öneririm.</p><p>Sağlıcakla kalın :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=562cd71ac0ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>