
Introduction
Across the world, diamonds are renowned for being the “ultimate gemstone.” In the context of jewelry, they symbolize commitment and love. Because of their massive value, diamonds are a major financial investment for the average consumer. Their price is measured by four categories: carat, cut, color, and clarity. In order to help people maximize their budget, our team wanted to answer the question - “Which of the 4 C’s (carat, cut, color, and clarity) affects diamond retail prices the most?” During analysis, our research question stayed consistent because of the data’s simplicity and readability.
Data Description
To answer our question, we used the Gemstone Price Dataset from Kaggle which originated from ggplot2. The dataset contains 53940 rows and 11 columns: Unnamed 0, carat, cut, color, clarity, depth, table, price, x, y, and z. We cleaned the data. Any rows with dimension values of 0 or duplicates were removed for being irrelevant, leaving us with 53755 rows. Finally, all columns except for carat, cut, color, clarity, and price were removed because we only needed these columns to answer our research question. Each of the 4 C’s have a specific value. For the features that were categorical variables, we found an online 1-8 scale to convert the values into numbers. We did this for the Cut, Clarity, and Color variables.
Data Exploration
The dataset ended with 53755 rows and 8 columns. In order to get a better understanding of our cleaned dataset, we explored it with some visualizations. First, we graphed the scatter plot of carat vs price. For the color, cut, and clarity graphs, we used a box plot to prevent the categorical data from clumping around a few numbers on the x-axis. Interestingly, when the color quality increased, the price actually decreased. Next we made a correlation matrix. Carat and price had a value of 0.92, which symbolized a very high correlation.
Model
Multiple Linear Regression
We assessed three different models to fit the data. Our first model was a multilinear regression model using the 4 C’s as features. We performed linear regressions between price, carat, cut, color, and clarity. After observing that the graph had an upwards curve, we used a second-degree polynomial linear regression model since we believed it would be a better fit. Using data split into an 80% train set and 20% test set, we fit the linear regression model on it and outputted our equation:
Price = -5707.877 + 3773.190(carat²)+ 145.228(cut_num) + 358.693(color_num) + 613.223(clarity_num)
Train R² Score: 0.841
Random Forest
Therefore, we chose a random forest model. The random forest model is better because it is able to capture non-linearities better than a standard linear regression model. For example, increasing the carat from 0.5 to 1.0 will not affect price the same way as an increase from 2.5 to 3.0, but on the linear regression model, these are treated as the same interval. It also requires little tuning and resists overfitting because each tree sees a slightly different dataset; they make different errors and averaging their results reduces variance. The random forest algorithm can also learn combinations of features. For example, large carat diamonds with high clarity get exponentially more expensive. This model works by bagging and training many different trees on random subsamples of the training data (drawn with replacement). Then, the model averages each tree’s predictions. Using 500 estimators, and a max depth of 10, we arrived at a
Test R² = 0.98
These results were much better than the linear regression model as the R² score was larger.
Gradient Boosting
Finally, we implemented gradient boosting as it can also predict nonlinearities and interactions similar to a random forest, but it improves sequentially by correcting previous mistakes. A gradient boosting model works by combining multiple small decision trees. The model starts with an initial prediction for the price, then measures the residual between the actual and predicted prices of diamonds. It trains a small decision tree to predict these errors and adds it to the model. Repeating this many times allows the model to become more and more accurate. The hyperparameters used were 500 iterations of the model, maximum depth of 10 and a learning rate of 0.01. This resulted in a Test R² = 0.98
Results
Based on the data, carat is by far the most important decider of price, followed by clarity, color, and cut. These numbers were decided by their coefficients from the linear regression. However, this model is not the one that we decided to use at the end. We decided to use the gradient boosting model at the end, as it produced the highest R² score and was the best representation of the data.
Presentation
If the presentation does not load inline, you can open it directly here: Presentation - Project 5 Diamonds.pdf
Report
If the report does not load inline, you can open it directly here: Report - Project 5 Diamonds.pdf
Video
If the video does not load inline, you can open it directly here: Google Drive video
Collaborators: Eric Yan, Dheeraj Garg, William Lu