Cannabis Connoisseurs: An Analysis of User-reported Cannabis Data
Introduction
The legality of cannabis in the United States has been a topic of conversation for close to 100 years. Now, more and more states are choosing to legalize cannabis and its byproducts for recreational or medicinal use. While states choose whether or not to legalize the plant at the local level, cannabis still remains illegal at the federal level.
Throughout this post, I will provide a brief history on the legality of cannabis in the United States. Current industry trends will be discussed, followed by an analysis of marijuana data from my web scraping project. I will discuss user-reported data on the effects and ratings of various marijuana strains from the data set. Furthermore, I will make recommendations to several localities about highly rated strains in their area.
Background
Hemp production in the United States was, according to Deitch (2003), a primary reason for colonial America. Hemp is a variant of the cannabis plant that is grown for its fiber. Hemp fibers were used for textiles, ropes, and bags. By royal decree in 1619, the colonists were required to grow hemp as an export to England to begin paying their own way. Clark (1916) noted the importance of various crops during the colonial era. He discussed “bounties” which were established to encourage ample production of certain crops (p. 33). Notably, one of the crops that maintained a bounty during the 1700s was hemp.
Uses of industrial hemp continued well into the 1900s, Deitch (2003) reported. Ultimately, for various reasons resulting from economic and political pressures, interest grew in regulating and taxing cannabis. The result was the passage of the Marijuana Tax Act in 1937 which significantly taxed the transfer of cannabis. The legality of cannabis and hemp was challenged for much of the first half of the 1900s. During the Nixon administration, the Federal Controlled Substances Act was passed further ensuring that cannabis would remain illegal.
Following a period of increased penalties for marijuana, California passed the Compassionate Use Act of 1996 (California Legislative Information). The Act was the first medical marijuana law in the United States. Since then states have been reexamining cannabis laws. Now, 11 states and Washington D.C. have legalized recreational marijuana and 33 states have legal medicinal marijuana (Berke and Gould 2020). Additionally, seven more states are considering some form of marijuana legalization this election year (Zhang, 2020). However, it is important to note that cannabis is still illegal at the federal level.
Marijuana Industry Trends
BDS Analytics (2019) reported the 2018 total legal cannabis sales in the U.S. were approximately $9.8 billion. Alternatively, Hudock (2019) reported the 2018 legal cannabis sales in the U.S. were $10.3 billion. Hudock (2019) and BDS Analytics (2019) report the estimated growth of legal cannabis sales to reach between $27.2 billion and $30 billion by 2024, respectively. Furthermore, Hudock (2019) and Evans (2019) reported that total cannabis sales, including illicit sales, exceeded $50 billion in 2016. This highlights the room for growth in the cannabis industry. Additional economic impacts reported by Evans (2019) included that that the cannabis industry employs approximately 250,000 people and is expected to exceed 300,000 by 2022.
Leafly and Project Goals
My web scraping project involved scraping the cannabis consumer site Leafly. Leafly connects people with cannabis news, products, and provides a strain database. Leafly partners with labs to report data on cannabis. Additionally, they allow website users to review, rate, and report effects, flavors, and potency information from the cannabis they purchased.
The first goal of my project was to examine what cannabis strains had high ratings. Additionally, I wanted to examine if a primary strain type was related to higher ratings. Lastly, I wanted to examine what types of effects might be related to higher ratings. This information could then be utilized by dispensaries for product purchasing and when making recommendations to customers.
The Scraper
Before beginning any analysis the web scraper had to be built. The spider was built using Scrapy. The first class method allows the spider to scrape all of the individual cannabis strain URLs based on the number of pages. Each strain URL is passed to another method where the spider scrapes the desired data for each strain. The scraped data is passed through the Scrapy pipeline where it is saved as a csv file.
Analysis
I began exploring my data with scatter plots of my interested features. Again, I was interested in examining the relationship between ratings and cannabis strains, strain type, and reported effects. It is important to note that effects consisted of three categories: “feelings,” “helps with,” and “negatives.” “Feelings” referred to how users felt from a particular strain. Also, users reported whether a strain “helped with” the specified topic. Finally, users reported whether the strain had any negatives.
Effect categories and corresponding effects:
Feelings: | Helps with: | Negatives: |
Happy | Stress | Dry mouth |
Euphoric | Anxiety | Dry eyes |
Relaxed | Depression | Paranoid |
Uplifted | Pain | Dizzy |
Creative | Insomnia | Anxious |
Initially, it appeared that ratings was not correlated to effects.
However, one notable relationship was the relationship between effects in the “helps with” category. There were some outliers, so I filtered the data to include observations within three standard deviations. The relationship appears to be quite linear, implying that strains that help with stress also help with the other effects in the “helps with” category:
An additional insight from the scatter plots were that ratings appear to be relatively clustered. Most ratings occur between a four to a five; five was the max rating. We can see how tightly ratings are clustered in the histogram and box plot below:
Next, I examined the Pearson correlation between variables. Furthermore, I filtered the correlation table for correlations greater than 0.6 or less than -0.6 to make it easier see variables that had a moderate or stronger linear relationship. This again confirms the relationship between effect variables from the “helps with” category:
Utilizing the trend line, one notable trend was observed between rating and the dry mouth effect. Dry mouth was a negative effect users could have reported. As the percentage of dry mouth reports decreased, ratings appear to have increased. This is most accurate in in the hybrid strain type. Additionally, we can see the relationship between a couple of the effects from the “helps with” category. This reinforces the trend discussed above among effects from the “helps with” category.
Next I examined the strains and primary strain type by their popular location. Overwhelmingly, for state locations, Washington appeared the most. Other frequently mentioned states included Oregon, California, and Colorado. At the local level, Seattle was the most frequently mentioned popular city. Portland was the second most frequent and was followed by Denver. I used the City appearance frequencies in my strain recommendations.
In order to evaluate the highest rated strains and primary strain type, I took the weighted average of the rating for each strain. I weighted the rating by the number of reviews for each strain. The weighted average ratings by primary strain type for the three most frequently mentioned cities are provided in the table below. Note that I rounded to two decimal places.
Primary strain type by weighted average ratings and location:
Primary Type | Seattle | Portland | Denver |
Sativa | 4.37 | 4.33 | 4.32 |
Indica | 4.32 | 4.28 | 4.33 |
Hybrid | 4.31 | 4.32 | 4.36 |
As noted above, I also utilized the weighted average rating to examine highly rated strains by location. Due to the high cluster of ratings, there are several strains for the three most frequently appeared cities that received a weighted ranking average of five. My recommendation to dispensaries would be to examine the list of strains with the highest weighted average by their location and carry options of each primary strain type that received the max rating.
Areas of Further Study
With the passage of a recent farm bill at the federal level came the decriminalization of cannabidiol (CBD). CBD is one type of cannabinoid found in cannabis and is frequently taken without or with very low levels of THC, the active ingredient in cannabis. CBD is being researched for its effects with epilepsy among other conditions. This data set did not contain many data points with CBD percentages. CBD and its relationship with ratings and effects would be worth examining as more data is made available.
Additionally, while the data did suggest many effects may be related to rating, the relationship between strains that help with stress, anxiety, depression, pain, and insomnia were highly correlated; the lowest correlation value was 0.737. I hope to explore this relationship in the future. Even though I only intended to examine ratings, this could lead to an alternative product base. By knowing which strains help with these effects, producers could develop new strains to assist in with these factors. In turn, this would help dispensaries offer alternative products to their customers.
Conclusion
The legality of cannabis and its byproducts are still in question. Although cannabis is still illegal at the federal level, medical and recreational legalization does not appear to be slowing. Thirty-three states and Washington D.C. have cannabis legal for medical or recreational purposes. Furthermore, seven more states are considering legalization in some form this year. This likely to contribute to the expected growth of an already billion dollar industry in the United States. This analysis and review of cannabis data from Leafly begins to shine a light on the type of cannabis people consume and the types of effects that may lead to new strains for people to explore.
References
BDS Analytics. (2019). The state of legal cannabis markets, 7th edition infographic. Retrieved from https://bdsanalytics.com/infographics/the-state-of-legal-cannabis-markets-7th -edition-infographic/
Berke, J., & Gould, S. (2020). Legal marijuana just went on sale in Illinois. Here are all the states where cannabis is legal. Business Insider. Retrieved from https://www.businessinsider.com/legal-marijuana-states-2018-1
Clark, V. S. (1916). History of manufactures in the United States: 1607-1860 (Vol. 1). Carnegie institution of Washington.
Deitch, R. (2003). Hemp: American history revisited: The plant with a divided history. Algora Publishing.
Evans, P. (2019). 8 incredible facts about the booming U.S. marijuana industry. Retrieved from https://markets.businessinsider.com/news/stocks/weed-us-marijuana-industry-facts-2019-5-1028177375#a-colorado-county-made-35-million-off-the-marijuana-industry-in-20165
Hudock, C. (2019). U.S. legal cannabis market growth. Retrieved from https://newfrontierdata.com/marijuana-insights/u-s-legal-cannabis-market-growth/
Zhang, M. (2020). Marijuana legalization may hit 40 states. Now what?. Politico. Retrieved from https://www.politico.com/news/2020/01/20/marijuana-legalization-federal-laws-100688
The skills the authors demonstrated here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.