5 Key points to train a Linear Regression model
<p>Machine learning framework use two main ingredients, first one is the algorithms which is referenced by models and second one is the data. Thinking in machine learning, it’s asking our self how machine learns and take decisions based on data. First of all, we have to think about how humans learn: it’s by logic and by experience. So we can said that machine uses experience to take decisions and this experience at the end is data.</p>
<p>Linear regression model in short words is a linear combination of features to estimate label or target variable. In this short review, we will use python coding and mpg dataset <a href="https://archive.ics.uci.edu/static/public/9/auto+mpg.zip" rel="noopener ugc nofollow" target="_blank">mpg dataset</a>. The main idea is to predict the mpg(miles per gallon) fuel consumption from features like cylinders, horsepower, acceleration, mode, origin, etc.</p>
<pre>
df = pd.read_csv('./dataset/df_new.csv')
df.head()</pre>
<p><img alt="" src="https://miro.medium.com/v2/resize:fit:696/1*KCMTfRNejoWl4-Gx4zRHyw.png" style="height:156px; width:696px" /></p>
<h1>#Point 1: How to define the model?</h1>
<p>Besides our subject related to linear regression, first of all, we have to do some analysis to the data and business reason. With data, we have to check the type of data, if pre-processing is needed, what we can do, get some insights before modeling. For business, we have to double confirm which variable will be estimated or predicted so the model depends of what we want to do with data.</p>
<p>In our case, we want to estimate the value of “miles per gallon”, it means the fuel consumption of a car. Analyzing the type of data of “mpg” label, we can see that this a numerical data which is float numbers. So the output of our model has to be a number. In this way, we can do a linear regression model in order to estimate or predict numbers, but for making a simple model, we will use only the horsepower feature.</p>
<h2>Model Representation</h2>
<p>This kind of model can be represented as a linear combination of features to represent a label, it means a linear equation: a line with an slope and y-intercept.</p>
<p><a href="https://medium.com/@yon.keenn/5-key-points-to-train-a-linear-regression-model-20523ff45a56">Visit Now</a></p>