<?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 Esma Bozkurt on Medium]]></title>
        <description><![CDATA[Stories by Esma Bozkurt on Medium]]></description>
        <link>https://medium.com/@esmabozkurt?source=rss-78dccce92e8c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gxeXap5YtwnatxylrizArw.jpeg</url>
            <title>Stories by Esma Bozkurt on Medium</title>
            <link>https://medium.com/@esmabozkurt?source=rss-78dccce92e8c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 20:09:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@esmabozkurt/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[Introduction to Recurrent Neural Networks]]></title>
            <link>https://esmabozkurt.medium.com/introduction-to-recurrent-neural-networks-2a4cc0238601?source=rss-78dccce92e8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a4cc0238601</guid>
            <category><![CDATA[artificial-neural-network]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[rnn]]></category>
            <category><![CDATA[recurrent-neural-network]]></category>
            <dc:creator><![CDATA[Esma Bozkurt]]></dc:creator>
            <pubDate>Fri, 14 Apr 2023 19:06:20 GMT</pubDate>
            <atom:updated>2023-04-14T19:06:20.648Z</atom:updated>
            <content:encoded><![CDATA[<p>I<a href="https://esmabozkurt.medium.com/how-do-artificial-neural-networks-learn-in-deep-learning-e28fc36c4bf5"> have mentioned that Convolutional Neural Networks (CNN)</a>, which is a type of Artificial Neural Networks, consists of layers and learning occurs with the forward/backward propagation mechanism with each layer. In this article, I will talk about Recurrent Neural Networks (RNN) which is another type of neural networks and how they work.</p><p>We can say that RNN produce solutions to problems expressed as time series. It is especially used in voice processing (such as speech to text/text to speech, music production) because sound is a continuous data over time. It is also used in natural language processing (especially emotion recognition and emotion analysis from text, positive-negative interpretation) and text translation (Text Search and Analytics). At the same time, RNN types (such as LSTM) are frequently used in medical applications such as predictions of DNA sequences. Moreover, it is also used in the coding and production of drugs and chemicals. Although we use a CNN in image processing, we can also use RNN in the solutions of videos where this image extends over the time series. RNN can also be used when deciding whether a machine is due for maintenance or determining whether it will fail (Predictive Maintenance). It can even be used in finance. So, let’s make an introduction to RNN, which has a very wide usage area.</p><p>In classical neural networks, the inputs goes the output with layers, and when feeding forward, all inputs affect all outputs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*M0TXAL2pTQQt3BuxMsHmdg.png" /></figure><p>Here we can encounter situations where x&lt;T&gt; and y&lt;T&gt; are not equal to each other. Due to the effect of time and sequence, different sequences encountered throughout the text would not be learned in such a model. We use RNN for such reasons.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*r9FtN9KeEpNRvSjiODwoYg.png" /></figure><p>Here are the words according to the working principle of RNN; It is expressed with vectors by giving 1 to the related word and 0 to other words. For example, in the sentences above, we see that proper nouns are given 1 and others 0. Each word is placed in the dictionary (vector) in turn. In the text example above, the vector length is set to 10000 based on the number of words. Then, in the part of the word, that word is given 1 and the others 0 and learning is provided sequentially. Learning takes place iteratively in this way, and for every input, each output is equal. In this way, the model of the artificial neural network we have created has changed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*uQcqyGv9rbrBDho_vj8qoQ.png" /></figure><p>Here a&lt;0&gt; becomes the input weight vector and I need to know the values of the first input x&lt;1&gt; and a&lt;0&gt; to calculate the estimation y^&lt;1&gt;. In the next step, I get the values of y^&lt;2&gt; and a&lt;2&gt;, which I estimated by processing a&lt;1&gt; and x&lt;2&gt;. Here, each of the x entries represents a word. Let’s not forget that these are not layers, but rather time-dependent progression. At the same time, the weights are the same for each word, and the y^&lt;Ty&gt; value at the last moment will depend on each operation before it. Here I will need to know each x input values for output. For example, to calculate y^&lt;3&gt;, I need to know x&lt;3&gt;,x&lt;2&gt;,x&lt;1&gt;,a&lt;1&gt;,a&lt;0&gt;.</p><blockquote>Note: The y values obtained in CNN were not dependent on each x input value and were different weights.</blockquote><p>The biggest disadvantage of RNN is that estimations are always depend on previous information. In some cases we will have to take future information into account and it will be a problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*0bezLfyo7SG7wjC1Hhsoeg.png" /></figure><p>To define Candy, as in this example, we should look at the words after it, not the words before it. For this, we will need to take information about future into account.</p><h4><strong>RNN Calculations</strong></h4><p>First, let’s look at the processing of a&lt;0&gt; and x&lt;1&gt; and the calculation of y^&lt;1&gt; and a&lt;1&gt;:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/1*0NJ7QzUr620JHG69T6_ZFg.png" /></figure><p>Firstly, the new a value is determined by multiplying the x input and a values with the W weights and adding the bias value. While calculating the y value, the new a value we found is weighted again and the bias is added. Here “g” is an activation function like ReLu. Although the ReLu activation function is often preferred in CNN, it is not preferred in RNN. Hyperbolic tangent (tanh) is generally preferred in RNN. The same or different activation functions can be preferred when calculating a and y in the process. If we generalize the operation we have described, we get the following expressions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*QbVJPRH1t6BW9H0GVwj1Kw.png" /></figure><p>Therefore, when calculating y^&lt;t&gt;, I am using the value of a&lt;t&gt; that I have calculated. Generally, when calculating a, hyperbolic tangent (tanh) and ReLu (rarely) and sigmoid activation functions are preferred when calculating y outputs. Softmax can also be used for output according to the problem.</p><p>Here, Waa is a 100x100 matrix and a is a vector of 100. Considering that the x input value is a 10000 long vector according to the number of words in the input, we express the Wax value as a 100x10000 matrix.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*bqFSZ48XYj4plixudQ3fJg.png" /></figure><p>We can also express the Wax expression and the general a expression as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*Npn9VUscwfVV1pJERR9gBg.png" /></figure><p>We will use more indexed expressions in the future and we will have a hard time writing the expression a and y. So we simplify the expression in this way.</p><blockquote>We can think of these calculations, which we have progressed from left to right, as feed-forward. Well, let’s examine how the back propagation algorithm works in RNN.</blockquote><p>First of all, we need to use the loss value and the current values of the weights in back propagation. With the loss function (euclidean distance, mean squares error, cross entropy, etc.), we can calculate the loss value between the estimated y^ and the real y value. So how do we update the weights?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*NvGt2SixYLCyscKYtwWEug.png" /></figure><p>In the forward propagation, we calculated the a and y values using the W weights and the L value. Now we need to update these weights. For this, we will use optimization algorithms such as gradient descent.</p><p>In backpropagation, we will calculate the y and a values, respectively, by going backwards from Loss. The outputs we will obtain will be the current Wa, Wy values. Then again, forward propagation will take place using these Wa, Wy values.</p><blockquote>Recursive neural networks (RNN) may need different designs according to their usage areas.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*Uqp0WsyE6a49gKcoGydIOQ.png" /></figure><p>For example, there can be a single input and multiple outputs, as in music production, or multiple inputs and single outputs, as in sentiment analysis, or multiple inputs, multiple outputs, such as in machine translation. In this way, it is possible to design different RNNs for the inputs and outputs of different data types.</p><h4><strong>Language Model and Sequence Generation with RNN</strong></h4><p>While reading, we may encounter words and sentences that are very similar to each other but have quite different meanings. For example, structures used in different tenses such as “red” and “read”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*ibeeWTBeBXSomXaiosLuBQ.png" /></figure><p>We know that we will encounter “read” more often here, so its probability will be high.</p><p>The same is true for word indexes. For example, after the phrase “hard to”, the word above is more common:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*Jilo6CSxVUOF3JyucedjKg.png" /></figure><p>At the same time, we need to assign a “dot” or a value to indicate that the sentence is finished. In other words, while we get y output for each word, we should also get y output for the dot. I will use the EOS (end of sentence) value to express the point:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*Lt7ldW6BkoqdQ_4NJ1C7wA.png" /></figure><p>We may also encounter “unknow” words that are not found in the dictionary. In this example there are two words denoting the breed of dog. I have to define them as &lt;&lt; Unk &gt;&gt;:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*43bNbfbol0e_CWfK4NtKig.png" /></figure><p>Now let’s examine the RNN model in the sentence “Dogs live for about 14 years &lt;&lt;EOS&gt;&gt;”. Here we can consider the entire dictionary as a pool of possibilities. The pool contains the probability of all words from P(a) to P(&lt;EOS&gt;):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*OBdOolnuBUp7XY39p5K6Sg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*IK44nYGoLs_7na72WzizDQ.png" /></figure><p>Here, the first word of the sentence is dogs, and there is no word before it. So x&lt;1&gt; = 0. Then we make the y^&lt;1&gt; estimation. The estimated value will be the input of the new word. So x&lt;2&gt; = y^&lt;1&gt; (dogs). After Dogs, live comes and x&lt;3&gt; = y^&lt;2&gt; (live). We see that each word depends on the previous words. Finally, there is the situation where &lt;&lt;EOS&gt;&gt; comes after “years”.</p><p>Here we see that y&lt;2&gt; is a probability depending on y&lt;1&gt; before it and y&lt;3&gt; depending on y&lt;2&gt; and y&lt;1&gt; before it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*wiRBp6vB_4VKpF6S05WG5A.png" /></figure><p>With this model we created, I learn new words from left to right, and at the end of the model, I get a loss function (softmax, cross entropy, etc.). At this loss value, we calculate the loss between the real y and the estimated y’s. The loss function is expressed as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/1*EcqpDHaQcVXn_CeYRJd81w.png" /></figure><p>For example, we can use the Cross entropy loss function here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*LYLVCMV-mrd29ZQ9ZhWUCw.png" /></figure><h4><strong>Character-Level Language Model</strong></h4><p>This word-level language model makes it difficult to predict the next word in “unknown” words and will cause errors in the calculations. We use the character-level language model for this. For example, the two words here are “unknown”, which indicates the breed of dog:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/1*fi89HaRBV1QiPspWS0kijw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*_UMoNcQAdIFssHaY77fr8w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/1*5_FP1phzUxqkCnKBRy0zQQ.png" /></figure><p>Here x inputs will be “character (letters)”, not words. We often use this model to define &lt;&lt; Unk &gt;&gt; words. It would require us to calculate longer strings as we would have to express each character, which would increase the processing overhead. Therefore, we have a higher success rate in the word-level language model and use it more often.</p><h4>Vanishing Gradients</h4><p>Where the derivative of the activation function we used while taking the derivative in back propagation was 0, the weights were also updated with 0 and causing loss of information. Therefore, there was no learning in those parts (Vanishing Gradients). We may encounter this problem in the RNN model as well.</p><p>In order to have information about a word in RNN, the previous word or words, that is, words as close as possible, are looked at. However, this may not always be so.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*ijM5wbltSpwL-LDs7gcxwg.png" /></figure><p>For example, in order to predict “French” in this sentence, we must have information about the word “France”, but this information was given to us at the beginning of the article. There may be many sentences in between and different city names in those sentences.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*yawRl9wMDq5lx9jse4B08w.png" /></figure><p>Like here, in order to decide which was/were to use, I need to be able to decide whether the first word is singular or plural. RNN is not very skilled at getting information from the old past so it may not be successful in long sentences. So how can we learn this?</p><p>Actually, there are many methods we use for this problem. These methods are:</p><ul><li>Gated Recurrent Units (GRU)</li><li>Long Short Term Memory (LSTM)</li><li>Bidirectional RNN</li><li>Deep RNN</li></ul><p>I will include these methods on my next article. For now, don’t forget to follow me, see you soon!</p><p><em>Reference: </em>deeplearning.ai</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a4cc0238601" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Özyinelemeli Sinir Ağlarına Giriş]]></title>
            <link>https://esmabozkurt.medium.com/%C3%B6zyinelemeli-sinir-a%C4%9Flar%C4%B1na-giri%C5%9F-29ef9004d9c5?source=rss-78dccce92e8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/29ef9004d9c5</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[recurrent-neural-network]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[rnn]]></category>
            <category><![CDATA[neural-networks]]></category>
            <dc:creator><![CDATA[Esma Bozkurt]]></dc:creator>
            <pubDate>Sat, 08 Apr 2023 12:37:37 GMT</pubDate>
            <atom:updated>2023-04-08T12:37:37.841Z</atom:updated>
            <content:encoded><![CDATA[<p>Yapay Sinir Ağlarının bir sınıfına özgü Evrişimli Sinir Ağları’nın (Convolutional Neural Networks (CNN)) katmanlardan oluştuğunu ve her katmanla birlikte ileri/geri yayılım mekanizması ile öğrenmenin gerçekleştiğini <a href="https://esmabozkurt.medium.com/derin-%C3%B6%C4%9Frenmede-yapay-sinir-a%C4%9Flar%C4%B1-nas%C4%B1l-%C3%B6%C4%9Frenir-aab34917552a">öğrenmiştik</a>. Bu yazımda ise Özyinelemeli Sinir Ağları’ndan (Recurrent Neural Networks (RNN)) ve nasıl çalıştıklarından bahsedeceğim.</p><p>Özyinelemeli Sinir Ağları, zaman serisi şeklinde ifade edilen problemlere çözüm üretir diyebiliriz. Özellikle ses işlemede (speech to text/text to speech, müzik üretimi gibi) sıkça kullanılır çünkü ses zaman boyunca süregelen bir veridir. Doğal dil işleme alanında (özellikle metinden duygu tanıma ve duygu analizi, olumlu-olumsuz yorum gibi) ve metin çevirisinde ve seslendirilmesinde (Text Search and Analytics) de kullanılmaktadır. Aynı zamanda DNA dizilimlerinin kestirimleri gibi medikal uygulamalarda da RNN türleri (LSTM gibi) sıkça kullanılır. Dahası ilaç ve kimyasalların kodlanmasında ve üretiminde de kullanılıyor. Görüntü işlemede de her ne kadar biz evrişimli sinir ağı kullansak da bu görüntünün zaman serisi boyunca uzanmış olduğu videoların çözümlerinde de RNN kullanabiliyoruz. Bir makinenin bakım zamanının gelip gelmediğine karar verirken veya arıza oluşturup oluşturmayacağını tespit ederken (Öngörücü Bakım) de RNN kullanılabilir. Finans alanında dahi kullanılabilir. Öyleyse kullanım alanı oldukça geniş olan RNN’e bir giriş yapalım.</p><p>Klasik yapay sinir ağlarında girişlerimiz katmanlarla birlikte çıkışa ulaşıyordu ve ileri besleme yaparken tüm girişler tüm çıkışları etkiliyordu:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*oHvspnAwlXM4dmZGLNbiww.png" /></figure><p>Burada x&lt;T&gt; ve y&lt;T&gt; ‘nin birbirine eşit olmadığı durumlarla karşılaşabiliyoruz. Zaman ve dizi etkisi dolayısıyla böyle bir modelde metin boyunca karşılaşılan farklı dizilimler öğrenilmemiş olur. Bu gibi etkenler dolayısıyla RNN kullanırız.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*BfcL9EEgsY9ch5xDGdZOfA.png" /></figure><p>Burada RNN’in çalışma prensibine göre kelimeler; ilgili kelimeye 1, diğer kelimelere 0 verilirerek vektörlerle ifade edilir. Örneğin yukarıdaki cümlelerde özel isimlere 1, diğerlerine 0 verildiğini görüyoruz. Her kelime sırayla sözlüğe (vektöre) yerleştirilir. Yukarıdaki metin örneğinde kelime sayısına göre vektör uzunluğu 10000 olarak ayarlanmış. Daha sonra her kelimenin bulunduğu kısımda o kelimeye 1 diğerlerine 0 verilir ve sırayla öğrenme sağlanır. Öğrenme bu şekilde yinelenerek gerçekleşir ve her giriş için her çıkış eşit olmuş olur. Bu şekilde oluşturmuş olduğumuz yapay sinir ağının modeli değişmiş oluyor:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*h9ERGPX_UEsUX9U0KZjINQ.png" /></figure><p>Burada a&lt;0&gt; giriş ağırlık vektörü olmuş oluyor ve y^&lt;1&gt; kestirimini hesaplamak için ilk giriş olan x&lt;1&gt; ve a&lt;0&gt;’ın değerlerini bilmem gerekiyor. Daha sonraki aşamada a’nın 1’den gelen değeri ile x&lt;2&gt; ‘nin işleme girmesiyle kestirdiğim y^&lt;2&gt; ve a&lt;2&gt; değerlerini elde ediyorum. Burada x girişlerinin her biri birer kelimeyi ifade ediyor. Bunların katman değil, zamana bağlı ilerleme olduğunu unutmayalım. Aynı zamanda ağırlıklar her bir kelime için aynı olup son andaki y^&lt;Ty&gt; değeri, kendisinden önceki her işleme bağlı olmuş olacak. Burada çıkış için her x giriş değerlerini biliyor olmam gerekecek. Örneğin y^&lt;3&gt; ü hesaplayabilmek için x&lt;3&gt;,x&lt;2&gt;,x&lt;1&gt;,a&lt;1&gt;,a&lt;0&gt;’ı bilmem gerekir.</p><blockquote>Not: CNN’de elde edilen y değerleri her x giriş değerine bağlı değildi ve farklı ağırlıklar söz konusuydu.</blockquote><p>RNN’in en büyük dezavantajı kestirimlerin her zaman kendinden önceki bilgilere bağlı olarak gerçekleşmesidir. Bazı durumlarda gelecekteki bilgileri de hesaba katmamız gerekecek ve problem oluşturacaktır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*pXA7B067EtjH99AzDs8NZQ.png" /></figure><p>Bu örnekteki gibi Candy’i tanımlayabilmemiz kendisinden önceki kelimelere değil, sonraki kelimelere bağlıdır ve gelecekteki bilgileri hesaba katmamızı gerektirecektir.</p><h4>RNN Hesaplamaları</h4><p>İlk olarak a&lt;0&gt; ve x&lt;1&gt; in işleme sokulup y^&lt;1&gt; ve a&lt;1&gt;’in hesaplanmasını inceleyelim:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*aANL9utHpZelS8bR-9Q-wg.png" /></figure><p>Öncelikle x giriş ve a değerleri W ağırlıklarıyla çarpılarak ve bias değeri eklenerek yeni a değeri belirlenir. Daha sonra y değeri hesaplanırken de bulmuş olduğumuz yeni a değeri tekrar ağırlandırılır ve bias eklenir. Burada “g” ReLu gibi bir aktivasyon fonksiyonudur. ReLu aktivasyon fonksiyonu CNN’de sık tercih edilmesine rağmen, RNN’de pek tercih edilmemektedir. RNN’de genellikle hiperbolik tanjant (tanh) tercih edilmektedir. İşlemde a ve y hesaplanırken aynı veya farklı aktivasyon fonksiyonları tercih edilebilir. Belirttiğimiz işlemi genelleştirirsek şu ifadeleri elde ederiz:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*wYoPkX4k19OiRLHbzBqzhQ.png" /></figure><p>Dolayısıyla y^&lt;t&gt; hesaplanırken, hesaplamış olduğum a&lt;t&gt; değerini kullanmaktayım. Genellikle a hesaplanırken hiperbolik tanjant (tanh) ve ReLu (nadiren de olsa) ve y çıkışları hesaplanırken de sigmoid aktivasyon fonksiyonları tercih edilmektedir. Probleme göre çıkış için softmax de kullanılabilir.</p><p>Burada Waa 100x100’lük bir matris olup a değeri de 100’lük bir vektör olmuş olsun. Girişteki kelime sayısına göre x giriş değerinin 10000’lik bir vektör olduğunu düşünürsek Wax değerini 100x10000’lik bir matris olarak ifade ederiz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*T7i0hSzQoY8-kPoQ46HR-A.png" /></figure><p>Wax ifadesini ve genel a ifadesini şu şekilde de ifade edebiliriz:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*o_UUVWBcxBouDhFUFiqDUg.png" /></figure><p>İleride daha fazla indisli ifadeler kullanacağımızdan a ve y ifadesini yazmakta zorlanacağız. Dolayısıyla ifadeyi bu şekilde basitleştirmekteyiz.</p><blockquote>Soldan sağa doğru ilerlemiş olduğumuz bu hesaplamaları ileri besleme olarak düşünebiliriz. Peki RNN’de geriye yayılım algoritması nasıl çalışıyor biraz da bunu inceleyelim.</blockquote><p>Öncelikle geriye yayılımda loss (yitim) değeri ve ağırlıkların güncel değerlerini kullanmamız gerekiyor. Loss fonksiyonu ile (öklid uzaklığı, ortalama kareler hatası, cross entropi vs.) kestirilen y^ ve gerçek y değeri arasındaki loss değerini hesaplayabiliriz. Peki ağırlıkları nasıl güncelleyeceğiz?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*b_8rw8f0BiRTEy_WO9cA7g.png" /></figure><p>İleri yayılımda W ağırlıklarını kullanarak a ve y değerlerini, buna bağlı olarak da L değerini hesaplamıştık. Şimdi bu ağırlıkları güncellememiz gerekiyor. Bunun için de gradient descent gibi optimizasyon algoritmaları kullanacağız.</p><p>Geriye yayılımda Loss’dan geriye doğru giderek sırasıyla y ve a değerlerini hesaplayacağız. Elde edeceğimiz çıkışlar güncel Wa, Wy değerleri olacak. Daha sonra yine bu Wa, Wy değerleri kullanılarak tekrar ileri yayılım gerçekleşecek.</p><blockquote>Özyinelemeli sinir ağları (RNN) kullanım alanlarına göre farklı tasarımlara ihtiyaç duyabilir.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*zXdx0CorlhyRO7r4nyDICw.png" /></figure><p>Örneğin müzik üretmedeki gibi tek bir giriş ve çoklu çıkış olabilir veya duygu analizindeki gibi çoklu giriş tek çıkış şeklinde de olabilir. Bu şekilde farklı veri tiplerinin girişleri ve çıkışları için farklı RNN’ler tasarlamak mümkün olur.</p><h4>RNN ile Dil Modeli ve Dizi Üretimi</h4><p>Okunurken birbirine çok benzeyen ancak oldukça farklı anlamlara sahip kelime ve cümlelerle karşılaşabiliriz. Örneğin “red” ve “read” gibi farklı tense’lerde kullanılan yapılar gibi:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*H9vNjerAkk0WGkGMnxDszw.png" /></figure><p>Burada “read” ile daha sık karşılaşacağımızı biliyoruz, o yüzden onun olasılığı daha yüksek olacaktır.</p><p>Kelime dizinlerinde de bu böyledir. Örneğin hard to ifadesinden sonra üstteki kelime ile karşılaşılma sıklığı daha yüksektir:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*XjJpPnS7Shwg4YKddhQStA.png" /></figure><p>Aynı zamanda cümlenin bitmiş olduğunu ifade eden “nokta” ya da bir değer atamamız gerekir. Yani her kelime için bir y çıktısı elde ederken nokta için de bir y çıktısı elde etmeliyim. Noktayı ifade etmek için de EOS (end of sentence) değerini kullanacağım:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*1PRwj7zyXLpsaNqkSeuG_Q.png" /></figure><p>Sözlükte bulunmayan “unknow” kelimelerle de karşılaşabiliriz. Bu örnekte köpek cinsini ifade eden iki kelime var. Bunları da &lt;&lt;UNK&gt;&gt; olarak tanımlamış olmam gerekiyor:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*MKgKLCHD9N7x9PXTFq7mhQ.png" /></figure><p>Şimdi “Dogs live for about 14 years. &lt;&lt;EOS&gt;&gt;” cümlesindeki RNN modelini inceleyelim. Burada sözlüğün tamamını bir olasılık havuzu gibi düşünebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*sXIiTcZ7cV1TuZM4xqBCHw.png" /></figure><p>Havuz P(a)’dan başlayıp P(&lt;EOS&gt;)’a kadar tüm kelimelerin olasılığını içerir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*fBkurlawI_ZmZmjZGVhneg.png" /></figure><p>Burada cümlenin ilk kelimesi dogs ve ondan önce herhangi bir kelime yok. O yüzden x&lt;1&gt; = 0 olacaktır. Daha sonra y^&lt;1&gt; kestirimini yapıyorum. Kestirdiğim değer yeni kelimenin girişi olmuş olacak. Yani x&lt;2&gt; = y^&lt;1&gt; (dogs) olmuş oluyor. Daha sonra Dogs’dan sonra live geliyor ve x&lt;3&gt; = y^&lt;2&gt; (live) olmuş oldu. Her kelimenin bir önceki kelimelere bağlı olduğunu görüyoruz. En sonda da “years” den sonra &lt;&lt;EOS&gt;&gt; gelmesi durumu var.</p><p>Burda y&lt;2&gt;’nin kendinden önceki y&lt;1&gt; ve y&lt;3&gt;’ün kendinden önceki y&lt;2&gt; ve y&lt;1&gt;’e bağlı bir olasılık olduğunu görmekteyiz:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*ZsBH9xLjsZ7Ub4QcyNZvdA.png" /></figure><p>Oluşturduğumuz bu model ile soldan sağa doğru yeni kelimeler öğrenmiş oluyorum ve modelin sonunda bir loss fonksiyonu ile (softmax, cross entropy vs.) elde ediyorum. Bu loss (yitim) değerinde de gerçek y ve kestirdiğimiz y’lerin arasındaki loss’u hesaplıyoruz. Genel ifadesiyle loss fonksiyonu şu şekildedir:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*evvKmiOXLIvEMIBpxdfQAg.png" /></figure><p>Örneğin burada Cross entropy loss fonksiyonunu kullanabiliriz:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*zZX2lV2pYVQFKfQDNBnPzA.png" /></figure><h4>Karakter Seviyeli Dil Modeli</h4><p>Bu kelime seviyeli dil modeli “unknown” bilinmeyen kelimelerde bir sonraki kelimenin tahminini zorlaştırır ve hesaplamalarda hataya sebebiyet verecektir. Bunun için karakter seviyeli dil modelini kullanırız.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*8UN1NQmQSr9y-d7Bt6Sz2Q.png" /></figure><p>Örneğin buradaki iki kelime köpek cinsini belirten “unknown” bir kelimedir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*QnInOTXee-EjUz8osEh8aw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*NC8wyPaO7_onTJytqap59Q.png" /></figure><p>Burada x girişleri kelime değil “karakter (harf)” olacaktır. Bu modeli sıklıkla &lt;&lt;UNK&gt;&gt; kelimeleri tanımlayabilmek için kullanırız. Her bir karakteri ifade etmemiz gerekeceğinden daha uzun diziler hesaplamamızı gerektirir ve bu da işlem yükünü arttıracaktır. Dolayısıyla biz kelime seviyeli dil modelinde başarı oranımız daha yüksektir ve onu daha sık kullanırız.</p><h4>Vanishing Gradients (Gradyanların Yok Olması Problemi)</h4><p>Geriye yayılımda türev alırken kullandığımız aktivasyon fonksiyonunun türevinin 0 olduğu yerlerde ağırlıklar da 0’la güncellenmiş olup bilgi kaybı yaşamımıza sebep oluyordu. Dolayısıyla o kısımlarda öğrenme gerçekleşmiyordu (Vanishing Gradients). Bu problemle RNN modelinde de karşılaşabiliriz.</p><p>RNN’de bir kelime hakkında bilgi sahibi olabilmek için bir önceki kelimeye veya kelimelere yani olabildiğince yakın kelimelere bakılır. Ancak bu her zaman böyle olmayabilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*bPg75D26FLAxr3YlUwUIjg.png" /></figure><p>Örneğin bu cümlede “French” tahmini yapabilmemiz için “France” kelimesi hakkında bilgi sahibi olmalıyız ancak bu bilgi yazının en başında bize verilmiştir. Yani arada birçok cümle geçmiş olabilir ve o cümlelerde farklı şehir isimleri de geçmiş olabilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*X0_84JM60OMlhaeG_iyd2w.png" /></figure><p>Buradaki gibi was/were hangisini kullanacağıma karar verebilmem için de en baştaki kelimenin tekil mi çoğul mu olduğunu karar verebilmem gerekir. RNN eski geçmişten bilgi alma konusunda pek yetenekli değil yani uzun cümlelerde başarılı olamayabilir. Peki bunu nasıl öğrenebiliriz?</p><h4>DO NOT PANIC!</h4><p>Aslında bu problem için kullandığımız birçok yöntem var. Şimdi bu yöntemlerin ne olduğuna bakalım:</p><ul><li>Gated Recurrent Units (GRU)</li><li>Long Short Term Memory (LSTM)</li><li>Bidirectional RNN</li><li>Deep-RNN</li></ul><p>Yazıyı daha fazla uzatmamak adına bu yöntemlere bir sonraki yazımda yer vereceğim. Şimdilik beni takip etmeyi unutmayın, görüşmek üzere!</p><p><em>Kaynak: </em>deeplearning.ai</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29ef9004d9c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Do Artificial Neural Networks Learn in Deep Learning?]]></title>
            <link>https://medium.com/codex/how-do-artificial-neural-networks-learn-in-deep-learning-e28fc36c4bf5?source=rss-78dccce92e8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e28fc36c4bf5</guid>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[artificial-neural-network]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Esma Bozkurt]]></dc:creator>
            <pubDate>Fri, 24 Feb 2023 08:02:23 GMT</pubDate>
            <atom:updated>2023-02-24T08:02:23.550Z</atom:updated>
            <content:encoded><![CDATA[<p>Deep learning is a sub-branch of machine learning based on the functioning of the human brain in data processing. The aim is to create the modeling of neural networks in the brain and to produce humanoid solutions to problems. In this way, it allows machines to learn without human supervision. It uses artificial neural networks for this purpose. Neural networks can be single-layer or multi-layered. Deep learning models are based on multilayer neural networks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*Uzraphxv6aozpVYbqYYAVw.jpeg" /></figure><p>To understand the functioning of neural networks, we can think of impulse transmission in neurons. Here, the data received from the dendritic ends are weighted in the nucleus (multiplied by w) and transmitted along the axon and connected to another nerve cell. Axons (x’s) coming out of one neuron become inputs to the other neuron. In this way, transmission between nerves is ensured. In order to model and train it on the computer, we need to know the algorithm of this operation, that is, we need to be able to obtain output by applying a series of commands to the inputs. So how can we express this mathematically?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*wuxiLXRkjQpheKziXa9a4g.png" /></figure><p>The values [1] and [2] in the picture represent the layer numbers, and you can see a single-layer network structure at the top and a simple multi-layer network structure at the bottom (it has become 2 layers by adding 1 hidden layer). It would be useful to examine both at the same time so that the operations are understandable.</p><p>The x input values are multiplied with the w weights (these weights reflect the importance of the inputs), which are given random values at the beginning, and the bias (the error/bias value reflecting the distance between the predicted data and the actual data as a result of the modeling) is added to get the z value, this value has a value in the common node (neuron). The a value obtained by subjecting it to the activation function (sigmoid) becomes our output and this a value is subjected to a loss function (which gives information about the error rate of the model) with the desired y value. First, this loss function will have a high value because the system is just starting to learn.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/461/1*IPb6Hk8S-1AdLTgYkKPF2A.png" /></figure><p>Then we have to go back and do all the work in the opposite direction. We go backwards by derivative (back propagation) and note down the values obtained. The new weight values become important in this process because we will use these new weight values as we go forward again. We continue this process, which we call the feed forward back propagation algorithm, until the loss converges to the minimum and we find the best model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*7JlZZaN-0nDCDKPMrFYmhw.png" /></figure><p>In the picture above, you can see a 2-layer neural network, a hidden layer with 4 neurons and an output layer with a single neuron. The input layer (0&#39;nd layer) has no effect on the number of layers. These values are expressed as w(number of neurons in its layer, number of input values) and b(number of neurons in its layer, 1). The inputs of the hidden layer are x and the inputs of the output layer are the values of a:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*Z1ytkmmA0D71yDnMfxiJ3w.png" /></figure><p>Instead of sigmoid function as activation function, hyperbolic tangent, ReLU, Leaky ReLU etc. available. These functions are used in layers and must be differentiable. Because we update the weights by taking the derivative operation in back propagation.</p><p>Hyperbolic tangent (tanh) is the sigmoid shifted from -1 to +1. Since its average is 0, we can say that it performs better than the sigmoid function, whose average is 0.5. It is also exponential.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*gioeFcHM8NwGUXIGcLXF1Q.png" /></figure><p>It is more meaningful to use tanh in the hidden layers and sigmoid in the output layers. Especially if we want a value in the range of 0–1 at the output, we should use sigmoid because sigmoid is in the range of 0–1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*h1_i7yLVEEC3jIrvbsqreA.png" /></figure><p>Recently, ReLU activation function is most used in deep learning. Since parts less than 0 are not differentiable in ReLU, they cannot participate in the process and learning does not occur in that part. Values less than 0 are also differentiable in Leaky ReLU, and since there is a result for each value, learning takes place in any case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*TID3chLljPOhq15SLY1QcA.png" /></figure><p>The above expression is called cost function, we can express y^ and y in the cost function as the average of the difference between the desired value and the value we get.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/172/1*GhHnzgQ3K6ALMG-7C_MClw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/134/1*J0Mc72RadeH1jB8jh7rZdg.png" /></figure><p>The above expression is called Gradient Descent Algorithm. The purpose of the gradient descent algorithm is to minimize the cost. There are other methods for this as well. Convergence to the minimum is important to optimize our model. The alpha value here is the learning rate.</p><h4><strong>Backpropagation Algorithm &amp; Chain Rule</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*XRiCALTRm09FPb-02b4ugw.png" /></figure><p>We said that we are going backwards by taking the derivative in backward propagation. Let’s examine this through an example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*4vKupafn6wvVnhSEWPIesQ.png" /></figure><p>Let’s go step-by-step, assuming the sigmoid function is used in the example and the result of f (its derivative) at the output is 1. Let’s go backwards, taking the derivative of the last 1/x operation:</p><p>First, replace d(1/x)/dx= (-1/x²) → x with 1.37 and multiply by 1, indicated in red→ -0.53:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/264/1*3mvVqjiWxeoxRhtYRWjfmg.png" /></figure><p>It goes to the previous operation. d(c+x)/dx=1 will come from the derivative of the sum in the +1 operation and it is multiplied by the previous value of -0.53 → -0.53 :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/228/1*PRRJwx8GJ7gJTYti4NPB0g.png" /></figure><p>In the other operation, the derivative of e^x is itself and (e^-1.00)*-0.53 =-0.20. We multiply the -0.20 value we found, this time by the derivative of the previous product, d(ax)/dx=-1, and our other value will be 0.20. If we do all the backwards operations in this way, we calculate the new weights:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*U285up9HRwfFXUZxF625qA.png" /></figure><p>We can also express this process as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*YTH6SlUTMfd52JRyQWTz6Q.png" /></figure><p>In multi-layer neural networks, the initial values cannot be chosen as 0 as in single-layer, because learning will not take place because its derivatives will be the same as itself. Therefore, we should initially choose random values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*Td6UenWEoYg9aUcOu6woxw.png" /></figure><p>Finally, you can review the Python code of a two-layer network model below. See you in my next post!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/866828fef30c9c446f293d4a49790708/href">https://medium.com/media/866828fef30c9c446f293d4a49790708/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/197/1*zQUwgrHkvWAC-JVWTMzhrQ.png" /></figure><p><em>Reference: </em>deeplearning.ai</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e28fc36c4bf5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/how-do-artificial-neural-networks-learn-in-deep-learning-e28fc36c4bf5">How Do Artificial Neural Networks Learn in Deep Learning?</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Derin Öğrenmede Yapay Sinir Ağları Nasıl Öğrenir?]]></title>
            <link>https://esmabozkurt.medium.com/derin-%C3%B6%C4%9Frenmede-yapay-sinir-a%C4%9Flar%C4%B1-nas%C4%B1l-%C3%B6%C4%9Frenir-aab34917552a?source=rss-78dccce92e8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/aab34917552a</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[artificial-neural-network]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[derin-ogrenme]]></category>
            <dc:creator><![CDATA[Esma Bozkurt]]></dc:creator>
            <pubDate>Mon, 20 Feb 2023 11:12:43 GMT</pubDate>
            <atom:updated>2023-02-20T11:12:43.267Z</atom:updated>
            <content:encoded><![CDATA[<p>Derin öğrenme, veri işlemede insan beyninin işleyişini taklit eden bir makine öğrenimi alt dalıdır. Amaç beyindeki sinir ağlarının modellenmesini oluşturmak ve problemlere insansı çözümler üretmektir. Bu şekilde makinelerin insan denetimi olmadan öğrenmesini sağlar. Bunun için de yapay sinir ağlarını (artificial neural networks) kullanır. Sinir ağları tek katmanlı veya çok katmanlı olabilir. Derin öğrenme modelleri çok katmanlı sinir ağlarının üzerine temellendirilmiştir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*ry2alxU3pdxrpurnEPZWOw.png" /></figure><p>Sinir ağlarındaki işleyişi anlayabilmek için nöronlardaki impulse iletimini düşünebiliriz. Burada dentrit uçlardan alınan veriler çekirdekte ağırlandırılarak (w ile çarpılarak) akson boyunca iletiliyor ve başka bir sinir hücresine bağlanıyor. Bir nörondan çıkan aksonlar (x‘ler) diğer nöronun girdileri olmuş oluyor. Bu şekilde sinirler arası iletim sağlanmış oluyor. Bunu bilgisayarda modelleyip eğitebilmemiz için bu işlemin algoritmasını bilmemiz gerekir yani girdilere bir dizi komutlar uygulayarak çıktı elde edebilmemiz gerekir. Peki bunu matematiksel olarak nasıl ifade edebiliriz?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*wuxiLXRkjQpheKziXa9a4g.png" /></figure><p>Resimdeki [1] ve [2] değerleri katman numaralarını ifade etmekte olup üst kısımda tek katmanlı bir ağ yapısını ve alt kısımda basit bir çok katmanlı ağ yapısını görmektesiniz (1 gizli katman eklenerek 2 katmanlı olmuştur). Anlaşılabilir olması için ikisini aynı anda incelemek faydalı olacaktır.</p><p>Burada X girdi değerleri başlangıçta rastgele değerler verilen w ağırlıklarıyla (bu ağırlıklar girdilerin önemini yansıtıyor) çarpılıyor ve bias (modelleme sonucunda tahmin edilen veriler ile gerçek veriler arasındaki uzaklığı yansıtan hata/sapma değeri) eklenerek z değeri elde ediliyor, bu değerin ortak düğümde (nöron) bir aktivasyon fonksiyonuna (sigmoid) tabi tutulmasıyla elde edilen a değeri bizim çıkışımız oluyor ve bu a değeri istenilen y değeri ile bir loss fonksiyonuna (modelin hata oranı hakkında bilgi verir) tabi tutuluyor. İlk olarak bu loss fonksiyonu yüksek bir değerde olacaktır çünkü sistem daha yeni öğrenmeye başladı.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*0x95CexC5-taK3_lmH4EVg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*MQLz3D-Gp6m-cTGJF8cBnA.png" /></figure><p>Daha sonra geriye giderek tüm işleri tersi yönde yapmamız gerekiyor. Sigmoidde türevini alarak geriye doğru gidiyoruz (geriye yayılım) ve elde edilen değerleri not ediyoruz. Bu işlemde yeni ağırlık değerleri önemli hale geliyor çünkü tekrar ileri giderken bu yeni ağırlık değerlerini kullanacağız. İleri beslemeli geriye yayılım algoritması adını verdiğimiz bu işleme loss’u minimuma yakınsayıp en iyi modeli bulana kadar devam ediyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*7JlZZaN-0nDCDKPMrFYmhw.png" /></figure><p>Yukarıdaki resimde 4 nörona sahip 1 gizli katman ve tek nöronlu çıkış katmanı olmak üzere 2 katmanlı sinir ağını görüyorsunuz. Giriş katmanının (0.katman) katman sayısına etkisi yoktur. Bu değerler w(bulunduğu katmandaki nöron sayısı, girdi değerlerinin sayısı) ve b(bulunduğu katmandaki nöron sayısı, 1) olarak ifade edilir. Gizli katmanın girdileri x olup, çıkış katmanının girdileri a değerleridir:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*Z1ytkmmA0D71yDnMfxiJ3w.png" /></figure><p>Aktivasyon fonksiyonu olarak burada sigmoid kullanılmış olsa da, hyperbolic tangent, ReLU, Leaky ReLU vs. kullanılabilir. Bu fonksiyonlar katmanlarda kullanılır ve türevlenebilir olmalıdır. Çünkü geriye yayılımda türev işlemi alarak ağırlıkları güncelliyoruz.</p><p>Hyperbolic tangent (tanh), sigmoid’in -1 ile +1 arasında kaydırılmış halidir. Ortalaması 0 olduğundan ortalaması 0,5 olan sigmoid fonksiyonuna göre daha iyi performans sergiliyor diyebiliriz. Aynı şekilde üsteldir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*gioeFcHM8NwGUXIGcLXF1Q.png" /></figure><p>Ara katmanlarda tanh ve çıkış katmanlarında sigmoid kullanmak daha mantıklıdır. Özellikle çıkışta 0–1 aralığında bir değer istiyorsak sigmoid kullanmalıyız çünkü sigmoid 0–1 aralığındadır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*h1_i7yLVEEC3jIrvbsqreA.png" /></figure><p>Son zamanlarda derin öğrenmede en çok ReLU aktivasyon fonksiyonu kullanılır. ReLU’da 0’dan küçük kısımlar türevlenebilir olmadığından işleme katılamaz ve o kısımda öğrenme gerçekleşmez. Leaky ReLU’da 0’dan küçük değerler de türevlenebilir olup her değer için bir sonuç olduğundan her durumda öğrenme gerçekleşiyor demektir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/439/1*q1Fp17nao86RJXgZEz60uA.png" /></figure><p>Burada maliyet (cost) fonksiyonundaki y^ ve y ‘yi istenilen değer ile aldığımız değerin farkın ortalaması olarak ifade edebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*uPAy8QsrCDHHRw--TH_KUw.png" /></figure><p>Gradyan iniş (Gradient Descent) algoritmasındaki amaç da maliyeti minimalize etmektir. Bunun için başka yöntemler de vardır. Modelimizi optimize edebilmek için minimuma yakınsama önemlidir. Buradaki alfa değeri öğrenme oranıdır (learning rate).</p><h4>Geriye Yayılım Algoritması ve Zincir Kuralı (Backpropagation Algorithm &amp; Chain Rule)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*XRiCALTRm09FPb-02b4ugw.png" /></figure><p>Geriye yayılımda türev alarak geriye doğru gidiyoruz demiştik. Bunu bir örnek üzerinden inceleyelim:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*4vKupafn6wvVnhSEWPIesQ.png" /></figure><p>Örnekte sigmoid fonksiyonu kullanıldığını ve çıkışta f’in sonucunun (kendisinin türevi) 1 olduğunu varsayarak adım adım ilerleyelim. En sondaki 1/x işleminin türevini alarak geriye doğru gidelim:</p><p>İlk olarak d(1/x)/dx= (-1/x²) → x yerine 1.37 koyup kırmızıyla belirtilen 1 değeriyle çarpılır→ -0.53 :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/264/1*3mvVqjiWxeoxRhtYRWjfmg.png" /></figure><p>Bir önceki işleme geçilir. +1 işlemindeki toplam türevinden d(c+x)/dx=1 gelecektir ve az önceki -0.53 değeriyle çarpılır → -0.53 :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/228/1*PRRJwx8GJ7gJTYti4NPB0g.png" /></figure><p>Diğer işlemde e üzeri x in türevi yine kendisidir ve (e^-1.00)*-0.53 =-0.20 bulunur. Bulduğumuz -0.20 değerini bu sefer de bir gerideki çarpımın türevi d(ax)/dx=-1 ile çarparız ve diğer değerimiz 0.20 olur. Bu şekilde geriye doğru tüm işlemleri yaparsak yeni ağırlıkları hesaplamış oluyoruz:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*U285up9HRwfFXUZxF625qA.png" /></figure><p>Bu işlemi şu şekilde de ifade edebiliriz:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*YTH6SlUTMfd52JRyQWTz6Q.png" /></figure><p>Çok katmanlı sinir ağlarında başlangıç değerleri tek katmanlıdaki gibi 0 seçilemez çünkü türevleri de kendisinin aynısı olacağından öğrenme gerçekleşmeyecektir. Dolayısıyla başlangıçta rastgele (random) değerler seçmeliyiz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*Td6UenWEoYg9aUcOu6woxw.png" /></figure><p>Son olarak iki katmanlı bir ağ modelinin Python kodunu aşağıda inceleyebilirsiniz. Bir sonraki yazımda görüşmek üzere!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/866828fef30c9c446f293d4a49790708/href">https://medium.com/media/866828fef30c9c446f293d4a49790708/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/151/1*mse1gB0ppiIxno8gHxUrWg.png" /></figure><p><em>Kaynak: </em>deeplearning.ai</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aab34917552a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Statistics for Data Science in 20 Steps-I]]></title>
            <link>https://medium.com/analytics-vidhya/statistics-for-data-science-in-20-steps-i-622faff7ed84?source=rss-78dccce92e8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/622faff7ed84</guid>
            <category><![CDATA[normal-distribution]]></category>
            <category><![CDATA[hypothesis-testing]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[statistical-analysis]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Esma Bozkurt]]></dc:creator>
            <pubDate>Sat, 20 Mar 2021 18:04:11 GMT</pubDate>
            <atom:updated>2021-03-22T15:24:09.742Z</atom:updated>
            <content:encoded><![CDATA[<p>I mentioned that Data Science and Statistics complement each other but even the only statistics field is quite extensive. In this article, I will consider the statistic in the roadmap of data scientists in a very simplified and understandable way. So let’s dive into our topic, which is puzzling by most students, but doesn’t need to be feared! Here are our subheadings:</p><ol><li>Statistical Analytics Types</li><li>Standard Deviation and Variance</li><li>Gaussian/Normal Distribution</li><li>Standard Normal Distribution and Q-Q Plot</li><li>z-Score and Standardization</li><li>Probability Density Function</li><li>Kernel Density Estimation</li><li>Central Limit Theorem</li><li>Hypothesis Testing</li><li>Types of Errors</li><li>Skewness</li><li>Covariance Analysis</li><li>Correlation Analysis</li><li>Chebyshev’s Inequality</li><li>Binomial Distribution</li><li>Log-Normal Distribution</li><li>Power law</li><li>Box-Cox Transform</li><li>Poisson Distribution</li><li>Non-Gaussian Distribution</li></ol><h4>1) Statistical Analytics Types</h4><p>Statistical Analytics consists of defining, interpreting data for a specific purpose, making predictions for the future and taking action.</p><p><strong>Descriptive Analytics</strong> performs mathematical operations (such as mean, median, standard deviation) on the data and derives meaning from them. Thus, the data set is better understood. The data are visualized with graphs such as box graphs and histograms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*BnCgXV2iw65RtUfIHNUB_g.png" /></figure><p><strong>Predictive Analytics</strong> is a concept used in determining metrics such as sales and performance for the past or the future. Time Series Analysis, Regression, Multivariate Statistics techniques characterize the predictive model.</p><p><strong>Prescriptive Analytics</strong> is a prescriptive advanced analytics technique. It is the process of taking certain actions. For the continuity of the process, it is characterized by Graph analysis, Simulation, Neural Networks, Recommendation Engines, Heuristics, and Machine Learning techniques.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*JQdbId-3t739LiSsURjtmg.png" /></figure><h4>2) Standard Deviation and Variance</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*uN2AARTgY-QhAhxvHxTOiA.png" /></figure><p>Standard deviation is a measure used to summarize the spread of data values of a population, a sample, a probability distribution or a random variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HrZQIxCKEgh4itD8JvlSGQ.png" /></figure><p>The further the data is from the mean, the standard deviation increases and the distribution spreads.</p><p><strong>Variance</strong></p><p>Variance is the square of the standard deviation. It gives information about the extent of the variance distribution and it spreads as it increases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*NxUpeXc7Tmsu3ArBYx4c3Q.png" /></figure><h4>3) Gaussian/Normal Distribution</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*NpVt7Cs1gZ3EwJza7V5lyg.png" /></figure><p>It is a symmetrical probability distribution equidistant from the mean. Data closer to the average occur more frequently than data farther away.</p><h4>4) <strong>Standard Normal Distribution and Q-Q Plot</strong></h4><p>The distribution with a mean of zero and a standard deviation of 1 is called the Standard Normal Distribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*hAnJuU8oBCfdlJfWrDL_Bw.png" /><figcaption>Standard Normal Distribution</figcaption></figure><p>For example, this could be the distribution of the exam grades a class gets. Grades close to the average are in the majority, while there are fewer students who get low or high.</p><p><strong>Q-Q Plot</strong></p><p>Q-Q Plot is a probability plot used to graphically compare two probability distributions relative to each other. It provides a graphical view of how properties such as location, scale, skewnees are similar or different in the two distributions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a30625bd6e18927c013b7374986cea02/href">https://medium.com/media/a30625bd6e18927c013b7374986cea02/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/327/1*3x_u98KR__XsUA0vUOhpLg.png" /><figcaption>Q-Q Plot</figcaption></figure><h4>5) z-Score and Standardization</h4><p>It also called Standart Score. It is the number of standard deviations by which the value of a raw score (i.e., an observed value or data point) is above or below the mean value of what is being observed or measured. Raw scores above the mean have positive standard scores, while those below the mean have negative standard scores.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*qyG0Nas6T-ocUZaDcnh7_w.png" /></figure><p>This process of converting a raw score into a standard score is called <strong>standardizing</strong> or <strong>normalizing</strong>.</p><p><strong>Standardization (z-Score Normalization)</strong></p><p>We want to examine the relationship between the two values, but these data are numerically irrelevant. For example, if we look at the relationship between age and salary, salary data are very high compared to age. For example here, using z-Score Normalization, a meaningful relationship is provided between the two data.</p><p>Or we want to relate the midterm and final grades, but the final average is quite low. For example, the student who gets 45 from the midterm may be the last in the class, and the best in the final. Hence the values ​​are normalized to relate these two exams.</p><p>It subtracts the mean sequentially from the data and divide it by the standard deviation. We code in python like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/25de8b7ac99c25c3b61b98549356d444/href">https://medium.com/media/25de8b7ac99c25c3b61b98549356d444/href</a></iframe><h4>6) Probability Density Funciton</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*dCrbon3qRIc1XluaAj1pZg.png" /><figcaption>Probability of x between a-b</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*FzVQyKiALVFc3_FiQK0P1Q.png" /></figure><p>Probability density function is a statistical expression that defines a probability distribution (the likelihood of an outcome) for a discrete random variable (e.g., a stock or ETF) as opposed to a continuous random variable.</p><h4>7) Kernel Density Estimation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*RlAEJyqWizU6PVh71FexJw.png" /></figure><p>Kernel density estimation (KDE) is a non-parametric way to estimate the probability density function of a random variable. KDE is a fundamental data smoothing problem where inferences about the population are made, based on a finite data sample.</p><p>For example, let’s be a data set defined as patient-healthy. We show these data on the number line. Estimating the probability density (f(x)) by looking at this sample is called density estimation. Here we would expect f(x) to be larger where the sample is dense.</p><h4>8) Central Limit Theorem</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/1*JELtK8DSIQ9ZNkvdoQfFOg.png" /></figure><p>The central limit theorem states that if you have a population with mean μ and standard deviation σ and take sufficiently large random samples from the population with replacement , then the distribution of the sample means will be approximately normally distributed.</p><h4>9) Hypothesis Testing</h4><p>Hypothesis testing in statistics is a way for you to test the results of an analysis or experiment to see if you have meaningful results. You’re basically testing whether your results are valid by figuring out the odds that your results have happened by chance. If your results may have happened by chance, the experiment won’t be repeatable and so has little use.</p><p><strong>Hypothesis</strong></p><p>H0 (Null Hypothesis ): It basically defines the statement which states that there is no exact or actual relationship between the variables.</p><p>H1 or Ha (Alternative Hypothesis): It makes a statement that suggests or advises a potential result or an outcome that an investigator or the researcher may expect.</p><p><strong>Significance Level</strong></p><p>In hypothesis testing, the significance level is the criterion used for rejecting the null hypothesis. In other words, it is the numerical measure that we use to determine the strength of the sample evidence we are willing to consider strong enough to reject H0 is called the level of significance and it is denoted by alpha (α). Traditionally, experimenters have used either the 0.05 level (sometimes called the 5% level) or the 0.01 level (1% level).</p><p><strong>Test Statistic</strong></p><p>A test statistic is a statistic (a quantity derived from the sample) used in statistical hypothesis testing. The farther away a test statistic is away from the middle, the more likely it has a larger probability of being truely abnormal or enough evidence to say the null hypothesis is wrong.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*P-Ilk0V4-JHi0EBHJyMlug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*OsBDb7FeXv-hv9ZXDzbk1w.png" /></figure><p><strong>P-Value</strong></p><p>The <strong>P-value</strong> is the probability of observing a sample statistic. Low p-values are good; They indicate your data did not occur by chance. For example, a p-value of .01 means there is only a 1% probability that the results from an experiment happened by chance. In most cases, a p-value of 0.05 (5%) is accepted to mean the data is valid.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oNV0iGxI5G01LKNQL76fRA.png" /></figure><p><em>In questions, H0 is accepted as correct and the test statistic (z or t) is made. </em><br><em>The critical value is compared with the test statistic. If the z or t values ​​we find are in the part to be rejected (</em>if out of critical value<em>), H0 is rejected.</em></p><h4>10) Types of Errors</h4><p>Two potential types of statistical error are Type I error (α, or level of significance), when one falsely rejects a null hypothesis that is true, and Type II error (β), when one fails to reject a null hypothesis that is false.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YOmwaBdBIrg5YX5dNBjYwQ.png" /></figure><p>These were our first 10 steps. I do not want to extend this article in order not to bore you, stay tuned for the other 20 steps I will talk about covariance and correlation analysis!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=622faff7ed84" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/statistics-for-data-science-in-20-steps-i-622faff7ed84">Statistics for Data Science in 20 Steps-I</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Machine Learning Classification Algorithms with Codes]]></title>
            <link>https://medium.com/analytics-vidhya/machine-learning-classification-algorithms-with-codes-5a8af4491fcb?source=rss-78dccce92e8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a8af4491fcb</guid>
            <category><![CDATA[logistic-regression]]></category>
            <category><![CDATA[knn-algorithm]]></category>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[classification-algorithms]]></category>
            <dc:creator><![CDATA[Esma Bozkurt]]></dc:creator>
            <pubDate>Sun, 14 Mar 2021 18:17:30 GMT</pubDate>
            <atom:updated>2021-03-15T16:14:08.716Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone, today I will talk about Classification Algorithms. You can find my article on the difference between Regression and Classification <a href="https://medium.com/analytics-vidhya/introduction-to-machine-learning-regression-5bbf4ed96f40">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*uQjXtB4cEKYXJ2DO7l0BLw.png" /></figure><p>We said that we use regression for predicting numerical data such as price prediction, and classification for problems where there is no continuous variable such as labeling, yes or no. I have to say that some algorithms can be applied and work well for both regression and classification (such as K-NN, SVM, Decision Tree and Random Forest). Today’s Topics:</p><ul><li>Naive Bayes Classifier (Probabilistic Based)</li><li>K-Nearest Neighbors Classifier (Group Based)</li><li>Logistic Regression (Maximum Entropy Based)</li><li>Decision Tree Classifier (Tree Based)</li><li>Random Forest Classifier (Ensemble Based-Bagging)</li><li>Gradient Boost Classifier (Ensemble Based-Boosting)</li><li>Support Vector Machine (SVM)</li></ul><h4>Naive Bayes Classifier</h4><p>The <strong>Naive Bayes algorithm</strong> is a classification technique based on Bayes’ Theorem with an assumption of independence among predictors. In simple terms, a Naive Bayes classifier assumes that the presence of a particular feature in a class is unrelated to the presence of any other feature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*O1wfWpbSw0iAcUSjARtQmw.png" /><figcaption>Bayes Theorem</figcaption></figure><p>P(A|B): The probability that event A will occur when event B occurs.</p><p>In this dataset, we will predict whether employees will be hired or not.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4bbf8cfb9ea47ffa693000c1045d660f/href">https://medium.com/media/4bbf8cfb9ea47ffa693000c1045d660f/href</a></iframe><p>We divide the data into test and train. We use train to train the data, and we use the test to test our prediction.</p><p>It learns from the data with the fit function and makes predictions with the predict function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/42111c05e243755c2a694fb5853f0c5f/href">https://medium.com/media/42111c05e243755c2a694fb5853f0c5f/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*BFzZd-XDS5XE68QMYCEVKg.png" /></figure><p>Accuracy Score: It is the percentage of values classified as correct.</p><p>Precision Score: It shows how many of the values we guess positively are actually positive.</p><p>Recall Score: It shows “How many of the true positives have been correctly defined?”.</p><p>F1 Score: It is the harmonic mean of the Precision and Recall values. If both Precision and Recall values are important for the problem, the F1 score will also become important.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c85360674074971b0d07a7781a074b2/href">https://medium.com/media/2c85360674074971b0d07a7781a074b2/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/409/1*2EFKoiiEnC1xK7ESQCgJQg.png" /><figcaption>Confusion Matrix of b-test</figcaption></figure><p>The numbers in the confusion matrix are the number of TN, FP, FN, TP values in the data. Here our probability of</p><p>Accuracy: (TP + TN) / (TN + FP + FN + TP)<br>Precision: TP / (FP + TP)<br>Sensitivity: TP / (TP + FN)<br>Specifity: TN / (TN + FP)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*g5zpskPaxO8uSl0OWT4NTQ.png" /><figcaption>Confusion Matrix</figcaption></figure><p>Let’s calculate the accuracy according to confusion matrix:</p><p>(233+15) / (233+16+38+15) = 0.8211920529801</p><h4>K-Nearest Neighbors Classifier</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/423/1*ZaNAjZg-x6uszouMe6R1HQ.png" /><figcaption>It is included in the green class because it has more of its green neighbors.</figcaption></figure><p>KNN makes predictions according to the class density of the nearest neighbors of the vector formed by the independent variables of the value to be predicted. The distance of the point to be predicted to other points is calculated. The Minkowski distance calculation function is used for this. (K: We tell you how many nearest neighbors will be calculated.)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7e0ca22fa867eda849ed2be416076daa/href">https://medium.com/media/7e0ca22fa867eda849ed2be416076daa/href</a></iframe><p>In order to obtain more successful results in distance-based algorithms such as KNN, the data are normalized.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3b3614d7072652130cf903e465518d2c/href">https://medium.com/media/3b3614d7072652130cf903e465518d2c/href</a></iframe><h4>Logistic Regression</h4><p>Logistic Regression tries to find the best line that separates the two classes. It is frequently used in linear classification problems. Because of linearity, it is very similar to Linear Regression.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*IvifY_BB4N5oDy45gG-O2A.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/860f2010e0b1a3eb8037b04ab0bc21d0/href">https://medium.com/media/860f2010e0b1a3eb8037b04ab0bc21d0/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6f67412b6dcaf0a407d645b3a49a91b7/href">https://medium.com/media/6f67412b6dcaf0a407d645b3a49a91b7/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*1KCWF9gKMtVM8xHapqZiHw.png" /></figure><p>The ROC curve plots the false positive rate versus the correct positive rate. The area under this curve is found with the function roc_auc_score (). The closer this field is to 1, the better the model is predicted. To find the ROC-AUC score:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2498af6cee7c4ecceb44be7153748422/href">https://medium.com/media/2498af6cee7c4ecceb44be7153748422/href</a></iframe><h4>Decision Tree Classifer</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*DqXA5RZD7c-D8kJGPQaO-w.png" /></figure><p>Decision Tree<strong> </strong>is a type of supervised learning algorithm that is mostly used in classification problems. It starts with a single node and turns into a tree structure. It creates a model that predicts the value of a variable by extracting simple rules from data properties and learning those rules (just like a human).</p><p>Now, let’s predict the species of flowers in the Iris data set.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/399171163e63d6b482e3fdeca3a9264d/href">https://medium.com/media/399171163e63d6b482e3fdeca3a9264d/href</a></iframe><h4>Random Forest Classifier (Bagging)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*oNJqSIOvENuqhsxqnza3AA.png" /></figure><p>In Bagging, each collection of subset data is used to train their decision trees. As a result, we end up with an ensemble of different models. Majority of the votes predictions from different trees are used which is more robust than a single decision tree.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e271d7707beee6e0d93ca190c9fa625e/href">https://medium.com/media/e271d7707beee6e0d93ca190c9fa625e/href</a></iframe><h4>Gradient Boost Classifier</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*NKNzHZebRQ3_OyCQyU0ohg.png" /></figure><p>Gradient Boosting= Gradient Descent+Boosting. It uses gradient descent algorithm which can optimize any differentiable loss function. An ensemble of trees are built one by one and individual trees are summed sequentially. Next tree tries to recover the loss (difference between actual and predicted values).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/73f842727733ceda1c936c9c4f8d1276/href">https://medium.com/media/73f842727733ceda1c936c9c4f8d1276/href</a></iframe><h4>Support Vector Machine</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*VpISpxZaGY0BSkpBn9TBZg.png" /><figcaption>Destek Vektörleri means Support Vectors</figcaption></figure><p>Support Vector Machine tries to find the best line that separates the two classes just like logistic regression. The green region within ± 1 of this line is called Margin. The wider the margin, the better the separation of two or more classes. SVM predicts which side of the gap the new samples will fall.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4f74faf5616203b8ce586e39660e77ab/href">https://medium.com/media/4f74faf5616203b8ce586e39660e77ab/href</a></iframe><p><a href="https://github.com/esmabozkurt">github account/esmabozkurt</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a8af4491fcb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/machine-learning-classification-algorithms-with-codes-5a8af4491fcb">Machine Learning Classification Algorithms with Codes</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Machine Learning: Regression]]></title>
            <link>https://medium.com/analytics-vidhya/introduction-to-machine-learning-regression-5bbf4ed96f40?source=rss-78dccce92e8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/5bbf4ed96f40</guid>
            <category><![CDATA[lasso-regression]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[ridge-regression]]></category>
            <category><![CDATA[regression]]></category>
            <dc:creator><![CDATA[Esma Bozkurt]]></dc:creator>
            <pubDate>Thu, 11 Mar 2021 14:16:57 GMT</pubDate>
            <atom:updated>2021-03-12T16:38:12.446Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello, first of all today’s topic is Machine Learning and Algorithms. But before starting this, I would like to touch upon the relationship between statistical learning as well. Then prepare your coffee because I’m going to tell a lot today!</p><p>Most of the learning models were born with statistics, and the optimization and prediction success of these models were advanced in computer science. What a wonderful combination. So, what are their differences in technical terms?</p><p>Interpretation can be made about the expected changes in the response variable of the changes in the independent variables used to establish a model in statistical learning. In machine learning approaches, on the other hand, assumptions are less, models are easier to use and result-oriented. These are like two close friends that we cannot separate from each other. Now that we understand the difference, we can focus on Machine Learning.</p><h3>Machine Learning</h3><p>There are three types of Machine Learning Supervised, Unsupervised and Reinforcement Learning.</p><ul><li>Supervised Learning (Labeled Input)</li><li>Unsupervised Learning (Unlabeled Input)</li><li>Reinforcement Learning</li></ul><p>In supervised learning, input are labeled and output is known. But in unsupervised learning, the input is unlabeled. We expect the machine discovers hidden patterns and trends in the data. In Reinforcement Learning, it is the discovery of the machine with actions without input and output. It works with a system that gives rewards for righteous and punishments for wrongs. Autonomous vehicles are the best example of this.</p><p>There are two types of Supervised Learning, Regression and Classification. I will explain Regression in this article. You can find Classification in my next article. (Regression has many types, and there are also types that fall into the classification. Do not confuse this with Linear Regression.) While we use regression to predict by establishing a linear relationship between variables (such as predicting price a car), we use classification for problems where we will get yes-no answers (such as spam e-mail or not).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*5AzXsvFLSLZFBbYovL1jOw.png" /></figure><h4>Regression</h4><p>Simple Linear Regression examines the target variable against one other variable, while Multiple Linear Regression examines more than one other variable for the target variable. For example, let’s first examine the target variable according to a one variable:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e8dda9e14e323d110fdd44b70d462581/href">https://medium.com/media/e8dda9e14e323d110fdd44b70d462581/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*pBIabjFx1xbFctcoIcwXMQ.png" /></figure><p>We talked about a linear relationship, that is, the change of y depending on the x in y = ax + b. Let’s show this on the graph:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0dcd718c92310876b1442ae3304e6491/href">https://medium.com/media/0dcd718c92310876b1442ae3304e6491/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*VCFoESQfiHEBVsUbW-bvtA.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb2d530ec9313705f7c3133b616be3ad/href">https://medium.com/media/fb2d530ec9313705f7c3133b616be3ad/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*4GzeE2GiDByLAlhQf5UJNg.png" /></figure><p>However, it is rare for a dependent variable to be explained by only one variable. In this case, We use multiple regression that tries to explain a dependent variable using multiple independent variables. Multiple regressions can be linear and nonlinear. Multiple linear regression (MLR) is used to determine a mathematical relationship between a set of random variables. In other words, MLR examines how multiple independent variables relate to a dependent variable (y= b0 + a x1 + bx2 + c a x3 + d). Now let’s look at the relationship of our target variable with all other variables except itself:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ec0833dd8531a206a120ad2908d04c98/href">https://medium.com/media/ec0833dd8531a206a120ad2908d04c98/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*7Fze2V4Q6NPm9fPhllgAAg.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9664394ca2d9ba30701c2db1a1b52ab/href">https://medium.com/media/f9664394ca2d9ba30701c2db1a1b52ab/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*L3z_yfUuO1IJiQe5MP4URA.png" /><figcaption>Our success rate has increased.</figcaption></figure><p>Other algorithms used to analyze multivariate regression data are:</p><p><strong><em>Ridge Regression(L2 regularization), Lasso Regression (L1 regularization), Elastic Net</em></strong></p><p>The aim is to find the coefficients that minimize the error sum of squares by applying a penalty to these coefficients. It is resistant to over-fitting. It sets up a model with all variables and brings the coefficients of unrelated variables closer to zero. Unlike the Ridge regression, it equals the coefficients of unrelated variables to zero. It makes both variable selection and regularization to increase the predictive accuracy and interpretability of the model it produces. Elastic Net, on the other hand, offers a model that combines the good sides of the two.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*TIa-3bHCD8bqYx81qVioqw.png" /></figure><p>Let me explain what the r2 and mean squared error are here.</p><p>R square measures the rate of variation of the dependent variable according to the independent variables in the model, that is, how much of the variability in the dependent variable can be explained by the model. It is the square of the correlation coefficient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*rqkznJFBm-zz51z4E3Q9UA.png" /></figure><p>Mean Square Error gives you an absolute number of how different your predicted results differ from the actual number. It gives an actual number to compare with other model results and helps you choose the best regression model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*tY_eNpvMbrBIp6VhW59YkQ.png" /></figure><h4>Model Evaluation</h4><ul><li>The data we use is usually split into training data and test data. The training set contains a known output and the model learns on this data in order to be generalized to other data later on. We have the test dataset (or subset) in order to test our model’s prediction on this subset.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*6BmInC-b7vbkiKYmHxHZkQ.png" /></figure><ul><li>Cross Validation is very similar to train/test split, but it’s applied to more subsets. Meaning, we split our data into k subsets, and train on k-1 one of those subset. What we do is to hold the last subset for test. We’re able to do it for each of the subsets. In K-Folds Cross Validation we split our data into k different subsets (or folds). We use k-1 subsets to train our data and leave the last subset (or the last fold) as test data.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*co0FAGpmbX81L2D9OT6avw.png" /></figure><p>From now on, we will separate the data this way before we make predictions.</p><p>I will explain classification in my next article, my goal is to explain machine learning to you step by step. If you like it, follow me, have a nice day! :)</p><p><a href="https://github.com/esmabozkurt">github account/esmabozkurt</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5bbf4ed96f40" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/introduction-to-machine-learning-regression-5bbf4ed96f40">Introduction to Machine Learning: Regression</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploratory Data Analysis and Feature Engineering]]></title>
            <link>https://medium.com/analytics-vidhya/exploratory-data-analysis-and-feature-engineering-a95e6a79f73a?source=rss-78dccce92e8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/a95e6a79f73a</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[feature-engineering]]></category>
            <category><![CDATA[titanic-dataset]]></category>
            <category><![CDATA[exploratory-data-analysis]]></category>
            <category><![CDATA[normalization]]></category>
            <dc:creator><![CDATA[Esma Bozkurt]]></dc:creator>
            <pubDate>Tue, 09 Mar 2021 19:38:12 GMT</pubDate>
            <atom:updated>2024-02-20T08:08:14.635Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone again, today’s post will include these topics:</p><p><em>Creating a Dataframe and Reading Data, Exploratory Data Analysis (EDA)-PPR, Feature Engineering</em></p><p>In my previous article, I talked about what data is and how it looks. Now let’s start with data structures and analysis by writing code with python. First of all, there are two types of data structures in <a href="https://www.analyticsvidhya.com/blog/2021/03/pandas-functions-for-data-analysis-and-manipulation/?utm_source=Backlink&amp;utm_medium=SEO"><strong>Pandas</strong></a> library, dataframe and series. Series is a one-dimensional data structure as follows and dataframe is a data structure with two or more dimensions, it has rows and columns.</p><h4><strong><em>Creating a Dataframe</em></strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/1*AZcysQmdRUWL11Z7UdNz0Q.png" /></figure><p>We use “df.columnname or df [“columnname”] to view a specific column. For exp. these are series, and they form a dataframe “df”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*WIjslMhqcAR7hUGZgM584g.png" /></figure><h4><strong><em>Reading Data</em></strong></h4><p>With Pandas library, we can read data in many formats such as csv, excel, sql.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*lzgA685C1b6WnRncTqWgZw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*k4MWpQLVabXtjF3ERBf8FA.png" /></figure><h4><strong><em>Exploratory Data Analysis (EDA)-PPR</em></strong></h4><p><a href="https://www.analyticsvidhya.com/blog/2022/07/step-by-step-exploratory-data-analysis-eda-using-python/?utm_source=Backlink&amp;utm_medium=SEO"><strong>EDA</strong></a> is a set of various functions that allow us to examine data. Let’s explore the “Titanic Project” with eda. This is a tradition! :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*jzbGxDNMUiwR2vSozgE8lw.png" /><figcaption>We also see the train data size with the train.shape() function.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*IaKZV4oChyFKddnAuN9Qqg.png" /><figcaption>These are our dear basic functions:)</figcaption></figure><p>Instead of examining all data one by one, you may want to provide a faster and clearer view by using visuality to compare data with each other. We use PPR for this as well. This great method allows us to see summary information about the data in graphs. Try it and surprise you!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1cb91c07d3ffb0f0343c2bac4ac90c6c/href">https://medium.com/media/1cb91c07d3ffb0f0343c2bac4ac90c6c/href</a></iframe><h4>Feature engineering</h4><p>Feature engineering is the process of using domain knowledge of the data to create features that make machine learning algorithms work. Feature engineering can substantially boost machine learning model performance. Some Fundamental Feature Engineering Techniques are here:</p><ul><li>Imputation</li><li>Handling Outliers</li><li>Binning</li><li>Log Transform</li><li>One-Hot Encoding</li><li>Grouping Operations</li><li>Scaling</li></ul><p>The data may not be completely full, so how do we deal with missing values? Of course We do <em>imputation</em>. With Imputation we fill in numerically or categorically missing values. We can replace the missing/null values with either of 3 M’s (Mean/ Mode/ Median) depending on the possible values of the given column, or simply drop the missing values. We can also fill in missing values using prediction model (such as regression). Let’s fill in the missing values in the “Age, Embarked” columns in Titanic data:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3af92699b903f79406e9426e9af4f2f4/href">https://medium.com/media/3af92699b903f79406e9426e9af4f2f4/href</a></iframe><p>Ok, we filled our data. But machine learning can only operate on numbers. If we have categorical values, we should use dummies! In machine learning, it often describes the individual variables in a <em>one-hot encoding</em> scheme. Thus, dummy or Boolean variables are qualitative variables that can only take the value 0 or 1 to indicate the absence or presence of a specified condition.It is then presented to machine learning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*UOB6h3v32xglAmZxosdVxg.png" /></figure><p>What if our success rate is low? Maybe there are outliers values in our data? So where are they? The best way <em>to detect outliers</em> is to demonstrate the data visually.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*UZavk2ahNN0J-tEUAfdSUQ.jpeg" /></figure><p>If a value has a distance to the average higher than x * standard deviation, it can be assumed as an outlier. Another way, if your data ranges from 0 to 100, your top 5% is not the values between 96 and 100. Top 5% means here the values that are out of the 95th percentile of data.</p><p>Well, we got rid of outliers data, but we still want higher success. For these, we will use other techniques of feature engineering:</p><p>For example, with <em>binning</em>, we can draw meaningful results from the values in an age column. In this way, you can make your data more organized.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*UdrjCmQSJor6cN24a2SKeA.png" /></figure><p>Or with <em>grouping operations</em>,<em> </em>You can group data categorically with pivot table or numerically with pd.concat() function. You will see how to use it in projects.</p><p><em>Log Transform</em> helps to handle skewed data and after transformation, the distribution becomes more approximate to normal. It also decreases the effect of the outliers due to the normalization of magnitude differences and the model become more robust.</p><p>Another technique is <em>Scaling</em>. In most cases, the numerical features of the dataset do not have a certain range and they differ from each other. In order for a symmetric dataset, scaling is required. In scaling (also called min-max scaling), you transform the data such that the features are within a specific range e.g. [0, 1]. It is for your benefit to know statistics here.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0be5b76f5c44ecd18a52ec011255d379/href">https://medium.com/media/0be5b76f5c44ecd18a52ec011255d379/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*xK09ZZ2PJJ55taxdtm1-Fw.png" /></figure><p><strong>References</strong></p><p>[1] <a href="https://kharshit.github.io/blog/2018/03/23/scaling-vs-normalization">https://kharshit.github.io/blog/2018/03/23/scaling-vs-normalization</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a95e6a79f73a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/exploratory-data-analysis-and-feature-engineering-a95e6a79f73a">Exploratory Data Analysis and Feature Engineering</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Veri Bilimine Giriş]]></title>
            <link>https://esmabozkurt.medium.com/veri-bilimine-giri%C5%9F-42c8f704e216?source=rss-78dccce92e8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/42c8f704e216</guid>
            <category><![CDATA[python-pandas]]></category>
            <category><![CDATA[matplotlib]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[veri-bilimi]]></category>
            <dc:creator><![CDATA[Esma Bozkurt]]></dc:creator>
            <pubDate>Mon, 08 Mar 2021 21:09:19 GMT</pubDate>
            <atom:updated>2021-03-08T22:03:54.078Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction to Data Science</h3><p>Hi, I’m Esma Bozkurt. I am a student of electrical and electronics engineering. I have completed the Data Science with Deep Learning training with Dear Mr. Data Scientist Zafer Acar and I have been a Data Scientist for 2 months. I would like to thank my esteemed professor for providing an American-standard Data Science and Artificial Intelligence training with 256 hours of lectures and real-life projects in approximately 6 weeks. I am starting a series to convey what I learned from him and to help friends who want to progress in this field. In this series:</p><ul><li>Reading Data, Data Visualization, Exploratory Data Analysis (EDA)-PPR, Feature Engineering, Missing Value Imputation, Creating Dummies</li><li>Regression, Classification, Clustering, Pycarot</li><li>Principal Component Analysis (PCA), Graph Theory, Natural Language Processing (NLP), Computer Vision, Deep Learning, Recommender Systems, Time Series Analysis</li></ul><p>I will summarize these issues as much as possible and support them with projects. Now let me dive into the main subject and introduce you to data science, which you have heard a lot recently.</p><p>Data is a raw piece of information. Almost everything around us is data. There are many types of data, numerical, logical, and our names, our numbers, and every post we like are data. Data science is a discipline that brings together many fields, including statistics, scientific methods, and data analysis, to extract value from data.</p><p><em>It makes sense of the past.</em></p><p><em>He interprets the present.</em></p><p><em>Makes predictions about the future.</em></p><p>While doing these, it uses statistics and probability, Machine Learning and Deep Learning, which are sub-disciplines of Artificial Intelligence. These are all terms that complement and explain each other, and the data scientist uses them to make sense of and analyze data. Python and R programming languages ​​are generally used as tools.</p><p>In data science, the first step is to read and make sense of the data. We will do this using the Python Pandas library. Then we will use the visualization tools, which are the best way to make sense of the data. Data analysis is the next thing to be done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*JBDQjvuprJA3mlngkufM4Q.png" /><figcaption>Python — Sample graphics created using the Matplotlib Library</figcaption></figure><p>Matplotlib is a low-level python library with a Matlab-like interface. With the Seaborn library, which has a high-level interface, we can get more attractive graphics that will make your work easier with shorter codes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*kutbkFTO_iligUG-OfxqyQ.png" /><figcaption>For example, like heatmap where we can examine all data correlations</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*cp6rsuWYfeiV9ocyeDUBog.png" /><figcaption>Or comparing sns.pairplot with whole rows and columns…</figcaption></figure><p>After reading the data, we can visualize using the columns we want to create meaningful graphs. Want a more assertive graphic? Let’s see how we can examine the area and population of a state’s cities without being overwhelmed by numbers.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1cef68531d606649dfbc4a6d99e24dce/href">https://medium.com/media/1cef68531d606649dfbc4a6d99e24dce/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*B5Li8nTt4in2_DcP8torLA.png" /><figcaption>Area and population distribution map of cities in the state of California</figcaption></figure><p>First of all, we read the data file with information such as latitude, longitude, population, area with pandas library and selected the columns we are interested in. We draw a scatter chart using size and color. Don’t worry, this was an ambitious attempt to show what we can do. We will use useful graphics with shorter codes in projects. So see you in my next post, I hope you enjoyed my post ! :)</p><p><a href="https://github.com/esmabozkurt">github account/esmabozkurt</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42c8f704e216" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Markov Zincirleri]]></title>
            <link>https://esmabozkurt.medium.com/markov-zincirleri-f46d506b27f6?source=rss-78dccce92e8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f46d506b27f6</guid>
            <category><![CDATA[jupyter-notebook]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[markov-chains]]></category>
            <category><![CDATA[markov-models]]></category>
            <dc:creator><![CDATA[Esma Bozkurt]]></dc:creator>
            <pubDate>Wed, 27 Jan 2021 18:58:12 GMT</pubDate>
            <atom:updated>2021-01-27T18:58:12.063Z</atom:updated>
            <content:encoded><![CDATA[<ul><li>Markov Zincirleri, dinamik ve skolastik sistemlerin analizinde ve özellikle bir sistemin zaman boyunca içinde bulunabileceği farklı durumlar arasında yaptığı hareketlerin incelenmesinde kullanılan modellerdir.</li><li>Bu modelde, her bir anda sistem belirli bir olasılık dağılımına bağlı olarak kendi durumundan başka bir duruma geçebilir yahut aynı durumda kalabilir. Durumda olan değişiklikler <em>geçiş</em> olarak bilinir ve çeşitli durum değişmeleriyle ilişkili olasılıklar da <em>geçiş olasılıkları</em> olarak adlandırılır.</li><li>Genel olarak geçmişe bakmaksızın bir durum üzerinden başka bir duruma geçiş kurallarını olasılıksal olarak belirlenebileceği bir model sunduğu için hafıza gibi özelliklere ihtiyaç duymaz. Kısaca bu sürecin en önemli özelliği hafızasız olması ve geçmiş değerlerinden bağımsız çıktı üretebilmesidir diyebiliriz.</li><li>Rastgele süreçleri istatistiksel olarak modellemenin basit bir yoludur. Metin üretiminden finansal modellemeye kadar birçok farklı alanda kullanılmıştır. En çok kullanılan alanları ise metin oluşturma ve otomatik tamamlama uygulamalarıdır.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*1yr86O8SG6MY8jSbYiuVgQ.png" /><figcaption>(Markov zinciri ile rastgele oluşturulmuş cümlenin analizi yapılarak aşağıda verilmiş yapı oluşturulmuştur.)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/206/1*1i-kI83lmJ4zAKsb689zJA.png" /></figure><p>Her defasında farklı yemek veren (hamburger, pizza, sandviç) bir otomat hayal edelim.</p><p>Örneğin ilk yemeği hamburger verdi. Diğer vereceği yemek %60 olasılıkla pizza olsun veya %20 olasılıkla tekrar hamburger versin.</p><p>Böylelikle biz bunu markov zincirinde şu şekilde ifade ederiz:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/304/1*Q13yRf22-y41JD9x8ipy7A.png" /></figure><p>Buradaki oklar bir durumdan diğer duruma geçişi temsil etmektedir.</p><ul><li>Ardı ardına gelen, <em>X</em>1, <em>X</em>2, <em>X</em>3, … ile ifade edilen, bir seri rassal değişkendir.</li></ul><p><strong>Formüle edecek olursak:</strong></p><p>P( Xn+1 = x | X1 = x1, X2 = x2, …, Xn = xn) = P( Xn+1 = x | Xn = xn)</p><p>Örneğe devam edelim:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/1*Ye0fAE9TWIIrrt2bR5vboQ.png" /><figcaption>(Markov zinciri)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*l--xZW_4c4yhra6nM-XpbA.png" /><figcaption>Sandviç çıkma olasılığı nedir?</figcaption></figure><p>P( Xn+1 = x | Xn = xn) olduğundan =&gt; Pizzadan sandviçe geçiş olasılığı 0.7’dir. Dolayısıyla 0.7 olasılıkla sandviç çıkacaktır.</p><p>Peki 10 adımda otomattaki işlemler sırasıyla şöyle olsun:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*_2aFac66LlQ_-XDkn_nobA.png" /></figure><p>olasılık dağılımları:</p><p>P(H)=4/10= 0.351 , P(P)=2/10= 0.212 , P(S)=4/10= 0.435 olur.</p><p>Lineer cebir kullanarak bu geçiş olasılıklarını bitişik matrisle ifade edelim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/1*iV6qI9aWxQTDOW-abdV3kg.png" /><figcaption>Pizzayı inceleyeceğiz. pizza-&gt;1 diğerleri-&gt;0</figcaption></figure><p>A bitişik matrisini yazarken satır ve sütunların sırayla hamburger, pizza, sandviç sırasına göre yazdığımıza dikkat edelim. Şimdi pizza olasılığı için bitişik matrisle pizza olasılığını çarpalım, ta ki durağan değer elde edene kadar…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*jwTw9t9Ugpqn6O-nTpclHw.png" /><figcaption>(Farkettiyseniz eşitliğin diğer tarafı matristeki pizza olasılığının değeridir.)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*0KNle4IjqyrXqVnuDmU6Nw.png" /></figure><p>Evet durağan durumu yakaladık, bundan sonra çarpmaya devam etsek de sonuç çok değişmeyecektir.</p><p>Formüle göre ne kadar yaklaşmışız görelim :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ik5HrxC75ceBeHG_vr0bTg.png" /><figcaption>Olasılıkların toplam değeri 1&#39;dir.</figcaption></figure><p>Şimdi de üzgün olduğunda uyuyan, dondurma yiyen veya koşan birinin örneğini python ile kodlayarak inceleyelim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/305/1*oFSbxHNX_5jgkWRKkvrZ6g.png" /><figcaption>(Markov zinciri)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*20aCIoIeSkGIXaItyv25pg.png" /><figcaption>(Bitişik matrisi)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*3pvwrxWJxZE5-VvxTMigRQ.png" /></figure><p>Deney sayısı arttıkça, sonuçların gerçek oranı teorik veya beklenen sonuç oranına yakınlaşacaktır. Dolayısıyla durumları aktivite listesinde biriktirelim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*42809ytyl2fnxKHstNaCPQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ra9jEeO65Fc17rH0S0A7Tg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*qTNdfvMw_YGjI2jA7L1LyQ.png" /></figure><p>Buraya kadar basit markov zincirinden bahsettim. Fakat çeşitli markov zinciri modelleri bulunmakta.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*SWhDvsKLd89CKTCzljIXGg.png" /></figure><p>Son olarak farklı bir markov zincirinde olasılığı inceleyelim:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*zj7Z3Y6Td7mvscNNyyiMEA.png" /></figure><p>Burada ilk olasılık hesaplamamızdan farklı olarak üs alma yöntemini kullanıyoruz. 2 adımda ulaşma olasılığı için karesi, 3 adımda ulaşma olasılığı için küpü gibi…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PedsNYBlvN_nmbjiuLUMiw.png" /></figure><h4>Chapman Kolmogorov Teoremi:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*o2yum9ySqpbN-rjlq6BG_w.png" /></figure><p>P02(2) = P00(1) x P02(1) + P01(1) x P12(1) + P02(1) x P22(1)</p><p>Öyleyse İ’den başlayarak sonsuz adımdan sonra j’de olma olasılığı:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*uThfZfITEfrbJXxKBZRX5w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*iLS_ddpcaqnvxyoTQ6sQCQ.png" /><figcaption>(0&#39;dan 2&#39;ye sonsuz adımda ulaşma olasılığı)</figcaption></figure><p>En çok metin oluşturmada kullanıldığını belirtmiştik. Son olarak yeni metinler nasıl oluşturuluyor merak ediyorsan bu videoyu izleyebilirsin!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FE4WcBWuQQws%3Fstart%3D140%26feature%3Doembed%26start%3D140&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DE4WcBWuQQws&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FE4WcBWuQQws%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7fbab8ab56156dd9a308326dc292c5c6/href">https://medium.com/media/7fbab8ab56156dd9a308326dc292c5c6/href</a></iframe><h4><strong>Esma Bozkurt</strong></h4><p><strong>Kaynakça</strong></p><p>[1] <a href="https://www.datacamp.com/community/tutorials/markov-chains-python-tutorial">https://www.datacamp.com/community/tutorials/markov-chains-python-tutorial</a></p><p>[2] <a href="https://www.youtube.com/watch?v=E4WcBWuQQws&amp;t=140s">https://www.youtube.com/watch?v=E4WcBWuQQws&amp;t=140s</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f46d506b27f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>