Table of contents

Fashun: an R Shiny app of fashion trends

I want to start by saying fashion (or fashun) is whatever you want it to be - whether that is wearing double denim, or two completely different patterns. I enjoy fashion. By “fashion” I mean any outfit - I find clothing an outlet to expressing oneself.

» Fashun app

Introduction

Setting the scene: I have just handed in my PhD thesis and found that there’s extra free time in my evenings. I thought, what skills can I learn in my spare time? I enjoy text wrangling, mining, and overall text analysis and so wanted to dive into a text-based project.

Using Google Trends, Twitter API, and R Shiny I created a project that looks at fashion trends, correlations, and sentiment analysis.

  1. The Trends analysis includes correlations and seasonal trends of Google data.
  2. Sentiment analysis of Twitter posts that included particular fashion terms compares various fashion topic sentiments.

You can explore data via the interactive R Shiny app I developed, Fashun.

Methodology

Other than R for the Shiny app, I used Python to extract and wrangle the data.

I used Google’s pytrends to collect the data using category 185 “Fashion & Style” from official category list. Date from the beginning of 2019 until July 2022.

from pytrends.request import TrendReq as UTrendReq 
pytrends.build_payload(values, cat=185, geo="GB-ENG", timeframe=f'2019-01-01 {date.today()}',)

Trend occurances

trends correlation matrix

Figure: Correlation matrix of trend occurrences between terms of interest. Green represents positive correlation, white neutral, and purple negative. For example: earrings and necklace are highly correlated, both a fashion accessory.

We can see some fashion correlations from the above matrix, such as: accessories (earrings and necklace) and seasonal (winter, coat, boots, scarf). Winter itself correlating negatively with Summer. Correlation can infer semantics (coat and jacket) and indicate synonyms. Some interesting correlations include a positive relationships between earrings and black; and a negative relationship between Summer and bracelet & earrings.

High correlationLow correlation
earrings & scarfearrings & summer
earrings & bootssummer & bracelet
earrings & blackshorts & scarf
bag & braceletsunglasses & scarf
winter & autumnsummer & scarf
summer & sunglassesshorts & boots
coat & scarfwinter & summer
jacket & coatsummer & boots
winter & coatcoat & shorts
coat & bootscoat & sunglasses
winter & bootssummer & coat
beach & dress
jeans & trainers

Below dives in deeper with two terms with correlated highly with others, summer and boots. We can see that summer correlates positively with sunglasses, shorts, floral, dress, and beach (x > 0.5). However, correlates negatively with winter, boots, coat, scarf, and interestingly earrings (x < -0.5).

On the other hand, boots correlate with scarf, coat, black, and more (x > 0.5). Correlates low with terms that summer correlates high with.

SummerBoots
heatmap of summer correlations
heatmap of boots correlations

Seasonality

seasonal terms longitudinal line plot

Figure: Longitudinal line plot showing the trend of seasonal terms over the year.

The above plot shows seasonal fashion over time: spring starts to trend in the new year, summer trends over longer intervals, and both autumn and winter start to trend in July (mid-Summer).

Below are specific terms and their trends both over the year (left) and a weekly average (right). Scarf starts to trend in the autumn and peaks in December. The floral (pattern) trends around the beginning of Summer and cardigan have no obvious trend with the exception of peaks in June/July.

SeasonalWeekly
yearly trend scarf
weekly trend scarf
yearly trend floral
weekly trend floral
yearly trend cardigan
weekly trend cardigan

Below represents a visualisation of “upcoming” fashion, specifically within the Summer season, and shows trends from January 2022 to June 2022. As expected, Summer starts to become more popular as the year progresses toward Summer and a somewhat foundation to compare “Pink”. Pink, which was fashionable in Summer 2022, steadily increased over time.

Upcoming SummerUpcoming Pink
progression trend of summer
progression trend of pink

Twitter API Sentiment

I used Twitter’s API package tweepy only obtaining single tweets - excluding replies, retweets, and links.

tweet_search = "lang:en -filter:links -filter:replies -filter:retweets"

I used VADER for sentiment analysis as it is a rule-based method pre-trained with tweets.

sentiment scores boxplots

Figure: Boxplots of sentiment scores across all fashion topics.

Looking into categories: in accessories earrings and ring have a lower average sentiment with ring being less than 0 (most neutral). In make-up, mascara has the lowest average sentiment yet remains higher than 0. In patterns: stripes have the lowest sentiment while gingham has the highest average sentiment. Finally, in shoes we see that both heels and boots have a lower average sentiment as footwear - which we know can be uncomfortable.

AccessoriesMake-up
...
...
PatternsShoes
...
...

Wrapping-up

» Shiny Fashun app

This project was fun! In future - with more time - I would need to investigate the outputs in more detail. For example, with the Twitter API text output, I would need to properly investigate and conduct further NLP tasks on the text as some fashion terms may have pulled irrelevant information. Although, future work on this can be difficult: as of 2023, Twitter is now X and so I don’t believe I can replicate the sentiment analysis.

Please do have a little explore of the Fashun app and your own investigations.