<?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 Aysegul Ozcelik on Medium]]></title>
        <description><![CDATA[Stories by Aysegul Ozcelik on Medium]]></description>
        <link>https://medium.com/@aysegul_ozcelik?source=rss-69b9eecb71ff------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*lWl-NFzbIvIPwg-_jgMCIQ.jpeg</url>
            <title>Stories by Aysegul Ozcelik on Medium</title>
            <link>https://medium.com/@aysegul_ozcelik?source=rss-69b9eecb71ff------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 20:04:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aysegul_ozcelik/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[SIMPLE LINEAR REGRESSION]]></title>
            <link>https://medium.com/@aysegul_ozcelik/simple-linear-regression-3c47beebe9fa?source=rss-69b9eecb71ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c47beebe9fa</guid>
            <category><![CDATA[r-square]]></category>
            <category><![CDATA[simple-linear-regression]]></category>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[f-test]]></category>
            <category><![CDATA[explained-variance]]></category>
            <dc:creator><![CDATA[Aysegul Ozcelik]]></dc:creator>
            <pubDate>Fri, 03 May 2024 11:03:32 GMT</pubDate>
            <atom:updated>2024-05-03T11:03:32.590Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3lK-_JHnUzWxA7ay8F3iTw.jpeg" /></figure><p>Machine learning is a branch of artificial intelligence that focuses on the development of algorithms and statistical models from data.<br>One of the most remarkable protagonists in this world is the machine learning algorithm linear regression.</p><p>Linear regression is also a type of machine learning algorithm, <br>is a supervised machine learning algorithm that learns from labeled datasets and performs data points with optimized linear functions. It can be used to make predictions on new datasets.<br>Let’s take a closer look at the inner world of this algorithm.</p><p>It is a type of machine learning where the algorithm learns from labeled data. <br><strong>Labeled data</strong> means the dataset whose respective target value is already known.</p><p>Labeled data is a type of data in the dataset used in the learning process of a machine learning model, where each data point is associated with the desired output values. That is, each data point is accompanied by a label that is the target or output value of that data point. For example, if we want to train a linear regression model to predict the price of a house, our labeled dataset has a label for each house, such as the selling price. The sale price serves as the dependent variable or label, while other variables (e.g., size of the house, location, age, and so on) are used as independent variables. In short, labeled data is the type of data used in training machine learning models, where each data point is associated with the correct output value. These labels play an important role in the model’s learning process so that the models can make accurate predictions.</p><p>Supervised learning has two types:<br><strong>Classification</strong>: It is used to predict whether the input data belongs to a certain category or not. Its main purpose is to classify the input data into different categories.<br>Classification is used when it is necessary to distinguish between instances. For example, determining whether an email is spam, identifying the content of an image or predicting whether a patient has a disease.<br>Classification usually results in a categorical or discrete output.</p><p><strong>Regression</strong>: Used to predict a continuous output value based on input data.<br>Its main purpose is to build a model based on given input data to predict or determine the value of a variable.<br>Regression is used when a continuous value needs to be estimated across samples.<br>For example, using the characteristics of a house to determine its price, or using demographics to predict the likelihood of a customer buying a product.<br>Regression usually results in a continuous numerical output.</p><p>Here, I will focus on <strong>Linear Regression</strong>, one of the simplest types of regression;</p><p><strong>Linear regression</strong> is a supervised machine learning algorithm used to model the linear relationship between the dependent variable and one or more independent variables using observed data. <br>This model finds a line or plane that best fits the data and describes the relationship between the variables through this line/plane.</p><p><strong>Simple Linear Regression</strong>: A type of linear regression that uses a single independent variable.</p><p><strong>Multiple Linear Regression</strong>: It is a type of linear regression in which more than one independent variable is used.</p><p>Let’s look at the prediction models used in simple linear regression:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*5BkL1Gb3i6dvRyJAYXy1Ag.png" /></figure><p>Prediction models used in simple linear regression are equations used to explain the linear relationship between a dependent variable and an independent variable. Basically, these models are used to predict the value of the dependent variable based on the value of the independent variable. <br>When using linear regression, our primary goal is to find the line of best fit, which means that the error between predicted and actual values should be kept to a minimum. The line of best fit will have the least error.<br>The most basic prediction model used in simple linear regression is the linear regression equation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/242/1*rqGSfONNv6UhaPOjAUh46Q.png" /></figure><blockquote>Here;</blockquote><blockquote>ŷ is the predicted value of the dependent variable.<br> b₀ is the constant at the point where the line crosses the y-axis.<br> b₁ represents the slope of the line.<br> 𝑥 is the value of the independent variable.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*62nWgEFDi_Uu53osW1wiJA.png" /></figure><p>The Best Fit Line equation provides a straight line representing the relationship between the dependent and independent variables.<br> The slope of the line shows how much the dependent variable changes for a unit change in the independent variables.</p><p>Since different values of the weights or line coefficient result in different regression lines, we use the <strong>cost function</strong> to calculate the best fit line and the best values.</p><p>In simple linear regression, the cost function measures the model’s differences between actual values and predicted values. <br>Minimizing these differences allows the model to make more accurate predictions. <br>The cost function is usually defined using the least squares method and plays an important role in evaluating the performance of the model.<br>In simple linear regression, the cost function is usually defined as the mean squared error <strong>(MSE)</strong>.</p><p><strong>Mean Squared Error (MSE)</strong>: It is the average of the squares of the differences between actual values and predicted values. <br>In simple linear regression, we calculate the error term of the model (the difference between the true value and the predicted value) and square these errors. We then average these squares to find the MSE. <br>When the MSE has lower values, it indicates that the model provides a better fit and makes better predictions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*4cxp7QiN_vGye4dkLHSRhg.png" /></figure><blockquote>Here;</blockquote><blockquote>n is the number of observations,<br> The actual value of yᵢ,<br> ŷᵢ represents the predicted value.</blockquote><p>MSE measures how far the model’s predictions are from the true values.<br>Lower MSE values are associated with better predictions and better model performance. If your focus is on the accuracy of the model’s predictions, MSE can be an important metric.</p><p><strong>R-square (Coefficient of Determination):</strong> It represents the percentage of the variance of the dependent variable explained by the independent variables. It is a measure of how well the model explains the data. Values are usually between 0 and 1, and the closer it is to 1, the better the model explains the variability in the data set.</p><p>If you want to measure the overall performance of a model, R-square is preferable. R-squared measures the ability of the independent variables to explain the total variance in the dependent variable and therefore assesses from an overall perspective how well the model fits. This measure can be used to understand the predictive ability of the model and, in general, to assess how well the model fits the data.</p><p><strong>Explained Variance:</strong> It refers to the total amount of variance explained by the independent variables of the linear regression model. In simple linear regression, it is interpreted as the ability of the independent variable to explain the variance in the dependent variable. A higher explained variance indicates that the model’s independent variables have more influence on the dependent variable.<br>If your focus is to determine the effect of each independent variable in the model on the dependent variable, Explained Variance may be more useful. Explained variance measures the ability of each independent variable to explain the variance in the dependent variable, which can help you determine the importance of each variable in the model.</p><p>R-squared and Variance Explained assess the ability of the independent variables to explain the variance in the dependent variable. If your focus is on how well the model explains the data and how much variance it can account for, R-squared and Variance Explained can be important.</p><p>Which measure to use may depend on the purpose and context of your analysis. For example, in an academic study, R-squared is preferred to assess overall performance, whereas in an industrial application, lower MSE values are important as they can lead to better predictions and a more efficient model.</p><p>The complexity of the model may also influence which metric to use. In more complex models, MSE can provide a better fit of the model to the data, while R-square and Variance Explained can provide a more general model evaluation.</p><p>Let us examine the <strong>F-test</strong>, a statistical test used in simple linear regression to determine whether the model is generally significant.</p><p>The F-test is an important tool used in regression analysis to assess the overall performance of the model. A high F-value indicates that the model is generally significant, while a low F-value may indicate that the model is not significant. The test statistic F is calculated as the ratio of the variance explained by the model to the variance not explained by the model.</p><p>The F statistic is calculated by the following formula:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*Z5wYB49dMpCYLwsaIeuw1g.png" /></figure><blockquote>MSR (Mean Square Regression): The total variance explained by the model.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*2WSOGLY-ZK_7dIlYFDlGOg.png" /><figcaption>k: Number of independent variables.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*b77iaWOmKzof5t1-bqc8wQ.png" /><figcaption>n: Number of observations.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/1*IICIK_R3AF1jEExPUL7fgQ.png" /><figcaption>SSR (Sum of Squares due to Regression)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*8VbnJ7g5Q9msNgsptefeFQ.png" /><figcaption>SSE (Sum of Squared Errors)</figcaption></figure><p><strong>SSE (Sum of Squared Errors)</strong> is the sum of the squares of the differences between the predicted values of a regression model and the actual observations. SSE is a measure of how accurately the regression model predicts. Lower SSE values indicate a better fit of the regression model.<br><strong>SSR (Sum of Squares due to Regression)</strong> indicates how much the regression model explains the total variance of the independent variables in the dependent variable.</p><p>It is also used to calculate the fraction of the total variance explained by the regression model. During this calculation, the ratio of the SSR to the total variance is called R-square (Coefficient of Determination).</p><p>The calculated F-value is then compared against a predetermined significance level (usually α = 0.05). If the calculated F value is greater than the specified significance level, the model is generally significant and the null hypothesis is rejected. Otherwise, the model is generally insignificant and the null hypothesis is accepted.</p><p>In simple linear regression, the F-test is usually used to test the following hypotheses:</p><p>Significance Test (Global Test): The null hypothesis states that the independent variable has no significant effect in the model (β1 = 0).<br> The alternative hypothesis states that the independent variable has a significant effect in the model (β1 ≠ 0).</p><p>Testing the Significance of the Model: This test assesses whether the model is significant overall. The null hypothesis states that the model has no significant effect (β1 = β2 = … = βk = 0). The alternative hypothesis states that at least one coefficient is significantly different in the model.</p><p>Finally, I will talk about the various environments and programs used to perform linear regression.</p><p><strong>Python:</strong> Python is a very popular programming language for data analysis and machine learning. Libraries such as scikit-learn, statsmodels, etc. enable the creation and analysis of simple linear regression models in Python.<br><strong>R:</strong> R is a widely used programming language for statistical analysis and data mining. The lm() function is used to build simple linear regression models in R.<br><strong>Matlab:</strong> Matlab is a widely used program for engineering and scientific calculations. In Matlab, the fitlm() function can be used to create a simple linear regression model.<br><strong>Microsoft Excel:</strong> Excel’s Regression Analysis tool can be used to create and analyze simple linear regression models. You can easily build the regression model using data tables and visually analyze the results.<br><strong>SPSS (Statistical Package for the Social Sciences):</strong> SPSS is a common software for statistical analysis. You can create models in SPSS using the interface or through <strong>scripts for simple linear regression analysis.<br>Jupyter Notebook: </strong>Jupyter Notebook provides an interactive environment for data analysis and machine learning projects. It is compatible with Python, R and other languages and can be used to build simple linear regression models.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c47beebe9fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>