Welcome to cannabis data science. You're in for a particular treat today. You know, as
we've been at this for a long time now, just slow and methodically collecting data, standardizing
it, looking at it, asking interesting research questions, trying to draw insights. And we try
to follow the demand. We try to listen, keep our ears to the ground, hear what statistics are
people demanding, and then try to put those statistics and data into people's hands because
we think that's our comparative advantage and the way that we can help people out in the cannabis
space. I'll share with you a lot of new ground, a lot of work that can be done, some exciting new
developments, and of course, we'll just have a fun day crunching cannabis data at the end of the day.
So that's what I have to share with you today. We'd love to hear about some of your adventures.
It's a meetup after all, so you know, feel free to share some of your interests. So I'll start,
so I don't put anyone on the spot. I'll start with my intrepid co-host, Candice, who's been
helping me wrangle data for a long time now. She's got an impressive technical setup. So I'll pass
it off to you, Candice, anything you'd like to share? Any of your thoughts you want to put on
the table? Well, it's been a fun week. I ran Get Results or Get Licenses for Florida. That was
pretty cool. Came up with real nice CSV. Thank you, Keegan. And also to Get Results Florida,
I'm getting those as well. I have 17.3 gigabyte of COAPDS, and actually, I made some changes in the
code that where I resulted with Cannot Save File into a Non-Existent Directory Parent, but I know
where that is. And otherwise, yeah, it's, you know, parsing and putting into a results data set. And
I'm really excited because it's a lot of information for Florida. And I have been trying to obtain it by
purchasing product and, you know, with Facebook group medical patients in Florida that were
sharing COAs. So I'm really excited about this. And that and the metric API, I'm getting closer to
that. I'm just waiting now. I filled out everything, the agreement. And as far as the Massachusetts
Freedom of Information Act, I am going to pursue it. You know, because, you know, like, CCC does
have the records, they have it in a database, and all they have to do is just publish it to a CSV.
file instead of printing it out. But they're saying that they don't have the records. And I don't
know, you know, I, I could be mistaken, right. But I just want to ask them, you know, about that. I
really don't understand why it can't be done, or it can't be done by other states. But that's it.
And hi, everybody.
I absolutely love it. Because that's sort of the lesson of the day is ask and you shall receive.
And just the act of asking, as we've discussed in the past, and I'll drill home today, adds value,
right. And I always say, right, one of the lessons in the past was, you know, it doesn't hurt to ask.
So, as Candice was saying, you know, she's at least asking for lab results for some of these cannabis
products in her state, because those are data points that she's interested in. And Candice isn't
alone. There's a lot of people out there searching for this data. I'll actually piggyback on a lot of
the things Candice said momentarily. But I'll have a lot to say on that. So while I'm, you know,
formalizing my thoughts, I'll go ahead and let everybody have a chance to speak. So, it's
phenomenal to see you. You've been on my mind as we've got some new data science algorithms to
write, and Canlytics is going to be looking for some of its first hires in the near future. So,
I'm going to be getting everybody formally contacted once I get all the job postings listed. As I will
share with you today, I've been sprinting on something interesting. I can go back to just a nice
methodical jog at this point, and try to get some of you awesome people involved. So, but what's on
your mind or plate or any thoughts you want to put on the table? I'm doing a data science boot camp
right now. Well, hi, my name is Hector. I sporadically show up in these meetings every once in a while.
I'm doing a data science boot camp. And right now we're on break, we just finished our second capstone.
And I did a project on identifying candidates who were going to go bankrupt. And so I ran several
machine learning algorithms, including random forest and XGBoost. And I was able to get some
pretty good results from running my models. I ran PCA, I did a whole bunch of stuff. It was a lot
of fun. I look forward to being able to use my skills even further in the future. Well, in the
past, remember, we poked around at survival analysis. I think we were looking at Washington
State, but we've got traceability data, and even lab results, it contains a surprising amount of
information. And one thing is just who's operating. So just from say lab results alone, you can kind of
get a pulse of who's going to the lab, how many samples are they sending in. But in Washington
State, we've got full traceability data, so we can even look at sales. And so we were saying, Oh, you
know, we're, we're trying to look at people's sales over time. And we noticed people would drop out of
the market. And of course, people would enter the market. So what you could potentially do is maybe
you could adapt your bankruptcy model to the Washington State data, and almost have a risk
assessment model, or slash survival model. So maybe you could apply it to licensees there. And yeah,
maybe some of the licensees, they're going along steady, they're at low risk of bankruptcy, or, or
falling out of the market. But maybe you can identify people who are at high risk of exiting,
and they may not even realize it. So you may be able to send them an email and just say, Hey, some
of your key performance indicators aren't looking that great, or I've got this risk assessment model,
and you know, maybe you were flagged. And, you know, maybe we could, you know, work together to try to
figure out some ways to, to, to lower your risk of exit. So, but I'm just brainstorming, I'm sure you
can think of, you know, many more uses or even a better, better application than that. But I love
that you're, you're keeping your nose to the grindstone and working on your skills. That's important.
So, Robert, good to see you. I think we were corresponding about some, some work to be done. And
I've started to share some of the, the data collection efforts, slash standardization efforts,
even the AI efforts that we're working on in Slack, and so on and so forth. So please, please,
everyone get in touch with me if you need an invite to the Slack channel or anything. But how
is your work going, Robert? Good, yes, similar to Hector. I'm also in a data science boot camp and
finished up Capstone 2 projects where I did something somewhat similar. And that was looking
at a credit card, credit scoring classification model where I used about six different classification
algorithms. And then before that, I also had a fair amount of data scrubbing and standardizing
to do. And, you know, most, or in the past, as a SQL developer, I would, you know, not be crazy
about the idea of data scrubbing, but it was a good chance to practice Python. So I was pretty
happy or totally fine with running a bunch of different Python scripts to get clean CSV files
that would be able to import into a SQL database without generating errors and so on, import errors.
And then similarly, I'm, you know, these days, super enthused with, you know, what AI and chat
GPT and what Bard can do. Very interesting stuff going on right now with all this AI that's out
there. So yeah, that's me, you know, studying hard and I'll circle back to you on getting some of
those data files and how I can assist. Well, once again, Robert, going to tie in your interests as
well, because I always like to explore all the latest and greatest tools. I always caution people,
you know, don't put all your eggs in, in one basket. You know, in the past, we talked about,
you know, some of the blockchain technologies. And while I still think those are awesome
technologies, and to a certain extent, we use little pieces of them, we use hashing. And as I
was talking about, like there's ways that we can start incorporating more of those ideas into our
work. But I think the slow approach is good, just slow adoption. As I said, don't just want to rush
full steam into it. So I'm a little careful with AI in that I don't necessarily want to rush full
steam into it. But at the same time, I think it would be negligent to not explore it. It's a
awesome new technology, everyone's raving about it. So shouldn't we understand it fairly well?
And that's truly, as I'll show you today, it can be interesting to help us do well estimation.
Remember, statistics at the end of the day is about prediction. So today, I'll show you how we can
use the AI model for predictive purposes. So we may not want to say that this is the definitive
answer. But sometimes, remember, when we were doing forecasting, I was saying, you know, any
forecast is better than no forecast. And so in this case, it will be any look at the data is better
than no look at the data. So that's a teaser to really, really exciting things to share with you
momentarily. But before I get to that, Rick, thrilled to see you today. Going to be picking
up with some of the topics from last week, in particular, Dino hunting. So that's sort of the
the theme of the day today. So we'd love to hear about some of your thoughts, or ideas that you
want to put on the table. Yeah, I'm excited to see what you've come up with for today. It was a
great conversation last week. So hi, everyone. My name is Rick. Right now, my main focus is AI. I've
been working not so much with collecting number data, but more text data. This is I don't know if
you consider it like tribal knowledge or what, but in terms of cultivating, I think it's a
great idea to be collecting, you know, history about genetics and where they came from and trying
to track origins of specific expressions and plants, so on and so forth. There's not a huge
database available for collecting a lot of that there is books and stuff. So I've essentially
just been scraping all of that data from various forums like Reddit, there's a lot of good
things there. And then running those through an embedding process and then storing it in a vector
database for retrieval for AI. So you just kind of throw like an AI chat bot on top of that and it
can query the database and get really accurate responses after, you know, a minimal amount of
fine tuning. It's got a lot of moving pieces and it's hard to keep up with because things change
and I haven't used it for numbers yet. Gigan and I suspect it's because of a lot of your cautions
as well. But for text and stuff like growing or helping someone that has a cultivation question,
it's working pretty well right now. So that's what I'm working on.
I absolutely love it, Rick, and hopefully we can add some tools to your tool belt today and, you
know, just kind of, you know, bounce good ideas off of each other because a lot of the work we're
doing is complementary. So absolutely love it. Excited to see, you know, how you develop
and how your projects grow. So keep us up to date on these. So this is exciting work that you're doing.
It's right in the vein of everything we're doing today. And it's funny that you once again bring
up Reddit because I'll tie in some of the work you're doing today too. So simply phenomenal.
Simply phenomenal. How about you, Anna? Welcome to the group. Well, you've been to the group. So
good to see you today. Thrilled to see you. We'd love to hear about some of the things that are
on your plate and any ideas that you want to put on the table. Oh my gosh. I haven't been working
on anything exciting. I've just been doing a lot of housekeeping. So setting up the
external hard drive and just my file system and all that. But I am finding that there's not a whole
lot of data for Oregon to scrape off the web. And so I've still been looking around. I've
guess, yeah, I'm still a little bit lost on that part. And I am looking for other people from
Portland or Oregon in general. So yeah, I may be shifting off of the medical focus, even though
that's always where I want to put my efforts. But right now I'm a little distracted with some
of the stuff going on in the policy arena. So yeah, but I don't really have anything very
interesting to present just puttering along still. But I just wanted to reconnect for sure. So
thank you. I'm in good company, it looks like. Well, Anna, I think we can give you some rays of
sunshine here because I think we can provide or you can maybe even Kindle, Spark up a way to
actually get some of this Oregon data. And once again, it all begins, as we said, with asking.
So I'll go ahead and share my screen here, but you're definitely on the right path. And as I
tell everybody, you know, even if you're just able to spend 20 minutes a day, just doing some sort of
data science thing, right, even if that's just setting up, like you said, your external hard drive,
that's still moving the ball forward. And these external hard drives, I've gone, this is my third
one now. So be really careful with them. And because they're really, they're actually kind of
fragile. And so like I did, you drop it on the floor, it's, it's gone, I'm going to try to do like
some some data recovery. Once, once again, my philosophy is, you know, archive, archive, archive.
So you want to have data stored in multiple places. And that's why, yes, you know, it's phenomenal
for me to have it on my external hard drive. And I think that's a great way to do that. And
you know, if you can afford it, to put it in the cloud, you can do that. But you know, cloud prices
can be non negligible. And then distribute, that's the our third source of resiliency. So if I drop
my hard drive with a bunch of this lab results, you know, on the floor, like I did, that's okay,
because all of you awesome data scientists are also archiving data. So you know, as Candice has
mentioned, she's beginning her archive of lab results. And I would encourage all of you to, to
archive data, because just, you know, maybe I dropped my hard drive on the floor, Candice drops
her hard drive on the floor. But, you know, thankfully, Anna has has a copy. So, you know, you
just never know when your copy is going to pay off or be useful to someone. And Anna, you also
mentioned medical patients. Well, as Candice was mentioning in the beginning, in Florida, there's
medical cannabis, and look at this. So we were telling people that, you know, it doesn't hurt to
ask, you know, you're going to be going to a dispensary, I think, you know, that if you're
consuming a product, it's pertinent to know what you're consuming. So it wouldn't hurt to ask for
the certificate. I don't think in Florida, they're mandated to provide them. In some states, they are
like Washington State. And in some states, they're maybe not mandated, but people will provide them.
So I've seen them in Massachusetts before from just asking at a dispensary, and I don't think
it's mandated there. But this is pretty typical, right? And as I said, don't get mad, right? So
just because it's okay to ask doesn't necessarily mean they have to say yes. So, you know, you may
get a no, and you have to kind of just be okay with that. So here they say, oh, you know, they said,
oh, the printer was offline. And once again, that may be perfectly the that may actually be the case
because printers are notoriously fickle. But this is my point is, if you go around asking, well,
so that was three months ago. Well, eight days ago, look at this, somebody made a post, you know,
Dita can finally put their CEO is up. And so they said they thought, oh, you know, they never thought
it would happen. But they're like, oh, this is amazing. You know, I can now shop off of turpies.
And in like, this is another thing is, you know, you shouldn't have to look at the COA
after you purchased it, right? Because ideally, you want to know what you're consuming,
you know, before you purchase it. And so I'll let you explore this. But, you know, now people
are saying like, oh, look, you know, here, I bought this product. And they're saying, oh, you know,
what's up with the THC values? And then, you know, people chime in, in the comments, you know, kind of,
you know, having a conversation about it. And I think this is this is brilliant, right? Because
this is kind of reducing some of the the murkiness that was in the market, right? People were
kind of, you know, getting hung up on these THC numbers. But now they're actually kind of able to
see like, oh, like, there's more to it. Then, you know, there's more to this than just total THC.
You know, we've got all the the other cannabinoids. And oh, you know, what's going on, you know, here
with with turpines? And sure enough, so here's somebody saying, like, oh, like, so I think I like
terpenes, right? So and they're saying, you know, oh, you know, what's the deal with with barnesine,
which, which is a terpene they test for in in Florida. And so once again, you know, this person
just finally, you know, saw some COAs, and they're just asking, like, okay, like, they didn't even
know about terpenes. And they're like, you know, can someone just please explain terpenes to me?
And, you know, sure enough, you know, once again, you've got to be cautious about things people tell
you, right, you want to, you know, check it for factual accuracy and everything. But this is still
a conversation. And so that's the point is, ask a question, and it can, you know, get the conversation
going. They asked the question about COAs got the conversation going. You know, they posted a COA,
you know, that got the conversation going to terpenes. And then, you know, and then now, Rick,
now this is sort of up your vein. People are now saying like, okay, you know, is there any way we
can start, you know, accumulating some of these COAs, so that way we can kind of understand them
as a whole. So for example, if you see beta pionene at 0.2%, is that a lot? Or is that a little? Well,
as we've seen, if you actually look at the distribution, you can find out if something
is, you know, above average or below average, and that's the useful data point. So that's what
people are kind of after. And once again, the Rick, these aren't finished projects. And so this is
what I call a demand for a product, right? So these are people saying that, oh, you know, we want
some COAs, you know, we want a COA database. Here's somebody who's got a research question. So they say,
you know, oh, you know, what's going on with with Farnes? And now finally, you know, somebody just
asks the question, you know, can we just get a, you know, a universal COA search site? Well,
remember at the beginning, ask, and you shall receive. So this is, you know, just the Reddit,
on Reddit was just the crude origins, you know, to this, you know, very, very day, or a couple days
ago, you know, people are just posting up their results. And, you know, you can get the the various
you know, you can start looking at some of these COAs. And, you know, so what I realized is, oh,
well, they have, you know, QR codes on them. So what you can do is scan the QR code on your URL,
or I mean, scan the QR code on your phone, or with with Python, or however you please,
and you know, you can now get this. And actually, here, we can actually do this in Python real quick.
So to just show you how you can actually get the COA URL off of this thing. And, you know,
you can use CANlytics. And our favorite COA parsing tool, and you can use the
COA doc. And then we can find the COA URL over here. So I think we can do this without too much
trouble. Hopefully, if it's too much trouble, I'll just pass it. But we can just say, oh, let's find
the COA URL. And then we can find the COA URL over here. So I think we can do this without too much
trouble. And then we can just say, oh, let's find this QR code. And so this just checks all the images
and sees if any of them are QR codes, and if there's a parsable URL from them. And so once again,
not super fast. So if any of you want to get in there, and also I'm running a bunch of processes
now. But long story short, you know, you can start to, you know, find the direct source of these
COAs. And basically, upon, you know, further exploration, you know, you can basically find
that these various laboratories are publishing, I think, similar to NCR labs, where maybe certain
clients want to make their COAs publicly available. So for example, you know, VitaCAN,
you know, they're trying to get their COAs in the hands of consumers. And just to kind of show you,
so for example, one of the things like Candice was working on, that I was working on, was just
archiving all of these. So basically, let's see if we can't, here one second here, just going to see
if we can't just pull these up real quick for you. So for example, say we wanted to look at VitaCAN
to look at VitaCAN COAs. We can do that. Okay, let me try one more thing.
Okay, maybe not. I think I just had an extra backslash in there. Okay, let's try one more time.
Okay, so they just have, so remember, they just started, you know, eight days ago or so. So they
may not have, well, actually these look like they're from earlier. Oh, so here's the latest one.
So here's one from April 28th. So maybe they don't have all of their COAs here, but you can,
you know, start to look at them. And once again, they've got the terpene values.
And so, okay, so why am I jammering on about all of this?
Well, there's a demand for COA data. So, you know, why don't we basically, you know,
give the people what they want. So, you know, what you can do is, you know,
you can at least find all of these COA links. So, you know, there's, we were just doing them,
finding them through crude manners. So, you know, people, so here's someone who bought some animal
tsunami. And sure enough, they posted their COA. You know, you can basically get the QR code,
then get the official COA. That's my recommendation, because as you can see, people's pictures
sometimes cut off portions of the certificate. So it's best if you can get the official URL,
you know, as we said, you know, go straight to the source. And then, you know, and then we can
basically work on COA parsing tools, because that's where people are around the world.
COA parsing tools, because that's what people are worried about, right? They're saying like,
oh, you know, what's going on with barnesine? And, you know, we've been interested in
limonene and, you know, beta pinyin. And it doesn't really make much sense to just
have to to plough through this COA. So, you know, why don't we basically do this with Python here?
So I'll go ahead and show you how we can do that. But before I do that, any thoughts, comments,
questions before we dive into this code here? Okay. Still with you all, right?
Yep. Okay, phenomenal. So I'll try to tie this, tie this all together and bring it home. So long
story short, you can start archiving some of these COAs. And this is just a little setup here. So,
as I said, we're going to use OpenAIs. So what we can do, well, right, we can find this PDF.
And so, right, so people are posting up their various PDFs here. And so this, this is just
a sample here that somebody tested this. See, it's a goo berry extraction. And this one was tested at
ACS laboratory. And so here's one, right, this one was at Keisha Labs. And I am working on it,
basically a parsing algorithm for for some of these, you know, Keisha certificates, and some of
these ACS certificates. But I started looking at some of this, some of the data, some of these
certificates. So I'll just show you some of the PDFs here. Here, I'll try to find one that's got
a large span of... So, right, here's, you know, like a more recent COA, a one to one CBD THC ball.
Interesting, you know, you can, you know, you're not going to see many terpenes in this ball.
But for some reason, they put in put in this one, a hexa, what's it say, hexa drothymol. So interesting.
But remember, this is a ball. The important thing on this one is just the CBD and the THC
concentrations. And but I realized, you know, not all these COAs are made the same. And, you know,
if you go way back in time, so here's a COA from either... So this looks like a COA from 2019.
And, you know, you don't have as much information. And in fact, you don't even have total THC or CBD
on this one. And as you can kind of see from like the file sizes here, like over time,
there's COA just, you know, gradually changed into, you know, what it is today. But some of the,
you know, the earlier ones are going to be a little different, right? So here's like an early
Caesia lab COA, where this one was in 2019. This one does have total cannabinoids on it,
which is what we're after, at least for some of our analyses, we would like terpenes too,
but at the minimum, we'd like to get cannabinoids. And so what I realized is, you know, it may not
actually make sense to write an algorithm to parse a particular COA, because the formatting's always
changing. And, you know, why is it changing? Well, because, you know, software developers like to be
continuously improving upon their code. And, you know, the laboratories would like to be, you know,
hopefully continuously improving their COAs, you know, to a certain extent. And so, you know,
they maybe they looked at this and they realized, oh, you know, we could add terpenes to it. And so
just over time, you can see, you know, more styling was done, various elements moved around on the
pages, which is, you know, fine and dandy, but it's going to make COA parsing super difficult. But
why should we let that stop us? Because, you know, at the end of the day, the data's there,
so remember, you know, never throw away any data. So this is sort of the problem we're faced with.
People want these lab results. They're there. They're right there on the web. The data is even
on the PDF. But as we said, it's basically locked and unobtainable. Like as we said,
the data is so close, yet so far away, right? You can get all the certificates and, you know,
people are diligently doing that here on Reddit, right? They recognize that the data is so close,
it's so close, let's at least get these URLs. And, you know, they did a noble thing there,
because it pointed us in the direction of them. And, you know, we've got some interesting
tools up our tool belt here. So without further anticipation, let's just go ahead and get into it.
So we've got the first page here of the certificate. So here's this crew clear syringe.
So remember, this is the ACS laboratory certificate for the true clear syringe.
Okay, so let's keep this in mind. So we basically just have all of the text from the front page.
Let me print this out nicely for you. This is just the raw text. So there's the true clear syringe.
You know, here's all the cannabinoid information. Oh, look, you know, there's farinezine.
Actually, just for fun, let's just go ahead and get farinezine. Okay, we'll just let AI deal with
the spelling on this one. So here's the
text. So what if we just tell you, remember, let's try an untrained chat GPT model and just say,
hey, you know, extract as many of these data points to JSON from the following text, right,
because that's basically the same data point that we're going to extract from the following text.
Right, because that's basically what you could tell a human to do. It would take them a long time,
you know, a handful of minutes, and they wouldn't love to do it. But you could tell a human, okay,
put the product name here, put the product type here, put the producer here, put the THC CBD and
some of these terpenes here, right. And then we would go through and we would say, okay, here's
farinezine, they want the farinezine percent, you know, it's 4.807. I'm going to give the model a
supplement prompt here. And I basically am saying only, or I say return only JSON and always return
at least an empty object if no data can be found. So I'm basically saying at least a few points,
so I'm basically saying at least return me something here. And let's just see what happens.
So there's a lot of things that can go wrong here. There's the connection error, hopefully,
you know, I'm streaming after all. So we may not want to expect this to be super speedy, but
as often with proof of concepts, they can always be refined. So the idea is you want to at least
make sure you can do something and then you can, you know, do it better and faster. And so check
this out. So we've got the product name, there's the true clear syringe. It did not get the product
type out of this. Unless it did, but here let's look at the COA real quick. So it didn't quite get
the sample type correct. So it's in sample matrix. Well, I don't know, that's debatable. So we'll
maybe have to try this out on more COAs, but the product type may have been a miss. It got the
producer as true leave. And for some reason, they put it in all capital letters, but I'm not sure why
it did that, but we at least have true leave right there. And check this out. Total THC, we've got 87.
Let me actually just try to put this side by side instead of going back and forth. Okay, so we're
looking for total THC of 80. Yep. So there's 87.66. Then we've got 0.303% CBD. Then we've got 0.099%
beta-pinene, 0.39% d-limonene, and check it out, even got the farnazine, the 4.807. And as I said,
it would be phenomenal to get every single last data point. And so I think we should work on that.
But I think we tried this in some prior weeks where we just tried to get the kitchen sink, and it
didn't quite work very well. I mean, it kind of did, but it was a little hit or miss. So this is
the GPT-4 model. So it's a slightly better model. I think last time we may have been using GPT-3 or
3.5. So it's a slightly better model. Maybe it's a better prompt. It's a different COA. So there's a
lot of things that we can tinker with here. So there's, as Rick was saying at the beginning,
there's a lot of moving pieces. This is kind of an arbitrary prompt. And so this is maybe where they
say people talk about prompt engineering. So I'll post this code. I should have done it before the
meetup, but I'll do it immediately after. And you can try to tinker around with this. So maybe you can
add...that would be an experiment. Just keep adding data points until maybe it breaks. So maybe it can
handle parsing them all. But that's something for you to experiment. And there's other parameters you
can toggle. The temperature is basically how creative you want the model to be. And I thought we
wanted it to not be creative. We don't want it making up answers. So that could be sort of another
check you could do. You could maybe make a query and you can say, is this number in fact in the
COA? So you could even say, oh, is this in the front page text? And it is. So that could potentially be
like various checks you could do after you parse it. Because remember, these are numbers. And it's
one thing for GPT to just turn out a paragraph that you send in an email. It's another thing for it to
turn out cannabinoid percentages that say medical patients in Florida are going to be using to make
purchasing decisions. So we may want to put a little bit of double checking in place to be pretty
certain about these numbers. And in fact, what people always kind of recommend with AI models is it
doesn't hurt to have somebody check them like a human at the end of the day. So what I was thinking
was we can work on the COA doc user interface and basically somebody could upload their certificate
here. We could try to parse it with COA doc or OpenAI and just try to get as many data points as
possible and then just suggest those to the user that, okay, this may be the answer. And then they
can either say yes or no. So you could then parse the COA. You can get this list back. And they may
say, yes, that's the product name. No, that's not the product type. Yes, that's the producer. Yes, yes,
yes, yes. So that way you can kind of have a human confirm this at the end of the day. Well, do you
want to see it put to use at scale? Or what are your thoughts on this one?
Show us if you got it. I'm excited to see what you've got up your sleeve.
Okay. Well, this one's here. I'll just get this one turning away and then let's go look at that other one.
So basically I just wrote this into a function. So this is just the exact work we did here, but just in a
simple function. So this is just the prompt. And so these are the things I think, right, this was just
almost like a throwaway prompt. This is just when I kind of just came up with this morning. But these
may be the things that people, these may be people's prized possessions. Just doing a little
demonstration with some of the image generation, it's all about the prompts. And so people are just trying to
figure out the right, right, that's X, right. You've got to think about this as a statistical function or
output is Y and this is X. So this matters a lot to people. And as I said, that's what statisticians have
fun about at lunch is talking about X, talking about what goes into the model and its parameters.
So you can spend a lot of time on this. Okay. But anywho, just the prompt and then all this is doing is
opening the PDF, getting the front page, formatting the prompt from the front page, then pinging open AI.
It's either going to fail or maybe the parsing fails. But you know, we're going to try to get the data at
the end of the day, because basically, this is what the content looks like. And then we can format that
into a nice tidy base on. So I'll just let this one rip here with I'm just going to do five COAs because I
had it run in full in another interpreter. And I'll basically show you the full results. Okay.
So unfortunately, this first one failed. And this is where a lot of trial and error is needed.
And that's why I encourage you all to to play with these prompts, because I've been kind of running this one
on and off. And it's weird because this first observation sometimes fails and sometimes succeeds.
Which is which is just completely strange and bizarre to me that, you know, you'd get, you know, two different
outputs from the same query, but it happens. So I would, you know, encourage you all to try to try to figure out
why that's happening. So that way we can fix it. But this is where I get into the what I the point I raised at the
beginning was, this is now imperfect. You know, we're definitely in the realm of statistics now, right?
We've got a non random sample. These are just certificates that people were posting non randomly in Florida.
So that's our sample we're working with. It's further biased because certain queries are failing.
So that's an unknown source of bias. So like, why are those are those queries failing?
And it may not actually be necessarily by well, actually, I forget if this is technically bought.
Actually, so there's different things that can happen in your statistics, right?
So if you have measurement error or missing observations, please research if that can lead to bias or not.
I don't know off the top of my head. I want to say that miscalculations can I forget if missing data can or not.
I want to say it may lead to bias. So that's some statistical homework for you.
But these are different concepts in statistics.
You know, bias is a statistical concept, you know, missing data and miscalculations or entry error.
Those are just characteristics of the data.
But here you see we got four out of five. So running around 80 percent, which is awesome.
Right. As I said at the beginning, I'd rather look at any data than no data.
So, you know, let's look at this. So that's the first step, right, is get the data.
Let's make sure I've got it here.
So there it is. And now let's visualize it.
And we've got some Khalifa Kush.
And it's so interesting because I just it's so strange how the world works with these little coincidences.
But I just shared a video with you all on Slack the last week about burner of cookies discussing some of the strains that he's tied to.
And he was saying that, you know, Wiz Khalifa wanted a strain and I think they just maybe, you know, branded maybe a really potent variety of the OG Kush as, you know, Wiz Khalifa's Khalifa Kush.
And, you know, just from what I was watching on the video, they were like saying that, like, you know, he wants to be the only one to grow this variety.
And that's awesome. Well, as cannabis data scientists, you know, we can kind of help at least characterize some of the rates.
So burners, the one who grew the strain, but we can, you know, help them with statistics.
So, you know, maybe or maybe not. They may not know it. Say the average rate.
Is this a Sativa or is this an Indica leaning strain into how much?
And so what we can do is we can look at some of our favorite ratios here. So here, I forget how this function works.
Just simple division.
Okay, let's take the mean.
So, remember, my rule of thumb is anything greater than 0.25 or anything greater than a one to four ratio of beta pinene to D-limonene.
I would think of as a Sativa. We were looking at, say, Durban poison.
And that's closer to a three to four or almost a one to one ratio. And that's when I think of a strong Sativa.
So the higher this number goes, typically, I think the more Sativa leaning it is.
And then the lower it goes, the more Indica it's leaning.
And from looking at a sample of this data, it was looking to me like maybe it's some strong, strong Indicas.
Maybe down towards like 0.1 or 0.15.
So to me, this one looks like it's on the Indica side, maybe not the strongest, like the heaviest Indica out there.
But that's how I would characterize this one.
And then here, here I've just parsed a bunch more. So there's a whole lot more parsing to be done.
So this is just the same script, but I just let it run on 57 strains.
Then we can plot all of these on the map.
So here you see these are ones that I would consider heavy Indicas.
So this one, look at this, they're even calling this one a MPX Sativa OSFG Live ROS.
Right. But that one is just kind of spitballing here.
It's around 0.16.
So it's interesting here because as we were saying, names may not always be perfect.
But to me, this looks like it's labeled the Sativa OSFG.
Double check this name for me, please. But this one's a Live ROS. And as I was saying, in my book, I would categorize that one as a strong Indica.
And I would kind of, you know, different people have their different tastes.
Some people seek out the Indicas.
And then, you know, personally, I'm just a bit more fan of the Sativa, but everybody's got their personal preferences.
So if I was shopping, you know, I would be looking for, you know, one of these like these yellow or green strains.
So, you know, I'd be looking for like, you know, one of these Califa cushions.
And so this is where I was getting into the fact, or remember we were talking about at the beginning.
One of the things we would like to start looking at would be phenotypes.
So what you can do here is you can just look at, hopefully.
Yes, so you can. There's a ton of them. So let's just do like a sample of.
Let's just look at 10 of them.
We'll just look at, actually that may have been too many.
So it looks like they're kind of clustering down there. Maybe it was enough.
It looks like the Califa cushions are clustering down, you know, down here towards, as I was saying, you know, more on the Indica side.
But it's just kind of interesting because, you know, now and again, you'll just have essentially a phenotype or phenotype.
So this is the Califa cush strain. But just for whatever reason, just something about that plant.
Maybe it was an environmental factor. Maybe it was a genetic factor.
If they're growing these from seed instead of clone, if they're all clones, then it must be some sort of environmental factor.
But something happened with these two varieties here.
And in my book, you know, they're just more on the Sativa side.
So maybe if, you know, say, you know, Wiz, Califa and Berner were trying to say branch this into two different product lines.
You know, they may be able to, you know, spin off, you know, a Califa Cush Sativa variety strain.
And they, you know, maybe they mix it with Durbin, right?
Maybe you mix this phenotype with the Durbin, that's, you know, Sativa with some of the Califa Cush attributes that you like.
And then maybe they just keep this phenotype around as their classic line.
Or maybe they would say, oh, this one doesn't match the typical Califa Cush that people are expecting in the market.
So maybe that one doesn't meet their quality control standards.
So, you know, there's a lot you can do with this from here.
But as I was saying, this is just a prediction, right?
We need to actually, I've got all the code up here.
So we've actually see this so strange, right?
Because look, this time, right, when I just ran this code for you over here, the first AI query failed.
But for whatever reason, when I ran it the first time, it succeeded and did give a result.
So as I was saying, you know, more work needs to be done to figure out, you know, why are these requests succeeding and why are they failing?
And, you know, are these results accurate?
So, for example, you know, this one didn't report any beta-pionine or delimiting.
And so what we can do is we can actually pull up that.
You can actually pull up this PDF.
And, you know, we can confirm if this thing has terpenes on it or not.
So here we have the NC, sure enough, it's got beta-pionine and it also has delimiting.
So this would be an inaccurate prediction.
So actually, 0.69.
Oh, wait, actually, hold on.
This one actually, maybe that wasn't the null one.
Maybe these ended up getting sorted somehow.
Okay, so these may not be in order, but let's see if I can find one with missing values.
Okay, so that may have actually worked out okay.
So once again, I'm going to go ahead and start wrapping up since I've gone way over time.
But I would encourage you all to basically, you know, we're going to have to start double checking these, right?
Because it's like if we're going to use this model to extract cannabinoid and terpene data,
then we want to have some measure of accuracy.
So I still think it would be a useful exercise to say parse these through a well-defined algorithm
that we know for certain is pulling all the terpenes and parsing them, you know, say to 99% accuracy
and then compare that to the OpenAI model.
And we would like this OpenAI model to, you know, approach.
It's probably never going to be 100% accurate,
but we would like it to at least approach 100% accuracy even if we never get there.
So that's the first step, I think, or a next step is figure out what exactly is the accuracy of this prompt slash algorithm.
And then, as I was saying, this takes a little bit of time here.
So, you know, this may have taken five to 10 to 15 minutes or so to parse 50.
And also, remember, there's a non-negligible price here.
So actually, I've kind of raked up a little bit of a bill this morning.
So through all of my development and parsing, so remember, you know, I parsed, you know, maybe 100 or so of these.
It has, you know, cost me about five bucks.
So once again, that's not the most in the world, but, you know, it's non-negligible.
But my philosophy is these are such small costs and the data is so valuable.
Surely, the marginal benefit exceeds these tiny marginal costs.
So we've got north of 15,000 COAs that we could potentially parse.
Don't have to do them all with AI, but check this out.
I'll just tie this off at the end of the day with remember at the beginning, why are we doing all of this?
Because somebody says, you know, can't we just get a universal COA site where we can say search and look at results?
Well, ask and you shall receive.
So I encourage you all to put this in your browser and smoke it.
And this is just a work in progress, but a this is an extreme work in progress.
So this is just a pure development version.
And so there's still a lot more work to be done, especially on the parsing front.
So I haven't incorporated the parsing yet, but this is just a retrieval tool.
But, you know, now if we start populating a database, this may have been too much to ask for.
OK, may have crashed. OK.
So as I said, there's more work to be done to make sure that the website doesn't crash.
And you can do cool things with this list, you know, like all the fun things people like to do, like sort, filter, search, download.
So right now it just has the this one doesn't I'm not sure if this is a valid PDF.
Oh, yeah. Check that out.
So here's just a rosin from from green scientific.
So, you know, this and the search algorithm I cooked up last night is is far from perfect.
So there's a thousand and one ways that this can be improved upon or just taking an entirely different direction.
So, Rick, you know, if you want to to work on, you know, an entirely different aspect, you're welcome to.
There's just this is just a demonstration that, hey, this data is there.
These are just links to PDFs that exist on the Web.
We can make these readily searchable.
And so now we can at least get these ways.
So now somebody can at least search and find a way.
Well, you know, now we have written just this morning an algorithm to actually parse this.
So once again, it's going to be a non zero cost.
But somebody could now try to parse this way, get the cannabinoids or the terpenes out of it.
And as I was saying, we may have to adjust the parsing algorithm.
Right. This one is just looking at the front page.
But as we see here, the front page contains some of the information,
but we'll have to go to some of the subsequent pages to actually get the terpene data.
So once again, this parsing algorithm is going to need to be tailored so that maybe you say iterate over all of the pages
until you've gotten all the data points that you're looking for.
And once again, we're only getting, say, two or three terpenes here.
Ideally, we could get all of the terpenes.
So we're going to have to do this in a way that's clever prompting to do.
So that's sort of the work that I've been tinkering on.
You know, I encourage you all to play out, play around with this tool because I populated this with, as I said, north of 15,000 COAs.
So that's why I'm kind of opening it up to you to kind of do development.
I'm trying to sort of get an estimation about, you know, what is the marginal cost of making all this data searchable, parsable.
And once it's parsed, then you'll have, you know, your nice data file here that awesome people like Rick and whoever.
So you can now finally use Panabinoid Terpene data, all the data on the certificate, to build rich models and find amazing insights.
So I encourage you all to play around with this.
Submit issues, grab your keyboard and contribute, clone the code and use it in your own projects.
Use it however you wish.
And then if you scroll down here, you're also free to contribute.
Because as I said, you know, I'm going to kind of be watching the usage here and I'm going to have to maybe think about, you know,
if I make this tool widely available, it would be, I may unfortunately either have to charge for the service
or if any of you want to contribute, then you're welcome to as well or run it on your own machine.
And, you know, as I said, there's going to be a cost there.
But as I said, there's a small marginal cost, but we've got the sources, we've got the methods, we've got the data.
Let's dive into the analysis.
So please feel free to contribute or explore or, you know, check out the GitHub and tinker to your heart's content.
Or at the very least, give the repository a star if this is something that you find useful.
What is everybody's thoughts, comments, questions?
I know it was a lot of material, but it seems like we've finally achieved or not achieved,
but we're finally starting to make progress on some tangible progress that people can put in their hands and use or put in their pipes and use.
Did anybody have any thoughts they want to share?
I needed that review, so thank you very much.
It was good to, you know, for my first time back up for a long time.
So thank you for that.
But I'll go through the GitHub again, as well as the videos like we talked about.
Thank you.
And there's a lot there, and as I would really want to drive home, this is more of a demonstration.
A lot of this needs to be perfected or if not perfected, probably, right, we can never get to 100 percent, but it can always be improved upon.
So that was just a first iteration of what a COA parsing prompt could look like or a lab results search could look like.
So these are all just a first iteration.
And as I was pointing out, there's many, many imperfections and things that can be improved upon.
So I encourage you all to use it, make it your own, tinker, explore, pester me if you want anything added to it or you want any data.
So I think there's a lot there.
We've just begun to explore.
Rick, comment, question?
No, I just wanted to say awesome presentation that I mean, you met or created a proof of concept, a really good one for a problem, a real problem, and use some cutting edge technology to do it.
I think that you're right.
You could improve the cost associated with it through like playing around with different models and stuff like that.
I've been doing some like computer vision training and stuff, which you might that might be an application for this as well in terms of like collecting specific stuff and parsing it in a format that you want consistently.
I'm going to take a look at the GitHub.
I haven't seen it yet, so I'm excited and I'll try to contribute as much as I can.
So thank you.
Oh, phenomenal. And remember, this is actually only a cost we technically have to bear once.
So once the COAs parsed, it's parsed.
And so that's where you were mentioning your vector databases.
And that's exactly what it can be used for.
Parse the COA once that may cost one or two cents or say five to ten cents or what have you through OpenAI, but then save that in your vector database.
So that way, if you see a PDF, remember we talked about hashes, it would be similar with a vector.
So as soon as you see a PDF, you create a vector for it, you see if that vector already exists in your database.
If it does, you can get the lab results without having to reparse it.
If it doesn't yet exist, then you, you know, you parse it and save it in your database.
So that could be a way you could save costs right off the bat.
Well, if there's fifteen hundred of them out there right now, I'll play around with saving them to my vector database and then let you know how it works out.
Is please I encourage you all to play play around with it.
And as I was showing you, I just started with a sample size of five.
And then as you saw, gradually worked up to a sample size of around fifty five.
So as I was I always mentioned, I'm a small sample guy.
You can do a lot with the small sample.
So I encourage you to put five of these observations or put fifty in your vector database.
If it proves useful, works well for your application, fill it up with fifteen hundred.
But as I said, the cost may get a little high.
But if there's value, I think hopefully there will be people out there who'd be willing to chip in a couple bucks to get their COA data.
Phenomenal. Thank you all for coming.
Your eyes, your ears, your attention. This is all moving the ball forward.
This wouldn't happen without you. So you're the ones who are really helping this actually happen.
And move everything forward. It's all the thoughts, the questions, the ideas that have happened throughout the whole cannabis data science meetup that's led us on this journey.
You realize people wanted COAs. You realize there was a way we could parse them, get the text out of them.
And we started exploring open AI tools and people wanted to learn more about those and learn more about terpene profiles and phenotypes.
It's just all of this ties together until we are where we are today, where we realize, oh, there's Florida patients.
They've been asking for their certificates like we encourage people to do.
There's finally a lot of these URLs that are available because companies are making them available.
That's my final point for today is we started asking and now we saw large companies like Cureleaf or putting these in VitaCann.
They're putting them out by the hundreds, if not thousands. And it's becoming popular.
So there's a company in Florida, The Flowery, and they do what's called COA drops.
And so every few weeks or month, they'll just drop, say, 20 to 60 COAs.
And that's their new inventory they're releasing at the store.
And it's brilliant because we were talking about these tests can run up to, say, 500 bucks a pop.
So if you tested 20 samples at 500 bucks a pop, that's like a $10,000 bill.
And instead of just eating that bill, you actually get to use it for your benefit.
So they're now using their COAs as a marketing tool. So they're like they're hyping it up.
They're saying, OK, we're going to drop the COAs. And then they release them.
And then everybody's excited about it. They're looking through them and they're talking about them on Reddit.
They're saying, like, oh, like, check this one out. This one's got this one's got a ton of D-Lemonine or oh, watch out.
This one's this one's a foreign bomb. So you can get quick feedback, get people excited for your products and use the lab result data to your advantage.
Instead of just letting the COAs accumulate dust on somebody's old dusty hard drive.
So I love it seeing companies putting this data to good use.
It's getting consumers excited about it. And because of all of you awesome cannabis data scientists,
we can add our piece to the puzzle and actually make the data readily accessible and analyzable.
So and then it's up to all of you to start drawing nifty little insights. So what is the average for Nizine that you can expect?
You know, what's the ranges on that? You know, what's the range on this beta pinin to D-Lemonine ratio?
Like what's the strongest sativa in the Florida market? And what's the strongest indica?
You know, you can start to discover these things and you know, you may find gold.
Too cool. I'll get all these links and material posted and available for you.
I encourage you all to to get in touch throughout the week, even if you want to use some of this material, you know, in your own projects or however you see fit.
You know, let's just keep working on this, because as I said, as soon as I discovered this, all of a sudden, you know, now there's a, you know, a thousand and one more things to do that we can just keep slowly and methodically tinkering on it.
Well, you need to go out and enjoy your day. I've kept you too long.
Thank you one more time for coming, helping advance candidate science.