<?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 Ömer Yıldız on Medium]]></title>
        <description><![CDATA[Stories by Ömer Yıldız on Medium]]></description>
        <link>https://medium.com/@yildiz.omer.92?source=rss-544ff2e451c3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*KKOiJ8-07BXIYzn3vBADBQ.jpeg</url>
            <title>Stories by Ömer Yıldız on Medium</title>
            <link>https://medium.com/@yildiz.omer.92?source=rss-544ff2e451c3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 16:40:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yildiz.omer.92/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[AWS (Amazon Web Service) EC2 Makineye Apache Spark Kurulum Aşamaları-TR]]></title>
            <link>https://medium.com/@yildiz.omer.92/aws-amazon-web-service-ec2-makineye-apache-spark-kurulum-a%C5%9Famalar%C4%B1-tr-ba7d3b38b17a?source=rss-544ff2e451c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba7d3b38b17a</guid>
            <category><![CDATA[spark]]></category>
            <category><![CDATA[apache]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[hadoop]]></category>
            <dc:creator><![CDATA[Ömer Yıldız]]></dc:creator>
            <pubDate>Mon, 30 May 2022 21:31:41 GMT</pubDate>
            <atom:updated>2022-05-30T21:31:41.831Z</atom:updated>
            <content:encoded><![CDATA[<p>Merhaba. Bu yazımda <a href="https://medium.com/@yildiz.omer.92/aws-amazon-web-service-%C3%BCzerinden-ec2-ubuntu-i%CC%87%C5%9Fletim-sistemli-makine-a%C3%A7ma-ve-uzaktan-ba%C4%9Flant%C4%B1-8ddeda4a79a?source=user_profile---------0----------------------------">AWS(Amazon Web Service) Üzerinden EC2 Makine Açma ve Uzaktan Bağlantı Aşamaları-TR</a> paylaşımımın ardından, açtığımız makineye Spark‘ı nasıl kuracağımızı aktarmaya çalışacağım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*Uq6gyU9HohtXuSD3HaQkww.png" /></figure><p>Önceki yazımda EC2 makineyi açmış idik. Bu makine üzerinden kurulum aşamalarını sürdüreceğiz. İlk aşamaya geçmeden önce <a href="https://medium.com/@yildiz.omer.92/aws-amazon-web-service-%C3%BCzerinden-ec2-ubuntu-i%CC%87%C5%9Fletim-sistemli-makine-a%C3%A7ma-ve-uzaktan-ba%C4%9Flant%C4%B1-8ddeda4a79a?source=user_profile---------0----------------------------">AWS(Amazon Web Service) Üzerinden EC2 Makine Açma ve Uzaktan Bağlantı Aşamaları-TR</a> 2.5. Adım PuTTy bağlantısını yaparak makinemizi açıyoruz.</p><p><strong><em>1.Adım update’leri kontrol et ve uygula.</em></strong></p><blockquote>sudo apt-get update</blockquote><p>Bu kod parçacığı ile makinemizde <a href="https://itsfoss.com/apt-get-linux-guide/"><strong><em>apt</em></strong></a><strong><em> </em></strong>(advanced package tool) kullanarak paket güncellemelere bakıyor ve yüklüyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*QaFvUEzAkPmcUz8EBA_ceg.png" /></figure><p><strong><em>2.Adım jupyter yükle</em></strong></p><blockquote>sudo apt install python3-pip</blockquote><p>Python paketlerini kurabilmek için önce <strong><em>pip3</em></strong>&#39;ü yüklüyoruz. Bunu yapmak için de python3-pip paketini kurmalıyız.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*xgGsDkpUM13QbuODwbYYhQ.png" /></figure><p>Bu kısımda karşımıza çıkan soruya <strong><em>y</em></strong> yazıp <strong><em>enter</em></strong>’a basıyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*-aZrmJ-nuy4dM-NEb6F4hQ.png" /></figure><p>Şimdi pip3 vasıtası ile <strong><em>jupyter</em></strong><em>’</em>ı<strong><em> </em></strong>kurabiliriz.</p><blockquote>pip3 install jupyter</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*PvTRN9BAEbezFdthuWVshQ.png" /></figure><p><strong><em>3.Adım </em></strong><a href="https://www.infoworld.com/article/3296360/what-is-the-jdk-introduction-to-the-java-development-kit.html"><strong><em>default-jdk</em></strong></a><strong><em> (oracle java development kit) yükle</em></strong></p><blockquote>sudo apt-get install default-jdk</blockquote><p>Spark’ı yükleyebilmek için Scala, Scala’yı yükleyebilmek için ise Java’ya ihtiyacımız vardır.</p><p>Bu kod parçacığı ile de java development kit yüklüyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*N6DCMgeqf0w09eu7Is_mqw.png" /></figure><p>Bu kısımda karşımıza çıkan soruya <strong><em>y</em></strong> yazıp <strong><em>enter</em></strong>’a basıyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*6Kp1EIr879p-RZvkfE2ObQ.png" /></figure><p><strong><em>4.Adım </em></strong><a href="https://www.redhat.com/en/topics/cloud-native-apps/what-is-a-Java-runtime-environment"><strong><em>default-jre </em></strong></a><strong><em>(java runtime environment) yükle</em></strong></p><blockquote>sudo apt-get install default-jre</blockquote><p>Bu kod parçacığı ile java runtime environment yüklüyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*7lkJdVjoD3o3y8NI-akwJw.png" /></figure><p><strong><em>5.Adım </em></strong><a href="https://www.scala-lang.org/"><strong><em>scala </em></strong></a><strong><em>yükle</em></strong></p><blockquote>sudo apt-get install scala</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*i--ZQyK_xsHYUOQ22DMMBA.png" /></figure><p>Bu kısımda yine karşımıza çıkan soruya <strong><em>y</em></strong> yazıp <strong><em>enter</em></strong>’a basıyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*b958mgye4fGZBrRDipVJjw.png" /></figure><p><strong><em>6.Adım py4j yükle</em></strong></p><p>Makinemizdeki Java ile Python’ın konuşabilmesi için py4j köprüsünü kuruyoruz. py4j, sayesinde Python, Java nesnelerine dinamik olarak erişebilmektedir.</p><blockquote>pip3 install py4j</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*dGhv5dUVvA8X9a8Q5tVsoA.png" /></figure><p><strong><em>6.Adım versiyon kontrolü yap</em></strong></p><p>Java versiyon kontrolü : 11.0.015</p><blockquote>java -version</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*J_B8zxfe45L36KAFQxJV_Q.png" /></figure><p>Scala versiyon kontrolü : 2.11.12</p><blockquote>scala -version</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*rxSqZxvHnio0ZjhYwMDG0w.png" /></figure><p>Python versiyon kontrolü : 3.6.9</p><blockquote>python3 --version</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*tPaw4nrwWgAsAfeki4L3wQ.png" /></figure><p>Bu konfigürasyonlar ilerleyebilmek için yeterlidir. Versiyon uyumsuzlukları ile birlikte onlarca sorun karşımıza çıkmaktadır. Bu sebeple uygun versiyonlar ile ilerlemeliyiz.</p><p>Diğer yandan Spark kurulumu için gerekli olan Scala, Java, Python üçlüsünün de kurulu olduğunu teyit etmiş olduk. Artık Spark kurulumuna geçebiliriz.</p><p><strong><em>7.Adım kurulum için spark tar formatlı dosyasını indir</em></strong></p><blockquote>wget http://archive.apache.org/dist/spark/spark-2.1.1/spark-2.1.1-bin-hadoop2.7.tgz</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*3to-rt9uLgYd9a0y7kEPmw.png" /></figure><p><strong><em>ls</em></strong> (list)komutu ile bulunduğumuz dizindeki mevcut dosya ve klasörleri listeleyebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*1HvB0FB-8jLZ_vsTCEP2pQ.png" /></figure><p>Dosyaların indirildiğini görüyoruz. Şimdi unzip ile dosyaları çıkartmalıyız.</p><p><strong><em>8.Adım indirilen dosyaları unzip edin</em></strong></p><blockquote>sudo tar -zxvf spark-2.1.1-bin-hadoop2.7.tgz</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*SPMiijF4md2u3kUXcu8J4w.png" /></figure><p><strong><em>ls </em></strong>(list) ve <strong><em>cd</em></strong> (change directory)komutlarını kullanarak dosyaların unzip edilip edilmediğini kontrol ediyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*44tcxcrw0TrpRImYNrOtnA.png" /></figure><p><strong><em>cd </em></strong>(change directory) ile ana dizine gelebiliriz.</p><p><strong><em>9.Adım findspark’ı kur</em></strong></p><blockquote>pip3 install findspark</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*bW2j7GvQ1E1mmGNM8u08sg.png" /></figure><p><strong><em>10.Adım jupyter yapılandırması oluştur</em></strong></p><blockquote>jupyter notebook --generate-config</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*f69vSttiiC08HamX-ZXWpA.png" /></figure><p><strong><em>11.Adım .pem file oluştur ve konfigurasyon dosyasını düzenle</em></strong></p><p><strong><em>cd</em> </strong>(change directory) komutu ile en üst -ana- dizine geliyoruz.</p><p>Ardından ana dizinde aşağıdaki kod parçası ile certs adında bir klasör oluşturuyoruz.</p><p><em>mkdir</em> (make directory)</p><blockquote>mkdir certs</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*IuVL5vDvfCpKHUjHCIB98A.png" /></figure><p><strong><em>ls </em></strong>(list)<strong><em> </em></strong>ile listeleme yaptığımızda certs klasörünün oluşturulduğunu görüyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*Lyl66lsuPVIB9RUTBxKJig.png" /></figure><p>Şimdi certs klasörünün içine gireceğiz. Bunun için <strong><em>cd </em></strong>(change directory) komutunu kullanıyoruz.</p><blockquote>cd certs</blockquote><p>Aşağıda gördüğünüz gibi içinde bulunduğumuz dizin de değişmiş oldu. Artık certs klasörü içindeyiz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*ihIhbRsxi0-W7mu6bwzkxQ.png" /></figure><p>İlgili konfigurasyonlarda pem dosyası oluşturuyoruz.</p><blockquote>sudo openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*oNd3-o1tuo58VYpQ5JRtBA.png" /></figure><p>Önümüze çıkan soruları <strong><em>enter </em></strong>ile geçiyoruz:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*nuVJZug4gUrT2O3KDKLYWw.png" /></figure><p>Şimdi tekrar jupyter dizinine gidiyoruz. Hatırlarsanız bu dizin değişimlerini <strong><em>cd </em></strong>(change directory) komutu ile yapıyorduk.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*fcdjvDx0NtO55eE7_a_8-w.png" /></figure><p>Gördüğünüz üzere artık jupyter dizinindeyiz.</p><p><strong><em>ls </em></strong>(list)<strong><em> </em></strong>ile içerdeki dosyaları listelediğimizde jupyter_notebook.config.py konfigurasyon dosyamızı görüyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*Z4XJiIRGRLV5zm-v0fm12A.png" /></figure><p>Şimdi konfigurasyon dosyamızın içine girip birtakım ayarları düzenleyeceğiz. Bunun için <strong><em>vi </em></strong>(visual editor) editörünü kullanıyoruz. (Dizin değiştirmediğimiz için cd kullanmadık.)</p><blockquote>vi jupyter_notebook.config.py</blockquote><p>Kodu çalıştırdığımızda karşımıza aşağıdaki gibi bir editör penceresi açılacak.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*AcLGi5tz7FleJkQjb2DE5A.png" /></figure><p>Bu adımda klavyeden i tuşuna basıyoruz.(Insert komutu demektir.)</p><p>Aşağıda INSERT komutunun çalışacağını görünce de enter’a basıyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*LF2xGZZ213ZXukArdvgmWQ.png" /></figure><p>Ardından aşağıdaki kod parçasını buraya kopyalayıp yapıştırıyoruz.</p><blockquote>c = get_config()</blockquote><blockquote>c.NotebookApp.certfile = u’/home/ubuntu/certs/mycert.pem’</blockquote><blockquote>c.NotebookApp.ip = ‘*’</blockquote><blockquote>c.NotebookApp.open_browser = False</blockquote><blockquote>c.Notebook.ports = 8888</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*CZeF74ziWSKzgLPc5vEqSw.png" /></figure><p>Yapıştırmanın ardından <strong>esc </strong>tuşuna basıyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*pgQ9Tj9wUhT60JU_DE9oKA.png" /></figure><p>Artık düzenleyicinden çıkmış bulunuyoruz. Önceki dizine çıkmak için bu adımda aşağıdaki çıkış komutunu kullanıyoruz.</p><blockquote>:wq!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*zR5R9OU2N5D2SerIeuxVxQ.png" /></figure><p>Ardından <strong><em>enter</em></strong>’a basarak üst dizine çıkabiliriz.</p><p>Bu işlemi certs klasörü içinde oluşturduğumuz .pem file’ın konfigurasyonlarını düzenleyebilmek için yapmış olduk.</p><p>Artık tüm düzenlemeler bitti ve jupyter notebook’u açıp spark’ı kullanma vakti geldi.</p><p>Hatırlarsanız en son vi ile jupyter_notebook.config.py içinde bazı düzenlemeler yapıp üst dizine çıkmıştık ki burası jupyter klasörü idi.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*qogz2lHFdTJ8ds7UAELemQ.png" /></figure><p>Buradan da dizin değiştirmek için bildiğiniz gibi <strong>cd</strong> (change directory) komutunu kullanıyoruz ve ana dizine ulaşıyoruz.</p><p>Artık ana dizine çıkmış bulunuyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*JR7Fra4S24A1c2XazBBFVQ.png" /></figure><p>Şimdi jupyter notebook’u açma vakti. Bunun için aşağıdaki kodu kullanıyoruz.</p><blockquote>jupyter notebook --ip=*</blockquote><p>Makineye mevcut ve ulaşılabilir tüm IP’ler üzerinden jupyter notebook’u aç dedik.</p><p>Karşımıza bağlanabileceğimiz URL’in olduğu bir kod satırı gelecektir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*pV0Mr_tAuYfJvPPfURhskw.png" /></figure><p>Bu adımda ok ile işaretlenen URL’i tarayıcımızda yeni bir sekme açarak arama kutucuğuna yapıştırıyoruz.</p><p>Burada prompt ekranından kopyalama yaparken <strong><em>CTRL + Shift + C</em></strong> kombinasyonunu kullanmanızı tavsiye ederim. <strong><em>CTRL + C</em></strong> kombinasyonu shell’in kapanmasını tetikleyebilir.</p><p>Ayrıca URL’i yapıştırırken arada boşluk kalmamasına dikkat etmeliyiz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*2Orzx_9J_YUV6h8YCfQGwQ.png" /></figure><p>Yapıştırdığımız URL’in aşağıdaki bloğu yerine AWS üzerinde yer alan <strong><em>Public IPv4 DNS</em></strong>’i yapıştırıyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*ckQevcG8TpnN23WPQ1qYig.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9GFD9DZBGVZIYHraEXfddg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*14N15ofH1P3PPbBuvI025A.png" /></figure><p>Yani URL son durumda şu hale gelmiş oluyor :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*na2Aj267Jdx_YJhT6nHfDw.png" /></figure><p>Kırmızı ile işaretlenmiş alanda<em> </em><strong><em>Public IPv4 DNS</em></strong> mevcut.</p><p>Enter’a tıkladığınızda jupyter ekranı açılacaktır.</p><p><strong>**BONUS**</strong></p><p>Bu kısımda <strong><em>enter</em></strong>’a tıkladığınızda Jupyter Notebook açılmıyorsa ve hata veriyorsa sorun ekseriyetle PATH ile ilgilidir. Bu durumda şu adımları takip edebilirsiniz.</p><p>PuTTy ile temiz bir prompt açın. (Nasıl açıldığını bir önceki yazımda 2.3. adımdan itibaren bulabilirsiniz.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*emSNzKbMW5hDWGeLfu7ERg.png" /></figure><p>Aşağıdaki kodu yapıştırın ve çalıştırın.</p><blockquote>export PATH=$PATH:~/.local/bin/</blockquote><p>Bu makinenin doğru path’e yönlendirilmesini sağlayacaktır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*UIq0J75pRYjSzmA2PigTEw.png" /></figure><p>Ardından aşağıdaki koddan itibaren yukarıdaki adımlar ile aynı yolu takip edin.</p><blockquote>jupyter notebook — ip=*</blockquote><p>Spark kurulu şekilde Jupyter Notebook açılacaktır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hDfZYLS93Srenx2lnxc5Kw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba7d3b38b17a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS(Amazon Web Service) Üzerinden EC2 Makine Açma ve Uzaktan Bağlantı Aşamaları-TR]]></title>
            <link>https://medium.com/@yildiz.omer.92/aws-amazon-web-service-%C3%BCzerinden-ec2-ubuntu-i%CC%87%C5%9Fletim-sistemli-makine-a%C3%A7ma-ve-uzaktan-ba%C4%9Flant%C4%B1-8ddeda4a79a?source=rss-544ff2e451c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ddeda4a79a</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ec2-instance]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[putty]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <dc:creator><![CDATA[Ömer Yıldız]]></dc:creator>
            <pubDate>Thu, 12 May 2022 00:17:37 GMT</pubDate>
            <atom:updated>2022-05-12T10:58:40.261Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*CgdwiAUQ6Pl8cYsIjmjiGg.png" /></figure><p>Blogumun bu yazısında Amazon Web Hizmeti üzerinden EC2 makine açma ve uzaktan bağlantı aşamalarından bahsetmek istiyorum. Bu yazının devamında açmış olduğumuz EC2 makineye Apache Spark yükleme adımlarını paylaşıyor olacağım.</p><p>İlgili konularda Türkçe kaynak eksikliğinden ve kendi adıma bir bilgi stoğu oluşturma maksadıyla bu gönderiyi hazırlamış bulunmaktayım.</p><p>Bahsi geçen terimlerin açıklamaları, Büyük Veri konsepti, Amazon Web Service ve daha birçok konu ile ilgili de yakın gelecekte Türkçe metinler hazırlamayı planlıyorum.</p><p>******************************************************************</p><p><strong>1.Adım : EC2 Instance Oluşturma</strong></p><p>AWS üzerinden Ubuntu işletim sistemine sahip bir adet EC2 makine kuracağız. EC2 makinenin kurulumu adım adım şu şekildedir :</p><p><strong>1.1. Adım :</strong></p><p>AWS Bulut Bilişim Hizmetleri web sayfasına gidiyoruz.</p><p><a href="https://aws.amazon.com/tr/">Bulut Bilgi İşlem Hizmetleri - Amazon Web Services (AWS)</a></p><p>Linke tıkladığımızda bizi aşağıdaki şekilde bir giriş sayfası karşılayacaktır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xoSXruo_ytLpqCmyvRyE5Q.png" /></figure><p>Giriş yapmak için “Konsolda Oturum Açın” butonuna tıklıyoruz.</p><p><strong>1.2. Adım :</strong></p><p>Account ID, IAM user name ve Password bilgilerimiz ile sisteme giriş yapıyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yQHZ-qU6vR9FaZ0QVIU_4g.png" /></figure><p><strong>1.3. Adım :</strong></p><p>Sisteme giriş yaptıktan sonra bizi karşılayan ekranda işaretlenen arama barına “EC2” yazıyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZSCtZTD3vZQZlMicUsRqxA.png" /></figure><p>EC2 yazdıktan sonra açılan seçenekli ekranda EC2 servisine tıklıyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nHUsNsPA4ykY80Yqc7SSIA.png" /></figure><p><strong>1.4. Adım :</strong></p><p>Açılan dashboard ekranında “Launch Instance” butonuna tıklayarak yeni makine açma sayfasına geçiş yapıyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*H3rf9uynn1EJVL8XqOCTow.png" /><figcaption>Bu kısımda Launch Instance seçeneğini tıklayabilirsiniz.</figcaption></figure><p><strong>1.5. Adım :</strong></p><p>Artık makinemizi belirleyeceğimiz seçeneklerle açabiliriz.</p><p>Bu adımda bizi karşılayan sayfa aşağıdaki gibidir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NKQf8R8ErcwSQDzuxzU1cQ.png" /></figure><p>İlk ekranda AMI (Amazon Machine Image) seçimini yapmamız gerekecektir.</p><p>Bunun için sayfayı aşağı kaydırarak <em>“</em><strong><em>Ubuntu Server 18.04 LTS (HVM), SSD Volume Type” </em></strong>makinesini 64-bit (x86) olarak seçiyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tu9MzD_xMKx-oz-tVkQatQ.png" /></figure><p><strong>1.6. Adım :</strong></p><p>Artık Ubuntu makinemizi seçtik ve seçtiğimiz makinenin tipini belirleme adımına ulaşmış olduk.</p><p>Bu adımda yapacak olduğumuz işin boyutuna göre bir makine seçebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Imei30yWNh7o6cD1ws-sHg.png" /></figure><p>t3.xlarge makineyi seçiyoruz ve “Next:Configure Instance Details” butonu ile bir sonraki adım olan konfigurasyon ayarlarına geçiyoruz.</p><p><strong>1.7. Adım :</strong></p><p>Konfigurasyon ayarları kısmında herhangi bir değişiklik yapmadan “Next:Add Storage” butonu ile ilerleyebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NJSQbsKv1yEuZyhVdlHExg.png" /></figure><p><strong>1.8. Adım :</strong></p><p>Bu bölümde makinemizin size’ını(bellek) belirliyoruz. Bu kısımda da ihtiyaca göre hareket edebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hMQq4EfCQUElgyM_WPji4g.png" /></figure><p>Ardından “Next:Add Tags“ butonuna tıklayıp ilerliyoruz. Etiket ekleme bölümünde de herhangi bir işlem yapmamıza gerek yoktur.</p><p>“Next:Configure Security Group“ seçeneği ile Güvenlik Grubu Konfigurasyon Ayarları adımına geçebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1RbKseVnVSKbzmSIOki7Ww.png" /></figure><p><strong>1.9. Adım :</strong></p><p>Configure Security Group aşamasını da geçerek Review and Launch diyerek son adıma geçebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8pxrB9U0cAz_3b9r2pz_xQ.png" /></figure><p><strong>1.10. Adım :</strong></p><p>Son kez ayarlara göz gezdirdikten sonra “Launch” butonuna tıklayarak makinemizi çalıştırmak için bir sonraki aşamaya geçebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AVrX8HcTxHxYTe5f83SLfg.png" /></figure><p><strong>2.Adım : PuTTY Konfigurasyonlarının Düzenlenmesi ve Terminal Ekranından Makineye Bağlanma</strong></p><p><strong>2.1. Adım :</strong></p><p>1.10. Adımda “Launch” butonuna tıkladıktan sonra aşağıdaki şekilde bir pencere açılacaktır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*-D4AhuDV_89vaxCx59byzw.png" /></figure><p>Açılan bu ekranda “Choose an existing key pair” seçeneğine tıklıyoruz ve açılan pencerede “Create a new key pair” alternatifini seçiyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*RgfvGqDYdzKht2kNujlzPg.png" /></figure><p>“Create a new key pair” seçeneğine tıkladıktan sonra sayfa aşağıdaki gibi değişecektir.</p><p>Burada Key pair name kısmına herhangi bir isim yazabiliriz. Yazacağımız isim makineye girerken ilk aşamada kullanacağımız .pem uzantılı dosyanın adı olacaktır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*bWTNQqsEC5YVfvBv5rDCwg.png" /></figure><p>Key pair name kısmını da doldurduktan sonra “Download Key Pair” butonuna tıklamamız gerekecektir.</p><p>İndirilecek olan .pem uzantılı dosyayı hatırlayacağımız bir yere kaydediyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DbSQCj9Bly1U6D_u8wYNIw.png" /></figure><p>Ardından “Launch Instance”a tıklıyoruz ve makinemiz hazır hale geliyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*yyKF9zABGS4IeKP41t-wUQ.png" /></figure><p>“View Instances” butonu ile nihai makinelerimizi görebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RkTA5yuEGtc8ssGX6FENow.png" /></figure><p>Açmış olduğumuz makine aşağıdaki gibi listeleme ekranına düşecektir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EIM78GNs5bS82Ahn7C3rOA.png" /></figure><p><strong>2.2. Adım :</strong></p><p><a href="https://www.putty.org/">Download PuTTY - a free SSH and telnet client for Windows</a></p><p>Yukarıda yer alan linkten PuTTY internet sitesine giriyor ve işaretli bölümden programı bilgisayarımıza indirip kuruyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8sh0-ZHf4sRtyU5eMaJSsA.png" /></figure><p>İndirme işlemini yaparken bilgisayarınızın belleği yönetme biçimine göre 32bit ya da 64bit olmasına dikkat ederek bir tercih yapmalısınız.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GD_LjKTDzizMjMp8lQQxPg.png" /></figure><p>Bilgisayarınızın 32 bit ya da 64 bit olduğunu bilmiyorsanız Windows’un aşağıdaki sayfasını ziyaret edebilirsiniz.</p><p><a href="https://support.microsoft.com/tr-tr/windows/32-bit-ve-64-bit-windows-s%C4%B1k-sorulan-sorular-c6ca9541-8dce-4d48-0415-94a3faa2e13d">32 bit ve 64 bit Windows: Sık sorulan sorular</a></p><ul><li>PuTTY kurulumunda özel bir seçenek olmadığı için bu kısmı atlıyorum. (Tüm seçenekleri Next diyerek geçebilirsiniz.)</li></ul><p><strong>2.3. Adım :</strong></p><p>Bilgisayarımızın Windows tuşuna basıp klavyeden “PuTTYgen” yazarak PuTTY Key Generator uygulamasını açıyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/339/1*Hvazy3vVGuJD8A5DaC-G7Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*xfdED28hlDWdHYkG7RgSBA.png" /></figure><p>PuTTYgen programı açılan penceresinde “Load” butonunu tıklıyoruz ve 2.1. Adım’da bilgisayarımıza indirdiğimiz .pem uzantılı dosyayı seçiyoruz.</p><p><strong><em>*** Bu bölümde .pem uzantılı dosyanızı direkt olarak göremeyeceksiniz. Bu sebeple aşağıda işaretlenen bölümde tüm dosya tiplerini seçmeniz gerekmektedir.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*Qs1xOs-sKDw_B1Kr4wVFbw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*XYNxSejZoobEQVoG19dDYA.png" /></figure><p>Artık .pem uzantılı dosya görünür hale geldi ve seçilebilir durumdadır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*I72rvhowBHRpV2EWR30XRw.png" /></figure><p>.pem uzantılı dosyamızı çift tıklayarak seçiyoruz.</p><p>PuTTY Key Generator bizim için bir Key oluşturmuş oldu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*lFRz1DtN7e3j7OhMERPl5A.png" /></figure><p>Tamam diyoruz ve ardından “Save Private Key” butonuna tıklıyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*8jRyRJq26zkHvFs_x90xBg.png" /></figure><p>Açılan pencerede Evet seçeneğine tıklıyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*r4oGs7E3hZv6lijgV2q8Qw.png" /></figure><p>Bu adımda PuTTY Key Generator oluşturduğu .ppk uzantılı dosyayı kaydetmemizi isteyecek. Bilgisayarımızda uygun bir yere kaydediyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*d4jz5naw0v8CjWoVs3mFlA.png" /></figure><p>Artık PuTTY Key Generator ile işimiz bitti ve programı kapatabiliriz.</p><p><strong>2.4. Adım :</strong></p><p>Sıra geldi PuTTY ile oluşturduğumuz EC2&#39;ya bağlanmaya.</p><p>Şimdi yine klavyeden Windows tuşuna basarak PuTTY yazıyoruz. Bu sefer PuTTY programını açacağız.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/343/1*z0LADws374j96ZJSkZ6Hyw.png" /></figure><p><strong>2.5. Adım :</strong></p><p>PuTTY açıldığında sizi şu şekilde bir ekran karşılayacaktır.</p><p>Bu ekranda bir kaç konfigurasyon yapmamız gerekecek.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*tPhEP6n2mGL9zwew3TH4YA.png" /></figure><p>Host Name kısmına <strong>ubuntu@IPV4adresiniz </strong>formatını geçirmeniz gerekecek.</p><p>ubuntu@ kısmı sabittir. Public IPV4 adresinizi de EC2 makinenizin Details kısmından alabilirsiniz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5alVfO8ugJFmaQ6jzWol_A.png" /></figure><p>Dolayısıyla ben PuTTY’de Host Name kısmına <strong>ubuntu@3.127.236.224 </strong>yazıyor olacağım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*s1xjymDB607zEApY56piSw.png" /></figure><p>Ardından sol frame’de yer alan SSH seçeneği altından AUTH kısmına geçiyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*f68npff3qOcGLYifqukfVA.png" /></figure><p>Buradan da Browse butonuna tıklıyor ve 2.3. Adım’da kaydetmiş olduğumuz .ppk uzantılı dosyayı seçiyoruz.</p><p>Seçimi yaptıktan sonra Open butonuna tıklayabiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*6p13OtFf7bwh4SWrae2wPQ.png" /></figure><p>Açılan terminal ekranında “Accept” diyerek Security Alert ekranını kapatıp makinemize uzaktan bağlantı sağlayabiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*MUCFYf1iqZtZqxkYelq0yA.png" /></figure><p>Artık makinemiz kullanıma hazır.</p><p>*****************************************************************</p><p>Bir sonraki yazım :</p><p>AWS(Amazon Web Service) Üzerinden EC2 Makineye Apache Spark Kurulumu-TR</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ddeda4a79a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimization & Modelling with Omer]]></title>
            <link>https://medium.com/@yildiz.omer.92/optimization-modelling-with-omer-9d781da85c90?source=rss-544ff2e451c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d781da85c90</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[modelling]]></category>
            <category><![CDATA[linear-programming]]></category>
            <category><![CDATA[optimization]]></category>
            <dc:creator><![CDATA[Ömer Yıldız]]></dc:creator>
            <pubDate>Sun, 08 May 2022 17:11:59 GMT</pubDate>
            <atom:updated>2022-05-08T17:24:51.382Z</atom:updated>
            <content:encoded><![CDATA[<p>Chapter I : 1D Problem Sets (with X<em>i</em> decision variables)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qlY_pupAGSm4DWmoZJ-IvQ.jpeg" /></figure><p>This series has been created in order to convey the basics of optimization and modelling to those who are interested. By the end of the series, you will be able to easily understand and do the basic mathematical modelling and optimization operations on your own. We will follow a path that develops step by step. Firstly we will interest 1D Problem Sets (with X<em>i</em> decision variables), then in Chapter II: 2D Problem Sets (with X<em>ij</em> decision variables).</p><p><strong><em>So what is 1D Problem Sets (with Xi decision variables)?</em></strong></p><p>Don’t let its looks scare you, this isn’t a complicated thing. Also it is too simple like basic algebra problems. This name seems complex which is 1D Problem Sets means it has 1 changable decision variable on 1 diagonal. For instance X<em>i</em>. The variable <em>i</em> can take various values (0,1,2,3,4,….). In this way we can progress our solution on 1 diagonal.</p><p>For example,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/166/1*kOW2D8SBA19xa13WK0P6Og.jpeg" /><figcaption>Sum of Xi values and i values are changing from 1 to 5.</figcaption></figure><p>it means X1 + X2 + X3 + X4 + X5. So as you realize we interest just 1D space and changes only <em>i</em> values.</p><p>Or let we dream this situation on numerical axis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vyzE0BYyxvcuDiAEm0aj3g.jpeg" /><figcaption>Changing values on different axis</figcaption></figure><p>As you see we just move on 1 axis on 1D space.</p><p><strong><em>What types of problems do 1D Problem Sets cover?</em></strong></p><p>All basic problem types can be the subject of 1D Problem Sets. Especially, in LP (Linear Programming) discipline; Process Selection Problems, Cash-Flow Problems, Production Planning Problems, Multi-Period Planning, Workforce Scheduling etc.</p><p>*******************************************************************</p><p>Next topics ;</p><p>Chapter I.I :1D Problem Sets Case Studies (<em>with Python Solving)</em></p><p>Chapter II : 2D Problem Sets (with X<em>ij</em> decision variables)</p><p>Chapter II.I : 2D Problem Sets Case Studies (<em>with Python Solving)</em></p><p>Chapter III : Fundamentals and Types of Mathematical Modelling</p><p>*******************************************************************</p><p><em>Stay tuned.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d781da85c90" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prediction of 2021–2022 Turkish Super League Champion with a Hybrid Modelling Beta Geometric /…]]></title>
            <link>https://medium.com/@yildiz.omer.92/prediction-of-2021-2022-turkish-super-league-champion-with-a-hybrid-modelling-beta-geometric-7e6ee09ed480?source=rss-544ff2e451c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e6ee09ed480</guid>
            <category><![CDATA[binomial-distribution]]></category>
            <category><![CDATA[predictions]]></category>
            <category><![CDATA[hybrid]]></category>
            <category><![CDATA[football]]></category>
            <dc:creator><![CDATA[Ömer Yıldız]]></dc:creator>
            <pubDate>Thu, 23 Sep 2021 23:43:58 GMT</pubDate>
            <atom:updated>2021-09-29T06:02:23.387Z</atom:updated>
            <content:encoded><![CDATA[<h3>Prediction of 2021–2022 Turkish Super League Champion with a Hybrid Modelling <strong>Beta Geometric / Negative Binomial distribution model</strong> (BG/NBD) &amp; Gamma Gamma Model Methods</h3><p><em>A fantastic model to predict for 2021–2022 Turkish Super League champion based on historical data starting with 94–95 season.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*b0eHSTgsH7clS3aPNF-y5w.jpeg" /></figure><p>It will be a so interesting project, sit back and have fun :)</p><p>Lets start with some theorical information.</p><p><strong>What is BG/NBD ?</strong></p><blockquote><strong>Beta Geometric Distribution</strong> : The <strong>beta geometric distribution</strong> (also called the Type I Geometric) is a type of <a href="https://www.statisticshowto.com/geometric-distribution/">geometric distribution</a>, where the probability of success parameter, p, has a <a href="https://www.statisticshowto.com/beta-distribution/">Beta distribution</a> with <a href="https://www.statisticshowto.com/shape-parameter/">shape parameters</a> alpha(α) and beta(β); both shape parameters are positive (α &gt; 0 and β &gt; 0). It is a type of <a href="https://www.statisticshowto.com/compound-distribution/">compound distribution</a>.</blockquote><blockquote>The distribution often models the number of failures that will happen in a binomial process before the first observed success. The probability of success is the mean of the distribution, given by the formula α / (α + β). This particular usage is often called the shifted beta binomial.[1]</blockquote><blockquote><strong>Negative Binomial Distribution</strong> :<strong> </strong>A <strong>negative binomial distribution</strong> (also called the Pascal Distribution) is a <a href="https://www.statisticshowto.com/discrete-probability-distribution/">discrete probability distribution</a> for <a href="https://www.statisticshowto.com/random-variable/">random variables </a>in a negative binomial experiment.</blockquote><blockquote>The random variable is the number of repeated trials, X, that produce a certain number of successes, r. In other words, it’s the number of failures before a success. This is the main difference from the <a href="https://www.statisticshowto.com/probability-and-statistics/binomial-theorem/binomial-distribution-formula/">binomial distribution</a>: with a regular binomial distribution, you’re looking at the number of successes. With a negative binomial distribution, it’s the number of failures that counts.[2]</blockquote><p>Generally these two probability distribution methods are used for prediction of customer life time value. However, I used them to forecasting a different case thanks to their structure. They include recency, frequency, first transaction date and monetary values as variables. I changed the variables like :</p><p><strong>recency </strong>: <em>When was the last time teams beat each other?</em><br><strong>frequency </strong>: <em>How often did the teams beat each other?</em><br><strong>first transaction date </strong>: <em>When was the first match between two teams ?</em><br><strong>monetary</strong> : <em>Result of match score based as point</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*jqOFMhXj0nIBjAL1rvZYEA.jpeg" /></figure><h4>Prediction of 2021–2022 Turkish Super League Champion</h4><h4>Content</h4><ol><li>Introduction</li><li>Data Pre-Processing</li><li>Data Processing &amp; Analysing</li><li>BG/NBD Modelling</li><li>Gamma Gamma Modelling (GGM)</li><li>Hybrid Modelling with BG/NBD &amp; GGM</li><li>Segmentation</li><li>Pointing</li><li>Result</li></ol><p><strong>1.Introduction</strong><br>For this project I’ve prepared a dataset which includes all of match scores until 1994–1995 season of Turkish Super League. You can download this dataset from my github page and find the link in references section.</p><p>I want to mention that some information about the dataset. <em>First of all</em>, I’ve used a unique ID and Index record for all combination of match score. For instance, all combination of matches of between Galatasaray and Fenerbahçe are ;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*DWrsilUJWagDHqKUPwkUqw.png" /></figure><p>I’ve assigned same ID to same result. Because who wins is important for this method. <strong><em>Also,</em></strong> I’ve given points according to results. Win result is 3 points, draw result is 1 point.</p><p>As all we know football matches are played as match week period. But, the period is not regular for various reasons. I mean that for example,<br>1st. week matches are played<strong><em> 01.01.2021</em></strong><br>2nd. week matches are played <strong><em>12.01.2021</em></strong><br>3th. week matches are played<strong> <em>23.01.2021</em></strong></p><p>As you see, the date series is not regular. So I’ve assigned a visual date for match week increasingly seven days per week like as,<br>1st. week matches are played<strong><em> 01.01.2021</em></strong><br>2nd. week matches are played <strong><em>08.01.2021</em></strong><br>3th. week matches are played<strong> <em>15.01.2021</em></strong></p><p>I had to do this for optimal solving. <strong><em>On the other hand,</em></strong> To using BG/NBD &amp; GGM, we have to specify a ‘<em>today date</em>’ for finding first match date, last match date etc. Generally it is admitted max. date + 2 days.</p><p><strong>2. Data Pre-Processing</strong></p><pre>##############################################################<br># Importing Libraries and Setting Options<br>##############################################################<br><br>import datetime as dt<br>import pandas as pd<br>from lifetimes import BetaGeoFitter<br>from lifetimes import GammaGammaFitter<br>from lifetimes.plotting import plot_period_transactions<br><br>pd.set_option(&#39;display.max_columns&#39;, None)<br>pd.set_option(&#39;display.max_rows&#39;, None)<br>pd.set_option(&#39;display.width&#39;, 500)<br>pd.set_option(&#39;display.float_format&#39;, lambda x: &#39;%.4f&#39; % x)<br>from sklearn.preprocessing import MinMaxScaler<br><br>##############################################################<br># Data Reading<br>##############################################################<br><br>df_ = pd.read_excel(&quot;C:/Users/omery/Desktop/meta_tsl.xlsx&quot;)<br>df = df_.copy()</pre><pre>##############################################################<br># Data Pre-Processing<br>##############################################################<br><br>df.dropna(inplace=True)<br><br>today_date = dt.datetime(2021, 9, 23)<br>df.head()</pre><p><strong>3. Data Processing &amp; Analysing</strong></p><pre>##################################################<br># Data Processing % Analysing<br>##################################################<br><br># last_m : number of days from last match until today<br># first_m : number of days from first match until today<br># m_series : count of match between two teams<br># points : points according to result<br><br><br>res_df = df.groupby([&#39;Index&#39;]).agg({<br>&#39;SPE_DATE&#39;: [lambda date: (date.max() - date.min()).days,<br>             lambda date: (today_date - date.min()).days],<br>&#39;ID&#39;: lambda num: num.count(),<br>&#39;Points&#39;: lambda points: points.sum()})<br><br>res_df.columns = res_df.columns.droplevel(0)<br>res_df.columns = [&#39;last_m&#39;, &#39;first_m&#39;, &#39;m_series&#39;, &#39;points&#39;]<br><br>res_df = res_df.merge(df,on=&#39;Index&#39;, how=&#39;left&#39;)<br><br>res_df = res_df[[&#39;ID&#39;,&#39;Index&#39;,&#39;last_m&#39;,&#39;first_m&#39;,&#39;m_series&#39;,&#39;points&#39;]]<br><br>res_df.drop_duplicates()<br><br>res_df[&quot;avg_points&quot;] = res_df[&quot;points&quot;] / res_df[&quot;m_series&quot;]<br><br>res_df[&quot;last_m&quot;] = res_df[&quot;last_m&quot;] / 7<br><br>res_df[&quot;first_m&quot;] = res_df[&quot;first_m&quot;] / 7<br><br>res_df.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*FryRNKZ8a2FPq0ialywLew.png" /></figure><p><strong>4. BG/NBD Modelling</strong></p><pre>##############################################################<br># BG-NBD Modelling<br>##############################################################<br><br>bgf = BetaGeoFitter(penalizer_coef=0.001)<br><br>bgf.fit(res_df[&#39;m_series&#39;],<br>        res_df[&#39;last_m&#39;],<br>        res_df[&#39;first_m&#39;])</pre><p><strong>5. Gamma Gamma Modelling (GGM)</strong></p><pre>##############################################################<br># GAMMA-GAMMA Modelling<br>##############################################################<br><br><br>ggf = GammaGammaFitter(penalizer_coef=0.01)<br>ggf.fit(res_df[&#39;m_series&#39;], res_df[&#39;avg_points&#39;])<br><br><br>ggf.conditional_expected_average_profit(res_df[&#39;m_series&#39;],<br>                                        res_df[&#39;avg_points&#39;]).head(10)<br><br><br>ggf.conditional_expected_average_profit(res_df[&#39;m_series&#39;],<br>                                        res_df[&#39;avg_points&#39;]).sort_values(ascending=False).head(10)<br><br>res_df[&quot;expected_average_rate&quot;] = ggf.conditional_expected_average_profit(res_df[&#39;m_series&#39;],<br>                                                                             res_df[&#39;avg_points&#39;])<br><br>res_df=res_df.drop_duplicates()<br>res_df.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*UG-n-8qDc-82wOngtxGwGw.png" /></figure><p><strong>6. Hybrid Modelling with BG/NBD &amp; GGM</strong></p><pre>##############################################################<br># Hybrid Modelling with BGNBD &amp; GGM<br>##############################################################<br><br>rate = ggf.customer_lifetime_value(bgf,<br>                                   res_df[&#39;m_series&#39;],<br>                                   res_df[&#39;last_m&#39;],<br>                                   res_df[&#39;first_m&#39;],<br>                                   res_df[&#39;avg_points&#39;],<br>                                   time=8,  # for 8 months &lt;33weeks&gt;<br>                                   freq=&quot;W&quot;,  # frequency<br>                                   discount_rate=0.00)<br><br>rate.head()<br>res_df = res_df.reset_index()<br>rate = rate.reset_index()<br>rate[&#39;prob&#39;] = rate[&#39;clv&#39;]<br><br>res_df.sort_values(by=&quot;expected_average_rate&quot;, ascending=False).head(50)<br><br>res_final = res_df.merge(rate, on=&quot;index&quot;, how=&quot;left&quot;)<br><br>res_final = res_final[[&#39;ID&#39;, &#39;Index&#39;, &#39;last_m&#39;, &#39;first_m&#39;, &#39;m_series&#39;, &#39;points&#39;, &#39;avg_points&#39;, &#39;expected_average_rate&#39;, &#39;prob&#39;]]<br><br>res_final = res_final.drop_duplicates()<br><br>res_final.sort_values(by=&quot;prob&quot;, ascending=False).head(10)<br><br><br>scaler = MinMaxScaler(feature_range=(0, 1))<br>scaler.fit(res_final[[&quot;prob&quot;]])<br>res_final[&quot;prob&quot;] = scaler.transform(res_final[[&quot;prob&quot;]])<br><br><br>res_final.sort_values(by=&quot;prob&quot;, ascending=False).head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*noBW8XhJMDUapGKeqDRVBQ.png" /></figure><p><strong>7. Segmentation</strong></p><pre>##############################################################<br># Segmentation<br>##############################################################<br><br>res_final[&quot;bags&quot;] = pd.qcut(res_final[&quot;prob&quot;], 6, labels=[&quot;very_weak&quot;, &quot;weak&quot;, &quot;low_med&quot;, &quot;high_med&quot;,&quot;strong&quot;,&quot;too_strong&quot;])<br><br>res_final.head()<br><br><br>res_final.to_csv(&quot;championss.csv&quot;)</pre><p><strong>8. Pointing</strong></p><p>I’ve segmented the probability of matches to 5 groups accoding to their probability score.<br>very_weak 0 pts<br>weak 1 pts<br>low_med 2 pts<br>high_med 3 pts<br>strong 4 pts<br>too_strong 5 pts</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ikZan6Wp5b_pBS5aZStWAQ.png" /></figure><p>And, then I’ve matched probability of matches and their probabilty score with 2021–2022 fixtures.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oLw19FguTKJQvUNuqSnR4A.png" /></figure><p><strong>9. Result<br>As a result of this project Beşiktaş is the Champion of 2021–2022 Super League Season.<br>Note : </strong>I haven’t been happy, because I’m a Galatasaray fan :(</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/281/1*Ey5BC5DfVSV2UcuLerXV5A.png" /></figure><p>⚫️⚪️⚫️⚪️⚫️⚪️⚫️⚪️⚫️⚪️⚫️️ 🦅 ⚫️⚪️⚫️⚪️⚫️⚪️⚫️⚪️⚫️⚪️⚫️</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_m4U9T4ON_hBmNV-uIpT-A.jpeg" /></figure><p>⚫️⚪️⚫️⚪️⚫️⚪️⚫️⚪️⚫️⚪️⚫️️ ⚪️⚫️⚪️⚫️⚪️⚫️⚪️⚫️⚪️⚫️⚪️⚫️</p><p><strong>References</strong><br>Github Link : <a href="https://github.com/omerta92/Prediction-of-2021-2022-Turkish-Super-League-Champion-with-a-Hybrid-Modelling">https://github.com/omerta92/Prediction-of-2021-2022-Turkish-Super-League-Champion-with-a-Hybrid-Modelling</a></p><ol><li><a href="https://www.statisticshowto.com/shape-parameter/">https://www.statisticshowto.com/shape-parameter/</a></li><li><a href="https://www.statisticshowto.com/probability-and-statistics/binomial-theorem/binomial-distribution-formula/">https://www.statisticshowto.com/probability-and-statistics/binomial-theorem/binomial-distribution-formula/</a></li><li><a href="https://github.com/mvahit">https://github.com/mvahit</a></li><li><a href="https://github.com/mathchi/Calculation-of-Lead-Generation-with-Rule-Based-Classification">https://github.com/mathchi/Calculation-of-Lead-Generation-with-Rule-Based-Classification</a></li><li><a href="https://github.com/CagiriciOzlem/Ruled-Based-Classification/blob/main/Ruled_Based_Classification.py">https://github.com/CagiriciOzlem</a></li><li><a href="https://www.veribilimiokulu.com/">https://www.veribilimiokulu.com/</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e6ee09ed480" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CRM Series with Data Science— Basic to Expert : I. Rule-Based Classification]]></title>
            <link>https://medium.com/@yildiz.omer.92/crm-series-with-data-science-basic-to-expert-i-rule-based-classification-bd7e22ba7c40?source=rss-544ff2e451c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd7e22ba7c40</guid>
            <category><![CDATA[crm]]></category>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[customer-segmentation]]></category>
            <category><![CDATA[churn]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Ömer Yıldız]]></dc:creator>
            <pubDate>Sun, 12 Sep 2021 01:08:31 GMT</pubDate>
            <atom:updated>2021-09-12T22:42:12.271Z</atom:updated>
            <content:encoded><![CDATA[<h3>CRM Series with Data Science I : Rule-Based Classification</h3><p><strong>CRM Series with Data Science Basic to Expert I </strong><em>: Rule-Based Classification in a Banking Case.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3GpjdlUwe_442ef9" /><figcaption>Photo by <a href="https://unsplash.com/@martinadams?utm_source=medium&amp;utm_medium=referral">Martin Adams</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Welcome to the first part of this mini-series, where we take a look how can we improve CRM strategies supported with data science methods.</p><p>In this series we are pursuing a gradual strategy how is basic to expert.</p><p><strong>Rule-Based Classification</strong><br>Rule-based classification is a simple methodology whereby you would identify an attribute you’d want to segment your customers by and set different thresholds to determine what cluster each customer should be a part of. [1]</p><p>Segmenting your customers in this way doesn’t require a lot of skill. It’s intuitive and allows you to apply specific business logic to each segment for an easier way to keep track of specific KPIs. It also allows you to monitor trends over time by identifying how many customers you have in every group. [1]</p><p>The downside, however, is that it’s static and hard to add additional attributes to. So, the approach is typically two-dimensional and requires a lot of maintenance to keep up-to-date when customers’ behaviors change, causing the segmentation thresholds to be irrelevant.[1]</p><p><strong>Where is Rule-Based Classification Useful ?</strong><br>Rule-Based Segmentation can use to solve both small and large scale business problems. Especially, comes across <strong><em>Remarketing</em></strong> and<em> </em><strong><em>Lookalikes</em></strong> operations.</p><p><strong>In Remarketing</strong><br>Remarketing is perhaps where rule based audiences have the most impact.[2] For a bank for instance, a combination of age, sex, credit risk score, deposit, last financal activity information etc.can be used to regaining customers who have not used the product for a long time. Rule based segments can make remarketing relevant and effective by giving estimates to intent.</p><p><strong>In Lookalikes</strong><br>Rule based customer segments are immensely useful for creating Lookalike seeds.[2] Thanks to rule-based calassification, customers can be classify in a similar clusters and their behaviour can predict easily.</p><h4><strong>/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*</strong></h4><p><em>Business Problem</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*g8WROEwWYJPyvy8Z" /><figcaption>Photo by <a href="https://unsplash.com/@tjevans?utm_source=medium&amp;utm_medium=referral">Tim Evans</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3><strong><em>A Banking Case with Rule-Based Classification</em></strong></h3><h3><strong>Content</strong></h3><ol><li>Case</li><li>Data Pre-Processing &amp; Analysis</li><li>Defining Personas and Creating Segments Based on Personas</li><li>Prediction</li></ol><h4>1. Case</h4><p>A CRM department in a local bank works on classify their lost customers with their past datas. So they want predict with these method that average loss balance and passive duration for future.</p><p>Important variables :</p><ul><li><strong>AGE:</strong> Age of the lost customers</li><li><strong>JOB: </strong>Profession of the lost customers</li><li><strong>MARITAL : </strong>Marital status of the lost customers</li><li><strong>EDUCATION :</strong> Last graduated of the lost customers</li><li><strong>BALANCE :</strong> Losing money ($) per the lost customer</li><li><strong>LAST_TRANSACTION :</strong> Time since last transaction (day)</li></ul><h4>2. Data Pre-Processing &amp; Analysis</h4><p>In this part, we’re preparing data to ready before detailed analysis, also taking a short look to dataset for general terms.</p><p>Let’s import to libraries and read to database we need.</p><ul><li><em>Dataset is downloaded at kaggle. You can find the link in references section.</em></li><li><em>Also you can reach all detailed scripts from my github page. Link is in references section.</em></li></ul><pre># /*\*/*\*/*\* Importing Libraries *\*/*\*/*\*/<br>import numpy as np<br>import pandas as pd<br>import matplotlib.pyplot as plt<br>import seaborn as sns<br><br># /*\*/*\*/*\* Reading Datasets *\*/*\*/*\*/<br>df = pd.read_csv(&quot;C:/Users/omery/Desktop/Medium/Rule-Based Classification/BankCustomerData.csv&quot;)<br><br>pd.set_option(&#39;display.max_columns&#39;,None)</pre><p>Now, we can do descriptive analysis and take a short look to dataset.</p><pre># /*\*/*\*/*\* Descriptive Analysis *\*/*\*/*\*/<br><br>def check_df(dataframe, head=5, tail=5, quan=True):<br>    print(&quot;##################### Shape #####################&quot;)<br>    print(dataframe.shape)<br>    print(&quot;##################### Type #####################&quot;)<br>    print(dataframe.dtypes)<br>    print(&quot;##################### Head #####################&quot;)<br>    print(dataframe.head(head))<br>    print(&quot;##################### Tail #####################&quot;)<br>    print(dataframe.tail(tail))<br>    print(&quot;##################### NA #####################&quot;)<br>    print(dataframe.isnull().sum())<br><br>    if quan:<br>        print(&quot;##################### Quantiles #####################&quot;)<br>        print(dataframe.quantile([0, 0.05, 0.50, 0.95, 0.99, 1]).T)<br><br>check_df(df, head=5, tail=5)</pre><p>As we can see below; data shape, types, head, NA, quantiles.</p><ul><li><strong>Shape:</strong> The dimension of dataframe</li><li><strong>Type:</strong> The data type of each variable</li><li><strong>Head:</strong> The first “n” rows of the DataFrame</li><li><strong>Tail:</strong> The tail “n” rows of the DataFrame</li><li><strong>NA: </strong>Checking if any NULL Value is into DataFrame</li><li><strong>Quantile: </strong>Cut points dividing the <a href="https://en.wikipedia.org/wiki/Range_(statistics)">range</a> of a <a href="https://en.wikipedia.org/wiki/Probability_distribution">probability distribution</a> into continuous intervals with equal probabilities.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*Nps2_he3VEqjnXOaVCzpNw.jpeg" /><figcaption>Shape &amp; Types</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*c_DZl18hooPOyuyH88tcCg.jpeg" /><figcaption>Head &amp; Tail</figcaption></figure><p>In this part, we are detecting categorical and numerical variables.</p><pre># *\*/ Detection of Categorical and Numerical Variables *\*/<br><br>def grab_col_names(dataframe, cat_th=10, car_th=20):<br><em><br>    </em># cat_cols, cat_but_car<br>    cat_cols = [col for col in dataframe.columns if dataframe[col].dtypes == &quot;O&quot;]<br><br>    num_but_cat = [col for col in dataframe.columns if dataframe[col].nunique() &lt; cat_th and<br>                   dataframe[col].dtypes != &quot;O&quot;]<br><br>    cat_but_car = [col for col in dataframe.columns if dataframe[col].nunique() &gt; car_th and<br>                   dataframe[col].dtypes == &quot;O&quot;]<br><br>    cat_cols = cat_cols + num_but_cat<br><br>    cat_cols = [col for col in cat_cols if col not in cat_but_car]<br><br>    # num_cols<br>    num_cols = [col for col in dataframe.columns if dataframe[col].dtypes != &quot;O&quot;]<br><br>    num_cols = [col for col in num_cols if col not in num_but_cat]<br><br>    print(f&quot;Variables: {dataframe.shape[1]}&quot;)<br>    print(f&#39;cat_cols: {len(cat_cols)}&#39;)<br>    print(f&#39;num_cols: {len(num_cols)}&#39;)<br>    print(f&#39;cat_but_car: {len(cat_but_car)}&#39;)<br>    print(f&#39;num_but_cat: {len(num_but_cat)}&#39;)<br><br>    return cat_cols, num_cols, cat_but_car<br><br>cat_cols, num_cols, cat_but_car = grab_col_names(df)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*ttfgOqPvcNeVICg9dV8THw.jpeg" /><figcaption>Variable Types</figcaption></figure><ul><li><strong>variables :</strong> All variables</li><li><strong>cat_cols :</strong> Categorical variables</li><li><strong>num_cols :</strong> Numerical variables</li><li><strong>cat_but_car : </strong>Variables that appears categorical but they have a wide range of cardinality</li><li><strong>num_but_cat : </strong>Variables that appears categorical but they are numerical</li></ul><p>Now, lets take a general view to categorical datas.</p><pre># /*\*/*\*/*\* General View to Categorical Datas *\*/*\*/*\*/<br><br>def cat_summary(dataframe, plot=False):<br>    # cat_cols = grab_col_names(dataframe)[&quot;Categorical_Data&quot;]<br>    for col_name in cat_cols:<br>        print(&quot;############## Frequency &amp; Percentage Values of Categorical Datas ########################&quot;)<br>        print(pd.DataFrame({col_name: dataframe[col_name].value_counts(),<br>                            &quot;Ratio&quot;: dataframe[col_name].value_counts() / len(dataframe)}))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*rkBbQwqEUH7PDPu-MkRypw.jpeg" /><figcaption>Job, Marital Status &amp; Education</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*qN-oVN9ifzo2G6C-hTEYwg.jpeg" /><figcaption>Housing, Loan, Contact &amp; Month</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*gPylT6mW8Hr6Al88DXs3JA.png" /><figcaption>Poutcome &amp; Term_Deposit</figcaption></figure><p>Of course, numerical datas.</p><pre># /*\*/*\*/*\* General View to Numerical Datas *\*/*\*/*\*/<br><br>num_cols = [col for col in df.columns if df[col].dtypes !=&quot;O&quot; and col not in [&quot;day&quot;,&quot;campaign&quot;,&quot;pdays&quot;,&quot;previous&quot;]]<br>numerical_col = num_cols<br><br>def num_summary(dataframe, numerical_col):<br><br>    quantiles = [0.05, 0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 0.95, 0.99]<br>    print(&quot;########## Summary Statistics of &quot; + numerical_col + &quot; ############&quot;)<br>    print(dataframe[numerical_col].describe(quantiles).T)<br><br>for col in num_cols:<br>    num_summary(df, col)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*iol1w95bpCNuss6hH9T12w.jpeg" /><figcaption>Summary Statistics of Age</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*NtLinaQm9eXs-mP12v7hRA.jpeg" /><figcaption>Summary Statistics of Balance</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*AHeAJAcFZj1MUr6dEKm3dA.jpeg" /><figcaption>Summary Statistics of Last_Transaction</figcaption></figure><p>An easy way to data analysis.</p><pre># /*\*/*\*/*\* Data Analysis *\*/*\*/*\*/<br><br>pd.set_option(&#39;display.max_columns&#39;,None)<br>pd.set_option(&#39;display.max_rows&#39;,None)<br><br>def data_analysis(dataframe):<br>    # mean, min, max amount of balance, last transaction and age by job, marital and education.<br>    print(dataframe.groupby([&quot;job&quot;,&quot;marital&quot;,&quot;education&quot;]).agg({&quot;balance&quot; : [&quot;mean&quot;,&quot;min&quot;,&quot;max&quot;],<br>             &quot;last_transaction&quot; : [&quot;mean&quot;,&quot;min&quot;,&quot;max&quot;],<br>             &quot;age&quot; : [&quot;mean&quot;,&quot;min&quot;,&quot;max&quot;]}))<br>    # unique values of categorical variables<br>    print(&quot;Unique Values of Variables:\n&quot;, dataframe[cat_cols].nunique())<br> <br>data_analysis(df)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*07fUE0O2v6VXbzVORLvGow.jpeg" /><figcaption>Balance Amount According to Job-Marital-Education Groups</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*mYWTEwtgfeq_l6AsnuUBtw.jpeg" /><figcaption>Unique Values of Each Variables</figcaption></figure><h4>3. Defining Personas &amp; Creating Segments Based on Personas</h4><pre># /*\*/*\*/*\* Defining Personas *\*/*\*/*\*/<br><br>agg_df = df.groupby([&quot;job&quot;,&quot;marital&quot;,&quot;education&quot;,&quot;age&quot;]).agg({&quot;balance&quot; : &quot;mean&quot;,<br>                                                              &quot;last_transaction&quot; : &quot;mean&quot;})<br><br>agg_df = agg_df.reset_index()<br><br>age_list = [&quot;0_17&quot;,&quot;18_24&quot;,&quot;25_34&quot;,&quot;35_44&quot;,&quot;45_54&quot;,&quot;55_69&quot;,&quot;70_90&quot;]<br>agg_df[&quot;age_cat&quot;] = pd.cut(agg_df[&quot;age&quot;], [0,18,25,35,45,55,70,90], labels = age_list)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*zCMIdBSYMnbF0HaPdp54Pg.png" /><figcaption>AVG Last Transaction Time (day) and Balance According to Age Categories</figcaption></figure><pre># /*\*/*\*/*\* Creating Rule-Based Personas *\*/*\*/*\*/<br><br>agg_df[&quot;customer_level_based&quot;] = [row[0].upper()+&quot;_&quot;+ row[1].upper()+&quot;_&quot;+ row[2].upper()+&quot;_&quot;+ str(row[6]).upper() for<br>                                  row in agg_df.values]<br><br><br>del_list = [&quot;job&quot;, &quot;marital&quot;, &quot;education&quot;, &quot;age&quot;, &quot;age_cat&quot;]<br><br>agg_df.drop(del_list, axis=1, inplace=True)<br><br>agg_df = agg_df.groupby(agg_df[&quot;customer_level_based&quot;]).agg({&quot;balance&quot;: &quot;mean&quot;,<br>                                                             &quot;last_transaction&quot; : &quot;mean&quot; }).sort_values((&quot;balance&quot;), <br>                                                                                                        ascending=False)<br>agg_df.reset_index(inplace=True)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*K-TROp0L2JuEb6NKDqhodg.png" /><figcaption>Defined Personas</figcaption></figure><pre># /*\*/*\*/*\* Rule-Based Segmentation *\*/*\*/*\*/<br>agg_df[&quot;segment&quot;]= pd.qcut(agg_df[&quot;balance&quot;], 4, labels=[&quot;D&quot;,&quot;C&quot;,&quot;B&quot;,&quot;A&quot;])<br><br>seg= agg_df.groupby(agg_df[&quot;segment&quot;]).agg({&quot;balance&quot; : [&quot;mean&quot;, &quot;max&quot;, &quot;sum&quot;],<br>                                            &quot;last_transaction&quot; : [&quot;mean&quot;, &quot;max&quot;, &quot;min&quot;]})<br>seg = seg.reset_index()<br><br>seg.head().sort_values((&quot;segment&quot;),ascending=False)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*6OSc2TO7aVrdmWE5Y-GoqA.png" /><figcaption>Rule-Based Segmentation</figcaption></figure><h4>4. Prediction</h4><p>For example, we have a potential lost client who has the following information: “SERVICES_SINGLE_SECONDARY_45_54”.</p><pre># /*\*/*\*/*\* Prediction *\*/*\*/*\*/<br><br>lost_customer = &quot;SERVICES_SINGLE_SECONDARY_45_54&quot;<br><br>agg_df[agg_df[&quot;customer_level_based&quot;] == lost_customer]<br>seg.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*Vj9VsQ5CNuv15pk_j4-kkg.png" /><figcaption>Segmented the Lost Customers</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*Z3aibbc5b7UvAQTQ4HySLw.png" /><figcaption>Balance and Last Transaction Information of the Lost Customers</figcaption></figure><h3>Result</h3><p>As a result, with this analyze we can predict average balance loss generated the lost customers, also average of passive duration of lost customers. So, we can prevent losing before the customers completely leaving.</p><h3>References</h3><ol><li><a href="https://www.optimove.com/blog/the-beauty-of-customer-segmentation-part-2-3">https://www.optimove.com/blog/the-beauty-of-customer-segmentation-part-2-3</a></li><li><a href="https://fixel.ai/rule-based/">https://fixel.ai/rule-based/</a></li><li><a href="https://github.com/mvahit">https://github.com/mvahit</a></li><li><a href="https://github.com/mathchi/Calculation-of-Lead-Generation-with-Rule-Based-Classification">https://github.com/mathchi/Calculation-of-Lead-Generation-with-Rule-Based-Classification</a></li><li><a href="https://github.com/CagiriciOzlem/Ruled-Based-Classification/blob/main/Ruled_Based_Classification.py">https://github.com/CagiriciOzlem</a></li><li><a href="https://medium.com/@kemalgunay/customer-segmentation-the-key-to-finding-the-right-customers-68cc38f6bd71">https://medium.com/@kemalgunay/customer-segmentation-the-key-to-finding-the-right-customers-68cc38f6bd71</a></li></ol><p>Dataset Link : <a href="https://www.kaggle.com/kidoen/bank-customers-data/version/2">https://www.kaggle.com/kidoen/bank-customers-data/version/2</a></p><p>GitHub : <a href="https://github.com/omerta92/Rule-Based-Classification-in-a-Banking-Case..git">https://github.com/omerta92/Rule-Based-Classification-in-a-Banking-Case..git</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd7e22ba7c40" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>