The Word Palindrome Should be a Palindrome

I think we can all agree that the title of this blog post is a true statement. The word “palindrome” should be a palindrome. A palindrome is “a word, phrase, or sequence that reads the same backward…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Using Linear Regression to Predict the Value of the Monet Price

Spring 2022

For deep understanding of the dataset, I used data.describe() function to show the results of the statistical functions. Our target variable is price. We can see the descriptive statistical information related to the price such as, mean = 3.09, max =33.01, and min = 0.01. Also, we can see the results of the independent columns. I split 80% of the dataset into training data and 20% into testing data. We used test datasets to evaluate the models.

I used isnull() function to detect the missing values in our dataset. We can see that, there’s no missing values in this dataset.

I used logarithm base 2 to transform two independent columns (HEIGHT, WIDTH). Transformation makes the manipulation of the data easy and reduce the skewness.

I normalized the data to make the features consistent with each other. The model will be less sensitive to the scales. The result will be more accurate. If we don’t do normalization, the features that have large number will affect the result.

Image4: Normalizing the data

I used linear regression to predict the value of the Monet price. It estimates the relation between independent and dependent variables and finds the pest line that reduces the errors.

In model 1, I used simple linear regression model. The independent variable is logarithmic height and dependent variable is price of the Monet. I split 80% of the data into training data and 20% into testing data. After splitting, I trained the model and calculated the prediction error by using R-Squared error and Mean Square Error. R-Squared is a variance of dependent variable taken by the regression model. Mean Square Error captures the residual error. R-Squared and Mean Square Error are the cost functions that are used to evaluate the models. I used sklearn.metrics library to calculate R-Squared and Mean Square Error .The value of RSquared tells that our model explains 15.9% of variation within the data. Mean Square Error is 15.23.

Image5: Evaluate the Model.

In model 2, I also used simple linear regression model. The independent variable is logarithmic width and dependent variable is price of the Monet. I split 80% of the data into training data and 20% into testing data. The value of R-Squared tells that our model explains 3.7% of variation within the data. Mean Square Error is 17.43.

Image6: Evaluate the Model.

In model 3, I used multivariate linear regression model. The independent variables are width, logarithmic height, logarithmic width, height and dependent variable is the price of the Monet. I split 80% of the data into training data and 20% into testing data. Then, I applied liner regression with normalize parameter to normalize the data. The value of R-Squared tells that our model explains 9.6% of variation within the data. Mean Square Error is 16.36.

Image7: Evaluate the Model.

From the visualization below, we can infer that, most prices fell in between 0 to approximately 15 with logarithmic heights from 3.8 to 5.8. Some points aren’t observed to be fallen on the regression line, meaning we have some errors. Some Monet prices are increased after 3.8 and others around zero.

Image: Scatter Plot of Model1.

I used scatter plot to show the relationship between the price and the logarithmic width. I observed that, some prices of the Monet increased significantly after the logarithmic width 4.4. Most points fell in between the logarithm width from 4.2 to 5.4 and the prices in between 0 and 15. Some points fell on the regression line itself.

Image: Scatter Plot of Model2

The best model is model 1, because it’s prediction error less than models 2 and 3. The independent variable, logarithmic height will be more effective on the price because the prediction of error is lowest compared to the other models.

Add a comment

Related posts:

The SARS Song

Ode to the 2004 SARS outbreak in Toronto. A parody, sung to the tune of “If You’re Happy and You Know It”. “The SARS Song” is published by Jonathon Sawyer.

Home Appliances

The modern home is filled with appliances that make life easier. Whether you need to whip up a quick meal for your family or get the laundry done fast, having the right home appliances can make a big…

Is UK politics doomed or dithering?

For anyone living in the UK just now, there’s one word which sums up politics — division. Not division in the old sense of left and right, liberal and conservative, nationalist and unionist. Those…