<?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 Shaikh Arshiyan on Medium]]></title>
        <description><![CDATA[Stories by Shaikh Arshiyan on Medium]]></description>
        <link>https://medium.com/@shaikharshiyan91?source=rss-beaf98aa5ed8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*-SNl9wKxt57kNqKe</url>
            <title>Stories by Shaikh Arshiyan on Medium</title>
            <link>https://medium.com/@shaikharshiyan91?source=rss-beaf98aa5ed8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 11:59:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shaikharshiyan91/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[Multivariate Linear Regression]]></title>
            <link>https://medium.com/@shaikharshiyan91/multivariate-linear-regression-46c3b505168e?source=rss-beaf98aa5ed8------2</link>
            <guid isPermaLink="false">https://medium.com/p/46c3b505168e</guid>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[multivariate-regression]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[linear-algebra]]></category>
            <dc:creator><![CDATA[Shaikh Arshiyan]]></dc:creator>
            <pubDate>Sun, 01 Jan 2023 05:38:08 GMT</pubDate>
            <atom:updated>2023-01-01T05:38:08.683Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/337/1*7UhVO5AMA3Ojv8bryeYz0A.png" /></figure><p>Linear regression is a statistical method used to model the linear relationship between a dependent variable and one or more independent variables. It is used to predict the value of the dependent variable based on the values of the independent variables. In simple linear regression, there is only one independent variable, while in multiple linear regression, there are multiple independent variables. In this blog, we will focus on multiple linear regression, also known as multivariate linear regression.</p><p>Multiple linear regression is a powerful tool for predicting a continuous response variable based on multiple predictor variables. It is used when we want to predict a value of a dependent variable based on more than one independent variable. For example, we may want to predict the price of a house based on its size, number of bedrooms, and location.</p><p>The equation for multiple linear regression is:</p><pre>y = b0 + b1x1 + b2x2 + … + bnxn</pre><p>where y is the dependent variable, b0 is the intercept, and b1, b2, …, bn are the coefficients for the independent variables x1, x2, …, xn. The coefficients represent the relationship between each independent variable and the dependent variable.</p><p>To fit a multiple linear regression model, we need to find the values of the coefficients that minimize the difference between the predicted values and the observed values. This can be done using the least squares method, which finds the values of the coefficients that minimize the sum of the squared differences between the predicted values and the observed values.</p><p>Once we have fit the multiple linear regression model, we can use it to make predictions about the dependent variable given new values of the independent variables. For example, if we want to predict the price of a house based on its size and number of bedrooms, we can use the multiple linear regression model to estimate the price given the size and number of bedrooms.</p><p>There are a few assumptions that must be met in order to use multiple linear regression.</p><p>The first assumption is that the relationship between the dependent variable and the independent variables is linear. This means that the change in the dependent variable is constant for a given change in the independent variables.</p><p>The second assumption is that the errors are normally distributed and have constant variance. This means that the difference between the predicted values and the observed values should follow a normal distribution and have the same variance across all values of the independent variables.</p><p>Multiple linear regression is a useful tool for predicting a continuous dependent variable based on multiple independent variables. It is important to check that the assumptions of linearity and constant variance are met before fitting the model and using it to make predictions.</p><p>To find the values of the coefficients that minimize the difference between the predicted values and the observed values, we can use the least squares method. The least squares method finds the values of the coefficients that minimize the sum of the squared differences between the predicted values and the observed values.</p><p>The mathematical solution to the least squares method is given by the normal equation:</p><pre>(X^T X)^-1 X^T y = b</pre><p>where X is the design matrix containing the independent variables, y is the vector of observed values of the dependent variable, and b is the vector of coefficients.</p><p>The normal equation can be derived by setting the derivative of the sum of squared errors with respect to the coefficients equal to zero and solving for the coefficients. This results in the normal equation, which can be solved using linear algebra.</p><blockquote>It is important to note that the normal equation may not have a solution if the design matrix is not invertible. This can occur if the independent variables are highly correlated or if there are fewer observations than independent variables. In these cases, we can use alternative methods such as ridge regression or least absolute shrinkage and selection operator (LASSO) to fit the multiple linear regression model.</blockquote><p>To implement multiple linear regression using Python, we can use the LinearRegression class from the sklearn.linear_model module. This class provides an implementation of the ordinary least squares method for estimating the coefficients of the multiple linear regression model.</p><p>First, we need to install the sklearn library. This can be done using pip:</p><pre>pip install sklearn</pre><p>Next, we need to prepare our data. This involves splitting the data into predictor variables (also known as independent variables) and a response variable (also known as the dependent variable). The predictor variables should be stored in a 2D array or matrix, while the response variable should be stored in a 1D array.</p><p>Here is an example of how to prepare the data:</p><pre>import numpy as np<br><br># Predictor variables<br>X = np.array([[1, 2], [3, 4], [5, 6]])<br><br># Response variable<br>y = np.array([10, 20, 30])</pre><p>Now that we have our data prepared, we can fit the multiple linear regression model using the LinearRegression class. Here is an example of how to do this:</p><pre>from sklearn.linear_model import LinearRegression<br><br># Create a linear regression model<br>model = LinearRegression()<br><br># Fit the model to the data<br>model.fit(X, y)</pre><p>Once the model is fit, we can use it to make predictions. To make a prediction, we can call the predict method of the LinearRegression object and pass it a 2D array or matrix containing the predictor variables for which we want to make a prediction.</p><p>Here is an example of how to make a prediction using the multiple linear regression model:</p><pre># Predict the response for a new set of predictor variables<br>X_new = np.array([[7, 8]])<br>y_pred = model.predict(X_new)<br><br>print(y_pred)  # Output: [50]</pre><p>That’s it! We have successfully implemented multiple linear regression using Python. Keep in mind that it is important to check that the assumptions of the multiple linear regression model are met before using it to make predictions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46c3b505168e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linear Regression — Learning Via Machine]]></title>
            <link>https://medium.com/@shaikharshiyan91/linear-regression-learning-via-machine-7a34a80042b4?source=rss-beaf98aa5ed8------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a34a80042b4</guid>
            <category><![CDATA[linear-regression-python]]></category>
            <category><![CDATA[linear-regression-math]]></category>
            <dc:creator><![CDATA[Shaikh Arshiyan]]></dc:creator>
            <pubDate>Thu, 29 Dec 2022 07:21:26 GMT</pubDate>
            <atom:updated>2022-12-29T07:21:26.560Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*n9tphcy3xVZ2AWZlecLdpA.jpeg" /></figure><h3>Linear Regression — Learning Via Machine</h3><p>Linear regression is a machine learning algorithm used for predicting a continuous dependent variable based on one or more independent variables. It is based on the idea of finding a linear relationship between the predictor variables (independent variables) and the response variable (dependent variable).</p><p>Here is an example of linear regression in Python using the popular scikit-learn library:</p><pre>from sklearn.linear_model import LinearRegression<br># Load the data<br>X = [[1], [2], [3], [4], [5]]<br>y = [1, 2, 3, 4, 5]<br># Create the model<br>model = LinearRegression()<br># Fit the model to the data<br>model.fit(X, y)<br># Predict a value<br>prediction = model.predict([[6]])<br>print(prediction)</pre><p>In this example, we are using a simple dataset with one independent variable (X) and one dependent variable (y). The model is trained on this data using the fit() method, and then we use the predict() method to predict the value of the dependent variable for a new independent variable ([[6]]).</p><p>Linear regression is a simple but powerful algorithm that is widely used in various fields, including finance, economics, and data science. It is a good starting point for regression tasks and can often be used as a baseline model to compare with more complex models.</p><p>The mathematical form of a linear regression model with a single independent variable is given by the equation:</p><p>y = b0 + b1 * x</p><p>where y is the dependent variable, x is the independent variable, b0 is the intercept, and b1 is the slope.</p><p>To find the optimal values for the intercept and slope (b0 and b1), we use a method called “least squares.” The goal of least squares is to find the line that minimizes the sum of the squared distances between the data points and the line. This is done by taking the partial derivatives of the cost function (the sum of the squared distances) with respect to b0 and b1 and setting them to zero.</p><p>The resulting equations for the optimal values of b0 and b1 are:</p><p>b1 = sum((x(i) — mean(x)) * (y(i) — mean(y))) / sum((x(i) — mean(x))²)</p><p>b0 = mean(y) — b1 * mean(x)</p><p>where x(i) and y(i) are the i-th data points, and mean(x) and mean(y) are the means of the x and y variables, respectively.</p><p>Once we have calculated the optimal values for b0 and b1, we can use them to predict the value of the dependent variable for a given independent variable using the equation:</p><p>y = b0 + b1 * x</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a34a80042b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>