codigo

Polynomial Regression

Polynomial Regression is a form of linear regression model but fits a non-linear relationship between the value X and Y. Basically we have to add new features to the final equation. But what features? It's simple we can add the X1 feature as new feature: X1^2 or X1^3. If we have some input features (X1,X2,X3) also we can add new features as X1*X2 or X1^2*X3^2. So, the polynomial regression model is:

As you can see in the following figure you can get a linear regression (red line) or you can get a non-linear regression (blue and  yellow) if you add more features to your equation. The type of curve of non-linear regression model depends of the grade of your polynomial. If the grade of the polynomial is near 1 the model fits to traditional linear regression model. Instead, if the grade of the polynomial is high the model fits to training points.

(more…)

By rocapal, ago
codigo

Multi-variable linear regression

I continue working with machine learning algorithms. In a previous post I talked about linear regression with one variable and I described different algorithms to predict hypothesis.

In this case, I'm playing with linear regression but, with some features. Linear regression only have one input feature and one output feature. For example, you can predict the price of a house give the house's size. But imagine that you want predict the price of a house using size and rooms features. When you have more than one input feature is called 'multi-variable linear regression'.

In the following figure we can see the two input features (size and rooms), the training data (red dots), and the predictions (blue dots). In this case, we can represent the information with a 3D model. If your model have more than three features you must research the way to represent all the data.

(more…)

By rocapal, ago
floss

Playing with machine learning: Linear Regression

Since two months ago I'm researching about machine learning and its algorithms. The goal is get a good unsupervised and clustering algorithm to analyze every android applications and predict what application you want to install or use in a particular time. The first step is learn and understand the theory of machine learning. For this,  I began to study the Machine Learning Course of Stanford. It's a great and practical course with videos and material to help understand the classes.

The first model that I have studied is linear regression. This model consist in have a relation between two or more variables. For example, in my example I have a training data about the prices of the houses and its size in square meters. This training data is used to build a linear regression model to predict the prices of the house give the size of the house. As you  can see in the following figure, the black dots show the training data (I did web crawling to get real data). The blue line represents the trend line of the model, and the red dots show the predicts for two size of houses.

(more…)

By rocapal, ago