|

Fashion-Recommendation-Predicting-Dress-Suitability-Using-Machine-Learning (Part 2)

If you have missed part 1 – please read the first part following this link https://sabbirdewan.com/fashion-recommendation-predicting-dress-suitability-using-machine-learning-part-1/

I will share the methodology and results in this blog.

Method:

Decision Tree

A decision tree is a flowchart-like model used for classification and prediction, where each node represents a decision based on a feature, leading to an outcome. We used a decision tree classifier with the rpart package. This model used the selected dress attribute variables to predict whether a dress should be recommended.

Figure 1 – Decision Tree classifier before pruning

To ensure a balanced model complexity and avoid overfitting, we applied cross-validation (10-fold) and used the complexity parameter (cp) to avoid overfitting. We used the optimal cp value to minimise the cross-validation error. Then, pruned the tree to this optimal value, reducing the model’s overfitting.

Figure 2 – Decision Tree classifier after pruning



We split the dataset into training (70%) and validation (30%) sets to evaluate model performance.
Predictions were generated on the validation set using the pruned tree. We evaluated model accuracy through a confusion matrix containing the No of true positives, true negatives, false positives, and false negatives. We calculated the AUC (Area Under the Curve) and the ROC curve to measure the model’s ability to predict the recommended and non-recommended dresses.

Random Forest

A Random Forest model was used with 100 decision trees (ntree = 100). This 100-decision tree helped us reduce the likelihood of overfitting the training data. A confusion matrix was generated to check the model’s performance on the validation set by comparing predicted and actual recommendation values. We calculated the AUC and the ROC curve like the decision tree model. We applied 10-fold cross-validation with hyperparameter tuning to optimise the model. The best-performing model parameters were selected using the caret package based on the highest cross-validated accuracy.

Naive Bayes

We also used a Naive Bayes classifier; we applied the same training and validation set of data and the same process, like Decision Tree and Random Forest, followed to check the model performance, like ROC, AUC, and Confusion matrix. As Naive Bayes often performs better with discrete data, we binned the continuous variable Rating into categories (e.g., Low, Medium, High). Categories are as follows: Low: Ratings below 2, Medium: Ratings between 2 and 4, High: Ratings above 4. Then, we applied 10-fold cross-validation on the training set. We picked the fold with the highest accuracy.

Results:

From the Figure 1 decision tree, a lower rating is a strong predictor for dresses that are not recommended. Dresses with ratings below 4.6 are frequently classified as not recommended, meaning a clear link between higher customer satisfaction and recommendation. Additionally, specific styles like Brief, Fashion, and Work influence the non-recommendation dresses, specifically when paired with certain necklines (such as Boat-neck) or sleeve lengths (such as Short or Petal). The season also plays an important role in this classification; dresses categorised under Autumn, Summer, and Winter are not recommended. These findings suggest customer feedback and style alignment with seasonal relevance are essential in non-recommendation cases.

On the other hand, recommended dresses are influenced by different variables. High customer ratings, particularly scores of 4.6 or above, are strong variables of positive recommendations. Seasonally relevant styles, especially those suitable for Summer, have a higher time of recommendation, with styles like Casual, Novelty, and Party being particularly chosen. Price also influences recommendations, as dresses in the Average to Very-high price categories are more likely to be recommended. This suggests that higher-priced dresses may be perceived as higher quality or desirable. Also, certain neckline and sleeve length styles—such as the Sweetheart neckline and Cap-sleeves or Full sleeves—are often associated with a positive recommendation.

From Figure 2, the pruned classification tree focuses on the most influential variables. The tree begins by splitting based on the Season attribute; directing dresses in Autumn, Summer, or Winter are not recommended 75%, and those in Spring are 25% time, which is further classified. For dresses in Autumn, Summer, or Winter, the next critical factor is the Neckline. Dresses with necklines like Bowneck, O-neck, Slash-neck, Square-collar, or Turndowncollar are predominantly classified as No, with 75% of instances in this group not recommended. However, dresses with Boat-neck or V-neck necklines are more likely to be recommended by 5%.

The tree further splits based on the Style of dresses intended for Spring. Dresses in styles such as Casual, Flare, Sexy, Vintage, or Work are evaluated based on their neckline, with Boat-neck and V-neck styles leading to more recommendations. Meanwhile, dresses with styles like Bohemian, Brief, Cute, or Party are highly likely to be recommended, with 10% as Recommended.

Overall, this pruned tree highlights Season, Neckline, and Style as the primary factors influencing dress recommendations. Dresses intended for Autumn, Summer, or Winter with traditional or conservative necklines are less likely to be recommended. On the other hand, those for Spring with Bohemian, Brief, Cute, or Party styles are more likely to receive positive recommendations.

The overall accuracy of the model is 72.3%. Sensitivity, or the model’s ability to correctly identify Yes recommendations, is 32.08%. Specificity, or the model’s ability to correctly identify No recommendations, is 94.74%. Models have a bias toward predicting No recommendations.

Figure 3: ROC Curve for pruned tree

From Figure 3, the ROC curve shows a limited area under the curve (AUC) of 0.36, which suggests that the model performs poorly in distinguishing between the recommended and not recommended classes. An AUC score of 0.36 is below the baseline of 0.5, which indicates a model that performs worse than random guessing. This low AUC score aligns with the confusion matrix findings, where the model demonstrated high specificity but struggled with sensitivity, resulting in a limited ability to identify positive (Yes) recommendations correctly.

The Naive Bayes model demonstrates moderate overall accuracy (65.54%) and is better at identifying No recommendations than Yes recommendations, as indicated by the higher specificity (70.53%) compared to sensitivity (56.60%).

From figure 4, The ROC curve and AUC value of 0.638 indicate that while the Naive Bayes model can somewhat distinguish between positive (Yes) and negative (No) recommendations, its performance is not particularly strong. The curve gradually increases, reflecting moderate sensitivity and specificity balance but not optimal levels.

When comparing the Naive Bayes and Decision Tree models based on their ROC curves and AUC values, it becomes clear that the Naive Bayes model outperforms the Decision Tree between recommended and non-recommended dresses. The ROC curve for the Naive Bayes model showed a steady rise, meaning a moderate ability to balance sensitivity (true positive rate) and specificity (false positive rate). This is also highlighted by an AUC of 0.638, meaning that Naive Bayes performs better than random guessing and has reasonable discriminatory ability. On the other hand, the Decision Tree model’s ROC curve lies close to the diagonal, reflecting an inability to differentiate between the two classes effectively. Its AUC value of 0.36, below the threshold of 0.5, indicates that it performs worse than random guessing. This low AUC value highlights the Decision Tree model’s poor discrimination capability and suggests it may be unreliable for accurate recommendations. Overall, the Naive Bayes model, with its higher AUC and more favourable ROC curve.

The combined ROC curve of all three models is shown below:

Figure 4 – Combined ROC curve

The confusion matrix table of all these models is shown below:

A key trend is that all three models show more true negatives (correctly predicting not recommended dresses) than true positives (correctly predicting recommended dresses). However, the Random Forest model has the best overall performance, with the highest number of correct predictions in both categories. In contrast, the Decision Tree model struggles the most, particularly with false negatives (incorrectly predicting not recommended when the dress is recommended).

This can be further checked when the confusion matrix of these models is evaluated, and then the key matrices are represented in a Barchart.

We can see that Random Forest stands out as the top performer overall. It boasts the highest Accuracy (0.82), Specificity (0.95), and F1 Score (0.63). While its Precision (0.48) and Recall (0.59) are slightly lower than Naive Bayes, its superior performance in other areas, especially Specificity, makes it the most accurate model.

Decision Tree shows the lowest performance across most metrics, particularly Accuracy (0.64) and Specificity (0.3). Although it has the highest Recall (0.84), its low Precision (0.44) indicates a high rate of false positives.

Naive Bayes falls between the other two models, demonstrating moderate performance across all metrics. It achieves the highest Precision (0.79) and a good Recall (0.68), but its lower Specificity (0.75) compared to Random Forest is a notable drawback.

Image Credit – freepik.com

All the codes will find this GitHub link – https://github.com/sabbirdewan/Fashion-Recommendation-Predicting-Dress-Suitability-Using-Machine-Learning

Share this:

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *