<?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 Kardelen Yurtkuran on Medium]]></title>
        <description><![CDATA[Stories by Kardelen Yurtkuran on Medium]]></description>
        <link>https://medium.com/@kardelenyurtkuran?source=rss-80a94dbb3566------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*iYcsZkKoq3OAT621iAkVmg.jpeg</url>
            <title>Stories by Kardelen Yurtkuran on Medium</title>
            <link>https://medium.com/@kardelenyurtkuran?source=rss-80a94dbb3566------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 05:11:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kardelenyurtkuran/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[Grid Search vs. Random Search: Makine Öğrenimi Modellerinizi Optimize Etmenin İki Yolu]]></title>
            <link>https://medium.com/@kardelenyurtkuran/grid-search-vs-random-search-makine-%C3%B6%C4%9Frenimi-modellerinizi-optimize-etmenin-i%CC%87ki-yolu-ef5cc67e3e9d?source=rss-80a94dbb3566------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef5cc67e3e9d</guid>
            <category><![CDATA[hyperparameter-tuning]]></category>
            <category><![CDATA[grid-search]]></category>
            <category><![CDATA[model-optimization]]></category>
            <category><![CDATA[random-search]]></category>
            <category><![CDATA[model-tuning]]></category>
            <dc:creator><![CDATA[Kardelen Yurtkuran]]></dc:creator>
            <pubDate>Tue, 20 May 2025 11:21:55 GMT</pubDate>
            <atom:updated>2025-05-20T11:21:55.267Z</atom:updated>
            <content:encoded><![CDATA[<p>Makine öğrenimi problemlerinde doğru model seçimi elbette en önemli konudur. Ancak hiperparametre optimizasyonu ile modelinizin doğruluğunu, hızını ve genel başarımını büyük ölçüde artırabilirsiniz. En iyi kombinasyonu bulmak için kullanılan iki temel yöntem vardır:</p><ul><li><strong>Grid Search</strong></li><li><strong>Random Search</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GtghkB47sPOGyPj3IlEsQg.png" /></figure><p>Bu yazımda her ikisinin de temellerinden, farklarından ve ne zaman hangisini tercih etmeniz gerektiğinden bahsediyorum.</p><h3>Grid Search Nedir?</h3><p>Belirlediğiniz tüm olası hiperparametre kombinasyonlarını deneyen sistematik bir tarama yöntemidir. Brute-force (kaba kuvvet) yaklaşımıyla çalışır. Belirlenen “kafes”teki her noktayı ziyaret ederek model performansını yükseltmeyi amaçlar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*YHp4r0G64BVYlxp1yN31bw.png" /><figcaption><a href="https://www.researchgate.net/figure/Grid-Search-a-Grid-Search-involves-setting-up-a-column-of-hyperparameters-and_fig1_375960724">https://www.researchgate.net/figure/Grid-Search-a-Grid-Search-involves-setting-up-a-column-of-hyperparameters-and_fig1_375960724</a></figcaption></figure><p>Örneğin, bir karar ağacı için max_depth = [3, 5] ve min_samples_split = [2, 4] değerleri için Grid Search arama algoritması kullandığımızı düşünelim. Bu durumda Grid Search aşağıdaki tüm kombinasyonları test eder:</p><ul><li>(3, 2)</li><li>(3, 4)</li><li>(5, 2)</li><li>(5, 4)</li></ul><pre>from sklearn.model_selection import GridSearchCV<br>from sklearn.ensemble import RandomForestClassifier<br><br>param_grid = {<br>    &#39;n_estimators&#39;: [50, 100],<br>    &#39;max_depth&#39;: [3, 5]<br>}<br><br>grid_search = GridSearchCV(RandomForestClassifier(), param_grid, cv=3)<br>grid_search.fit(X_train, y_train)<br><br>print(grid_search.best_params_)</pre><h3>Random Search Nedir?</h3><p>Random Search ise Grid Search’ün aksine sistematik bir yöntem değildir. Hiperparametre uzayından rastgele kombinasyonlar seçerek çalışır. Her şeyi denemek yerine belirli sayıda deneme yapar ve genellikle daha kısa sürede iyi sonuçlar verir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/268/1*srKAAA88sCW2_THbcT490w.png" /><figcaption><a href="https://www.researchgate.net/figure/Grid-Search-a-Grid-Search-involves-setting-up-a-column-of-hyperparameters-and_fig1_375960724">https://www.researchgate.net/figure/Grid-Search-a-Grid-Search-involves-setting-up-a-column-of-hyperparameters-and_fig1_375960724</a></figcaption></figure><p>Bu yöntem, özellikle büyük parametre alanlarında oldukça verimlidir. Çünkü çoğu zaman yalnızca birkaç parametre model performansını gerçekten etkiler, diğerleri o kadar kritik değildir.</p><pre>from sklearn.model_selection import RandomizedSearchCV<br>from sklearn.ensemble import RandomForestClassifier<br>from scipy.stats import randint<br><br>param_dist = {<br>    &#39;n_estimators&#39;: randint(50, 200),<br>    &#39;max_depth&#39;: randint(2, 10)<br>}<br><br>random_search = RandomizedSearchCV(RandomForestClassifier(), param_dist, n_iter=10, cv=3, random_state=42)<br>random_search.fit(X_train, y_train)<br><br>print(random_search.best_params_)</pre><h3>Hangi Durumlarda Random Search, Hangi Durumlarda Grid Search Kullanılmalı?</h3><p>Her iki arama yönteminin de hem avantajı hem de dezavantajı vardır. Bunlar genellikle veri setinin büyüklüğüne ve zaman kısıtınıza bağlı olarak değişkenlik gösterebilir.</p><p>Ancak sınıflandırma, regresyon veya başka bir görev fark etmeksizin; büyük veri setlerinde veya karmaşık modellerde (örneğin derin öğrenme) Grid Search yavaş olabilir. Random Search bu durumda daha hızlı bir alternatiftir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*lR7VbYGlPvThtO8KExfUJQ.png" /></figure><h3>Hangi Problem Türlerinde Kullanılır?</h3><ol><li><strong>Sınıflandırma (Classification):</strong></li></ol><ul><li>Örnek: SVM, Lojistik Regresyon, Rastgele Orman gibi modellerde C, kernel, max_depth gibi parametreleri optimize etmek için.</li></ul><p><strong>2. Regresyon (Regression):</strong></p><ul><li>Örnek: Lineer Regresyon, Ridge, Lasso veya XGBoost gibi modellerde alpha, learning_rate gibi parametreleri ayarlamak için.</li></ul><p><strong>3. Kümeleme (Clustering):</strong></p><ul><li>Örnek: K-Means’te küme sayısı (n_clusters) veya DBSCAN’de eps ve min_samples gibi parametreleri optimize etmek için.</li></ul><p><strong>4. Derin Öğrenme (Deep Learning):</strong></p><ul><li>Örnek: Sinir ağlarında öğrenme oranı (learning_rate), katman sayısı, nöron sayısı veya dropout oranı gibi parametreleri ayarlamak için.</li></ul><p><strong>5. Diğer Görevler:</strong></p><ul><li>Doğal dil işleme (NLP), zaman serisi tahmini veya görüntü işleme gibi alanlarda da kullanılır. Örneğin bir LSTM modelinde units veya batch_size optimize edilebilir.</li></ul><h3>Hiperparametre Optimizasyonu İçin Alternatif Yöntemler</h3><p>Arama yöntemleri için daha gelişmiş yaklaşımlar da mevcuttur. Kısaca bahsetmek gerekirse:</p><ul><li><strong>Bayesian Optimization:</strong> Önceki denemelerden öğrenerek hiperparametre uzayında daha iyi kombinasyonlara odaklanır. Daha az denemeyle etkili sonuçlar sunar ancak uygulanması biraz daha karmaşıktır.</li><li><strong>Hyperband:</strong> Random Search’ü temel alır ve kötü performans gösteren kombinasyonları erken durdurarak hesaplama kaynaklarını verimli kullanır. Özellikle büyük ölçekli projelerde popülerdir.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*BYA6ywncpYPmDNCHe49X8Q.png" /><figcaption><a href="https://blog.quipu-strands.com/bayesopt_1_key_ideas_GPs">https://blog.quipu-strands.com/bayesopt_1_key_ideas_GPs</a></figcaption></figure><p>Bu yöntemler, Grid ve Random Search’e alternatif olarak daha hızlı ve gelişmiş optimizasyon sağlar.</p><h3>Sonuç</h3><p>Hiperparametre optimizasyonu, model performansınızı ciddi şekilde iyileştirebilir.<br>Grid Search sistematik ve detaylı bir yaklaşımsa, Random Search daha hızlı ve çoğu zaman yeterince iyi sonuçlar sunar.<br>Bu yöntemleri iyi tanımak, zaman ve kaynak yönetiminde fark yaratır.</p><h3>Kaynaklar</h3><ul><li><a href="https://www.kdnuggets.com/2016/08/automating-data-science.html">https://www.kdnuggets.com/2016/08/automating-data-science.html</a></li><li><a href="https://www.ibm.com/think/topics/hyperparameter-tuning">https://www.ibm.com/think/topics/hyperparameter-tuning</a></li></ul><p>Her türlü soru ve öneriniz için benimle iletişime geçebilirsiniz. Aynı konulara ilgi duyan kişilerle bağlantı kurmaktan mutluluk duyarım.;</p><p><a href="https://github.com/kardelenyurtkuran">kardelenyurtkuran - Overview</a></p><p><a href="https://www.linkedin.com/in/kardelenyurtkuran/">https://www.linkedin.com/in/kardelenyurtkuran/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef5cc67e3e9d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Performance Metrics for Classification Problems]]></title>
            <link>https://medium.com/@kardelenyurtkuran/performance-metrics-for-classification-problems-cd15c1455e3e?source=rss-80a94dbb3566------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd15c1455e3e</guid>
            <category><![CDATA[confusion-matrix]]></category>
            <category><![CDATA[model-evaluation]]></category>
            <category><![CDATA[performance-metrics]]></category>
            <category><![CDATA[f1-score]]></category>
            <category><![CDATA[accuracy]]></category>
            <dc:creator><![CDATA[Kardelen Yurtkuran]]></dc:creator>
            <pubDate>Wed, 12 Feb 2025 20:58:56 GMT</pubDate>
            <atom:updated>2025-02-12T20:58:56.415Z</atom:updated>
            <content:encoded><![CDATA[<p>Performance metrics play a critical role in selecting models or understanding the success of a developed model. The importance of specific metrics varies depending on the content of your project.</p><p>Additionally, the metrics you need to focus on can change based on factors such as the field of interest, the balance of your dataset, the cost of model errors, model complexity, dataset size, and time and resource constraints.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xTeYPscdkBbV0dd9XUV1xA.png" /></figure><p>In this article, I will explain the most commonly used metrics for classification problems and their areas of application. However, keep in mind that there are many other customized and derived metrics beyond these.</p><h3>Performance Metrics for Classification Problems</h3><ol><li><strong>Confusion Matrix:</strong></li></ol><p>A confusion matrix is essentially a table that shows how many true positive and negative results your model has produced. It may seem quite complex at first.</p><p>Let’s explain these concepts with a simple example. Suppose you have a medical dataset where sick individuals are labeled as (1) and healthy individuals as (0).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WDsdWV8LatcFwqDk1YPYSA.png" /></figure><h4>Definitions:</h4><ul><li><strong>True Positive (TP):</strong> The number of individuals who are actually sick (1) and predicted as sick (1) by the model.</li><li><strong>False Positive (FP):</strong> The number of individuals who are actually healthy (0) but predicted as sick (1) by the model.</li><li><strong>False Negative (FN):</strong> The number of individuals who are actually sick (1) but predicted as healthy (0) by the model.</li><li><strong>True Negative (TN):</strong> The number of individuals who are actually healthy (0) and predicted as healthy (0) by the model.</li></ul><blockquote><strong><em>Note:</em></strong><em> FN and FP concepts were quite confusing for me at first. To remember them, I use this method:</em></blockquote><blockquote><strong>False Negative:</strong> Wrongly classified as negative (but actually positive).</blockquote><blockquote><strong>False Positive:</strong> Wrongly classified as positive (but actually negative).</blockquote><p>For a target variable with <em>n</em> classes, an <em>nxn</em> confusion matrix is formed.</p><h4><strong>2. Accuracy:</strong></h4><p>Accuracy is one of the most frequently encountered metrics in performance measurement. It is calculated as the ratio of correctly predicted instances to the total number of instances. However, it is not sufficient on its own.</p><h4>Formula:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*EvmVs3CZZUmWUnl47qNCRA.png" /></figure><p>In imbalanced datasets, relying solely on accuracy can be misleading. Therefore, it is crucial to check other performance metrics.</p><p>For example, in a credit fraud detection dataset where 95% of the data is labeled as “safe” and only 5% as “fraudulent,” a model that predicts every case as “safe” would still achieve 95% accuracy, which is misleading.</p><h4>3. Precision:</h4><p>If the cost of <strong>false positives (FP)</strong> is high (e.g., marking important emails as spam), we focus on improving precision.</p><h4>Formula:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*PIRqe3ckd30wqcHsd65R9Q.png" /></figure><p>Here, the focus is on the cost of <strong>False Positives (FP)</strong>.</p><h4>4. Recall (Sensitivity):</h4><p>Recall measures how many of the <strong>actual positives (TP)</strong> are correctly predicted.</p><p>For example, in a bank fraud detection model, failing to detect a fraudulent transaction could cause significant losses to a customer.</p><h4>Formula:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*9mPfeW81aBv28bp5uXEPrw.png" /></figure><p>Here, the focus is on the cost of <strong>False Negatives (FN)</strong>.</p><h4>5. F1-Score:</h4><p>F1-Score is essential when dealing with imbalanced datasets and when we need to balance both precision and recall.</p><p>For example, when detecting fake users on an e-commerce platform, we want to avoid both missing fake users and mislabeling real users.</p><h4>Formula:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*F_BvpQ68GVCPLQ7A5tWG8Q.png" /></figure><p>If <strong>Precision is high but Recall is low</strong>, it means there are many <strong>False Negatives (FN)</strong>. If <strong>Recall is high but Precision is low</strong>, it means there are many <strong>False Positives (FP)</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*aDugyyAsFTz-ufugb_w1CQ.png" /></figure><h3>Advanced Metrics</h3><h4>1. ROC-AUC (Receiver Operating Characteristic — Area Under Curve):</h4><p>ROC-AUC measures how well the model can distinguish between positive and negative classes.</p><ul><li><strong>ROC Curve:</strong> Plots True Positive Rate (TPR) against False Positive Rate (FPR) at different threshold values.</li><li><strong>AUC (Area Under Curve):</strong> The area under this curve.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*yJYdZ4K1q1uIaNbopNeQOw.jpeg" /><figcaption>Geeks for Geeks — AUC ROC Curve in Machine Learning</figcaption></figure><h4>Interpretation of AUC values:</h4><ul><li><strong>AUC = 1.0</strong> → Perfect model, fully separates positive and negative classes.</li><li><strong>AUC &gt; 0.9</strong> → Very good model.</li><li><strong>AUC = 0.5</strong> → Poor model, making random predictions.</li><li><strong>AUC &lt; 0.5</strong> → Bad model, making incorrect predictions.</li></ul><h4>2. PR-AUC (Precision-Recall Curve):</h4><p>PR curve shows how <strong>Precision</strong> and <strong>Recall</strong> change at different thresholds. It is particularly useful for models where reducing <strong>False Positives (FP)</strong> and <strong>False Negatives (FN)</strong> is crucial.</p><h4>Interpretation of PR-AUC values:</h4><ul><li><strong>PR-AUC = 1.0</strong> → Perfect model.</li><li><strong>PR-AUC &gt; 0.9</strong> → Very good model.</li><li><strong>PR-AUC = 0.5</strong> → Random predictions.</li><li><strong>PR-AUC &lt; 0.5</strong> → Poor model.</li></ul><p>In medical applications, PR-AUC is preferred when detecting rare diseases because missing patients (FN) can have serious consequences.</p><h4>3. Log Loss (Logarithmic Loss):</h4><p>Log Loss measures the error in probabilistic classification models.</p><ul><li>Lower values indicate better performance.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*aE4v7OVo_wzF5mxoeabyLw.png" /></figure><ul><li>If a spam filter assigns a 90% probability to an email being spam, Log Loss is low. But if it assigns only 51%, the error is higher.</li></ul><h4>4. Matthews Correlation Coefficient (MCC):</h4><ul><li>Uses all elements of the confusion matrix (TP, TN, FP, FN) to measure model accuracy.</li><li>Ranges between -1 and +1.</li><li>Especially useful for <strong>imbalanced datasets</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*WAVAiB4NNwcTibyenMQjGQ.png" /></figure><ul><li><strong>MCC = +1 -&gt; </strong>Perfect model</li><li><strong>MCC = 0 -&gt; </strong>Random predictions</li><li><strong>MCC = -1 -&gt; </strong>Completely incorrect predictions</li></ul><h4>5. Cohen’s Kappa:</h4><ul><li>Measures whether the model is making random predictions.</li><li>Ranges between <strong>0 and 1</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*WAVAiB4NNwcTibyenMQjGQ.png" /></figure><ul><li><strong>Kappa &gt; 0.75 -&gt; </strong>Strong model</li><li><strong>Kappa 0.4–0.75 -&gt; </strong>Moderate model</li><li><strong>Kappa &lt; 0.4 -&gt; </strong>Unreliable model</li></ul><h3><strong>When to Use Which Metric?</strong></h3><p>This list provides a general guideline:</p><ul><li><strong>For balanced datasets:</strong> Accuracy may be sufficient.</li><li><strong>For imbalanced datasets:</strong> Precision, Recall, F1-Score, PR-AUC should be considered.</li><li><strong>For probabilistic models:</strong> Log Loss or ROC-AUC is evaluated.</li><li><strong>When different classes have varying importance:</strong> Precision vs. Recall analysis is necessary.</li></ul><p>If you have any questions or suggestions, feel free to reach out! I’d love to connect with others who share similar interests.</p><p><a href="https://github.com/kardelenyurtkuran">kardelenyurtkuran - Overview</a></p><p><a href="https://www.linkedin.com/in/kardelenyurtkuran/">https://www.linkedin.com/in/kardelenyurtkuran/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd15c1455e3e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sınıflandırma Problemleri İçin Performans Metrikleri]]></title>
            <link>https://medium.com/@kardelenyurtkuran/s%C4%B1n%C4%B1fland%C4%B1rma-problemleri-i%CC%87%C3%A7in-performans-metrikleri-840eedeb3946?source=rss-80a94dbb3566------2</link>
            <guid isPermaLink="false">https://medium.com/p/840eedeb3946</guid>
            <category><![CDATA[f1-score]]></category>
            <category><![CDATA[performance-metrics]]></category>
            <category><![CDATA[model-evaluation]]></category>
            <category><![CDATA[accuracy]]></category>
            <category><![CDATA[confusion-matrix]]></category>
            <dc:creator><![CDATA[Kardelen Yurtkuran]]></dc:creator>
            <pubDate>Wed, 12 Feb 2025 20:25:02 GMT</pubDate>
            <atom:updated>2025-02-12T20:57:46.763Z</atom:updated>
            <content:encoded><![CDATA[<p>Modellerin seçiminde ya da geliştirdiğiniz modelin başarısını anlamada performans metrikleri kritik bir önem taşır. Projenizin içeriğine göre hangi metriklerin önemli olduğu değişkenlik gösterebilir.</p><p>Bunun yanı sıra, ilgilendiğiniz alana, veri setinizin dengesine, model hatalarının maliyetine, modelin karmaşıklığına, veri setinizin boyutuna, zaman ve kaynak kısıtlarına göre de ilgilenmeniz gereken metrikler değişebilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xTeYPscdkBbV0dd9XUV1xA.png" /></figure><p>Bu yazıda sınıflandırma problemleri için en sık kullanılan metrikleri ve bunların kullanım alanlarını açıklamaya çalışacağım. Ancak bunlar dışında da özelleştirilmiş ve türetilmiş pek çok metrik olduğunu bilmelisiniz.</p><h3><strong>Sınıflandırma Problemleri İçin Performans Metrikleri</strong></h3><h4><strong>1. Confusion Matrix (Karmaşıklık Matrisi):</strong></h4><p>Aslında confusion matrix, modelinizin gerçekte kaç pozitif ve negatif sonuç ürettiğini gösteren bir tablodur. Başta oldukça karmaşık gelebilir.</p><p>Şimdi bu kavramları basit bir örnekle açıklamaya geçelim. Elinizde bir hastalık veri seti olduğunu varsayalım. Hasta bireyler (1), Sağlıklı bireyler ise (0) olarak etiketlenmiş olsun.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WDsdWV8LatcFwqDk1YPYSA.png" /></figure><p><strong>True Positive (TP):</strong> Gerçekte hasta olan (1), modelinizinde hasta(1) olarak tahmin ettiği birey sayısıdır.</p><p><strong>False Positive (FP):</strong> Gerçekte sağlık olan (0) ancak modelinizin hasta(1) olarak tahmin ettiği birey sayısıdır.</p><p><strong>False Negative (FN):</strong> Gerçekte hasta olan(1) ancak modelinizin sağlıklı(0) olarak tahmin ettiği birey sayısıdır.</p><p><strong>True Negative (TN):</strong> Gerçekte sağlıklı(0) olan modelinizinde sağlıklı(0) olarak tahmin ettiği birey sayısıdır.</p><blockquote><strong>Not:</strong> FN ve FP kavramları benim için de başta oldukça karmaşıktı. Ancak hatırlayabilmek için kendimde kullandığım yöntemi de buraya not olarak bırakıyorum.</blockquote><blockquote>False Negative -&gt; Yanlış Negatif (yada ezberlemek için yanlışlıkla negatif diye aklımda tutuyorum 😊) -&gt; Gerçekte pozitif</blockquote><blockquote>False Positive -&gt; Yanlış Pozitif (yada ezberlemek için yanlışlıkla pozitif diye aklımda tutuyorum 😊) -&gt; Gerçekte negatif</blockquote><p>n sınıflı bir hedef değişken için nxn boyutunda confusion matrix oluşacağı unutulmamalıdır.</p><p><strong>2. Accuracy (Doğruluk):</strong></p><p>Doğruluk performans ölçümünde en sık karşınıza çıkan metriklerden biridir.</p><p>Accuracy değeri modelinizde doğru tahmin ettiğiniz veri sayınızın toplam veri sayısına oranıdır. Ancak tek başına yeterli değildir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*EvmVs3CZZUmWUnl47qNCRA.png" /></figure><p>Özellikle dengesiz dağılmış veri setlerinde tek başına accuracy değerine göre yorumlamak yanıltıcı olabilir. Bu yüzden diğer performans metriklerini de control etmek gerekir.</p><p>Örneğin bir kredi dolandırıcılığında veri setiniz %95 “güvenli” ve %5 “dolandırıcı” şeklinde dağılmış olsun. Modeliniz herkese “güvenli” dediğinde aslında %95 doğruluğu yakalıyor değil mi ?</p><p><strong>3. Precision (Kesinlik):</strong></p><p>Yanlış pozitiflerin(FP — False Positive) maliyeti bizim için yüksekse, (örneğin, önemli e-postaları yanlışlıkla spam kutusuna göndermek gibi) precision metriğini arttırmaya odaklanırız.</p><p>Precision(kesinlik) “pozitif” tahmin ettiğimiz sonuçların gerçekte doğru olma olsalığını ölçer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*PIRqe3ckd30wqcHsd65R9Q.png" /></figure><p>Burada odaklanılan parametre FP (False Positive) maliyetidir.</p><p><strong>4. Recall (Duyarlılık):</strong></p><p>Gerçek pozitiflerin(TP — True Positive) ne kadarını doğru tahmin ettiğimizi gösterir. Örneğin bir bankanın dolandırıcılık tespit modeli, gerçekten dolandırıcı olan bir işlemi tespit edemezse, müşterisini büyük zarara uğratabilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*9mPfeW81aBv28bp5uXEPrw.png" /></figure><p>Burada odaklanılan parametre FN (False Negative) maliyetidir.</p><p><strong>5. F1-Score:</strong></p><p>Dengesiz veri setlerinde hem Precision’ı hemde Recall’u yüksek tutmaya çalıştığımız durumlarda önemlidir. Kesinlik ve Duyarlılık arasında bir denge sağlar.</p><p>Bir e-ticaret platformunda ki sahte kullanıcıları tespit ettiğimizi düşünelim. Burada sahte kullanıcıları kaçırmak da gerçek kullanıcıları sahte olarak etiketlemekte istemeyiz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*F_BvpQ68GVCPLQ7A5tWG8Q.png" /></figure><p>Burada odaklanılan parametre FN ve FP’ye bağlı olarak hem Recall hemde Precision’dır.</p><ul><li>Precision yüksek ama Recall düşükse -&gt; Çok fazla yanlış negatif (FN) olabilir.</li><li>Recall yükek ama Precision düşükse -&gt; Çok fazla yanlış pozitif olabilir.</li></ul><p>Bunu basit bir tablo ile özetlersek:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*nS6SUK5FCSBNFuj1DpA6KA.png" /></figure><h3>Gelişmiş Metrikler</h3><ol><li><strong>ROC-AUC (Receiver Operating Characterictic — Area Under Curve):</strong></li></ol><p>ROC-AUC, modelin pozitif sınıfı ne kadar iyi ayırt edebildiğini ölçer.</p><p>ROC Eğrisi; modelin True Positive Rate (TPR) ve False Positive Rate (FPR) değerlerini farklı eşik değerleri için gösterir. AUC ise bu eğrinin altında kalan alandır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*yJYdZ4K1q1uIaNbopNeQOw.jpeg" /><figcaption>Geeks for Geeks — AUC ROC Curve in Machine Learning</figcaption></figure><p>AUC’yi anlamak için şu aralıklar yol gösterici olabilir;</p><ul><li><strong>AUC = 1.0</strong> -&gt; Model pozitif ve negatif sınıfları tamamen birbirinden ayırt edebiliyor</li><li><strong>AUC &gt; 0.9</strong> -&gt; Çok iyi model</li><li><strong>AUC = 0.5</strong> -&gt; Kötü bir performans. Model tamamen rasgele tahmin yapıyor.</li><li><strong>AUC &lt; 0.5</strong> -&gt; Model kötü, ters tahmin yapıyor.</li></ul><p>2. <strong>PR-AUC (Precision-Recall Eğrisi):</strong></p><p>PR eğrisi, modelin <strong>eşik değeri değiştikçe</strong> Precision (Kesinlik) ve Recall (Duyarlılık) değerlerinin nasıl değiştiğini gösteren bir grafiktir.</p><p>Modelin ürettiği olasılıkları sıralayarak farklı eşik değerleri belirlenir ve her eşik değeri için Precision ve Recall hesaplanır.</p><p>PR eğrisi, düşük False Positive (Yanlış Pozitif) ve False Negative (Yanlış Negatif) değerlerini hedefleyen modeller için önemlidir.</p><ul><li><strong>PR-AUC = 1.0</strong> → Mükemmel model (Tüm pozitifleri yakalıyor ve yanlış pozitif üretmiyor).</li><li><strong>PR-AUC &gt; 0.9</strong> → Çok iyi model.</li><li><strong>PR-AUC = 0.5</strong> → Model rastgele tahmin yapıyor.</li><li><strong>PR-AUC &lt; 0.5</strong> → Model kötü, yanlış tahminler üretiyor.</li></ul><p><strong>3. Log Loss (Logaritmik Kayıp):</strong></p><p>Log Loss, probabilistic sınıflandırmalarda(olasılıklı tahmin) modelin hatasını ölçer. Yanlış tahminlerin ne kadar kötü olduğunu ölçmek için kullanılır.</p><p>Yani modelin tahmin ettiği olasılıklar ile gerçek etiketler arasında ki farktır. Bu nedenle düşük olması beklenir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*aE4v7OVo_wzF5mxoeabyLw.png" /></figure><p>Eğer spam bir e-posta düşünün. Model %90 olasılıkla spam diyorsa Log Loss düşük olur. Ancak %51 oranla spam diyorsa hata oranı daha yüksektir.</p><p><strong>4. Matthews Correlation Coefficient (MCC):</strong></p><p>Tüm confusion Matrix öğelerini (TP, TN, FP, FN) kullanarak model doğruluğunu ölçer.</p><ul><li>-1 ile +1 arasında değer alır.</li><li>Dengesiz veri setleri için sık kullanılır.</li><li>En güvenli sınıflandırma metriklerinden biri olarak kabul edilir.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*4rXN_A1bTxKCqnZ5HV9XZQ.png" /></figure><ul><li><strong>MCC = +1 -&gt;</strong> Mükemmel model</li><li><strong>MCC = 0 -&gt;</strong> Rasgele tahmin yapan model</li><li><strong>MCC = -1 -&gt;</strong> Model tamamen yanlış tahmin yapıyor</li></ul><p><strong>5. Cohen’s Kappa:</strong></p><ul><li>Modelin rasgele tahmin yapıp yapmadığını ölçer.</li><li>0 ile 1 arasında değer alır.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*WAVAiB4NNwcTibyenMQjGQ.png" /></figure><ul><li><strong>Kappa &gt; 0.75 -&gt; </strong>Güçlü, model çok iyi</li><li><strong>Kappa 0.4–0.75 -&gt; </strong>Orta seviyeli model</li><li><strong>Kappa &lt; 0.4 -&gt; </strong>Model performansı güvenli değil</li></ul><p>Özetle;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pySvfeRGlPOeUtbMIGhqkA.png" /></figure><h3><strong>Hangi Metrik Hangi Durumda Kullanılmalı ?</strong></h3><p>Aşağıda belirteceğim liste her koşul için olmasa da size bir yol gösterici olabilir.</p><ul><li>Dengeli veri setinde : Accuracy yeterli olabilir</li><li>Dengesiz veri setinde : Precision, Recall, F1-Score, PR-AUC</li><li>Probabilistik modellerde : Log Loss veya ROC-AUC değerlendirilir</li><li>Tahmin edilen sınıfların öneminin farklı olduğu durumlarda : Precision vs Recall analizi</li></ul><p>Her türlü soru ve öneriniz için benimle iletişime geçebilirsiniz. Aynı konulara ilgi duyan kişilerle bağlantı kurmaktan mutluluk duyarım.;</p><p><a href="https://github.com/kardelenyurtkuran">kardelenyurtkuran - Overview</a></p><p><a href="https://www.linkedin.com/in/kardelenyurtkuran/">https://www.linkedin.com/in/kardelenyurtkuran/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=840eedeb3946" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prediction with Distances: How Does KNN Work?]]></title>
            <link>https://medium.com/@kardelenyurtkuran/prediction-with-distances-how-does-knn-work-9ddd0ca97b5b?source=rss-80a94dbb3566------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ddd0ca97b5b</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[knn-algorithm]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[k-nearest-neighbours]]></category>
            <category><![CDATA[knn]]></category>
            <dc:creator><![CDATA[Kardelen Yurtkuran]]></dc:creator>
            <pubDate>Tue, 10 Dec 2024 09:57:46 GMT</pubDate>
            <atom:updated>2024-12-10T09:57:46.357Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the most intuitive and powerful members of machine learning algorithms is undoubtedly KNN. KNN algorithms focus on distances to the nearest neighbors when making predictions. But how are the nearest neighbors determined? How is the distance between them measured?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*Y_oenIUFUoe96hvxXLpA9g.png" /></figure><h3>1. What is KNN?</h3><p>K-Nearest Neighbors (KNN) is a supervised learning algorithm. It can be used for both classification and regression problems.</p><p>At its core, it relies on the assumption that “similar values are close to each other” to make predictions. It does not memorize or learn data; instead, it references known data points.</p><h3>2. How Does It Work?</h3><p>Let’s assume you have a dataset. You need to calculate the distance of a new data point to every neighbor. Common distance metrics used include:</p><ul><li><strong>Euclidean Distance</strong><br>Used when features are continuous (numerical) like length, width, or weight, and when there is a planar distance relationship between data points.<br><em>It is sensitive to noise and can be influenced by outliers.</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*3WnBcigiCW7RfedkZDYZ4g.png" /></figure><ul><li><strong>Manhattan Distance (Taxicab Distance or L1 Distance)</strong><br>Used when working with grid-like data, sparse matrices where some features are zero, or in cases requiring robustness to noise.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*qSWOoCnXxQAcMLBsYoLavg.png" /></figure><ul><li><strong>Minkowski Distance (Generalized Form)</strong><br>A formula that generalizes both Euclidean (p=2) and Manhattan (p=1) distances. By using different p values, it transforms into different distance metrics:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V_plvR-b0-Kr9J96uui6Sg.png" /></figure><ul><li>p=1 → Manhattan Distance</li><li>p=2 → Euclidean Distance</li><li>p&gt;2 → Highlights larger deviations.</li></ul><p>Once all distances are calculated, the K nearest neighbors are selected. If your problem is classification, the majority class among these neighbors (majority voting) determines the class of the new data point. For regression problems, the average of the neighbors is used as the predicted value.</p><p><strong>Example:</strong><br>Imagine you want to determine whether students pass or fail a course based on their study hours. Let the study hours and success statuses of students be:<br>[2,1], [1,0], [3,1], [0.5,0].</p><p>Now, you want to predict whether a student who studies for 2.5 hours will pass. First, calculate the distances:</p><ul><li>Distance between 2.5 and 2 hours: |2.5–2| = 0.5</li><li>Distance between 2.5 and 1 hour: |2.5–1| = 1.5</li><li>Distance between 2.5 and 3 hours: |2.5–3| = 0.5</li><li>Distance between 2.5 and 0.5 hours: |2.5–0.5| = 2</li></ul><p>Choose the K nearest neighbors (e.g., K=3).<br>The nearest 3 neighbors are students who studied 2 hours, 1 hour, and 3 hours. Their success statuses are 1, 0, and 1 respectively. Thus, the new data point (2.5 hours) belongs to the majority class, which is 1. The prediction is that a student studying for 2.5 hours will pass.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mwqbNERd9fe3mQa6r9tYPA.png" /></figure><h3>3. When to Use KNN?</h3><p>As mentioned earlier, KNN can be used for both classification and regression problems. Examples include email spam classification or predicting house prices.</p><p>Since KNN requires calculating distances to all data points, it is best suited for small datasets. It performs well in cases where data classes have clear boundaries and are not overly complex.</p><h3>4. Selecting the Value of K</h3><p>The value of K is the most critical hyperparameter in the KNN algorithm and directly impacts model accuracy. Here are some factors to consider when deciding on K:</p><ul><li><strong>Dataset Size:</strong> Generally proportional to the size of the dataset.</li><li><strong>Noise in Data:</strong> A slightly larger K can reduce the effect of a single wrong neighbor in noisy datasets.</li><li><strong>Class Distribution:</strong> In imbalanced datasets, K should reflect the class ratios. Increasing K may help.</li></ul><p>Small values of K (e.g., K=1) allow the model to capture local patterns but make it sensitive to noise and prone to overfitting.<br>Conversely, large values of K (e.g., K = dataset size) reduce noise effects and provide more balanced predictions but may ignore local patterns, leading to underfitting.</p><p><strong>Methods for Selecting K:</strong></p><ul><li><strong>Cross-Validation:</strong> Compare accuracy and error rates to choose the optimal K value.</li><li><strong>K ≈ √n (n: dataset size):</strong> Use this as a starting point.</li><li><strong>Error Graphs:</strong> Plot errors for different K values and choose the one with the lowest error.</li></ul><p>Odd values for K are often preferred to avoid ties.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dZaZliSN4BX1TequrNRc0Q.png" /></figure><h3>5. Advantages and Disadvantages</h3><p><strong>Advantages:</strong></p><ul><li>Does not require complex mathematical computations.</li><li>Applicable to both classification and regression problems.</li><li>Can handle non-linear and complex relationships.</li></ul><p><strong>Disadvantages:</strong></p><ul><li>High computational cost as it needs to refer to the entire dataset for each prediction.</li><li>Not suitable for unnormalized data.</li><li>High memory cost as it stores the entire dataset.</li><li>Risky for imbalanced datasets.</li></ul><h3>6. Example Code and Application</h3><pre># Import necessary libraries<br>import numpy as np<br>import matplotlib.pyplot as plt<br>from sklearn.model_selection import train_test_split<br>from sklearn.neighbors import KNeighborsClassifier<br>from sklearn.metrics import accuracy_score, confusion_matrix, classification_report<br><br># Create a sample dataset (2 features, 2 classes)<br>X = np.array([<br>    [2, 4], [4, 2], [4, 4], [6, 6], [6, 4], [8, 8],<br>    [1, 2], [3, 3], [7, 5], [9, 7], [2, 6], [3, 7]<br>])<br>y = np.array([0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0])  # Classes 0 and 1<br><br># Split data into training and test sets<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)<br><br># Create and train the KNN model<br>k = 3  # Number of neighbors (K value)<br>knn = KNeighborsClassifier(n_neighbors=k)<br>knn.fit(X_train, y_train)<br><br># Make predictions on the test set<br>y_pred = knn.predict(X_test)<br><br># Evaluate results<br>print(&quot;Accuracy Score:&quot;, accuracy_score(y_test, y_pred))<br>print(&quot;\nClassification Report:\n&quot;, classification_report(y_test, y_pred))<br>print(&quot;\nConfusion Matrix:\n&quot;, confusion_matrix(y_test, y_pred))<br><br># Visualization<br>plt.scatter(X[:, 0], X[:, 1], c=y, cmap=&#39;viridis&#39;, edgecolor=&#39;k&#39;, s=100, label=&quot;Data Points&quot;)<br>plt.scatter(X_test[:, 0], X_test[:, 1], c=&#39;red&#39;, marker=&#39;x&#39;, label=&quot;Test Data&quot;)<br>plt.title(f&quot;KNN Classification (K={k})&quot;)<br>plt.xlabel(&quot;Feature 1&quot;)<br>plt.ylabel(&quot;Feature 2&quot;)<br>plt.legend()<br>plt.show()</pre><pre>Accuracy Score: 1.0<br><br>Classification Report:<br>               precision    recall  f1-score   support<br><br>           0       1.00      1.00      1.00         3<br>           1       1.00      1.00      1.00         2<br><br>    accuracy                           1.00         5<br>   macro avg       1.00      1.00      1.00         5<br>weighted avg       1.00      1.00      1.00         5<br><br>Confusion Matrix:<br> [[3 0]<br>  [0 2]]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*emA9SNYAZ9KfkX4400F8Dw.png" /></figure><ul><li><strong>Data Generation:</strong><br>Create a small dataset manually with two features and two classes.</li><li><strong>Splitting Data:</strong><br>Split the data into training and test sets using train_test_split.</li><li><strong>Model Training:</strong><br>Train a KNN model using Scikit-learn’s KNeighborsClassifier.</li><li><strong>Prediction and Evaluation:</strong><br>Make predictions with the test set. Evaluate model accuracy, classification reports, and confusion matrices.</li><li><strong>Visualization:</strong><br>Visualize the data points and test points, with classes represented by colors.</li></ul><p>If you have any questions or feedback, feel free to reach out!</p><p><a href="https://www.linkedin.com/in/kardelenyurtkuran/">https://www.linkedin.com/in/kardelenyurtkuran/</a></p><p><a href="https://github.com/kardelenyurtkuran">kardelenyurtkuran - Overview</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ddd0ca97b5b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mesafelerle Tahmin: KNN Nasıl Çalışır?]]></title>
            <link>https://medium.com/@kardelenyurtkuran/mesafelerle-tahmin-knn-nas%C4%B1l-%C3%A7al%C4%B1%C5%9F%C4%B1r-bd36361d2389?source=rss-80a94dbb3566------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd36361d2389</guid>
            <category><![CDATA[knn-algorithm]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[knn]]></category>
            <category><![CDATA[supervised-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Kardelen Yurtkuran]]></dc:creator>
            <pubDate>Tue, 03 Dec 2024 11:29:58 GMT</pubDate>
            <atom:updated>2024-12-03T11:29:58.481Z</atom:updated>
            <content:encoded><![CDATA[<p>Makine öğrenmesi algoritmalarının en anlaşılır ve güçlü üyelerinden biri şüphesiz KNN’dir. KNN algortimaları tahmin yaparken en yakın komşularıyla olan mesafelere odaklanır. Peki en yakın komşular neye göre belirlenir? Aralarında ki mesafe nasıl ölçülür ?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*Y_oenIUFUoe96hvxXLpA9g.png" /></figure><h3>1. KNN Nedir?</h3><p>K-En Yakın Komşuluk(KNN/ K-Nearest Neighbors), denetimli makine öğrenmesi (supervised learning) algoritmasıdır. Hem sınıflandırma hem regresyon problemlenrinde kullanılabilir.</p><p>Temelde “birbirine yakın olan değerler birbirine benzer” varsayımını kullanarak tahminlerde bulunur. Veriyi ezberlemez, öğrenmez, bilinen verileri referans alır.</p><h3>2. Nasıl Çalışır?</h3><p>Elinizde bir veri seti olduğunu varsayalım. Yeni veri noktasının her komşuya olan mesafesini bulmanız gerekir. Bu mesafeleri bulmak için sık kullanılan ölçüm metrikleri;</p><ul><li><strong>Öklid Mesafesi (Euclidean Distance):</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*3WnBcigiCW7RfedkZDYZ4g.png" /></figure><p>Özelliklerin uzunluk, genişlik veya ağırlık gibi sürekli (sayısal) olduğu durumlarda, veriler arasında düzlemsel uzaklık ilişkisi varsa kullanılır.</p><p>Gürültüye duyarlıdır; aykırı değerler sonucu gereksiz değiştirebilir.</p><ul><li><strong>Manhattan Mesafesi(Taxicab Distance veya L1 Distance)</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*qSWOoCnXxQAcMLBsYoLavg.png" /></figure><p>Izgara şeklinde düzenlenmiş veriler, bazı özelliklerin sıfır olduğu seyrek matrislerle çalışırken yada gürültüye dayanıklı olması gereken durumlarda kullanılır.</p><ul><li><strong>Minkowski Mesafesi (Özel durumlar):</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V_plvR-b0-Kr9J96uui6Sg.png" /></figure><p>Hem Öklid (p=2) hem de Manhattan (p=1) mesafelerini genelleştiren bir formüldür. Farklı <strong>p</strong> değerleriyle farklı mesafe türlerine dönüşür:</p><ul><li>p=1 → Manhattan Mesafesi.</li><li>p=2 → Öklid Mesafesi.</li><li>p&gt;2 → Daha büyük sapmaları vurgulayan bir mesafe.</li></ul><p>Tüm uzaklıkları hesapladıktan sonra en yakın K adet komşu seçilir. Eğer probleminiz bir sınıflandırma problem ise çoğunluk sınıfı (majority voting) yeni veri noktanız için tahmin sınıfıdır. Eğer probleminiz bir regresyon problem ise komşuların ortalaması yeni veri noktanızın değeridir.</p><p>Basit bir örnek vermemiz gerekirse;</p><p>Örneğin öğrencilerin çalışma saatlerine bakarak dersten geçip geçmediklerine karar vermek istiyorsunuz. Öğrencilerin çalışma saatleri ve bunlara karşılık gelen başarı durumlarınız;</p><p>[2,1], [1,0], [3,1],[0.5,0] şeklinde olsun.</p><p>Tahminde bulunmanız gereken durum ise 2.5 saat çalışan öğrencinin başarılı olup olmayacağı olsun. İlk olarak uzaklıkları hesaplamalısınız.</p><ul><li>2.5 ve 2 saat arası mesafe : |2.5–2| = 0.5</li><li>2.5 ve 1 saat arası mesafe : |2.5–1| = 1.5</li><li>2.5 ve 3 saat arası mesafe : |2.5–3| = 0.5</li><li>2.5 ve 0.5 saat arası mesafe : |2.5–0.5| = 2</li></ul><p>K en yakın komşuyu belirlenir. (örn K=3)</p><p>Bu durumda en yakın 3 adet komşu 2 saat, 1 saat ve 3 saat çalışan öğrencilerdir. Bu öğrencilerin sırası ile başarı durumları; 1, 0 ve 1’dir. Bu durumda yeni veri noktamız olan 2.5 saat çoğunluk sınıfına dahil olacaktır. Yani 2.5 saat çalışan bir öğrencinin başarı durumu 1 kabul edilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mwqbNERd9fe3mQa6r9tYPA.png" /></figure><h3>3. Hangi durumlarda kullanılır?</h3><p>Yukarıda bahsettiğim gibi hem sınıflandırma hem regresyon problemleri için kullanılması uygundur. Örneğin e-posta spam sınıflandırması yada ev fiyatını tahmin etme gibi problemlerde kullanabilirsiniz.</p><p>Tüm verilere olan uzaklık hesaplanacağı için küçük veri setleri için kullanılması uygundur. Karmaşık olmayan, veri sınıfları arasında ki sınırların net olduğu durumlarda iyi performans göstermesi beklenir.</p><h3>4. K Değerinin Seçimi</h3><p>K değeri KNN algoritmasının em önemli hiperparametresidir ve modelin doğruluğunu doğrudan etkiler. Ancak K değerine karar verebileceğiniz yada dikkat etmeniz gereken birkaç faktör vardır.</p><ul><li>Veri setinin büyüklüğü: Genellikle veri setinin büyüklüğü ile orantılı seçilir.</li><li>Veri Gürültüsü: Eğer çok gürültülü bir veri ile çalışıyorsanız K değerini biraz daha büyük seçmek, tek bir yanlış komşunun etkisini azaltabilir.</li><li>Sınıf Dağılımı: Eğer veri setinizde ki sınıflar arasında dengesizlik varsa, K değerinin sınıf oranlarını yansıtacak şekilde ayarlanması önemlidir. Bu durumda yine K değerini arttırmayı düşünebilirsiniz.</li></ul><p>Çok küçük bir K değeri seçmek (örn K=1) modelin esnek olmasını ve yerel desenleri yakalamasını sağlarken, gürültüye karşı hassas olmasını ve aşırı öğrenme (overfitting) problemi ile karşılaşmanıza sebep olabilir.</p><p>Bunun yanı sıra, çok büyük bir K değeri seçmek (örn K= veri sayısı) gürültü etkisini azaltıp daha dengeli bir tahmin sağlarken, modelin yerel desenleri göz ardı etmesine ve modelin genelleştirme yapamamasına (underfitting) sebep olabilir.</p><p>K değerinin belirlenmesi için bir kaç yöntem vardır;</p><ul><li>Çapraz Doğrulama(Cross-Validation): Çapraz doğrulama yapılarak doğruluk (accuracy) ve hata oranları karşılaştırılarak en optimum K değeri seçilebilir.</li><li>K ≈ √n (n: veri sayısı) hesaplanarak çıkan değer bir başlangıç noktası kabul edilebilir.</li><li>Farklı K değerleri için model hatalarının grafiği çizilebilir. Bu sayede en düşük hataya sahip K değeri belirlenebilir.</li></ul><p>K değeri beraberlikten kaçınmak için tek sayı tercih edilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dZaZliSN4BX1TequrNRc0Q.png" /></figure><h3>5. Avantajlar ve Dezavantajlar</h3><p>Avantajlar;</p><ul><li>Karmaşık matematiksel işlemlere ihtiyaç duyulmaz</li><li>Hem sınıflandırma hem regresyon problemleri için kullanılabilir</li><li>Doğrusal olmayan karmaşık ilişkiler içinde kullanılabilir.</li></ul><p>Dezavantajlar;</p><ul><li>Her tahmin için tüm veri setine bakılır bu nedenle hesaplama maliyeti yüksektir</li><li>Normalizasyon yapılmamış verilerle çalışmak için uygun değildir</li><li>Tüm veri seti bellekte tutulduğu için hafıza maliyeti yüksektir.</li><li>Dengesiz veri setleri için risklidir.</li></ul><h3>6. Örnek Kod ve Uygulama</h3><pre># Gerekli kütüphaneleri içe aktar<br>import numpy as np<br>import matplotlib.pyplot as plt<br>from sklearn.model_selection import train_test_split<br>from sklearn.neighbors import KNeighborsClassifier<br>from sklearn.metrics import accuracy_score, confusion_matrix, classification_report<br><br># Örnek veri seti oluştur (2 özellik, 2 sınıf)<br>X = np.array([<br>    [2, 4], [4, 2], [4, 4], [6, 6], [6, 4], [8, 8],<br>    [1, 2], [3, 3], [7, 5], [9, 7], [2, 6], [3, 7]<br>])<br>y = np.array([0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0])  # 0 ve 1 sınıfları<br><br># Veriyi eğitim ve test setlerine böl<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)<br><br># KNN modelini oluştur ve eğit<br>k = 3  # K değeri<br>knn = KNeighborsClassifier(n_neighbors=k)<br>knn.fit(X_train, y_train)<br><br># Test seti ile tahmin yap<br>y_pred = knn.predict(X_test)<br><br># Sonuçları değerlendir<br>print(&quot;Doğruluk Oranı:&quot;, accuracy_score(y_test, y_pred))<br>print(&quot;\nSınıflandırma Raporu:\n&quot;, classification_report(y_test, y_pred))<br>print(&quot;\nKarmaşıklık Matrisi:\n&quot;, confusion_matrix(y_test, y_pred))<br><br># Görselleştirme<br>plt.scatter(X[:, 0], X[:, 1], c=y, cmap=&#39;viridis&#39;, edgecolor=&#39;k&#39;, s=100, label=&quot;Veriler&quot;)<br>plt.scatter(X_test[:, 0], X_test[:, 1], c=&#39;red&#39;, marker=&#39;x&#39;, label=&quot;Test Verileri&quot;)<br>plt.title(f&quot;KNN Sınıflandırması (K={k})&quot;)<br>plt.xlabel(&quot;Özellik 1&quot;)<br>plt.ylabel(&quot;Özellik 2&quot;)<br>plt.legend()<br>plt.show()</pre><pre>Doğruluk Oranı: 1.0<br><br>Sınıflandırma Raporu:<br>               precision    recall  f1-score   support<br><br>           0       1.00      1.00      1.00         2<br>           1       1.00      1.00      1.00         2<br><br>    accuracy                           1.00         4<br>   macro avg       1.00      1.00      1.00         4<br>weighted avg       1.00      1.00      1.00         4<br><br><br>Karmaşıklık Matrisi:<br> [[2 0]<br> [0 2]]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*emA9SNYAZ9KfkX4400F8Dw.png" /></figure><h4><strong>Veri Oluşturma</strong>:</h4><p>El ile küçük bir veri seti oluşturulur. İki özelliği ve iki sınıfı olan bir veri seti tasarlanmıştır.</p><h4><strong>Veri Bölme</strong>:</h4><p>Veri, eğitim ve test setlerine bölünür (<strong>train_test_split</strong>).</p><h4><strong>Model Eğitimi</strong>:</h4><p>Scikit-learn’ün <strong>KNeighborsClassifier</strong> sınıfı kullanılarak KNN modeli oluşturulur ve eğitilir.</p><h4><strong>Tahmin ve Değerlendirme</strong>:</h4><p>Test setindeki verilerle tahmin yapılır. Modelin doğruluk oranı, sınıflandırma raporu ve karmaşıklık matrisi değerlendirilir.</p><h4><strong>Görselleştirme</strong>:</h4><p>Veriler ve test noktaları görselleştirilir. Sınıflar renklerle temsil edilir.</p><p>Bana ulaşmak isterseniz;</p><p><a href="https://www.linkedin.com/in/kardelenyurtkuran/">https://www.linkedin.com/in/kardelenyurtkuran/</a></p><p><a href="https://github.com/kardelenyurtkuran">kardelenyurtkuran - Overview</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd36361d2389" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Intelligence or Imitation? The Turing Test and Artificial Intelligence Debates]]></title>
            <link>https://medium.com/@kardelenyurtkuran/intelligence-or-imitation-the-turing-test-and-artificial-intelligence-debates-86f049cfb9e6?source=rss-80a94dbb3566------2</link>
            <guid isPermaLink="false">https://medium.com/p/86f049cfb9e6</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[alan-turing]]></category>
            <category><![CDATA[turing-test]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Kardelen Yurtkuran]]></dc:creator>
            <pubDate>Thu, 03 Oct 2024 14:44:59 GMT</pubDate>
            <atom:updated>2024-10-04T12:55:28.007Z</atom:updated>
            <content:encoded><![CDATA[<p>The Turing Test is a significant measure for evaluating the human-like thinking and communication abilities of artificial intelligence. So, what exactly is the Turing Test? How is it conducted? Is it still relevant today? Why is it important in the field of AI? I’ll be addressing these questions. Enjoy the read!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LUqATwpds7M4IUoeRswvCQ.png" /></figure><p>As the name suggests, the Turing Test was introduced by the British mathematician Alan Turing in his 1950 paper titled “Computing Machinery and Intelligence.” — You know, the genius who led the efforts to crack the Enigma code and is also rumored to be represented by the bitten apple logo of Apple. Well, he’s the one who came up with the Turing Test too.-<br>This paper is the first to present what we now recognize as the important Turing Test. It begins with the following words:</p><blockquote>“I propose to consider the question, ‘Can machines think?’ This must begin by defining the meanings of the terms ‘machine’ and ‘think.’ The definitions could be framed to reflect the normal usage of the words as much as possible, but such an approach is dangerous. If the meaning of the words ‘machine’ and ‘think’ is to be determined by how they are commonly used, then it becomes difficult to avoid the conclusion that the meaning and answer to the question ‘Can machines think?’ should be sought through a statistical inquiry like a Gallup poll. But this is absurd. Rather than attempting such a definition, I will replace the question with another one, closely related, but expressed in relatively clear terms.</blockquote><blockquote>The new question can be described in terms of a game which we call the ‘imitation game.’ The game is played with three people: a man (A), a woman (B), and an interrogator © who may be of either sex. The interrogator stays in a room separate from the other two. The object of the game for the interrogator is to determine which of the two is the man and which is the woman. The interrogator knows them only by labels X and Y, and at the end of the game, he might say, ‘X is A, and Y is B,’ or ‘X is B, and Y is A.’ The interrogator is allowed to ask A and B questions like the following:</blockquote><blockquote>C: X, please tell me the length of your hair?</blockquote><blockquote>Now, suppose X is really A; then A must answer. The object of the game for A is to try and cause the interrogator to make an incorrect identification. So A might reply:</blockquote><blockquote>‘My hair is auburn and reaches about nine inches at its longest strands.’</blockquote><blockquote>The answers should be written, preferably typed, to prevent the interrogator from getting any help from the tone of voice. Ideally, the communication between the rooms would take place through a teleprinter. Alternatively, the questions and answers could be relayed by an intermediary. The object of the game for the third player (B) is to assist the interrogator in making the correct identification. The best strategy for B is probably to give truthful answers. B may also add remarks like, ‘I am a woman, don’t listen to him!’ But since the man can make similar remarks, this is of no help.</blockquote><blockquote>We now ask the question, ‘What will happen when a machine takes the part of A in this game?’ Will the interrogator decide wrongly as often when the game is played in this manner as when it is played between a man and a woman? These questions replace our original, ‘Can machines think?’”</blockquote><p>The Turing Test is a highly intriguing measure in the field of artificial intelligence. According to this test, the key criterion is whether a machine can exhibit behavior similar to human intelligence. However, what matters is not whether the machine gives the correct answer, but whether it behaves in a way that mimics human responses. — After all, humans don’t always produce the right outputs, do they? –</p><h4>So, what is the Turing Test, and how is it conducted?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vb9b6zYTV_Ythn_661MZ7w.png" /></figure><p>Actually, it fundamentally relies on the process where an interrogator decides whether a response comes from a human or a machine based on the answers given without seeing either. This process, of course, occurs through natural language conversation. At the end of the test, the interrogator is expected to consistently distinguish between the two.</p><p>In other words, a machine is expected to be “<strong>human-like</strong>” rather than “<strong>intelligent.</strong>” This includes details such as sensitivity to gestures, a tendency to lie, and spelling errors. However, it does not encompass intelligent behaviors such as providing insights or solving complex problems. For example, solving a computational problem that is nearly impossible would lead the interrogator to directly understand that the counterpart is a machine.</p><h4>What is the use of this concept?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Oe4qFk9V6PR6WMBbPtw4CQ.png" /></figure><p>Why is the Turing Test so controversial and so important? To address these questions, this criterion is actually an important concept that serves the field of artificial intelligence. It is significant for evaluating the potential of artificial intelligence to replicate or surpass human cognitive functions. Therefore, it is one of the fundamental elements in discussions about the future of artificial intelligence.</p><p>Turing proposed that if a machine exhibits human-like intelligent behavior to the extent that it can deceive a human, we should define that machine as intelligent.</p><h4>When was the Turing Test first passed?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8BGJb_gP7eFCYvpSI1AxVQ.jpeg" /><figcaption>Live Science, GPT-4 has passed the Turing test, researchers claim</figcaption></figure><p>Before 2004, the interrogators were considered “average,” while after 2004, the interrogator committees consist of philosophers, computer scientists, and journalists determined by the Loebner Prize organizers.</p><p>Although it is highly controversial, it is known that Weizenbaum first created a program called ELIZA (a non-AI chatbot). This program attempted to capture keywords from the user and transformed those keywords into responses. If it failed to capture any, it would mimic the previous response. While this program managed to convince some real people, it could not persuade others.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*ExCMwBu_bVqu-2ycv8dvng.jpeg" /><figcaption>csfieldguide, Chatterbots and the Turing test</figcaption></figure><p>Later, a similar test was applied to Colby’s PARRY program. PARRY, known as the “snarky ELIZA,” was designed to model the behavior of paranoid schizophrenia. A commission composed of experienced psychiatrists and real patients was formed for the Turing test. As a result of the test, it was found that the psychiatrists could only correctly identify which was the real patient and which was the machine with an accuracy of just 52%.</p><p>In addition to these historical developments, many sources on the internet report that software named Eugene Goostman, developed by Vladimir Veselov and Demchenko, was the first to pass the Turing test. Additionally, ChatGPT is also presented as a software that has passed the Turing test.</p><h4>Turing Tests in the Modern World</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*CqQDchCQ1MwrrMMqJjI4fg.jpeg" /><figcaption>arstechnica, 1960s chatbot ELIZA beat OpenAI’s GPT-3.5 in a recent Turing test study</figcaption></figure><p>“<strong>The Standard Turing Test</strong>” is a process focused on text-based responses.</p><p>In addition, “<strong>The Total Turing Test</strong>” focuses on machines producing audio and visual outputs and being distinguished in these areas.</p><p>“<strong>The Extended Turing Test</strong>,” on the other hand, aims to explore the cognitive abilities of machines in more depth. According to this test, machines are expected to perform tasks that involve humor and creativity as well.</p><p>“<strong>The Reverse Turing Test</strong>” is a process in which machines are in the interrogator position, and a human tries to prove that they are not a machine by deceiving it.</p><h4>Is the Turing Test still valid?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DhACjHtjPGqIzYwZT7FuVQ.jpeg" /></figure><p>This topic is still open to debate. Some researchers argue that machines can manipulate this test by merely mimicking human-like speech but cannot measure the depth of intelligence, such as learning, emotional intelligence, and solving complex problems.</p><p>In practice, the ability of machines to deceive humans is directly related to the skills and attitudes of the interrogator. There are no definitive frameworks regarding the characteristics of interrogators for the Turing test; instead, the term “average interrogator” is used. In this situation, it has been observed that machines that only mimic human-like behavior can deceive real humans without possessing actual intelligence. Additionally, a phenomenon known as the “confederate effect” has been observed in humans who compete with the machine. In this case, because people are not motivated to behave like humans, they can inadvertently convince the interrogator that they are machines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1nWAlJSq77piPq95m-eLwA.png" /></figure><p>Today, artificial intelligence researchers argue that this test is not efficient and that there may be more practical and logical ways to test machines. Stuart Russell and Peter Norvig state that the focus of this test is not appropriate:</p><blockquote>“Aerospace engineering texts do not define the purpose of their field as ‘making machines that can fly exactly like pigeons to fool other pigeons.’”</blockquote><p>Erik Brynjolfsson refers to this test as the “Turing Trap,” arguing that it serves as an incentive to create machines that imitate humans rather than empower them. Today, there is a need for more comprehensive measurement tools for evolving artificial intelligence models. This is because Turing Tests do not fully measure requirements such as emotional intelligence, ethical reasoning, and creative problem-solving. Nevertheless, the Turing test remains an important starting point for framing the capabilities of artificial intelligence.</p><p><strong>References</strong></p><ul><li>Evrim Ağacı. (n.d.). What is the Turing Test? Is the Turing Test Still a Valid Test Today? Retrieved from: <a href="https://evrimagaci.org/turing-testi-nedir-turing-testi-gunumuzde-halen-gecerli-bir-test-mi-17442">https://evrimagaci.org/turing-testi-nedir-turing-testi-gunumuzde-halen-gecerli-bir-test-mi-17442</a></li><li>Bilim Genç. (n.d.). Artificial Intelligence Tests from Turing to Today. Retrieved from: <a href="https://bilimgenc.tubitak.gov.tr/makale/turingden-bugune-yapay-zeka-testleri">https://bilimgenc.tubitak.gov.tr/makale/turingden-bugune-yapay-zeka-testleri</a></li></ul><p>If you would like to follow me on other platforms;</p><ul><li><strong>LinkedIn:</strong> <a href="https://www.linkedin.com/in/kardelenyurtkuran/">https://www.linkedin.com/in/kardelenyurtkuran/</a></li><li><strong>Github:</strong> <a href="https://github.com/kardelenyurtkuran">https://github.com/kardelenyurtkuran</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86f049cfb9e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Zeka mı ?, Taklit mi? Turing Testi ve Yapay Zeka Tartışmaları]]></title>
            <link>https://medium.com/@kardelenyurtkuran/zeka-m%C4%B1-taklit-mi-turing-testi-ve-yapay-zeka-tart%C4%B1%C5%9Fmalar%C4%B1-be0c2351a9f1?source=rss-80a94dbb3566------2</link>
            <guid isPermaLink="false">https://medium.com/p/be0c2351a9f1</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[turing-test]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[yapay-zeka]]></category>
            <category><![CDATA[alan-turing]]></category>
            <dc:creator><![CDATA[Kardelen Yurtkuran]]></dc:creator>
            <pubDate>Thu, 03 Oct 2024 14:18:39 GMT</pubDate>
            <atom:updated>2024-10-04T12:54:53.089Z</atom:updated>
            <content:encoded><![CDATA[<h3>Zeka mı ?, Taklit mi? Turing Testi ve Yapay Zeka Tartışmaları</h3><p>Turing Testi, yapay zekanın insan benzeri düşünme ve iletişim yeteneklerini değerlendiren önemli bir ölçüttür. Peki, Turing Testi nedir? Nasıl yapılır? Hala geçerliliği var mıdır? Yapay zeka alanında neden önemlidir? Bu soruların yanıtlarını ele alacağım. Keyifli okumalar!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LUqATwpds7M4IUoeRswvCQ.png" /></figure><p>Turing testi, adından da anlaşılacağı üzere, İngiliz matematikçi Alan Turing tarafından 1950 yılında “Computing Machinery and Intelligence” makalesinde ortaya atılmıştır. -Hani şu Enigma kodlarının kırılmasına öncülük eden, aynı zamanda Apple markasındaki ısırılmış elma logosunu temsil ettiği rivayet edilen dahi var ya, işte Turing testini ortaya atan kişi de bizzat kendisidir.-<br>Bu makale, günümüzdeki önemli Turing testinin yayınlandığı ilk makaledir. Şu cümlelerle başlamaktadır;</p><blockquote>“Makineler düşünebilir mi?” sorusunu ele almayı öneriyorum. Buna “makine” ve “düşünmek” terimlerinin anlamlarının tanımlanmasıyla başlanmalıdır. Tanımlar, kelimelerin normal kullanımını mümkün olduğunca yansıtacak şekilde çerçevelenebilir, ancak bu tutum tehlikelidir. “Makine” ve “düşünmek” kelimelerinin anlamı, yaygın olarak nasıl kullanıldıklarını inceleyerek bulunacaksa, “Makineler düşünebilir mi?” sorusunun anlamının ve cevabının Gallup anketi gibi istatistiksel bir araştırmada aranması gerektiği sonucundan kaçmak zordur. Ancak bu saçmadır. Böyle bir tanımlamaya girişmek yerine, soruyu, onunla yakından ilişkili olan ve nispeten açık kelimelerle ifade edilen bir başka soruyla değiştireceğim.</blockquote><blockquote>Sorunun yeni şekli, “<strong>taklit oyunu</strong>” olarak adlandırdığımız bir oyunla tanımlanabilir. Bu oyun üç kişiyle oynanır: bir erkek (A), bir kadın (B) ve her iki cinsiyetten de olabilen bir sorgulayıcı (C). Sorgulayıcı diğer ikisinden ayrı bir odada kalır. Sorgulayıcı için oyunun amacı, diğer ikisinden hangisinin erkek hangisinin kadın olduğunu belirlemektir. Onları X ve Y etiketleriyle tanır ve oyunun sonunda ya “X, A’dır ve Y, B’dir” ya da “X, B’dir ve Y, A’dır” der. Sorgulayıcının A ve B’ye şu şekilde sorular sormasına izin verilir:</blockquote><blockquote>C: X, lütfen bana saçının uzunluğunu söyler misin?</blockquote><blockquote>Şimdi X’in aslında A olduğunu varsayalım, o zaman A cevap vermelidir. A’nın oyundaki amacı C’nin yanlış tanımlama yapmasına neden olmaya çalışmaktır. Bu nedenle cevabı şöyle olabilir:</blockquote><blockquote>“Saçlarım kiremitlidir [20&#39;lerde meşhur olan bir saç tipi] ve en uzun telleri yaklaşık dokuz inç uzunluğundadır.”</blockquote><blockquote>Ses tonunun sorgucuya yardımcı olmaması için cevaplar elyazılı ya da daha da iyisi daktilo ile yazılmış olmalıdır. İdeal düzenleme, iki oda arasında iletişim kuran bir teleprinter’a sahip olmaktır. Alternatif olarak soru ve cevaplar bir aracı tarafından tekrarlanabilir. Üçüncü oyuncu (B) için oyunun amacı, sorgulayıcıya yardım etmektir. Onun için en iyi strateji muhtemelen doğru cevaplar vermektir. Cevaplarına “Ben kadınım, onu dinlemeyin!” gibi şeyler ekleyebilir, ancak erkek de benzer açıklamalar yapabileceği için bunun hiçbir faydası olmayacaktır.</blockquote><blockquote>Şimdi şu soruyu soruyoruz: “Bu oyunda A’nın rolünü bir makine aldığında ne olacak?” Sorgulayıcı, oyun bu şekilde oynandığında, oyun bir erkek ve bir kadın arasında oynandığında olduğu kadar sık yanlış karar verecek mi? Bu sorular bizim orijinal “Makineler düşünebilir mi?” sorumuzun yerini almaktadır. “</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*yxj4Fv5MV2ld7xFMDL8Wjw.jpeg" /><figcaption>investopedia, The Turing Test: What Is It, What Can Pass It, and Limitations</figcaption></figure><p>Turing testi, yapay zeka alanında oldukça dikkat çekici bir ölçüttür. Bu teste göre, bir makinenin insan zekası benzeri davranışlar sergileyip sergilemediği ölçen bir kriterdir. Ancak burada doğru yanıt verip vermemesi değil, insan benzeri davranışlar sergileyip sergilemediği önemli bir kriter olarak karşımıza çıkmaktadır. -Sonuçta insanoğlu da her zaman doğru çıktılar üretmiyor, değil mi?-</p><h4>Peki, nedir bu Turing testi ve nasıl yapılır?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vb9b6zYTV_Ythn_661MZ7w.png" /></figure><p>Aslında, temelde bir sorgulayacının bir makineyi ve bir insanı görmeden verdiği yanıtlara göre, insan ya da makine olup olmadığına karar vermesine dayanır. Bu süreç, elbette ki doğal dilde konuşma yoluyla gerçekleşir. Test sonunda, sorgulayıcının tutarlı bir şekilde ayırt etmesi beklenir.<br>Yani bir makinenin “<strong>zeki</strong>” değil “<strong>insan gibi</strong>” olması beklenir. Hareketlere karşı duyarlılık, yalan söyleme eğilimi, yazım hataları gibi detayları da içermektedir. Ancak içgörüler ortaya koyma ya da karmaşık problemleri çözme gibi zeki davranışları içermemektedir. Örneğin, çözülmesi imkansıza yakın bir hesaplama problemini çözmesi, sorgulayıcının karşı tarafın makine olduğunu doğrudan anlamasına neden olacaktır.</p><h4>Bu kavram ne işimize yarıyor?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Oe4qFk9V6PR6WMBbPtw4CQ.png" /></figure><p>Turing testi neden bu kadar tartışmalı ve neden bu kadar önemli? Bu sorulara gelecek olursak, aslında bu kriter, yapay zeka alanına hizmet eden önemli bir kavramdır. Çünkü yapay zekanın, insanın bilişsel işlevlerini kopyalama veya aşma potansiyelini değerlendirmek için önemlidir. Bu nedenle, yapay zekanın geleceği konusundaki tartışmaların temel unsurlarından biridir.<br>Turing, eğer bir makine, bir insanı kandırabilecek kadar insani zeka davranışları sergiliyorsa, o makineyi zeki olarak tanımlamamız gerektiğini öne sürmüştür.</p><h4>Turing testi ilk ne zaman geçildi?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8BGJb_gP7eFCYvpSI1AxVQ.jpeg" /><figcaption>Live Science, GPT-4 has passed the Turing test, researchers claim</figcaption></figure><p>2004 yılından önce sorgulayıcılar “ortalama” olarak kabul edilirken, 2004 sonrası sorgulayıcı komiteleri Loebner Ödülü organizatörlerince belirlenen filozoflar, bilgisayar bilimcileri ve gazetecilerden oluşmaktadır.</p><p>Çok tartışmalı olsa da, ilk olarak Weizenbaum’un ELIZA (yapay zeka olmayan bir chatbot) adında bir program yarattığı bilinmektedir. Bu program, kullanıcıdan anahtar kelimeler yakalamaya çalışıyor ve bu anahtar kelimeleri yoruma dönüştürüyordu. Eğer yakalayamazsa, bir önceki yorumunu taklit ediyordu. Bu program bazı gerçek insanları inandırmayı başarsa da, bazı denekleri ikna edememiştir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*ExCMwBu_bVqu-2ycv8dvng.jpeg" /><figcaption>csfieldguide, Chatterbots and the Turing test</figcaption></figure><p>Daha sonra, Colby’nin PARRY programı için benzer bir test uygulanmıştır. PARRY, “tavırlı ELIZA” olarak da bilinir ve Colby, paranoid şizofren davranışlarını modellemeye çalışmıştır. Turing testi için deneyimli psikiyatrlar ve gerçek hastalardan oluşan bir komisyon oluşturulmuştur. Test sonucunda, psikiyatrların hangisinin gerçek hasta hangisinin makine olduğunu belirlemede yalnızca %52 doğru tanımlama yapabildikleri görülmüştür.</p><p>Bu tarihsel gelişimlerin yanı sıra, internette yer alan pek çok kaynağa göre, Vladimir Veselov ve Demchenko tarafından geliştirilen Eugene Goostman isimli yazılımın ilk kez Turing testini geçtiği kaydedilmiştir. Ek bilgi olarak, ChatGPT de yine Turing testini geçen bir yazılım olarak karşımıza çıkmaktadır.</p><h4>Modern Dünyada Turing Testleri</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*CqQDchCQ1MwrrMMqJjI4fg.jpeg" /><figcaption>arstechnica, 1960s chatbot ELIZA beat OpenAI’s GPT-3.5 in a recent Turing test study</figcaption></figure><p>“<strong>Standart Turing Testi</strong>”, metin tabanlı yanıtlara odaklanan bir süreçtir.</p><p>Bunun yanı sıra, “<strong>Total Turing Testi</strong>” makinelerin ses ve görsel çıktılar üretip bu alanlarda ayırt edilmesine odaklanır.</p><p>“<strong>Genişletilmiş Turing Testi</strong>” ise makinelerin bilişsel yeteneklerini daha derinlemesine araştırmayı amaçlar. Bu teste göre, makinelerin mizah ve yaratıcılık içeren görevleri de yerine getirmesi beklenir.</p><p>“<strong>Ters Turing Testi</strong>” ise makinelerin sorgulayıcı pozisyonda olduğu ve bir insanın makineyi kandırarak insan olmadığını kanıtlamaya çalıştığı süreçtir.</p><h4>Turing Testi Hala Geçerliliğini Koruyor mu?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DhACjHtjPGqIzYwZT7FuVQ.jpeg" /></figure><p>Bu konu hâlâ tartışmaya açıktır. Bazı araştırmacılar, makinelerin yalnızca insan benzeri konuşma şeklini taklit ederek bu testi manipüle edebileceğini, ancak öğrenme, duygusal zeka ve karmaşık problemleri çözme gibi zekanın derinliğini ölçemeyeceğini savunmaktadır.</p><p>Pratikte, makinelerin insanı kandırabilmesi, sorgulayıcının becerisi ve tutumuyla doğrudan ilişkilidir. Turing testi için sorgulayacıların özellikleri konusunda kesin çerçeveler belirtilmemiştir; bunun yerine “ortalama bir sorgucu” ifadesi kullanılmaktadır. Bu durumda, bir zekaya sahip olmaksızın yalnızca insan benzeri davranışları taklit eden makinelerin gerçek insanları kandırabildiği gözlemlenmiştir. Ayrıca, makineye rakip olan yani sorgulanan insanlarda “konfedere etkisi” olarak adlandırılan bir durum gözlemlenmektedir. Bu durumda, insanlar insan gibi davranmaya motive olamadıkları için, istemeden de olsa sorgulayıcıyı makine olduklarına ikna edebilmektedir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1nWAlJSq77piPq95m-eLwA.png" /></figure><p>Günümüzde yapay zeka araştırmacıları, bu testin verimli olmadığını ve makineleri test etmenin daha pratik ve mantıklı yollarının olabileceğini savunmaktadır. Stuart Russell ve Peter Norvig, bu testin odak noktası olmadığını belirtmektedir:</p><blockquote>“Havacılık mühendisliği metinleri, alanlarının amacını ‘diğer güvercinleri kandırabilecek kadar tam olarak güvercin gibi uçan makineler yapmak’ olarak tanımlamaz.”</blockquote><p>Erik Brynjolfsson ise bu testi “Turing Tuzağı” olarak adlandırarak, insanı güçlendirmek yerine taklit eden makineler yaratmaya yönelik bir teşvik olduğunu savunmuştur. Günümüzde gelişen yapay zeka modelleri için daha kapsamlı ölçüm araçlarına ihtiyaç duyulmaktadır. Çünkü Turing Testleri, duygusal zeka, etik muhakeme ve yaratıcı problem çözme gibi ihtiyaçları tam olarak ölçememektedir. Yine de, Turing testi yapay zekanın yeteneklerini çerçevelemede önemli bir başlangıç noktasıdır.</p><h3>Kaynaklar</h3><ol><li>Evrim Ağacı. (n.d.). <em>Turing Testi Nedir? Turing Testi Günümüzde Hâlâ Geçerli Bir Test mi?</em> Erişim adresi: <a href="https://evrimagaci.org/turing-testi-nedir-turing-testi-gunumuzde-halen-gecerli-bir-test-mi-17442">https://evrimagaci.org/turing-testi-nedir-turing-testi-gunumuzde-halen-gecerli-bir-test-mi-17442</a></li><li>Bilim Genç. (n.d.). <em>Turing’den Bugüne Yapay Zeka Testleri.</em> Erişim adresi: <a href="https://bilimgenc.tubitak.gov.tr/makale/turingden-bugune-yapay-zeka-testleri">https://bilimgenc.tubitak.gov.tr/makale/turingden-bugune-yapay-zeka-testleri</a></li></ol><p>Beni diğer platformlardan da takip etmek isterseniz;</p><p><a href="https://www.linkedin.com/in/kardelenyurtkuran/">https://www.linkedin.com/in/kardelenyurtkuran/</a></p><p><a href="https://github.com/kardelenyurtkuran">kardelenyurtkuran - Overview</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be0c2351a9f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Quick Introduction to Data Science: A Beginner’s Guide with NumPy]]></title>
            <link>https://medium.com/@kardelenyurtkuran/a-quick-introduction-to-data-science-a-beginners-guide-with-numpy-c40fdba19123?source=rss-80a94dbb3566------2</link>
            <guid isPermaLink="false">https://medium.com/p/c40fdba19123</guid>
            <category><![CDATA[numpy]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[image-processing]]></category>
            <dc:creator><![CDATA[Kardelen Yurtkuran]]></dc:creator>
            <pubDate>Fri, 12 Jul 2024 12:34:13 GMT</pubDate>
            <atom:updated>2024-07-12T12:34:13.789Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello,</p><p>Data science is one of the most powerful fields in Python. Today, I have prepared a quick start guide to NumPy, one of Python’s indispensable libraries for data analysis.</p><p>Of course, NumPy is a rich library with many functions besides those I have mentioned below. Therefore, you can explore its documentation in detail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yiglbQvk90pycf7IkMYFRw.png" /></figure><pre>import numpy as np</pre><h4>1- Creating NumPy Arrays</h4><pre>ndarray = np.array([1,2,3])</pre><h4>2- Creating an Array with Numerical Values in a Specific Range</h4><pre>np.arange([start, ]stop, [step, ]dtype=None, *, like=None)</pre><ul><li><strong>start</strong>: (optional) The starting value of the array. Defaults to 0.</li><li><strong>stop</strong>: The endpoint of the array. This value is not included.</li><li><strong>step</strong>: (optional) The difference between consecutive numbers. Defaults to 1.</li><li><strong>dtype</strong>: (optional) The data type of the returned array.</li><li><strong>like</strong>: (optional) An object that behaves like a NumPy array. If provided, the returned array will be similar to this object.</li></ul><p>If you do not provide a specific start, your array will start from 0.</p><pre>ndarray = np.arange(10) # [0,1,2,3,4,5,6,7,8,9]</pre><p>If you provide a specific start and end, the start is included, but the end is not.</p><pre>ndarray =np.arange(5,15) #[5,6,7,8,9,10,11,12,13,14]</pre><p>You can specify a specific step value.</p><pre>ndarray =np.arange(1,10,2) #[1,3,5,7,9]</pre><h4>3- Creating an Array with All Elements as Zero in a Specific Size</h4><pre>np.zeros(shape, dtype=float, order=&#39;C&#39;, *, like=None)</pre><pre>a =np.zeros(5)<br>a=np.zeros((2,3))</pre><h4>4- Creating an Array with All Elements as One in a Specific Size</h4><pre>np.ones(shape, dtype=None, order=&#39;C&#39;, *, like=None)</pre><ul><li><strong>shape</strong>: An integer or a tuple of integers indicating the dimensions of the array to be created. For example, a single integer for a one-dimensional array, or a tuple of integers for a multi-dimensional array.</li><li><strong>dtype</strong>: (optional) The data type of the array. Defaults to float.</li><li><strong>order</strong>: (optional) The memory layout of the array. Can be ‘C’ (row-major) or ‘F’ (column-major). Defaults to ‘C’.</li><li><strong>like</strong>: (optional) An object that behaves like a NumPy array. If provided, the returned array will be similar to this object.</li></ul><pre>ndarray = np.ones((4,5))</pre><h4>5- Creating an Identity Matrix</h4><pre>np.eye(N, M=None, k=0, dtype=&lt;class &#39;float&#39;&gt;, order=&#39;C&#39;, *, like=None)</pre><ul><li><strong>N</strong>: The number of rows in the matrix.</li><li><strong>M</strong>: (optional) The number of columns in the matrix. If not specified, M=N, and a square matrix is created.</li><li><strong>k</strong>: (optional) Determines the position of the diagonal. Defaults to 0, which refers to the main diagonal. A positive value specifies the upper diagonals, while a negative value specifies the lower diagonals.</li><li><strong>dtype</strong>: (optional) The data type of the array. Defaults to float.</li><li><strong>order</strong>: (optional) The memory layout of the array. Can be ‘C’ (row-major) or ‘F’ (column-major). Defaults to ‘C’.</li><li><strong>like</strong>: (optional) An object that behaves like a NumPy array. If provided, the returned array will be similar to this object.</li></ul><pre>a = np.eye(5)</pre><h4>6- Reshaping an Array</h4><pre>np.reshape(a, newshape, order=&#39;C&#39;)</pre><ul><li><strong>a</strong>: The array whose shape is to be changed.</li><li><strong>newshape</strong>: The new shape. This can be an integer or a tuple of integers. The number of elements in the new shape must be the same as the number of elements in the original array.</li><li><strong>order</strong>: (optional) The memory layout of the array’s data. Can be ‘C’ (row-major) or ‘F’ (column-major). Defaults to ‘C’.</li></ul><pre>a = np.arange(24)<br>reshaped_array = np.reshape(a, (2,3,4))</pre><h4>7- Finding the Minimum and Maximum Values of an Array</h4><pre>ndarray.min(axis=None, out=None, keepdims=False, initial=&lt;no value&gt;, where=&lt;no value&gt;)</pre><ul><li><strong>axis</strong>: (optional) The axis along which to compute the minimum value. If not specified, the minimum value is returned for the entire array.</li><li><strong>out</strong>: (optional) An array into which the result is written.</li><li><strong>keepdims</strong>: (optional) If set to True, the results will have the same number of dimensions as the input array.</li><li><strong>initial</strong>: (optional) The starting value for the computation.</li><li><strong>where</strong>: (optional) A condition that specifies which values to include.</li></ul><pre>array = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])<br><br>min_value = array.min()<br><br>min_value_axis0 = array.min(axis=0) <br><br>min_value_axis1 = array.min(axis=1) </pre><pre>ndarray.max(axis=None, out=None, keepdims=False, initial=&lt;no value&gt;, where=&lt;no value&gt;)</pre><ul><li><strong>axis</strong>: (optional) The axis along which to compute the maximum value. If not specified, the maximum value is returned for the entire array.</li><li><strong>out</strong>: (optional) An array into which the result is written.</li><li><strong>keepdims</strong>: (optional) If set to True, the results will have the same number of dimensions as the input array.</li><li><strong>initial</strong>: (optional) The starting value for the computation.</li><li><strong>where</strong>: (optional) A condition that specifies which values to include.</li></ul><pre>array = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])<br><br>max_value = array.max()<br><br>max_value_axis0 = array.max(axis=0) <br><br>max_value_axis1 = array.max(axis=1) </pre><h4>8- Calculating the Average of Array Elements</h4><pre>ndarray.mean(axis=None, dtype=None, out=None, keepdims=False, *, where=True)</pre><ul><li><strong>axis</strong>: (optional) The axis along which to compute the average. If not specified, the average is computed for the entire array.</li><li><strong>dtype</strong>: (optional) The data type to use in the computations. It can be different from the data type of the input array.</li><li><strong>out</strong>: (optional) An array into which the result is written.</li><li><strong>keepdims</strong>: (optional) If set to True, the results will have the same number of dimensions as the input array.</li><li><strong>where</strong>: (optional) A condition that specifies which values to include. By default, all values are included.</li></ul><pre>array = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])<br><br>mean_value = array.mean()<br>mean_value_axis0 = array.mean(axis=0)<br>mean_value_axis1 = array.mean(axis=1)</pre><h4>9- Creating an Array with Numbers Spaced Equally Between Two Values</h4><pre>np.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0)</pre><ul><li><strong>start</strong>: The starting value.</li><li><strong>stop</strong>: The ending value.</li><li><strong>num</strong>: (optional) The number of samples to generate. Defaults to 50.</li><li><strong>endpoint</strong>: (optional) If True, the stop value is included in the array. If False, the stop value is not included. Defaults to True.</li><li><strong>retstep</strong>: (optional) If True, the step size is also returned. Defaults to False.</li><li><strong>dtype</strong>: (optional) The data type of the generated array.</li><li><strong>axis</strong>: (optional) Since NumPy 1.16.0, the axis along which the array is created.</li></ul><pre>array = np.linspace(0, 10, num=5)</pre><h4>10- Creating an Array of Random Integers Within a Specific Range</h4><pre>np.random.randint(low, high=None, size=None, dtype=int, endpoint=False)</pre><ul><li><strong>low</strong>: (required) The smallest value for the randomly generated integers (inclusive).</li><li><strong>high</strong>: (optional) The largest value for the randomly generated integers (exclusive). If not specified, low is considered the upper bound, and the range becomes [0, low).</li><li><strong>size</strong>: (optional) The shape of the array to be generated. Can be a single integer or a tuple of integers (e.g., (m, n, k)).</li><li><strong>dtype</strong>: (optional) The data type of the generated array. Defaults to int.</li><li><strong>endpoint</strong>: (optional) If True, the high value is included. Defaults to False.</li></ul><pre>array = np.random.randint(1,10) <br>array = np.random.randint(1,5,size=3) <br>array = np.random.randint(1,10,size=(2,3))</pre><h4>11- Generating Random Numbers in the Range [0, 1)</h4><pre>np.random.rand(d0, d1, …, dn)</pre><p><strong>d0, d1, …, dn</strong>: The dimensions of the array to be created. These parameters must be positive integers. If no dimensions are specified, a single random number is returned.</p><pre>a = np.random.rand() <br>a = np.random.rand(3) <br>a = np.random.rand(3,5)</pre><h4>12- Generating Random Numbers Using a Normal Distribution (Gaussian Distribution)</h4><pre>np.random.randn(d0, d1, …, dn)</pre><p><strong>d0, d1, …, dn</strong>: The dimensions of the array to be created. These parameters must be positive integers. If no dimensions are specified, a single random number is returned.</p><pre>b = np.random.randn() <br>b = np.random.randn(2) <br>b = np.random.randn(3,2,4) </pre><h4>13- Calculating the Sum of Array Elements</h4><pre>ndarray.sum(axis=None, dtype=None, out=None, keepdims=False, initial=&lt;no value&gt;, where=&lt;no value&gt;)</pre><ul><li><strong>axis</strong>: (optional) The axis or axes along which to compute the sum. If axis=None, the sum is computed over the entire array. It can be a single axis (e.g., axis=0 or axis=1) or a list of axes (e.g., axis=(0, 1)).</li><li><strong>dtype</strong>: (optional) The data type to use in the computation. Defaults to the data type of the array. However, in cases where the sum might exceed the range of the default data type, specifying a larger data type might be useful.</li><li><strong>out</strong>: (optional) An alternative output array to store the results. It must have the same shape.</li><li><strong>keepdims</strong>: (optional) If True, the dimensions of the reduced axes are retained as single-dimensional. This ensures that the result has the same number of dimensions as the original array.</li><li><strong>initial</strong>: (optional) The starting value for the sum operation. Defaults to zero.</li><li><strong>where</strong>: (optional) A boolean array that specifies which elements to include in the sum operation.</li></ul><pre>a = np.array([1, 2, 3, 4, 5])<br>total = a.sum() </pre><h4>14- Finding the Positions of the Maximum and Minimum Values in a NumPy Array</h4><pre>ndarray.argmax(axis=None, out=None)<br>ndarray.argmin(axis=None, out=None)<br>total_axis_0 = a.sum(axis=0)</pre><ul><li><strong>axis</strong>: (optional) The axis along which to find the maximum or minimum value. If axis=None, the array is flattened, and the position of the maximum or minimum value is returned for the entire array. It can be a single axis (e.g., axis=0 or axis=1).</li><li><strong>out</strong>: (optional) An alternative output array to store the results. It must have the same shape.</li></ul><pre>a = np.array([1, 3, 2, 5, 4])<br>max_index = a.argmax() # 3<br>min_index = a.argmin() # 0</pre><h4>15- Calculating the Determinant of a Matrix</h4><pre>np.linalg.det(a)</pre><p><strong>a</strong>: The square matrix for which the determinant is to be computed. This matrix must be a 2D NumPy array.</p><pre>a = np.array([[1, 2], [3, 4]])<br>determinant = np.linalg.det(a) # -2.0000000000000004</pre><p>The determinant is an important value for determining whether a matrix has an inverse. If the determinant is non-zero, the matrix has an inverse; if it is zero, the matrix does not have an inverse.</p><h4>16- Creating a Copy of a NumPy Array</h4><pre>ndarray.copy(order=&#39;C&#39;)</pre><p><strong>order</strong>: (optional) Specifies the memory layout of the copy. The default is ‘C’ (row-major order), with other options being ‘F’ (column-major order) and ‘A’ (same as the input, either C or Fortran order depending on the input).</p><pre>a = np.array([1, 2, 3, 4, 5]) # orjinal dizi [1 2 3 4 5]<br>b = a.copy()<br>b[0] = 99 # b dizisi = [99  2  3  4  5]</pre><p>This copy will have the same data as the original array but will be stored as an independent object. This means that changes made to the copy will not affect the original array.</p><h4>17- Calculating the Square Root of Each Element in a NumPy Array</h4><pre>np.sqrt(x, /, out=None, *, where=True, casting=&#39;same_kind&#39;, order=&#39;K&#39;, dtype=None, subok=True[, signature, extobj])</pre><ul><li><strong>x</strong>: The NumPy array or scalar for which to compute the square root.</li><li><strong>out</strong>: (optional) An alternative output array to store the results. It must have the same shape.</li><li><strong>where</strong>: (optional) A boolean array that specifies which elements to include in the computation.</li><li><strong>casting</strong>: (optional) Determines how data types are cast.</li><li><strong>order</strong>: (optional) Specifies the memory layout of the output.</li><li><strong>dtype</strong>: (optional) The data type to use in the computation.</li><li><strong>subok</strong>: (optional) If True, the output will be a subclass; if False, the output will be exactly an ndarray.</li></ul><pre>a = np.array([[1, 4, 9], [16, 25, 36]])<br>result = np.sqrt(a) # [[1. 2. 3.] [4. 5. 6.]]<br><br>a = np.array([-1, 4, -9, 16, -25])<br>result = np.sqrt(a) # [nan  2. nan  4. nan]</pre><h4>18- Creating a NumPy Array Filled with a Specific Value and Shape</h4><pre>np.full(shape, fill_value, dtype=None, order=&#39;C&#39;, *, like=None)</pre><ul><li><strong>shape</strong>: The shape of the array to be created. This can be an integer or a tuple of integers.</li><li><strong>fill_value</strong>: The value to be used to fill the array.</li><li><strong>dtype</strong>: (optional) The data type of the array. Defaults to the data type of the fill_value.</li><li><strong>order</strong>: (optional) Specifies the memory layout of the array. ‘C’ (default) for row-major (C-style), ‘F’ for column-major (Fortran-style).</li><li><strong>like</strong>: (optional) Allows the array to behave like another array; the like parameter must be an array object.</li></ul><pre>a = np.full(5, 3) # [3,3,3,3,3]</pre><h4>19- Getting the Dimensions of a NumPy Array</h4><pre>ndarray.shape</pre><pre>a = np.array([1, 2, 3, 4, 5])<br>shape = a.shape # (5,)<br><br>a = np.array([[1, 2, 3], [4, 5, 6]])<br>shape = a.shape # (2,3)</pre><p>This function returns a tuple containing the size of each dimension of the array.</p><h4>20- Finding the Total Number of Elements in a NumPy Array</h4><pre>ndarray.size</pre><pre>a = np.array([1, 2, 3, 4, 5])<br>a.size # 5<br><br>a = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])<br>a.size # 8</pre><p>The number of dimensions of the array does not matter.</p><h4>21- Finding the Number of Dimensions of a NumPy Array</h4><pre>ndarray.ndim</pre><pre>a = np.array([1, 2, 3, 4, 5])<br>a.ndim # 1<br><br>a = np.array([[1, 2, 3], [4, 5, 6]])<br>a.ndim # 2</pre><h4>22- Concatenating NumPy Arrays Along a Specified Axis</h4><pre>np.concatenate((arrays, axis=0, out=None))</pre><ul><li><strong>arrays</strong>: A tuple or list of NumPy arrays to be concatenated.</li><li><strong>axis</strong>: (optional) An integer specifying the axis along which to concatenate the arrays. Defaults to axis=0, meaning concatenation occurs along the rows.</li><li><strong>out</strong>: (optional) An alternative output array to write the result into. It must have the same shape.</li></ul><pre>a = np.array([[1, 2], [3, 4]])<br>b = np.array([[5, 6]])<br><br>result = np.concatenate((a, b), axis=0) #[[1 2] [3 4] [5 6]]</pre><p>The most important thing to note during concatenation operations is that the dimensions and shapes of the arrays being concatenated must be compatible.</p><h4>23- Concatenating by Adding a New Dimension Along a Specified Axis</h4><pre>np.stack(arrays, axis=0, out=None)</pre><ul><li><strong>arrays</strong>: A tuple or list of NumPy arrays to be concatenated.</li><li><strong>axis</strong>: An integer specifying the axis along which to concatenate. Defaults to axis=0.</li><li><strong>out</strong>: (optional) An alternative output array to write the result into. It must have the same shape.</li></ul><pre>a = np.array([1, 2, 3])<br>b = np.array([4, 5, 6])<br><br>result = np.stack((a, b)) # [[1 2 3] [4 5 6]]</pre><p>Unlike np.concatenate, which combines arrays along an existing dimension, np.stack always returns an array with an additional dimension.</p><h4>24- Splitting a NumPy Array into Equal Parts</h4><pre>np.split(ary, indices_or_sections, axis=0)</pre><ul><li><strong>ary</strong>: The NumPy array to be split.</li><li><strong>indices_or_sections</strong>: An integer or a list of integers specifying the split points or the number of sections.</li><li>If an integer is given, the array is split into equal parts.</li><li>If a list or tuple is given, the array is split at the specified indices.</li><li><strong>axis</strong>: (optional) An integer specifying the axis along which to split. Defaults to axis=0.</li></ul><pre>a = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])<br>parts = np.split(a, 5) # [array([1, 2]), array([3, 4]), array([5, 6]), array([7, 8]), array([ 9, 10])]</pre><h4>25- Finding the Indices of Sorted Sequences in a NumPy Array</h4><pre>np.argsort(a, axis=-1, kind=&#39;quicksort&#39;, order=None)</pre><ul><li><strong>a</strong>: The NumPy array to be sorted.</li><li><strong>axis</strong>: (optional) An integer specifying the axis along which to sort. Defaults to -1 (the last axis).</li><li><strong>kind</strong>: (optional) The sorting algorithm to use. Defaults to &#39;quicksort&#39;.</li><li><strong>order</strong>: (optional) The sorting key for structured arrays.</li></ul><pre>a = np.array([3, 1, 2, 5, 4])<br>indices = np.argsort(a) # [1 2 0 4 3]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CoWHLwuokH74NhnjWZ6mMg.png" /></figure><h3>Filtering (Logical Indexing)</h3><p>Used to access or filter elements that meet a specific condition.</p><p>Comparison (==, !=, &gt;, &lt;, &gt;=, &lt;=) and logical (&amp;, |, ~) operators are used.</p><pre>arr = np.array([1, 2, 3, 4, 5])<br>mask = arr &gt; 3<br>filtered_arr = arr[mask] # [4,5]</pre><h4>1- Checking if There is At Least One Element that Satisfies the Condition</h4><pre>np.any</pre><pre>arr = np.array([1, 2, 3, 4, 5])<br>mask = arr &gt; 3<br><br>result_any = np.any(mask) #True</pre><h4>2- Checking if the Condition is True for All Elements</h4><pre>np.all</pre><pre>arr = np.array([1, 2, 3, 4, 5])<br>mask = arr &gt; 3 <br>result_all = np.all(mask) #False</pre><p><a href="https://github.com/kardelenyurtkuran">kardelenyurtkuran - Overview</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c40fdba19123" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Veri Bilimine Hızlı Giriş: NumPy ile Başlangıç Rehberi]]></title>
            <link>https://medium.com/@kardelenyurtkuran/veri-bilimine-h%C4%B1zl%C4%B1-giri%C5%9F-numpy-ile-ba%C5%9Flang%C4%B1%C3%A7-rehberi-7f713543a0b1?source=rss-80a94dbb3566------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f713543a0b1</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[numpy]]></category>
            <dc:creator><![CDATA[Kardelen Yurtkuran]]></dc:creator>
            <pubDate>Fri, 12 Jul 2024 11:52:51 GMT</pubDate>
            <atom:updated>2024-07-12T11:52:51.826Z</atom:updated>
            <content:encoded><![CDATA[<p>Merhaba,</p><p>Veri bilimi, Python’ın en güçlü alanlarından biridir. Bugün, veri analizi için Python’un vazgeçilmez kütüphanelerinden biri olan NumPy’a hızlı bir başlangıç rehberi hazırladım.</p><p>Elbette NumPy aşağıda belirttiğim fonksiyonlar dışında pek çok fonksiyona sahip olan zengin bir kütüphane. Bu nedenle kendi <a href="https://numpy.org/doc/stable/">dökümantasyonunu</a> detaylı inceleyebilirsiniz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zvdQDPG_UAsTTveNp1SMyg.png" /></figure><pre>import numpy as np</pre><h4><strong>1-</strong> <strong>Numpy array oluşturma</strong></h4><pre>ndarray = np.array([1,2,3])</pre><h4><strong>2-</strong> <strong>Belirli bir aralıkta sayısal değerlerden oluşan array oluşturma</strong></h4><pre>np.arange([start, ]stop, [step, ]dtype=None, *, like=None)</pre><p>· start: (isteğe bağlı) Dizinin başlangıç değeri. Varsayılan olarak 0&#39;dır.</p><p>· stop: Dizinin durma noktası. Bu değer dahil edilmez.</p><p>· step: (isteğe bağlı) İki ardışık sayı arasındaki fark. Varsayılan olarak 1&#39;dir.</p><p>· dtype: (isteğe bağlı) Döndürülen dizinin veri tipi.</p><p>· like: (isteğe bağlı) NumPy dizisi gibi davranan bir nesne. Belirtilirse, döndürülen dizi bu nesneye benzer şekilde olacaktır.</p><p>Eğer belirli bir başlangıç vermezseniz arrayiniz 0’dan başlar</p><pre>ndarray = np.arange(10) # [0,1,2,3,4,5,6,7,8,9]</pre><p>Belirli bir başlangıç ve bitiş verirseniz, başlangıç dahil, bitiş dahil değildir.</p><pre>ndarray =np.arange(5,15) #[5,6,7,8,9,10,11,12,13,14]</pre><p>Belirli bir adım değeri belirtebilirsiniz</p><pre>ndarray =np.arange(1,10,2) #[1,3,5,7,9]</pre><h4><strong>3-</strong> <strong>Belirli bir boyutta tüm elemanları sıfır olan array oluşturmak</strong></h4><pre>np.zeros(shape, dtype=float, order=&#39;C&#39;, *, like=None)</pre><pre>a =np.zeros(5)<br>a=np.zeros((2,3))</pre><h4><strong>4-</strong> <strong>Belirli bir boyutta tüm elemanları bir olan array oluşturmak</strong></h4><pre>np.ones(shape, dtype=None, order=&#39;C&#39;, *, like=None)</pre><p>· shape: Oluşturulacak dizinin boyutlarını belirten bir tamsayı veya tamsayılar dizisi. Örneğin, tek boyutlu bir dizi için bir tamsayı, çok boyutlu bir dizi için ise bir tamsayılar demeti (tuple) verilir.</p><p>· dtype: (isteğe bağlı) Dizinin veri tipi. Varsayılan olarak float kullanılır.</p><p>· order: (isteğe bağlı) Dizinin bellek düzeni. ‘C’ (satır-major) veya ‘F’ (sütun-major) olabilir. Varsayılan olarak ‘C’dir.</p><p>· like: (isteğe bağlı) NumPy dizisi gibi davranan bir nesne. Belirtilirse, döndürülen dizi bu nesneye benzer şekilde olacaktır.</p><pre>ndarray = np.ones((4,5))</pre><h4><strong>5-</strong> <strong>Birim matris oluşturma</strong></h4><pre>np.eye(N, M=None, k=0, dtype=&lt;class &#39;float&#39;&gt;, order=&#39;C&#39;, *, like=None)</pre><p>· N: Matrisin satır sayısı.</p><p>· M: (isteğe bağlı) Matrisin sütun sayısı. Eğer belirtilmezse, M=N olur ve kare matris oluşturulur.</p><p>· k: (isteğe bağlı) Diyagonalın konumunu belirler. Varsayılan olarak 0’dır ve ana diyagonali belirtir. Pozitif bir değer üst diyagonalleri, negatif bir değer alt diyagonalleri ifade eder.</p><p>· dtype: (isteğe bağlı) Dizinin veri tipi. Varsayılan olarak float kullanılır.</p><p>· order: (isteğe bağlı) Dizinin bellek düzeni. ‘C’ (satır-major) veya ‘F’ (sütun-major) olabilir. Varsayılan olarak ‘C’dir.</p><p>· like: (isteğe bağlı) NumPy dizisi gibi davranan bir nesne. Belirtilirse, döndürülen dizi bu nesneye benzer şekilde olacaktır.</p><pre>a = np.eye(5)</pre><h4><strong>6-</strong> <strong>Arrayin boyutlarını değiştirmek</strong></h4><pre>np.reshape(a, newshape, order=&#39;C&#39;)</pre><p>· a: Şekli değiştirilecek dizi.</p><p>· newshape: Yeni şekil. Bu bir tamsayı veya tamsayılar demeti (tuple) olabilir. Yeni şeklin eleman sayısı, orijinal dizinin eleman sayısıyla aynı olmalıdır.</p><p>· order: (isteğe bağlı) Dizinin verilerinin bellek düzeni. ‘C’ (satır-major) veya ‘F’ (sütun-major) olabilir. Varsayılan olarak ‘C’dir.</p><pre>a = np.arange(24)<br>reshaped_array = np.reshape(a, (2,3,4))</pre><h4><strong>7-</strong> <strong>Arrayin min ve max değerlerini bulma</strong></h4><pre>ndarray.min(axis=None, out=None, keepdims=False, initial=&lt;no value&gt;, where=&lt;no value&gt;)</pre><p>· axis: (isteğe bağlı) Minimum değerin hesaplanacağı eksen. Belirtilmezse, tüm dizi boyunca minimum değer döndürülür.</p><p>· out: (isteğe bağlı) Sonucun yazılacağı bir dizi.</p><p>· keepdims: (isteğe bağlı) True olarak ayarlanırsa, sonuçlar girdi dizisi ile aynı boyutları korur.</p><p>· initial: (isteğe bağlı) Hesaplama için başlangıç değeri.</p><p>· where: (isteğe bağlı) Değerlerin dahil edileceği bir koşul.</p><pre>array = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])<br><br>min_value = array.min()<br><br>min_value_axis0 = array.min(axis=0) #her sütunun en küçük değerleri<br><br>min_value_axis1 = array.min(axis=1) #her satırın en küçük değerleri</pre><pre>ndarray.max(axis=None, out=None, keepdims=False, initial=&lt;no value&gt;, where=&lt;no value&gt;)</pre><p>· axis: (isteğe bağlı) Maksimum değerin hesaplanacağı eksen. Belirtilmezse, tüm dizi boyunca maksimum değer döndürülür.</p><p>· out: (isteğe bağlı) Sonucun yazılacağı bir dizi.</p><p>· keepdims: (isteğe bağlı) True olarak ayarlanırsa, sonuçlar girdi dizisi ile aynı boyutları korur.</p><p>· initial: (isteğe bağlı) Hesaplama için başlangıç değeri.</p><p>· where: (isteğe bağlı) Değerlerin dahil edileceği bir koşul.</p><pre>array = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])<br><br>max_value = array.max()<br><br>max_value_axis0 = array.max(axis=0) #her sütunun en büyük değerleri<br><br>max_value_axis1 = array.max(axis=1) #her satırın en büyük değerleri</pre><h4><strong>8-</strong> <strong>Arrayin elemanlarının ortalamasını hesaplamak</strong></h4><pre>ndarray.mean(axis=None, dtype=None, out=None, keepdims=False, *, where=True)</pre><p>· axis: (isteğe bağlı) Ortalamanın hesaplanacağı eksen. Belirtilmezse, tüm dizi boyunca ortalama hesaplanır.</p><p>· dtype: (isteğe bağlı) Hesaplamalarda kullanılacak veri türü. Girdi dizisinin veri türünden farklı olabilir.</p><p>· out: (isteğe bağlı) Sonucun yazılacağı bir dizi.</p><p>· keepdims: (isteğe bağlı) True olarak ayarlanırsa, sonuçlar girdi dizisi ile aynı boyutları korur.</p><p>· where: (isteğe bağlı) Değerlerin dahil edileceği bir koşul. Varsayılan olarak tüm değerler dahil edilir.</p><pre>array = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])<br><br>mean_value = array.mean()<br>mean_value_axis0 = array.mean(axis=0)<br>mean_value_axis1 = array.mean(axis=1)</pre><h4><strong>9-</strong> <strong>İki değer arasında eşit aralıklarla yerleştirilmiş sayılardan oluşan array oluşturma</strong></h4><pre>np.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0)</pre><p>· start: Başlangıç değeri.</p><p>· stop: Bitiş değeri.</p><p>· num: (isteğe bağlı) Oluşturulacak örnek sayısı. Varsayılan değeri 50&#39;dir.</p><p>· endpoint: (isteğe bağlı) True ise, stop değeri dizide yer alır. False ise, stop değeri dizide yer almaz. Varsayılan değeri True’dir.</p><p>· retstep: (isteğe bağlı) True ise, adım boyutunu da döndürür. Varsayılan değeri False’dir.</p><p>· dtype: (isteğe bağlı) Oluşturulan dizinin veri tipi.</p><p>· axis: (isteğe bağlı) NumPy 1.16.0&#39;dan itibaren, dizinin oluşturulacağı eksen.</p><pre>array = np.linspace(0, 10, num=5)</pre><h4><strong>10-</strong> <strong>Belirli bir aralıkta rasgele tam sayılardan oluşan array yaratmak</strong></h4><pre>np.random.randint(low, high=None, size=None, dtype=int, endpoint=False)</pre><p>· low: (Zorunlu) Oluşturulacak rastgele tamsayıların en küçük değeri (dahil).</p><p>· high: (isteğe bağlı) Oluşturulacak rastgele tamsayıların en büyük değeri (dahil değil). Belirtilmezse, low üst sınır olarak kabul edilir ve aralık [0, low) olur.</p><p>· size: (isteğe bağlı) Üretilmesi istenen sayıların boyutu. Tek bir tamsayı veya bir tamsayı dizisi olabilir (örneğin, (m, n, k)).</p><p>· dtype: (isteğe bağlı) Oluşturulan dizinin veri tipi. Varsayılanı intdir.</p><p>· endpoint: (isteğe bağlı) True ise, high değeri dahil edilir. Varsayılan değeri False’dir.</p><pre>array = np.random.randint(1,10) # 1(dahil)-10(hariç) arası rasgele tek bir sayı<br>array = np.random.randint(1,5,size=3) # 1(dahil)-5(hariç) arası 3 tam sayı<br>array = np.random.randint(1,10,size=(2,3)) # 2&#39;ye 3 boyutlarda rasgele tam sayılardan oluşan bir matris</pre><h4><strong>11-</strong> <strong>[0,1) aralığında rastgele sayılar üretmek</strong></h4><pre>np.random.rand(d0, d1, …, dn)</pre><p>· <strong>d0, d1, …, dn</strong>: Oluşturulacak dizinin boyutları. Bu parametreler pozitif tamsayılar olmalıdır. Eğer herhangi bir boyut belirtilmezse, tek bir rastgele sayı döndürülür.</p><pre>a = np.random.rand() # tek bir sayı üretmek<br>a = np.random.rand(3) # 3 random sayı üretmek<br>a = np.random.rand(3,5) #3&#39;e 5 boyutlarda matris oluşturmak</pre><h4><strong>12-</strong> <strong>Normal dağılım (Gauss dağılımlı) kullanarak rasgele sayılar üretmek</strong></h4><pre>np.random.randn(d0, d1, …, dn)</pre><p>· <strong>d0, d1, …, dn</strong>: Oluşturulacak dizinin boyutları. Bu parametreler pozitif tamsayılar olmalıdır. Eğer herhangi bir boyut belirtilmezse, tek bir rastgele sayı döndürülür.</p><pre>b = np.random.randn() # tek bir sayı üretmek<br>b = np.random.randn(2) # 2 random sayı üretmek<br>b = np.random.randn(3,2,4) #3x2x4 boyutlarda matris oluşturmak</pre><h4><strong>13-</strong> <strong>Arrayin elemanlarının toplamını hesaplamak</strong></h4><pre>ndarray.sum(axis=None, dtype=None, out=None, keepdims=False, initial=&lt;no value&gt;, where=&lt;no value&gt;)</pre><p>· axis: (isteğe bağlı) Toplamın alınacağı eksen veya eksenler. Eğer axis=None ise, tüm dizi boyunca toplam alınır. Tek bir eksen (örneğin, axis=0 veya axis=1) veya bir eksenler listesi (örneğin, axis=(0, 1)) olabilir.</p><p>· dtype: (isteğe bağlı) Hesaplamada kullanılacak veri tipi. Varsayılan olarak dizinin veri tipidir. Ancak toplamın büyük bir değere ulaşabileceği durumlarda daha geniş bir veri tipi belirlemek faydalı olabilir.</p><p>· out: (isteğe bağlı) Sonuçları saklamak için alternatif bir çıktı dizisi. Aynı şekle sahip olmalıdır.</p><p>· keepdims: (isteğe bağlı) True ise, azaltılan eksen(ler) boyutları, birim boyut olarak korunur. Bu, sonucunun orijinal dizi ile aynı sayıda boyuta sahip olmasını sağlar.</p><p>· initial: (isteğe bağlı) Toplama işleminin başlatılacağı başlangıç değeri. Varsayılan olarak sıfırdır.</p><p>· where: (isteğe bağlı) Toplama işleminin yapılacağı elemanları belirleyen bir boolean dizisi.</p><pre>a = np.array([1, 2, 3, 4, 5])<br>total = a.sum() #elemanların toplamı = 15</pre><h4><strong>14-</strong> <strong>NumPy dizisindeki max ve min değerlerin konumunu bulmak</strong></h4><pre>ndarray.argmax(axis=None, out=None)<br>ndarray.argmin(axis=None, out=None)<br>total_axis_0 = a.sum(axis=0) # axis = 0 boyunca toplam</pre><p>· axis: (isteğe bağlı) Maksimum veya minimum değerin bulunacağı eksen. Eğer axis=None ise, dizi düzleştirilir ve tüm dizi üzerinde maksimum veya minimum değerin konumu döndürülür. Tek bir eksen (örneğin, axis=0 veya axis=1) olabilir.</p><p>· out: (isteğe bağlı) Sonuçları saklamak için alternatif bir çıktı dizisi. Aynı şekle sahip olmalıdır.</p><pre>a = np.array([1, 3, 2, 5, 4])<br>max_index = a.argmax() # 3<br>min_index = a.argmin() # 0</pre><h4><strong>15-</strong> <strong>Bir matrisin determinantını hesaplamak</strong></h4><pre>np.linalg.det(a)</pre><p>· a: Determinantı hesaplanacak kare matris. Bu matris 2D bir NumPy dizisi olmalıdır.</p><pre>a = np.array([[1, 2], [3, 4]])<br>determinant = np.linalg.det(a) # -2.0000000000000004</pre><p>Determinant, matrislerin tersinin var olup olmadığını belirlemek için önemli bir değerdir. Eğer determinant sıfırdan farklıysa, matris tersine sahiptir; sıfırsa, matris tersine sahip değildir.</p><h4><strong>16-</strong> <strong>NumPy dizisinin bir kopyasını oluşturmak</strong></h4><pre>ndarray.copy(order=&#39;C&#39;)</pre><p>· order: (isteğe bağlı) Kopyanın bellek düzenini belirler. Varsayılan değeri ‘C’ (satır bazlı, C düzeni) olup, diğer seçenekler ‘F’ (sütun bazlı, Fortran düzeni) ve ‘A’ (girdiye bağlı olarak C veya Fortran düzeni) olabilir.</p><pre>a = np.array([1, 2, 3, 4, 5]) # orjinal dizi [1 2 3 4 5]<br>b = a.copy()<br>b[0] = 99 # b dizisi = [99  2  3  4  5]</pre><p>Bu kopya, orijinal diziyle aynı verilere sahip olur ancak bağımsız bir nesne olarak saklanır. Yani, kopya üzerinde yapılan değişiklikler orijinal diziye etki etmez</p><h4><strong>17-</strong> <strong>NumPy dizisinin her bir elemanının karekökünü hesaplamak</strong></h4><pre>np.sqrt(x, /, out=None, *, where=True, casting=&#39;same_kind&#39;, order=&#39;K&#39;, dtype=None, subok=True[, signature, extobj])</pre><p>· x: Kareköklü hesaplamanın yapılacağı NumPy dizisi veya skaler.</p><p>· out: (isteğe bağlı) Sonuçları saklamak için alternatif bir çıktı dizisi. Aynı şekle sahip olmalıdır.</p><p>· where: (isteğe bağlı) Hesaplamanın yapılacağı elemanları belirten bir boolean dizisi.</p><p>· casting: (isteğe bağlı) Veri tiplerinin nasıl dönüştürüleceğini belirler.</p><p>· order: (isteğe bağlı) Çıktının bellek düzenini belirler.</p><p>· dtype: (isteğe bağlı) Hesaplamada kullanılacak veri tipi.</p><p>· subok: (isteğe bağlı) True ise, çıktı alt sınıflandırılmış olacak; False ise, çıktı tam olarak ndarray olacak.</p><pre>a = np.array([[1, 4, 9], [16, 25, 36]])<br>result = np.sqrt(a) # [[1. 2. 3.] [4. 5. 6.]]<br><br>a = np.array([-1, 4, -9, 16, -25])<br>result = np.sqrt(a) # [nan  2. nan  4. nan]</pre><h4><strong>18-</strong> <strong>Belirli bir boyut ve değer ile doldurulmuş NumPy dizisi oluşturmak</strong></h4><pre>np.full(shape, fill_value, dtype=None, order=&#39;C&#39;, *, like=None)</pre><p>· shape: Oluşturulacak dizinin şekli. Bu, bir tamsayı veya tamsayıların bir demeti (tuple) olabilir.</p><p>· fill_value: Diziyi doldurmak için kullanılacak değer.</p><p>· dtype: (isteğe bağlı) Dizinin veri tipi. Varsayılan olarak, fill_value değerinin veri tipi kullanılır.</p><p>· order: (isteğe bağlı) Dizinin bellekteki düzenini belirler. ‘C’ (varsayılan) C düzeni (satır bazlı), ‘F’ Fortran düzeni (sütun bazlı).</p><p>· like: (isteğe bağlı) Başka bir dizi gibi davranmasını sağlar; like parametresi, bir dizi nesnesi olmalıdır.</p><pre>a = np.full(5, 3) # [3,3,3,3,3]</pre><h4><strong>19-</strong> <strong>NumPy dizisinin boyutlarını almak</strong></h4><pre>ndarray.shape</pre><pre>a = np.array([1, 2, 3, 4, 5])<br>shape = a.shape # (5,)<br><br>a = np.array([[1, 2, 3], [4, 5, 6]])<br>shape = a.shape # (2,3)</pre><p>Bu fonksiyon dizinin her bir boyutunu içeren demet(tuple) döner</p><h4><strong>20-</strong> <strong>NumPy dizisinin toplam eleman sayısını bulmak</strong></h4><pre>ndarray.size</pre><pre>a = np.array([1, 2, 3, 4, 5])<br>a.size # 5<br><br>a = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])<br>a.size # 8</pre><p>Dizinin kaç boyutlu olduğu önemli değildir.</p><h4><strong>21-</strong> <strong>NumPy dizisinin boyut sayısını bulmak</strong></h4><pre>ndarray.ndim</pre><pre>a = np.array([1, 2, 3, 4, 5])<br>a.ndim # 1<br><br>a = np.array([[1, 2, 3], [4, 5, 6]])<br>a.ndim # 2</pre><h4><strong>22-</strong> <strong>Belirtilen eksende NumPy dizilerini birleştirmek</strong></h4><pre>np.concatenate((arrays, axis=0, out=None))</pre><p>· arrays: Birleştirilecek NumPy dizilerinin demeti (tuple) veya dizi listesi.</p><p>· axis: (isteğe bağlı) Birleştirme işleminin hangi eksende yapılacağını belirten bir tamsayı. Varsayılan olarak axis=0 olarak ayarlanmıştır, yani birleştirme sütun bazında gerçekleşir.</p><p>· out: (isteğe bağlı) Sonucun yazılacağı alternatif bir çıktı dizisi. Aynı şekle sahip olmalıdır.</p><pre>a = np.array([[1, 2], [3, 4]])<br>b = np.array([[5, 6]])<br><br>result = np.concatenate((a, b), axis=0) #[[1 2] [3 4] [5 6]]</pre><p>Birleştirme işlemlerinde dikkat edilmesi gereken en önemli nokta, birleştirilen dizilerin boyutlarının ve şekillerinin uyumlu olmasıdır.</p><h4>23- <strong>Belirtilen eksende yeni bir boyut ekleyerek birleştirme</strong></h4><pre>np.stack(arrays, axis=0, out=None)</pre><p>· arrays: Birleştirilecek NumPy dizilerinin demeti (tuple) veya dizi listesi.</p><p>· axis: Birleştirme işleminin hangi eksende yapılacağını belirten bir tamsayı. Varsayılan olarak axis=0 olarak ayarlanmıştır.</p><p>· out: (isteğe bağlı) Sonucun yazılacağı alternatif bir çıktı dizisi. Aynı şekle sahip olmalıdır.</p><pre>a = np.array([1, 2, 3])<br>b = np.array([4, 5, 6])<br><br>result = np.stack((a, b)) # [[1 2 3] [4 5 6]]</pre><p>np.concatenate fonksiyonundan farklı olarak, np.stack sonucunda her zaman bir boyut eklenmiş bir dizi döndürür.</p><h4>24- <strong>NumPy dizisini eşit parçalara bölmek</strong></h4><pre>np.split(ary, indices_or_sections, axis=0)</pre><p>· ary: Bölünecek NumPy dizisi.</p><p>· indices_or_sections: Bölünme noktalarını veya bölünecek parça sayısını belirten bir tamsayı listesi veya tamsayı.</p><p>· Eğer bir tamsayı verilirse, dizi eşit parçalara bölünür.</p><p>· Eğer bir liste veya demet verilirse, belirtilen noktalarda dizi bölünür.</p><p>· axis: (isteğe bağlı) Bölme işleminin hangi eksende yapılacağını belirten bir tamsayı. Varsayılan olarak axis=0 olarak ayarlanmıştır.</p><pre>a = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])<br>parts = np.split(a, 5) # [array([1, 2]), array([3, 4]), array([5, 6]), array([7, 8]), array([ 9, 10])]</pre><h4><strong>25-</strong> <strong>NumPy dizisinin sıralı dizilerinin indeksini bulmak</strong></h4><pre>np.argsort(a, axis=-1, kind=&#39;quicksort&#39;, order=None)</pre><p>· a: Sıralanacak NumPy dizisi.</p><p>· axis: (isteğe bağlı) Sıralama işleminin hangi eksende yapılacağını belirten bir tamsayı. Varsayılan olarak -1 (son eksende) olarak ayarlanmıştır.</p><p>· kind: (isteğe bağlı) Kullanılacak sıralama algoritması. Varsayılan olarak ‘quicksort’ kullanılır.</p><p>· order: (isteğe bağlı) Yapılandırılmış diziler için sıralama anahtarıdır.</p><pre>a = np.array([3, 1, 2, 5, 4])<br>indices = np.argsort(a) # [1 2 0 4 3]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CoWHLwuokH74NhnjWZ6mMg.png" /></figure><h3><strong>Filtreleme (Mantıksal dizinleme)</strong></h3><p>Belirli bir koşulu sağlayan elemana erişmek veya elemanları filtrelemek için kullanılır.</p><p>Karşılaştırma(==, !=, &gt;, &lt;, &gt;=, &lt;=) ve mantıksal(&amp;, |, ~) operatörler kullanılır.</p><pre>arr = np.array([1, 2, 3, 4, 5])<br>mask = arr &gt; 3<br>filtered_arr = arr[mask] # [4,5]</pre><h4><strong>1-</strong> <strong>Koşulu sağlayan en az bir elemanın olup olmadığını kontrol etmek</strong></h4><pre>np.any</pre><pre>arr = np.array([1, 2, 3, 4, 5])<br>mask = arr &gt; 3<br><br>result_any = np.any(mask) #True</pre><h4><strong>2-</strong> <strong>Koşulun tüm elemanlar için doğru olup olmadığının kontrol etmek</strong></h4><pre>np.all</pre><pre>arr = np.array([1, 2, 3, 4, 5])<br>mask = arr &gt; 3 <br>result_all = np.all(mask) #False</pre><p><a href="https://github.com/kardelenyurtkuran">kardelenyurtkuran - Overview</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f713543a0b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Hidden Costs of Artificial Intelligence]]></title>
            <link>https://medium.com/@kardelenyurtkuran/the-hidden-costs-of-artificial-intelligence-ccd7df80a58e?source=rss-80a94dbb3566------2</link>
            <guid isPermaLink="false">https://medium.com/p/ccd7df80a58e</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[midjourney]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[gemini]]></category>
            <dc:creator><![CDATA[Kardelen Yurtkuran]]></dc:creator>
            <pubDate>Tue, 28 May 2024 20:53:49 GMT</pubDate>
            <atom:updated>2024-05-28T21:23:17.817Z</atom:updated>
            <content:encoded><![CDATA[<p>The rapidly advancing developments of artificial intelligence(AI) are creating radical changes in many areas of our lives. While these innovations provide great convenience, especially for desk workers and students, they also raise concerns about unemployment, data privacy and the risk of discrimination. However, the environmental effects of this technology should not be ignored. In this article, I would like to shed light on the less talked about aspects of this technology by examining the effects of artificial intelligence on the environment</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lAHiPfGEdGG7XU-P83NEWQ.png" /></figure><h4><strong>The Cost of Creating an AI Model</strong></h4><p>Creating a large-scale AI model requires extensive processes and high budgets. Training these algorithms with massive datasets demands immense computational power and energy consumption. Systems with intense processing power need advanced and costly cooling systems to operate efficiently. These cooling systems are used to prevent the hardware from overheating and to ensure it continuously operates at optimal performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5vCz-_I40tQ6Hv5zAXJqUA.png" /><figcaption><a href="https://oecd.ai/en/wonk/how-much-water-does-ai-consume">https://oecd.ai/en/wonk/how-much-water-does-ai-consume</a></figcaption></figure><h4><strong>Water Consumption by Tech Giants</strong></h4><p>Water cooling solutions are becoming increasingly common to ensure the efficient operation of AI systems. A significant portion of the water used in this process comes from sources that are almost as pure as drinking water.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-xReQzhrCPysEgMdI_TmOg.png" /><figcaption><a href="https://oecd.ai/en/wonk/how-much-water-does-ai-consume">https://oecd.ai/en/wonk/how-much-water-does-ai-consume</a></figcaption></figure><p>Here are some examples:</p><ul><li>According to <strong>Google’s</strong> 2023 Environmental Report, the company used 21 billion liters of water in one year, a 20% increase from the previous year.</li><li><strong>Meta’s AI model</strong>, Llama 2, consumed twice as much water as its previous version.</li><li><strong>OpenAI’s AI model</strong>, ChatGPT, consumes 500 ml of water for every 20–50 commands. The cooling system for GPT-3 used 700,000 liters of water and currently has over 100 million active users.</li><li><strong>Creating GPT-3</strong> required 1,287 megawatt hours of energy and resulted in 552 tons of carbon dioxide emissions. This was only the amount spent during its creation; current annual estimates suggest it continues to emit 8.4 tons of carbon dioxide.</li></ul><h4><strong>Future Projections</strong></h4><p>Training an AI to the information processing level of the human brain for one year could cost <strong>126,000 liters of water</strong>. The computational power of developing AI models <strong>increases tenfold each year</strong>, meaning more resources will be needed. It is estimated that by 2027, AI systems could consume between <strong>4.2 and 6.6 billion cubic meters</strong> of water.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jiBls00lCY1fbiA3MzgNgw.png" /></figure><h4><strong>Conclusion</strong></h4><p>Whether AI will greatly simplify our lives or take our jobs is still a matter of debate. However, the environmental impacts of rapidly advancing AI models should be a serious concern. Therefore, these impacts should not be ignored and should be minimized, especially by tech giants. The era of AI represents a significant turning point in the history of technology, but it must also pave the way for new cooling systems and environmentally conscious initiatives to address the increasing energy demands.</p><h4><strong>Sources</strong></h4><ol><li>U<a href="https://uskudar.edu.tr/tr/icerik/44571/yapay-zekayi-sogutmada-kullanilan-su-cevre-acisindan-endise-veriyor">skudar University: AI Cooling Water Concerns</a></li><li><a href="https://www.omu.edu.tr/tr/icerik/haber/prof-dr-ardali-yapay-zekaya-sorulan-her-soru-temiz-suyu-tuketiyor#:~:text=Ardal%C4%B1%2C%20%22Yapay%20zekan%C4%B1n%20iklim%20konusunda,karbon%20sal%C4%B1n%C4%B1m%C4%B1%20da%20ciddi%20boyutlarda.">Ondokuz Mayıs University: AI and Water Consumption</a></li><li><a href="https://www.indyturk.com/node/651391/bi%CC%87li%CC%87m/google-i%C3%A7me-sular%C4%B1n%C4%B1-t%C3%BCketiyor-bir-y%C4%B1lda-21-milyar-litre-kullan%C4%B1ld%C4%B1">IndyTurk: Google’s Water Usage</a></li><li><a href="https://www.ntv.com.tr/teknoloji/chatgpt-su-iciyor-her-gorusmede-yarim-litre-su-tuketimi,pBi0eVlMPUesCx9JbnLRTg">NTV: ChatGPT’s Water Consumption</a></li><li><a href="https://www.aquatechtrade.com/news/industrial-water/microsoft-data-centre-uses-too-much-water">Aquatech Trade: Microsoft’s Water Use</a></li><li><a href="https://theconversation.com/ais-excessive-water-consumption-threatens-to-drown-out-its-environmental-contributions-225854#:~:text=By%20comparison%2C%20Google&#39;s%20data%20centres,cost%20126%2C000%20litres%20of%20water.">The Conversation: AI’s Water Consumption</a></li></ol><p>For more information;</p><p><a href="https://github.com/kardelenyurtkuran">kardelenyurtkuran - Overview</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ccd7df80a58e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>