The plant Cannabis sativa is a potential goldmine for medicinal compounds. Several major pharmaceutical companies already make drugs that are based on or extracted from marijuana, but there’s still a lot about weed that we just don’t know thanks to decades of prohibition making research expensive and difficult.

Now, machine learning is being brought in to help, which may inspire specially-bred cannabis plants rich in chemicals useful for drug discovery.

There are upwards of 400 different chemicals produced in cannabis, including those that originate when the drug is smoked. There are cannabinoids like CBD and THC, the marijuana molecule responsible for getting people “stoned,” but also terpenoids and flavonoids, responsible for flavor, smell and also some psychoactive effects.

Variations across plants can make it hard to tease out which compounds in weed are responsible for any therapeutic effects, like pain or anxiety relief. There’s a lot of work to be done to unlock the true capacity of this plant. However, Ramesh Jagannathan, director of the International Medical Cannabis Association in Toronto, Canada, is wielding pattern recognition algorithms to make the job a little easier.

In an analysis published in the journal ACS Omega, Jagannathan applied machine learning to a database of 468 cannabis metabolites to see which ones came closest to THC. Of the 468 metabolites analyzed, 54 had a chemical structure very similar to THC. That means they could produce similar psychoactive effects, but that can’t be determined until pure compounds are tested in humans. Rather than picking cannabinoids to study at random, Jagannathan’s approach helps narrow down exciting candidates.

“It is very difficult to perform any human/animal studies using each and every cannabinoid,” Jagannathan said in an email, explaining why he turned to computational methods instead. He says this is, to the best of his knowledge, the first time someone has used AI methods to measure the potential psychoactivity of cannabinoids.

“Of course, we need more experimental proof to substantiate these results,” Jagannathan said. “Some of the metabolites in the list may be good candidates for therapeutics and others are for recreational use.”

That is, this technology could make weed that gives a slightly different buzz. THC may not be the only chemical in weed that gets people “high.” Delta-8-THC, an isomer of THC, reportedly gives users more energy and less of the intoxication associated with THC.

But that theory may be starting to change following the discovery of THCP last month, a similar drug found in cannabis plants that seems to be 30 times more potent than THC. It’s not known for certain if THCP is psychoactive at all, because it has yet to be isolated and tested in humans, but based on its chemical structure, it could influence your experience.

It’s an incremental step, but part of a broader scientific movement that is revolutionizing the way we think about marijuana, beyond just THC and CBD, the two most abundant cannabinoids in typical bud.

Jagannathan’s analysis could also broaden our understanding of how marijuana works in the brain. THC and CBD primarily work on receptors in the body called CB1 and CB2, but historically less scientific attention has been given to how cannabinoids work on other receptors, such as opioid receptors, which are partially responsible for pain relief. This could help explain how cannabis can help with certain types of pain, and help develop new anesthetics.

Machine learning is helping streamline pharmaceutical drug discovery, such as drugs to treat obsessive-compulsive disorder, although the process isn’t perfect. A common issue is being able to interpret the data an algorithm provides, as a 2019 article in Nature Reviews Drug Discovery explained. “[Machine learning] results have to be considered as only hypotheses or interesting starting points that are then further developed in studies by researchers,” the authors wrote. It’s better now than never to start pointing algorithms at cannabis plants.