Regression is a supervised machine learning method for understanding the relationship between independent variables or features and a dependent variable or outcome. One of the algorithms used for regression is the “Lasso Regression”.
Here, we use the diamonds.csv dataset for regression purposes and you can download the dataset from the link on top of this page. This dataset has 9 features:
“carat”, “cut”, “color”,
“clarity”, “depth”, “table”,
“x”, “y” and “z”
And the prediction variable is: “Diamond Price”.
In the above form, you enter the values of 9 features and the model returns the Diamond Price in a pop-up form. As the diamond prices in dataset are from 326$ to 18823$, when you enter features values in form, there is a possibility for small negative numbers returned by lasso model like: -50$. Therefore, we converted all small negative prices to 0.
Also, 3 features of our dataset are Categorical and 6 of them are Numerical. Hence, for using Lasso Regression for this mixed dataset, we need to convert categorical features to numerical labels and then we could use the Lasso Regression method.
Notice that the values and ranges of each feature are as below:
The sample code used to train a “Lasso Regression” model, is provided in the link on top of this page. Each time you run this form and predictions happen, the values will store in the database, and with the link “result” on top of this page, you will see the previous results of the model prediction. Your recent run will be added to the end of this list.