<?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 Baris Gül on Medium]]></title>
        <description><![CDATA[Stories by Baris Gül on Medium]]></description>
        <link>https://medium.com/@glbaris19?source=rss-12997aefc6eb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*wEHPpJO6L_e3QcASeBGB0g.jpeg</url>
            <title>Stories by Baris Gül on Medium</title>
            <link>https://medium.com/@glbaris19?source=rss-12997aefc6eb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 08:01:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@glbaris19/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[The Discussion about frequently used metrics on Classification Problems]]></title>
            <link>https://medium.com/@glbaris19/the-discussion-about-frequently-used-metrics-on-classification-problems-2cc1fead2c73?source=rss-12997aefc6eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/2cc1fead2c73</guid>
            <category><![CDATA[classification-metrics]]></category>
            <category><![CDATA[decide-for-metrics]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[confusion-matrix]]></category>
            <dc:creator><![CDATA[Baris Gül]]></dc:creator>
            <pubDate>Wed, 23 Nov 2022 00:42:11 GMT</pubDate>
            <atom:updated>2022-11-23T00:42:11.592Z</atom:updated>
            <content:encoded><![CDATA[<p>I wanted to focus on Evaluation Metrics for Classification Problems in this article. Of course, there are many resources to understand these metrics. What we want to focus on exactly is ;</p><p>— What are these shortly?</p><p>— When or Where to use and which is when important?</p><p>— In which case is which used?</p><p>Some similar questions are made clear.</p><h3>1) Confusion Matrix</h3><p>A Confusion matrix is an <em>N x N matrix</em> used for evaluating the performance of a classification model, where N is the number of <em>target classes</em>. The matrix compares the actual target values with those predicted by the machine learning model.</p><p>A confusion matrix is a tabular summary of the number of correct and incorrect predictions made by a classifier. It is used to measure the performance of a classification model. It can be used to evaluate the performance of a classification model through the calculation of performance metrics like accuracy, precision, recall, and F1-score.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*in3T2_tsMFrlWpR_YnfKWw.png" /><figcaption>Confusion Matrix</figcaption></figure><h3>2. Classification Measure</h3><h4>Accuracy</h4><ul><li>It is useful and meaningful when classification problems are well balanced and not skewed or No class imbalance.</li></ul><blockquote>Examples</blockquote><ol><li>An asteroid will hit the earth. Although our accuracy is % 99, but not at all valuable.</li></ol><h4>Precision</h4><ul><li>It is the answer to what proportion of predicted Positives is truly Positive? It is used when we want to be very sure of our prediction.</li></ul><blockquote>Examples</blockquote><ol><li>We want to see if we should decrease the credit limit on a particular account. In this case, we want to be very sure about the prediction to avoid customer dissatisfaction.</li><li>Assume that we want to find out Spam-Mails, in this case, precision must be optimal because we shouldn’t overlook actual Mails.</li></ol><h4>Recall (Sensitivity)</h4><p>It answers to question of what proportion of <strong>actual Positives </strong>is correctly classified. It is a very useful measure when we want to capture as many positives as possible.</p><blockquote>Examples</blockquote><ol><li>We want to predict cancerous persons. We want to capture disease even if we are not very sure.</li><li>We want all potential customers. In this case, we can get potential customers as much as possible. The prediction has not been completely correct. But although they are all not correct we have all potential. In this case, precision is low but recall is high. Assume we want to print out the show card. The money we spent doesn&#39;t matter. I can print out 1000 show cards for only 100 consumers. What matters is to get all customers.</li><li>We want to determine all COVID-19 residents to avoid infection. We can predict most of the residents as COVID-19 residents, although they are not. But all COVID-19 residents will be inside this group. It is the Focus.</li><li>In another issue, we have to determine bad loans. If we don’t determine all bad loans, they can be perceived due to not paid loans. In this case, the bank will wait until they will pay. Because we have to define all bad loans. If we give weight to precision here, we can accept not paid loans as bad loans. It’s not what we wish.</li></ol><blockquote>— Last explanation for both of them is:</blockquote><blockquote>If we want to determine the poisonous foods by high “recall”, we might say poisonous foods for non-poisonous foods too. In this case, we will waste them and a cost arises.</blockquote><blockquote>If we want to determine the poisonous foods by high “precision”, we might leave poisonous foods inside non-poisonous foods. In this case, a poisoning might occur.</blockquote><p>“Decide now on your own which cost is more dangerous.”</p><h4>F1 Score</h4><p>It is the harmonic mean of precision and recall between 0 and 1. We want to have a model with both good precision and recall. If your precision is low, the F1 is low, and if the recall is low again your F1 score is low.</p><blockquote>Examples</blockquote><ol><li>We are looking for an answer to the question of whether An asteroid will hit the earth. If it is “NO” presicion is 0. The recall is also 0. Hence the F1 score is also 0.</li><li>As police, you want to catch criminals. You want to be sure that the person you catch is a criminal (Precision) and you also want to capture as many criminals (Recall) as possible.</li><li>The same example (Bad-Loan) could be also given to the F1 Score. With recall, we want to determine all potential bad loans and with precision, we want to determine all actual bad loans. The Ratio of both should be also good for the goal. Recall should be low and precision should be high. A good F1 score means that you have low false positives and low false negatives, so you’re correctly identifying real threats and are not disturbed by false alarms. An F1 score is considered perfect when it’s 1, while the model is a total failure when it’s 0.</li><li>We have a disease. If we couldn’t determine all diseases it will be dangerous, that’s why we have to use “recall”. Assume that we will be cured by a certain treatment. But this treatment can be detrimental to those without the disease. In this case, we need a model that is sensitive to detecting positive cases and equally precise in its detection. That’s when the F1 Score comes into play. F1 Score is the harmonic mean of precision and recall, an average between precision and recall ratios.</li></ol><h4>AUC</h4><p>AUC is the area under the ROC curve. AUC ROC indicates how well the probabilities from the positive classes are separated from the negative classes. Here we can use the ROC curves to decide on a Threshold value.</p><p>The choice of threshold value will also depend on how the classifier is intended to be used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*_BzogAjd9JQzmwAaXHvHIQ.png" /><figcaption>AUC</figcaption></figure><h4>Micro Average</h4><p>We reviewed how to choose evaluation metrics for our binary classification data. But what do we do when our target is not yes or no but comprised of multiple categories? One way is to count each outcome globally regardless of within-class distribution and calculate the metric. We can accomplish this by using the micro average.</p><h4>Macro Average</h4><p>Another method to deal with multi-class is to simply calculate the binary measures for each class. For example, if our target variable can be either cat, dog, or bird, we get a binary yes or no answer for each prediction. Is this a cat? Is this a dog? Is this a bird? This will lead to as many scores as a number of our target classes. Then we can aggregate these scores and turn them into a single metric using a macro average or weighted average.</p><h4>Conclusion</h4><p>An important step while creating our machine learning pipeline is evaluating our different models against each other. A bad choice of an evaluation metric could wreak havoc on your whole system.</p><p>So, always be watchful of what you are predicting and how the choice of evaluation metric might affect/alter your final predictions.</p><p>Also, the choice of an evaluation metric should be well aligned with the business objective; hence, it is a bit subjective.</p><p>Kind regards</p><p>Baris Gül</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2cc1fead2c73" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[In a nutshell, Supervised Learning in ML]]></title>
            <link>https://medium.com/@glbaris19/in-a-nutshell-supervised-learning-in-ml-535a5edb3cf9?source=rss-12997aefc6eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/535a5edb3cf9</guid>
            <category><![CDATA[supervised-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[regression]]></category>
            <category><![CDATA[timeseries]]></category>
            <category><![CDATA[predictions]]></category>
            <dc:creator><![CDATA[Baris Gül]]></dc:creator>
            <pubDate>Tue, 04 Oct 2022 19:51:58 GMT</pubDate>
            <atom:updated>2022-10-04T19:51:58.475Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi friends,</p><p>I want to focus in this article only on Supervised Learning. Previously I have already written about ML, ML types, ML Algorithms, etc. Today I’ll try to explain all of them briefly and solve an example about them.</p><blockquote><strong>ML</strong></blockquote><p>Machine Learning is a branch of the broader field of artificial intelligence that makes use of statistical models to develop predictions. To create a model by formulating the data and predicting the target by inputting similar values. The Model determines rules for that by other results. Not Learn the rules, but make the rules.</p><p><strong>Types of ML: Supervised Learning, Unsupervised Learning, Reinforcement Learning</strong></p><h4><strong>Supervised Learning</strong></h4><p>It is defined by its use of labeled datasets to train algorithms that classify data or accurately predict outcomes. Supervised learning can be separated into two types of data mining problems: classification and regression.</p><blockquote><strong>Regression</strong></blockquote><p><strong>Independent Variables</strong>: The variables that are not affected by the other variables are called independent variables.</p><p><strong>Dependent Variables</strong>: The variables which depend on other variables or factors.</p><p><strong>Cost / Loss Function: </strong>It shows how successful our model is. It calculates the difference between the actual value and the value predicted by the model. The purpose of this function is to find out which of the theta values, which are redefined each time, is used, the cost will be lower.</p><p><strong>Regression and Correlation: </strong>Correlation quantifies the strength of the linear relationship between a pair of variables, whereas regression expresses the relationship in the form of an equation. The power of Correlation provides that regression occurs simply and reliably.</p><p><strong>Gradient Descent: </strong>Gradient Descent algorithm is one of the most popular optimization algorithms. Gradual reduction is an iterative algorithm that starts at a random point on a function and progresses incrementally in its slope until it reaches the lowest point of that function.</p><p><strong>Learning Rate: </strong>During the process of searching for the optimum value on the model for the problem, the learning step size of the model and the amount of change made in the model, as a result, is called the “learning rate”.</p><p><strong>Residual: </strong>Residuals in a statistical or machine learning model are the differences between observed and predicted values of data.</p><p><strong>Underfitting: </strong>The model can neither model the training data nor generalize to new data.</p><ul><li>High bias and low variance.</li><li>Poor performance on the training data and poor generalization to other data.</li></ul><p><strong>Overfitting:</strong> Overfitting refers to the machine learning algorithm or statistical model that learns the detail and noise in the training data to the extent that it negatively impacts the performance of the model on new data.</p><ul><li>High variance and low bias.</li><li>Good performance on the training data, poor generalization to other data.</li><li>How to avoid: <strong>Train with more data, Cross-validation, Data Augmentation, Regularization, Early stopping, Pruning, and Ensembling.</strong></li></ul><p><strong>Multicollinearity: </strong>Multicollinearity occurs when independent variables in a regression model are correlated. This correlation is a problem because independent variables should be independent. If the degree of correlation between variables is high enough, it can cause problems when you fit the model and interpret the results.</p><p><strong>Error metrics: Three error metrics are</strong> commonly used for evaluating and reporting the performance of a regression model.</p><ul><li><strong>R2: </strong>R-square is a measure of fitness for linear regression models.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/319/1*7Goxstm0kqLqlB8ejhNvQA.png" /></figure><ul><li><strong>Adjusted R2: </strong>Adjusted R2 is a corrected goodness-of-fit (model accuracy) measure for linear models.</li><li><strong>Mean Absolute Error(MAE): </strong>Mean absolute error gives the mean of the absolute difference between model prediction and target value.</li><li><strong>Mean Squared Error(MSE): </strong>Mean squared error gives the mean of the squared difference between model prediction and target value</li><li><strong>Root Mean Squared Error (RMSE): </strong>RMSE is the root mean square error, a measure of how much the actual values of a series differ from the values predicted by the model, and is expressed in the same units as those used for the series itself.</li></ul><p><strong>Regularization: </strong>Regularization is typically used to reduce the variance with a model by applying a penalty to the input parameters with the larger coefficients. There are several different methods, such as L1 regularization, Lasso regularization, dropout, etc., which help to reduce the noise and outliers within a model.</p><ul><li><strong>Lasso (L1): </strong>It adds a penalty term to the cost function. This term is the absolute sum of the coefficients.</li><li><strong>Ridge (L2): W</strong>hile lasso regression takes the magnitude of the coefficients, ridge regression takes the square.</li><li><strong>Elastic-Net: </strong>Elastic Net Regularization is a regularization technique that uses both L1 and L2 regularizations to produce the most optimized output. This is one of the best regularization techniques, taking the best parts of other techniques.</li></ul><p><strong>Scaling: S</strong>caling is a method used to normalize the range of independent variables or features of data.</p><ul><li><strong>Min-Max Normalization: </strong>This technique re-scales a feature or observation value with a distribution value between 0 and 1.</li><li><strong>Standardization: </strong>It is a very effective technique that re-scales a feature value so that it has a distribution with 0 mean value and variance equal to 1.</li></ul><p><strong>Cross-validation: </strong>It is a statistical method used to estimate the skill of machine learning models.</p><p><strong>Grid-search: </strong>It is used to find the optimal hyperparameters of a model which results in the most ‘accurate’ predictions.</p><h3>One Problem Solution</h3><p>This part is the actual point on that I want to focus. Because we’ll deepen to skills. We’ll solve a problem with the help of skills we learned previously.</p><h4><strong><em>Step 1</em></strong></h4><p>There are rental bikes in many urban cities to provide mobility. But it is important to make them available and accessible to the public at the right time. Because they reduce the waiting time. We aim here to find out the required bike count at each hour.</p><h4>Step 2</h4><p>In this step, we’ll make data engineering. Especially we have to make all required data numeric.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bFbmO7nzzwV_3j1nTVeAYg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Ms0CnvvtzSwzgNxH5gHJw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e7lb4qYJ7mXobUhSs7sNqA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LFWT2Jm7j4c_o2cqcd2nIQ.png" /><figcaption>The Last View</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RNF8WO4s7_BIx5lxef265w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SnouFJzPLloWLB6tAXGaQA.png" /><figcaption><strong><em>People don’t use rented bikes on no-functioning days.</em></strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*srA1T8FzLnGfG5xGaRZ22Q.png" /><figcaption>Heatmap for Correlation</figcaption></figure><p>After changing the “Types” with the proper other, we’ll make them numeric. Now we can implement some methods such as “get_dummies”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ojWY6zpilVaT26kWYoXi8Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dTMlQF-QnCFEPVJNQZlSpg.png" /></figure><p>So far, we have implemented our data engineering skills. We came to the actual point now.</p><h4>Step 3</h4><p>As the last step before model fitting, you need to split the data set as “train” and “test”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0TmnmKCASVnDFrc3s8QUvw.png" /></figure><h4>Step 4</h4><p>In this step, we’ll implement our model types.</p><blockquote><strong>Linear Regression</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9dV1OwJvYZZF6Dp39MefZQ.png" /></figure><p>We have such a function to evaluate our model. In short, we’ll fit our data parts called X_train and y_train to the selected model. And we’ll predict with this model the part called y_test_pred(y_pred) by using the data part called X_test. But here y_test_pred(y_pred) is the predicted part and we have an actual y_test also. We’ll compare both of them in this section (y_pred and y_test). That’s why we have such a function.<br>On the other hand, we predict the “train” part of our target column. Why? Because we want to compare the evaluation separately. In this way, we can see whether we have underfitting or overfitting.</p><p><strong>Model:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*IvlTAOedyxJGo_x55G9WCg.png" /></figure><ul><li>y_train,y_test: We have them already.</li><li>y_train_pred,y_pred: We predicted them with the created model.</li></ul><p><strong>Result:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*SvMmanrp3Z2TYlffeFWevg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*YhndRTwwPGzp_mup-kyJRg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*NTUyhYagSyx8HuJvVa_hGg.png" /></figure><p><strong>Comment:</strong></p><p>As already mentioned we have some evaluation methods. We have to apply the methods to both train_subset and test_subset. Because we can see in this way whether we have underfitting and overfitting or not. And it is possible to say that our model is working the same way in two sections.</p><p>We decide exact model with metrics. The assumption of the model depends on the situation. We can find this general information on the internet. The model we created is too simple. We can improve this model. We’ll use all methods we have learned.</p><p>In the second picture, we see Cross-Validation. With this method, we want to control whether the data was well distributed. One scenario is:<br>The selected data could be well distributed. But other parts might be not as selected part. We have taken a look at ten separate parts. And we determined that the average r2 is 0.67. It shows the data distribution is appropriate for our previous model.</p><ul><li>The important thing is to find the best model by applying all steps.</li></ul><blockquote><strong>Ridge</strong></blockquote><p>Whatever we make, our goal is always progress. We begin to improve our model with scaling.</p><p><strong>Scaling :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*jbGk_aXBnVkIhr2f3pwtfg.png" /></figure><p><strong>Model :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*nMpHeEc1iQMq8EKdfIh4CA.png" /></figure><p>We completed the first step (Scaling). Now we want to find out the best alpha in “Ridge”. I often want to repeat the goal of finding the best model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*CagrDW7xcUGgnWy8BWLqsQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*wuTusllMWuo38akrCsiEIw.png" /></figure><blockquote>Lasso</blockquote><p>We have already scaled the data.</p><p><strong>Model :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*MA_FkvvxFXVbjNoooHpcyg.png" /></figure><blockquote>Elastic-Net</blockquote><p><strong>Model:</strong></p><p>We want to execute “Elastic-Net” and use “Grid-Search” to find the best parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*no-hMYqLFWPdAvAUlo6UiA.png" /></figure><p>The result is very bad. And we have to find out the best parameters with “Grid Search”.</p><p><strong>Grid Search:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*7T0JIdoSgd4AzvxqYswS1w.png" /></figure><p>Finally, we can see that we have overfitting. But the point is not that. That’s why we’ll go further. We have to focus on “test”. So far we wanted to see the distribution of data, overfitting, and underfitting.</p><p>So far we have used all methods we learned and we tried to improve our model. All results are below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*E6oQB947NXmi1NTQ-kgZuw.png" /></figure><p><strong>Feature Importance and Last Model</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*GZKtkrMBLf2qAGnvQZpgSQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*dgG8hTmVOu_zlfi0BD2n7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*bSgcplkvdlJ88U6ASMS9NQ.png" /></figure><p>We wanted to see the coefficient because we’ll use some of the features to execute the model.</p><blockquote>Last Step</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*t35nSd29J8EbotK6oyGTew.png" /></figure><p>We wanted to use 8 features to execute again the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*Fh7QLLuUgkL3AooVtJwZIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*YoF9F6L5uHfIX3dWEKTjvA.png" /></figure><p>Now we can solve a problem with this model. We decided on a Model. The Model is clear and we create our model for this data again and predict the target.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*dJMfTGTyyQWlx1KN__xbfg.png" /></figure><p>Our new data is below. Now we’ll predict the target with that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*CibsEgydQtg7svQLBdkFFQ.png" /></figure><h4>The Result:</h4><p>As a result, we predicted and achieved this bike quantity with subsequently entered data by using the model. The model work with %67 accuracies.</p><p>The most important point is to show how to create a model with basic methods. Normally we should solve such problems with the “time series method”. If we would solve this problem with “time series” instead of basic methods, we can reach the best results.</p><p>**********************************THE END********************************</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=535a5edb3cf9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Evaluating a machine learning model]]></title>
            <link>https://medium.com/@glbaris19/evaluating-a-machine-learning-model-7d237b5f2146?source=rss-12997aefc6eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d237b5f2146</guid>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[logistic-regression]]></category>
            <category><![CDATA[evaluation-metric]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[evaluation]]></category>
            <dc:creator><![CDATA[Baris Gül]]></dc:creator>
            <pubDate>Mon, 18 Jul 2022 16:03:01 GMT</pubDate>
            <atom:updated>2022-07-18T16:03:01.018Z</atom:updated>
            <content:encoded><![CDATA[<p>In some articles, it was already explained how to create a model and split the data into train and test. In this session, the metrics for evaluating the model that is created in supervised learning are going to be explained. As known, there are two different algorithms in supervised learning called classification (basically discrete values ) and regression (basically continuous values).</p><h3>The Evaluation for Classification-Logistic Regression</h3><p>There are some evaluation metrics for the Classification model. And the most frequently used metrics will be handled.</p><h4><strong>Confusion Matrix</strong></h4><p>It is a most used performance measurement machine learning classification problem where the output can be two or more classes. It contains combinations of predicted and actual values.</p><p>A confusion matrix or error matrix shows the number of correct and incorrect predictions made by the model compared with the actual classifications in the test set or what type of errors are being made. It is a n*n matrix, where n is the number of classes. This matrix can be generated after making predictions on the test data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*fGSaBF8lJhr1XaQdgQHlOQ.png" /><figcaption>Confusion Matrix</figcaption></figure><ul><li><strong>Accuracy</strong>: the proportion of the total number of correct predictions.</li><li><strong>Positive Predictive Value or Precision</strong>: the proportion of positive cases that were correctly identified.</li><li><strong>Negative Predictive Value</strong>: the proportion of negative cases that were correctly identified.</li><li><strong>Sensitivity or Recall</strong>: the proportion of actual positive cases which are correctly identified.</li><li><strong>Specificity</strong>: the proportion of actual negative cases which are correctly identified.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*13-6kxxXUeqHzrQ61SjQ0A.png" /></figure><ul><li><strong>F1-score or F-measure:</strong> It is a single metric that combines both Precision and Recall. The higher the F1 score, the better the performance of our model. The range for F1-score is [0,1]. F1 score is the weighted average of precision and recall. The classifier will only get a high F-score if both precision and recall are high. This metric only favors classifiers that have similar precision and recall.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/1*skdbV6cw45HBWXAZK0mEiQ.png" /></figure><h3>The Evaluation for Linear Regression</h3><p>Of course, these are quite different metrics than what are used in classification. Here the continuous range instead of a discrete number of in classes is predicted. The reason for that could be explained as follows; we can predict the price of a car as 40K but it could be sold for 43K. It’d be pretty good. But since mostly the binary values are mentioned in classification, it would be tough to say correct-incorrect or good-bad. Therefore the other metrics are used here.</p><ol><li><strong>Mean Absolute Error</strong></li></ol><p>MAE is a very simple metric that calculates the absolute difference between actual and predicted values.</p><blockquote><strong>Advantages</strong></blockquote><ul><li>The MAE you get is in the same unit as the output variable.</li><li>It is most Robust to outliers.</li></ul><blockquote><strong>Disadvantages</strong></blockquote><p>The graph of MAE is not differentiable so we have to apply various optimizers like Gradient descent which can be differentiable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*ZCadrj23BVya5Ldb3SFy7g.png" /></figure><p><strong>2. R2 coefficient</strong></p><p>R2 score is a metric that tells the performance of your model, not the loss in an absolute sense that how many wells did your model perform. In contrast, MAE and MSE depend on the context as we have seen whereas the R2 score is independent of context.</p><p><strong>3. Mean Square Error</strong></p><p>MSE is a most used and very simple metric with a little bit of change in mean absolute error. Mean squared error states finding the squared difference between actual and predicted value.</p><blockquote><strong>Advantages</strong></blockquote><p>The graph of MSE is differentiable, so you can easily use it as a loss function.</p><blockquote><strong>Disadvantages</strong></blockquote><ul><li>The value you get after calculating MSE is a squared unit of output. for example, the output variable is in meters (m) then after calculating MSE the output we get is in meters squared.</li><li>If you have outliers in the dataset then it penalizes the outliers most and the calculated MSE is bigger. So, in short, It is not Robust to outliers which were an advantage in MAE</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*T7sXx_aeCcvTAEh4nhkQNQ.png" /></figure><p><strong>4. Root Mean Squared Error (RMSE)</strong></p><p>It is similar to MSE; just the final value is square-rooted as we calculated the square of errors in MSE.</p><blockquote><strong>Advantages of RMSE</strong></blockquote><ul><li>The output value you get is in the same unit as the required output variable which makes interpretation of loss easy.</li></ul><blockquote><strong>Disadvantages of RMSE</strong></blockquote><ul><li>It is not that robust to outliers as compared to MAE.</li></ul><p>for performing RMSE we have to NumPy NumPy square root function over MSE.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*5jMG7Sd-2qZ4QzHry59lTw.png" /></figure><p><strong>5. Root Mean Squared Log Error</strong></p><p>Taking the log of the RMSE metric slows down the scale of error. The metric is very helpful when you are developing a model without calling the inputs. In that case, the output will vary on a large scale.</p><blockquote><strong>6. Adjusted R2</strong></blockquote><p>The disadvantage of the R2 score is while adding new features in data the R2 score starts increasing or remains constant but it never decreases because It assumes that while adding more data variance of data increases. But the problem is when we add an irrelevant feature in the dataset then at that time R2 sometimes starts increasing which is incorrect.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d237b5f2146" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Supervised Learning]]></title>
            <link>https://medium.com/@glbaris19/supervised-learning-e255bd89217b?source=rss-12997aefc6eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/e255bd89217b</guid>
            <category><![CDATA[supervised-learning]]></category>
            <category><![CDATA[confusion-matrix]]></category>
            <category><![CDATA[evaluation-metric]]></category>
            <category><![CDATA[logistic-regression]]></category>
            <category><![CDATA[linear-regression]]></category>
            <dc:creator><![CDATA[Baris Gül]]></dc:creator>
            <pubDate>Sun, 17 Jul 2022 22:28:57 GMT</pubDate>
            <atom:updated>2022-07-17T22:28:57.976Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dN_61cEA1pGC9F7uIREIOw.png" /></figure><h4>What is Supervised Learning?</h4><p>Supervised learning refers to the use of labeled datasets to train algorithms that classify data or predict outcomes accurately. Supervised learning needs an accurately labeled dataset which is exhausting. Nevertheless, it is a really powerful and popular method. In this method, the machine learning algorithms focus on the labeled data to train the data set. Supervised learning helps organizations solve a variety of real-world problems at scale, such as predicting the prices of houses or cars, and classifying spam in a separate folder from your inbox. Some methods used in supervised learning include neural networks, naïve Bayes, linear regression, logistic regression, random forest, support vector machine, and more. The ML algorithm could be given a small training dataset that is a part of the bigger one in order to achieve a basic idea of the problem, solution, and data points. The algorithm then finds relationships between the parameters given. At the end of the training, the algorithm has an idea of how the data works and the relationship between the input and the output.</p><blockquote><em>Supervised learning is where you have input variables (x) and an output variable (Y) and you use an algorithm to learn the mapping function from the input to the output.</em></blockquote><p>Before we pass to the example we have to decide which one of the algorithms will be used.</p><h4>Linear or Logistic Regression</h4><p>Linear Regression is a commonly used supervised ML algorithm that predicts continuous values. Linear Regression assumes that there is a linear relationship between dependent and independent variables. In simple words, it finds the best fitting line/plane that describes two or more variables. On the other hand, Logistic Regression is another supervised “Machine Learning” algorithm that helps fundamentally in classification.</p><p>One key difference between logistic and linear regression is the relationship between the variables. Linear regression occurs as a straight line and allows analysts to create charts and graphs that track the movement of linear relationships. However, since logistic regression examines the probability of an event rather than the linear structure of a variable relationship, it’s unnecessary to track logistic regression using linear structures. Basically, logistic regression can hold non-linearity between variables.</p><ul><li>Continuous variables represent infinite values.</li><li>Discrete ordinal variables have a ranking order and end at some point.</li><li>Discrete nominal variables also end at some point but have no ranking order.</li></ul><h3>Steps of Linear Regression</h3><blockquote>Step 1</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*_QBJ24yMd3S4MLjqI8wIBA.png" /></figure><p>As a first step, the dependent and independent values are divided under the names X and Y. But first of all “get_dummies” must be applied.</p><blockquote>Step 2</blockquote><p>In this step, the data must be split into “Train” and “Test”.</p><p>In machine learning, datasets are split into two subsets.</p><p>The training data is a subset of your dataset that you use to teach a machine learning model to recognize patterns or perform your criteria.</p><p>Once your machine learning model is built (with your training data), you need unseen data to test your model. This data is called testing data, and you can use it to evaluate the performance and progress of your algorithms’ training and adjust or optimize it for improved results.</p><p>Testing data has two main criteria. It should:</p><ul><li>Represent the actual dataset.</li><li>Be large enough to generate meaningful predictions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*Q5CM301l__y1QfLxS6wMWA.png" /></figure><blockquote>Step 3</blockquote><ul><li>The “LinearRegression” will be determined as “lr”. And the suitability of “Train” and “Test” subsets is evaluated with “Score”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*mq33lJDSjXg0H9ymwHO29g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*8LdOEYnUjvONkpEZg7WFyw.png" /></figure><p>As seen the “Train” and “Test” sebsets were split well. In this part, the other themes won’t be covered. Otherwise, there are many implementations to make better results.</p><blockquote>Step 4</blockquote><ul><li>To evaluate the model there are some methods. These will be covered additionally in another article. But as an example, “mean_squared_error” will be implemented.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*gqw4SLLwKnf2X8itkmjaiA.png" /></figure><p>So far the model was covered generally. It is too basic for the beginning.</p><h3>Steps of Logistic Regression</h3><p>As the other supervised type was explained before, this will be also covered in the same way step by step.</p><blockquote>Step 1</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*iG5LVEGtWNLJOwYM0PMLLQ.png" /></figure><p>The Target is the “Survived column”. After the determination of “independent” and “dependent ” values, subsets are split.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*QaMRRMth2Re_vBLlIQk5QQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6pYH-OtAl-uKAlbPEqpeYw.png" /></figure><blockquote>Step 2</blockquote><p>This step aims to fit the data with the “logistic regression” model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*ldXHwhzMwo8nKojizJ-uhw.png" /></figure><blockquote>Step 3</blockquote><p>In this step, the model will be evaluated with evaluation metrics in logistic regression.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*Jz8bjZBw8-Eu7ZyP5Lp6tQ.png" /></figure><p>It might be said that overfitting exists here.</p><blockquote>Step 4</blockquote><p>In logistic regression, there is a parameter so-called “C”. It helps to regularize the data. Now, it will be tried.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*cv-qEQJq9fWk7w2YH1FicQ.png" /></figure><blockquote>Step 5</blockquote><p>To see how well the model was executed, let’s take a look at confusion_matrix.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*nLGEAtYOhkAyu6fzWu4ZCg.png" /></figure><ul><li>114 of them were predicted “T-T”</li><li>13 of them were predicted “T-F”</li><li>37 of them were predicted ”F-T”</li><li>59 of them were predicted “F-F”</li></ul><blockquote>Step 6</blockquote><p>In this step, a data set will be entered into the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*4UP7xF-Aob7OjDL7CXMqJA.png" /></figure><p>It is also a basic approach to logistic regression. So far the general explanation for both “logistic” and “linear” regressions was handled.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e255bd89217b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Regression Model in Supervised Learning with an Example from Beginning to End]]></title>
            <link>https://medium.com/@glbaris19/the-regression-model-in-supervised-learning-with-an-example-from-beginning-to-end-612fd67948f3?source=rss-12997aefc6eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/612fd67948f3</guid>
            <category><![CDATA[lasso-regression]]></category>
            <category><![CDATA[crossvalidation]]></category>
            <category><![CDATA[supervised-learning]]></category>
            <category><![CDATA[regression-modeling]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Baris Gül]]></dc:creator>
            <pubDate>Sun, 17 Jul 2022 13:39:04 GMT</pubDate>
            <atom:updated>2022-07-17T13:50:31.685Z</atom:updated>
            <content:encoded><![CDATA[<p>This writing aims to take a look at the Regression model. As far as the possible whole process of all Models will be handled. <a href="https://medium.com/@glbaris19/introduction-to-ml-a2222dad8599">As already known there are some types of ML</a> and one of them is “Supervised Learning”. On the other hand “supervised learning” is divided into two parts names “regression” and “classification”.</p><blockquote>Step 1</blockquote><p><strong>Overview of the Dataset</strong></p><ul><li>Head</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*7W3-9YfZQd1S9VKv2b4I5g.png" /></figure><ul><li>Info</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*xT-94qjEEP46glFpEwdf8A.png" /></figure><ul><li>Describe</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*HpuP1DoinHJhW2Sd-HyrNQ.png" /></figure><ul><li>Correlation</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SrScGnsMsMVcmWOFiKczjw.png" /></figure><h4>Get_dummies</h4><p><a href="https://medium.com/@glbaris19/select-dtypes-get-dummies-reset-index-rename-sort-values-919efcde55d7">Why “Get_dummies” is used and how to use</a> it are located in this “Medium account”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ehR5YVIA75BlZFGx46yscQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*MNgZNDB8wDMDhw0k5U5Ulw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*enfYeyAsVh3OXu7Q9fIAdQ.png" /></figure><blockquote>Step 2</blockquote><h4>Data Processing</h4><p>As you know, the data set must be edited before proceeding with the implementation of the model. As the last step before model fitting, you need to split the data set as train and test. Then, you should train the model with train data and evaluate the performance of the model on the test data. You can use the train and test data you have created for all algorithms.</p><p>You must also drop your target variable, the column you are trying to predict.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mWl-smhbxj9Qi7VKwgxpEQ.png" /></figure><blockquote>Step 3</blockquote><h4>Implement Linear Regression</h4><ul><li>Import the model</li><li>Fit the model</li><li>Predict the test set</li><li>Determine feature coefficient</li><li>Evaluate model performance (use performance metrics for regression and cross_val_score)</li><li>Compare different evaluation metrics</li></ul><p><em>Note: You can use the </em><a href="https://www.geeksforgeeks.org/python-dir-function/"><em>dir()</em></a><em> function to see the methods you need.</em></p><p>The first model that will be executed with parts of the data (train, test) is Linear Regression.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*7ppRQp9zfgLMdE4-X12RuA.png" /></figure><p>The regression model has been created and fitted to “X_train” and “Y_train”. Now the next is the evaluation of the model.</p><h4>Evaluation</h4><p>A function was created to evaluate both the train subset and test subset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WdyvozsF3DXrJN6qKikHag.png" /></figure><p>The result is as below;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*3B4zBpKpeymWWQAlvc6vdg.png" /></figure><p>By taking a look at this evaluation result;</p><ul><li>The result of R2 is good according to general assumptions. But as mentioned frequently, it depends on the domain.</li><li>Between “mae” and “rmse” there is a remarkable difference. That means the outlier could be mentioned here.</li></ul><blockquote>Step 4</blockquote><h4>Cross-Validation</h4><p>The former created “Train” and “Test” data sets could be taken from the most suitable part of the main data. That’s why the other parts of it should be handled with cross-validation. A Writing exits already in this account about Cross-Validation. In this project, it will be tried ten times, and used some evaluation types.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M7zpRcWWcCfty_KEylfN0Q.png" /></figure><p>When it comes to looking at the result, the former selected part of the data was good for the model. because as already seen the “test_r2” are quite similar to the previous R2. And other values are also around the formerly found values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*MrTDXCRy2fcrvnoLiLkOzg.png" /></figure><p>The average of values is also close to previous values by the comparison.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*3B4zBpKpeymWWQAlvc6vdg.png" /></figure><blockquote>Step 5</blockquote><h4>Prediction Error</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F0oPQt_dMsZ7SiP3wp8PJQ.png" /></figure><p>Here, two lines are seen, one of them is best which means the line that is created with real values, and another line (bold) is the line that is predicted by “Train” and “Test”.</p><p>It could be said the prices over 30000 could be excluded because seems they might be outliers. In this way, the line could occur better than previous.</p><p>The reason for the expression mentioned above lies in that the prices that could be called outliers are pulling the predicted line down.</p><blockquote>Step 6</blockquote><h4>Implement Ridge Regression</h4><p>Although Linear regression is already useful for this project. The Ridge or other types of regression models should be also executed. Because the size of features could differ from each other. For example, while the “km” of a car rises to 200.000, the age might maybe be until 20. That’s why executing Ridge (or other types as mentioned already) is a good way for the model.</p><ul><li>Import the modul</li><li>Do not forget to scale the data or use Normalize parameter as True</li><li>Fit the model</li><li>Predict the test set</li><li>Evaluate model performance (use performance metrics for regression)</li><li>Tune the alpha hyperparameter by using <a href="https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.RidgeCV.html">cross-validation</a> and determine the optimal alpha value.</li><li>Fit the model and predict again with the new alpha value.</li></ul><h4>Scale</h4><p>Before seeing Ridge regression the scaling must be implemented.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*fCsWt2VFvMjB8pkmB1D5Lg.png" /></figure><h4>Ridge</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KOmwUJZA5zlVSBLNvk37HQ.png" /></figure><p>As already mentioned the differences between “rmse” and “mae” might mean whether there is an outlier. The absence of outliers might be mentioned. It’s not certain but it could be said that Suspicion doesn&#39;t exist about outlier or <em>multicollinearity</em>. The Ridge regression was already explained on this “Medium Account”. But it is not a certain result. The best alpha for ridge should be detected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5gjc_srTaF0ChMsdeF2KLg.png" /></figure><p>Here, possible 100 alpha was saved into an array and will be used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LXrawVck7xvv0WzoHomhoA.png" /></figure><p>As an Evaluation, the “red” is used and for best alpha model is implemented 10 times. The created model will be fitted to the “scaled data part”. And from this model, the best alpha occurs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/265/1*KGuqnUs2sBcuKzEuxCePYA.png" /></figure><p>When the model is evaluated again, the results will be as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*hcVB53zkKCszDWM975GioQ.png" /></figure><blockquote>Step 7</blockquote><h4>Implement Lasso Regression</h4><ul><li>Import the modul</li><li>Do not forget to scale the data or use Normalize parameter as True(If needed)</li><li>Fit the model</li><li>Predict the test set</li><li>Evaluate model performance (use performance metrics for regression)</li><li>Tune the alpha hyperparameter by using <a href="https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LassoCV.html">cross-validation</a> and determine the optimal alpha value.</li><li>Fit the model and predict again with the new alpha value.</li><li>Compare different evaluation metrics</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*0ArPUVx8hzTlZxyw9QJ7dg.png" /></figure><p>Since the scaling has been already applied, there is no need for it. The first reason without finding the alpha is as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*gpkNzTgkl9uF2CWVeYWzWA.png" /></figure><p>Some usages are valid for Lasso too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*qTCjk5Qyh8vGe2KKHXd4fA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*oRZdq7W13-7On4Hea4rnmQ.png" /></figure><p>When it comes to the comparison of results, it could be realized there is no high difference.</p><blockquote>Step 8</blockquote><h4>Interpretation</h4><p>The values of all created models are visualized. It seems that there is no remarkable difference between them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*VQ-TSt92LFRI0AXHMz02Jw.png" /><figcaption>R2_score</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*4d6pXQaKFFttwjBzkd85uQ.png" /><figcaption>Mae</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*DPzEHqSBapZJgHJhu1_9jg.png" /><figcaption>Rmse</figcaption></figure><p>For this project, three models were executed and the results stand above.</p><blockquote>Step 9</blockquote><h4>The new model</h4><p>In this step, a new model will be created with the 6 most important features. The picture below shows the order of feature importance with negative and positive relationships.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*PRJR-o-ztvqrOtHhtyz1Dw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*maytANbUgxsE7bW0f5cnNQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*x08NJLKL4fIOwtIvRJJL9A.png" /></figure><p>The “get_dummies” is being implemented for the new “DataFrame” too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SIF1mijqew2xTYDQ512MDQ.png" /></figure><p>The previous steps will be implemented again. But these won’t be explained again, but be shown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*-OLlN8MlZZLaYa2B-5Li4Q.png" /></figure><p>Splitting, scaling, and modeling exist above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/289/1*m2G1fQCBdnQBf-beMSwA9Q.png" /><figcaption>The Evaluations of model</figcaption></figure><p>The results of evaluations that occurred by executing different regression models lie above.</p><h4>Prediction of new observations</h4><ul><li>Taking into account the result above, “the lasso_m” with “alpha=0.01” is decided to apply.</li><li>All data will be used.</li><li>The new scaler will be executed.</li><li>“Lasso_model” will be fitted.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*UBXVoVKE-QCbu2aH_ZsKoA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/238/1*cF1PpljxJCqOaEdHvoovsw.png" /><figcaption>The Scaler and Lasso model</figcaption></figure><ul><li>The Creating of new observation</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/1*Iv41bVfhAZncqaEOjzKZ3w.png" /></figure><ul><li>The most 6 important features created “DataFrame” has a lot of new features after “get_dummies”. That’s why the new “DataFrame” that will enter the model must have the same feature number. And the “get_dummies” and “reindex” will be also applied to the new “DataFrame”. Here “get_dummies” will be first implemented and then “Reindex”. The reason lies that if “get_dummies” would be alone used the column names might not be matched. That’s why “Reindex” must be implemented because it contains “fill” too.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*nqOpMFy9FUoa4zEPN1PcOg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*dPDw-q7-6W54E86p-2Asrg.png" /></figure><ul><li>The same scaler must be implameneted.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*Be7ytslUePStaTX2jOmE9Q.png" /></figure><h4>And the result</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*NQ23rJfdK-N5dVY9spa6lQ.png" /></figure><ul><li>The Evalution tpye is “neg_root_mean_squared_error”</li><li>The regression model is “Lasso”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/239/1*w8H7TPXO85zIxpRvW1hj0A.png" /></figure><p>The result shows if data like the above would be entered into this model, the price would emerge so. It means the model is correct with tolerance “-1900”,”+1900”.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=612fd67948f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Regularization]]></title>
            <link>https://medium.com/@glbaris19/regularization-a52627d77538?source=rss-12997aefc6eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/a52627d77538</guid>
            <category><![CDATA[lasso-regression]]></category>
            <category><![CDATA[crossvalidation]]></category>
            <category><![CDATA[ridge-regression]]></category>
            <category><![CDATA[elastic]]></category>
            <category><![CDATA[regularization]]></category>
            <dc:creator><![CDATA[Baris Gül]]></dc:creator>
            <pubDate>Thu, 07 Jul 2022 13:23:55 GMT</pubDate>
            <atom:updated>2022-09-24T09:21:51.116Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, some confusion about regularization will be tried to resolve.</p><p><strong>What is Regularization in Machine Learning?</strong></p><p>Overfitting is one of the most common problems occurs in ML. In a scenario, if any overfitting appears the model’s performens would be well on the training data but does not perform well on the test data. It means it is not able to predict the target. Regularization is implemented to avoid overfitting of the data, especially when there is a large variance between train and test set performances.</p><p>There are different ways of reducing model complexity and preventing overfitting in linear models. This includes regression models such as a ridge, lasso, and Elastic Net.</p><p><strong>What are the techniques?</strong></p><p><strong>Lasso Regression</strong></p><p>LASSO stands for <em>Least Absolute Shrinkage and Selection Operator</em>. Lasso regression performs L1 regularization. It adds a penalty term to the cost function. This term is the absolute sum of the coefficients. As the value of coefficients increases from 0, this term penalizes and causes the model, to decrease the value of coefficients to reduce loss. The difference between ridge and lasso regression is that it tends to make coefficients to absolute zero as compared to Ridge which never sets the value of coefficient to absolute zero. The linear regression loss function is simply augmented by a penalty term in an additive way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*uvq7zMWNU-QiqxGaMqM1HQ.png" /></figure><p>In this shrinkage technique, the coefficients are determined in the linear model from equation 1.1. above are shrunk towards the central point as the mean by introducing a penalization factor called the alpha α (or sometimes lambda) values. Alpha (α) is the penalty term that denotes the amount of shrinkage (or constraint) that will be implemented in the equation. With alpha set to zero, you will find that this is the equivalent of the linear regression model from equation 1.2, and a larger value penalizes the optimization function. Therefore, lasso regression shrinks the coefficients and helps to reduce the model complexity and multi-collinearity. Alpha (α) can be any real-valued number between zero and infinity; the larger the value, the more aggressive the penalization is.</p><ul><li>It uses the L1 regularization technique.</li><li>It is generally used when we have more features because it automatically does feature selection.</li></ul><p><strong>Ridge Regression</strong></p><p>Similar to the lasso regression, ridge regression puts a similar constraint on the coefficients by introducing a penalty factor. However, while lasso regression takes the magnitude of the coefficients, ridge regression takes the square.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/249/1*gj5I92xUqJXbMbFXbZqOIQ.png" /></figure><ul><li>It shrinks the parameters, therefore it is mostly used to prevent multicollinearity.</li><li>It reduces the model complexity by coefficient shrinkage.</li><li>It uses the L2 regularization technique.</li></ul><p><strong>Elastic Net</strong></p><p>A third commonly used model of regression is the Elastic Net which incorporates penalties from both L1 and L2 regularization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*crSwllyvAo0LAHktA3AErQ.png" /></figure><p>In addition to setting and choosing a lambda value, elastic net also allows us to tune the alpha parameter where 𝞪 = 0 corresponds to the ridge and 𝞪 = 1 to the lasso. Simply put, if you plug in 0 for an alpha, the penalty function reduces to the L1 (ridge) term and if we set alpha to 1 we get the L2 (lasso) term. Therefore we can choose an alpha value between 0 and 1 to optimize the elastic net. Effectively this will shrink some coefficients and set some to 0 for sparse selection.</p><h3>Important Points</h3><p>The main purpose of all techniques is to find out the best fit line. It means the residuals have to be minimized as soon as possible.</p><p><strong>Sum of residuals (∑(Y — h(X))): </strong>it might result in canceling out positive and negative errors.</p><p><strong>Some of the absolute values of residuals (∑|Y-h(X)|): </strong>absolute value would prevent the cancellation of errors</p><p><strong>Sum of the square of residuals ( ∑ (Y-h(X))2): </strong>it’s the method mostly used in practice since here we penalize a higher error value much more as compared to a smaller one so that there is a significant difference between making big errors and small errors, which makes it easy to differentiate and select the best fit line.</p><p><strong>Cross-Validation</strong></p><p>Cross-validation is a technique for evaluating ML models by training several ML models on subsets of the available input data and evaluating them on the complementary subset of the data. The k-fold method can be used for that. In k-fold cross-validation, the data is split into k subsets. Each model is trained and evaluated using complementary data sources — the data in the evaluation Datasource includes and is limited to all of the data that is not in the training data source.</p><p><strong>Scaling</strong></p><p>In practice, different types of variables are often encountered in the same data set. A significant issue is that the range of the variables may differ a lot. Using the original scale may put more weight on the variables with a large range. To deal with this problem, the technique of feature rescaling needs to be applied to independent variables or features of data in the step of data preprocessing. The terms “normalization” and “standardization” are sometimes used interchangeably, but they usually refer to different things.</p><blockquote><strong>Standardization</strong></blockquote><p>The result of standardization (or Z-score normalization) is that the features will be rescaled to ensure the mean and the standard deviation are 0 and 1, respectively.</p><p>This technique to rescale features value with a distribution value between 0 and 1 is useful for the optimization algorithms, such as gradient descent, that are used within machine-learning algorithms that weigh inputs (e.g., regression and neural networks). Rescaling is also used for algorithms that use distance measurements, for example, K-nearest neighbors (KNN).</p><blockquote><strong>Max/Min Normalization</strong></blockquote><p>Another common approach is the so-called max/min normalization (min/max scaling). This technique is to re-cales features with a distribution value between 0 and 1. For every feature, the minimum value of that feature gets transformed into 0 and the maximum value gets transformed into 1.</p><p><strong>In the data, multicollinearity could be seen. Multicollinearity is a statistical concept where several independent variables in a model are correlated.</strong></p><p><strong>What if there is multicollinearity between independent variables;</strong></p><ul><li>Making a decision could be tough which features are more important.</li><li>The coefficient estimates can swing wildly based on which other independent variables are in the model. The coefficients become very sensitive to small changes in the model.</li><li>Multicollinearity reduces the precision of the estimated coefficients, which weakens the statistical power of your regression model. You might not be able to trust the p-values to identify statistically significant independent variables.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a52627d77538" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deepening About Regression Model by an Example]]></title>
            <link>https://medium.com/@glbaris19/deepening-about-regression-model-by-an-example-b08ed5770fb9?source=rss-12997aefc6eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/b08ed5770fb9</guid>
            <category><![CDATA[regression]]></category>
            <category><![CDATA[polynomial-regression]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[classification]]></category>
            <dc:creator><![CDATA[Baris Gül]]></dc:creator>
            <pubDate>Mon, 04 Jul 2022 21:51:23 GMT</pubDate>
            <atom:updated>2022-07-17T16:04:51.912Z</atom:updated>
            <content:encoded><![CDATA[<p>This session aims to explain the regression model of supervised learning. As already mentioned in several ways, ML has some types. One of them is supervised learning. In the scope of supervised learning, there are two models so-called “Regression” and “Classification”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*I-KZhpzeGYDjA1UBYZgLWw.png" /></figure><p>The example will be handled for Regression.</p><h4><strong>Task; Prediction for Hous</strong></h4><h4>Solution;</h4><blockquote><strong><em>Step 1: The overview of Data</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*PnMX3wQnCDlJt6meQM4AaA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*1n1Ov9EKxcA2cVHZmNAYuw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*ZqaOrgXWOHrG6X40bnpVeA.png" /></figure><p>In step 1, the summary of the data is shown.</p><blockquote><strong>Step 2: The specification of dependent and independent values</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*ZOplj6P0fayueoS0R-Ht5g.png" /></figure><p>Here, the dependent value was derived under the name “y”. And the independent value was derived under the name “X” by dropping the other columns.</p><blockquote><strong>Step 3: The Splitting of the main data</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*I8Fvaf8J4vXnwvVk8xxyxw.png" /></figure><p>X_train and y_train are used to create the model, and X_test and y_test are used to test the model. They consist of independent and dependent values. Test_size shows the proportion of the data that are implemented for “Test”. If any value is not determined 0.25 is accepted as default. Random_State is to call the same value every time.</p><blockquote><strong>Step 4: The fitting of data</strong></blockquote><p>In this step, we’ll fit the data first with linear regression and then polynomial regression.</p><h3>Why Polynomial or Linear Regression?</h3><p>In simple linear regression algorithm only works when the relationship between the data is linear. But suppose if we have non-linear data then Linear regression will not capable to draw a best-fit line and it fails in such conditions. Consider the below diagram which has a non-linear relationship and you can see the Linear regression results on it, which do not perform well means which do not comes close to reality.</p><p><strong><em>Linear Regression</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/251/1*8LDcKDeKA8ND6dA2uzobig.png" /><figcaption>Fitting of Data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*pp6gVeGbDIwL_EdfHIy1ag.png" /><figcaption>Prediction of Y_test</figcaption></figure><p>With The linear regression model, we predicted the y_test by X_test.“ y_test_pred” and “Y_test” could be compared directly. But this comparison or evaluation will be executed with metrics. Then a new data frame will be created to see the comparison of y_test_pred” and “Y_test”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/215/1*l9rNL2YCJYGlyIqHUfI58Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*PxdTwc4bjf_xrMPNJzVgfw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kSuBA9nlx-sVjAc3WD9jkQ.png" /></figure><p>Now we should evaluate the model. One article was already written down in this account about how to use evaluation metrics. But before the same steps will be applied for the train part of the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*3wyXen_JN23X4an7_outtQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/409/1*aHnEKPhnGORLIgytmgakBw.png" /><figcaption>For the Evaluation</figcaption></figure><p>The metrics look like so for “Test”;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*_H5HIW56dTWN3tuurffIMA.png" /></figure><p>The metrics look like so for “Train”;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/354/1*0Eu2KfgXoQet-2xZYXLKyQ.png" /></figure><p>As seen the metrics in both data subsets are close to each other. But it seems the distribution on the scatterplot is proper for polynomial regression.</p><p><strong><em>Polynomial Regression</em></strong></p><p>Now a similar process will be executed with polynomial regression. There are already “X” and “Y”.</p><ul><li>Here the degree will be selected and the Conversion will be carried out.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*JbtZyqcZch50G1Wk8dsRWQ.png" /></figure><ul><li>Since we have transformed the data, linear regression will be used here.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*oFO1K2fdvPUg_jji0sWomw.png" /></figure><ul><li>After the necessary steps are completed, the comparison will be exceeded.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/348/1*5ki1XAHpz_XrP3rhOGEaYA.png" /><figcaption>The Evaluation for Test</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*994PEmwFPNWEqdYVYBMiAw.png" /><figcaption>The Evaluation for Train</figcaption></figure><p>It can be said the Polynomial 2-degree is more proper for this dataset. Because the noticeable difference occurs between these two regression models.</p><p>— If there is a big difference between the evaluations for Train and Test, it could be said, some problems occur such as underfitting or overfitting.</p><p>— To see where the big difference between train and test set occurs Polynomial should be executed in many more degrees.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*X8cbR6WSN7zPtq3wKrZ_Pg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*Gb8xfWCP5j4MBzYyXlBBnA.png" /></figure><p>The drawn conclusion is that the overfitting problem occurs after degree 2. It means degree-2 could be accepted.</p><p>The lapse could be also seen in the chart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*shDesPkd6ikBOx1eanI4Mg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b08ed5770fb9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ML / Bias-Variance, Overfitting-Underfitting]]></title>
            <link>https://medium.com/@glbaris19/ml-bias-variance-overfitting-underfitting-b54ecfe8ac1f?source=rss-12997aefc6eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/b54ecfe8ac1f</guid>
            <category><![CDATA[overfitting-underfitting]]></category>
            <category><![CDATA[bias-variance-tradeoff]]></category>
            <category><![CDATA[overfitting]]></category>
            <category><![CDATA[underfitting]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Baris Gül]]></dc:creator>
            <pubDate>Sat, 02 Jul 2022 23:07:12 GMT</pubDate>
            <atom:updated>2022-09-24T09:03:51.620Z</atom:updated>
            <content:encoded><![CDATA[<h3>Bias-Variance Trade off</h3><p>This part of the article aim to this article will examine bias and variance in machine learning. Bias is a systematic error that occurs in the machine learning model by incorrect assumptions in the ML process. We can define bias as the error between the average model and the ground truth. It refers to how well the model matches the training dataset.</p><p>On the other hand, variance refers to the changes in the model when using different proportions of the training data set. Variance is the variability in the model prediction.</p><p><strong>Bias: </strong>Assumptions made by a model to make a function easier to learn. It is the error rate of the training data. When the error rate has a high value, we call it High Bias and when the error rate has a low value, we call it low Bias.</p><p><strong>Variance: </strong>The error rate of the testing data is called variance. When the error rate has a high value, we call it High variance and when the error rate has a low value, we call it Low variance.</p><h3>Overfitting-Underfitting</h3><p>Overfitting refers to the machine learning algorithm or statistical model that learns the detail and noise in the training data to the extent that it negatively impacts the performance of the model on new data. When this happens, the algorithm, unfortunately, cannot perform accurately against unseen data, defeating its purpose. While the algorithms begin to train data if it takes a long time the model could learn the “noise,” or irrelevant information, within the dataset. In this case, the model becomes “overfitted,” and it is unable to generalize well to new data.</p><p>Reasons for Overfitting</p><ol><li>High variance and low bias.</li><li>The model is too complex.</li><li>The size of the training data.</li></ol><p>Underfitting is when the machine learning algorithm or statistical model is unable to capture the relationship between the input and output variables accurately, generating a high error rate on both the training set and unseen data. The model can neither model the training data nor generalize to new data. An underfitting machine learning model is not a suitable model and will be obvious as it will have poor performance on the training data.</p><p>Reasons for Underfitting</p><ol><li>High bias and low variance.</li><li>The size of the training dataset used is not enough.</li><li>The model is too simple.</li><li>Training data is not cleaned and also contains noise in it.</li></ol><ul><li><strong>Overfitting</strong>: Good performance on the training data, poor generalization to other data.</li><li><strong>Underfitting</strong>: Poor performance on the training data and poor generalization to other data.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*DhoMvLvI1bAGU6rWm8Et_Q.png" /></figure><blockquote>How to avoid it?</blockquote><p>There are several techniques that machine learning researchers can use to mitigate overfitting.</p><p><strong>Train with more data</strong></p><p>With the increase in the training data, the crucial features to be extracted become prominent. The model can recognize the relationship between the input attributes and the output variable. The only assumption in this method is that the data to be fed into the model should be clean; otherwise, it would worsen the problem of overfitting.</p><p><strong>Cross-validation</strong></p><p>This is done by splitting your dataset into ‘test’ data and ‘train’ data. Build the model using the ‘train’ set. The ‘test’ set is used for in-time validation. This way you know what the expected output is and you will easily be able to judge the accuracy of your model.</p><p><strong>Data Augmentation</strong></p><p>An alternative method to training with more data is data augmentation, which is less expensive and safer than the previous method. Data augmentation makes sample data look slightly different every time the model processes it.</p><p><strong>Regularization</strong></p><p>This is a form of regression, that regularizes or shrinks the coefficient estimates towards zero. This technique discourages learning a more complex model.</p><p><strong>Early stopping</strong></p><p>When training a learner with an iterative method, you stop the training process before the final iteration. This prevents the model from memorizing the dataset.</p><p><strong>Pruning</strong></p><p>This technique applies to decision trees. Pre-pruning: Stop ‘growing’ the tree earlier before it perfectly classifies the training set. Post-pruning: Allows the tree to ‘grow’, perfectly classify the training set, and then post-prune the tree.</p><p><strong>Ensembling</strong></p><p>It is a machine learning technique that combines several base models to produce one optimal predictive model. In Ensemble learning, the predictions are aggregated to identify the most popular result. Well-known ensemble methods include bagging and boosting, which prevents overfitting as an ensemble model is made from the aggregation of multiple models.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b54ecfe8ac1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to ML]]></title>
            <link>https://medium.com/@glbaris19/introduction-to-ml-a2222dad8599?source=rss-12997aefc6eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2222dad8599</guid>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[mls]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[supervised-learning]]></category>
            <category><![CDATA[unsupervised-learning]]></category>
            <dc:creator><![CDATA[Baris Gül]]></dc:creator>
            <pubDate>Sat, 02 Jul 2022 17:52:29 GMT</pubDate>
            <atom:updated>2022-08-19T18:49:39.263Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Machine learning is a subset of artificial intelligence (AI) and computer science that refers to the use of data and algorithms to imitate the way that humans learn, continuously improving its accuracy.</blockquote><p>Today, every other app and software all over the Internet uses machine learning in some form or the other.</p><h4>Types of Machine Learning</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*yi9N2UqOiqje05BhBxt06Q.png" /></figure><p>There are some variations of how to define the types of Machine Learning Algorithms but commonly they can be divided into categories according to their purpose.</p><p>ML algorithms help to solve different business problems like Regression, Classification, Forecasting, Clustering, Associations, etc.</p><p>Machine learning involves showing a large volume of data to a machine so that it can learn and make predictions, find patterns, or classify data. The algorithm used determines the machine learning type, which works a bit differently.</p><ol><li><strong>Supervised Learning</strong></li></ol><p>Supervised learning refers to the use of labeled datasets to train algorithms that classify data or predict outcomes accurately. In this type, the machine learning algorithm is trained on labeled data. Although the data needs to be labeled accurately for this method to work, it is a powerful method.</p><p>Supervised learning helps organizations solve a variety of real-world problems at scale, such as predicting House Prices or Cars, and classifying spam in a separate folder from your inbox. Some methods used in supervised learning include neural networks, naïve Bayes, linear regression, logistic regression, random forest, support vector machine, and more. The ML algorithm could be given a small training dataset that is a part of the bigger one to achieve a basic idea of the problem, solution, and data points. The algorithm then finds relationships between the parameters given. At the end of the training, the algorithm has an idea of how the data works and the relationship between the input and the output.</p><ul><li><a href="https://medium.com/p/e255bd89217b/edit">You can have an access to a detailed focus here on supervised learning!</a></li></ul><p><strong>2. Unsupervised Learning</strong></p><p>While supervised learning requires users to help the machine, unsupervised learning doesn’t use the same labeled training sets and data. In supervised learning, the labels allow the algorithm to find the exact nature of the relationship between any two data points. However, unsupervised learning does not have labels to work off of, resulting in the creation of hidden structures. The algorithm perceives relationships between data points abstractly, with no input required from human beings.</p><p>Unsupervised machine learning holds the advantage of being able to work with unlabeled data. The main aim of the unsupervised learning algorithm is to group or categorize the unsorted dataset according to the similarities, patterns, and differences. Machines are instructed to find the hidden patterns from the input dataset.</p><p><strong>3. Semi-supervised Learning</strong></p><p>Semi-supervised learning offers a happy medium between supervised and unsupervised learning. During training, it uses a smaller labeled data set to guide classification and feature extraction from a larger, unlabeled data set. Semi-supervised learning can solve the problem of having not enough labeled data (or not being able to afford to label enough data) to train a supervised learning algorithm.</p><p>We can imagine these algorithms with an example. Supervised learning is where a student is under the supervision of an instructor at home and college. Further, if that student is self-analyzing the same concept without any help from the instructor, it comes under unsupervised learning. Under semi-supervised learning, the student has to revise himself after analyzing the same concept under the guidance of an instructor at college.</p><p><strong>4. Reinforcement Learning</strong></p><p>Reinforcement machine learning is a behavioral machine learning model that is similar to supervised learning, but the algorithm isn’t trained using sample data. This model learns as it goes by using trial and error. A sequence of successful outcomes will be reinforced to develop the best recommendation or policy for a given problem.</p><p>It aims at using observations gathered from the interaction with the environment to take actions that would maximize the reward or minimize the risk. The reinforcement learning algorithm continuously iteratively learns from the environment. In the process, the agent learns from its experiences of the environment until it explores the full range of possible states.</p><p>In typical reinforcement learning use cases, such as finding the shortest route between two points on a map, the solution is not an absolute value. Instead, it takes on a score of effectiveness, expressed in a percentage value. The higher this percentage value is, the more reward is given to the algorithm. Thus, the program is trained to give the best possible solution for the best possible reward.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2222dad8599" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Examples with SQL]]></title>
            <link>https://medium.com/@glbaris19/examples-with-sql-1c832ebc7ecc?source=rss-12997aefc6eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c832ebc7ecc</guid>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Baris Gül]]></dc:creator>
            <pubDate>Thu, 23 Jun 2022 14:56:04 GMT</pubDate>
            <atom:updated>2022-06-23T14:56:04.979Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Example 1: List the products ordered in the last 10 orders in Buffalo city.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*Ri9udj1I4-pdKJBJbGPfow.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/146/1*V8xFdnqZk7lb762dZetJsg.png" /></figure><p>In step one we prepared our condition. And the desired values were queried.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/357/1*CxVqWXfwgoYltpRjhNSqLw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*JOu-kNC5ToBUIAOzx5j0LQ.png" /></figure><p><strong>Example 2: List the order amount, product amount, and total price of customers.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*Bfg5zMOqXl-dt3Z4_1IJUQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*y31mezrF8XBemCQ3nC-Pvg.png" /></figure><ul><li>The Reason for the usage of “Group by ”; In order to apply the calculation by the desired column in “SELECT”, “Group by” is necessary.</li><li>To see better the calculation by the desired column in “SELECT”, “Order By” is used.</li></ul><p><strong>Example 3: List the order amount, product amount, and total price in each city.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/1*CPPxdnglSz4SKZ9w0btPXw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*w1eCFXjxlFtUmSY-cXEr4Q.png" /></figure><p><strong>Example 4: The cities that have revenue lower than the average of the state where the cities are located.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*3_KKsWUZ77pMZP-MBcPw1w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*f6T0wmZrqgjQXAQrZdPBvA.png" /></figure><p><strong>Example 5: Write a query that returns how many days are between the third and fourth-order dates of each staff.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*fUSBFbPT8EH59XkUJjxErg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*KYZHEdbbEFA25F4D-g6GHA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c832ebc7ecc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>