Six ways to use ChatGPT code interpreter. Let's get started. OpenAI launched the new core
interpreter model to ChatGPT plus subscribers a week ago. It's based on the GPT-4 model, and now
you can upload files directly to it. No need of pasting text
into the chat box anymore. This model has access to a Python
environment, meaning it can execute code now, giving it some serious firepower. In this video, we are going to cover
basic to intermediate use cases. Here is a quick summary. Optical character recognition or OCR is a basic use
case for code interpreter. The Python environment has some
OCR libraries pre-installed. It can use these libraries
to extract texts from images. It works great on images of typed text,
but it's slightly off for handwritten text, which is understandable. Say you have pictures of a few invoices
and you want to extract the data in a csv. You can now do this easily. To test it out, we are going to run it
through an image of some handwritten text. As you can see, it is pretty
difficult to read anyways. Let's see how it goes
with the code interpreter. I'll upload the image and
ask it to OCR the image. All right. This is not looking quite right. Let's ask it to try again. Okay. It proposed a few techniques and
asked us to provide more context. We're not going to give it any context. Let's ask it to follow
the proposed techniques. Hmm. Slightly better but not accurate. At this point, I'm just going
to ask it to make an estimate. Awesome. Look at that. That is pretty darn accurate. It used "code" to find the text as best it
could and then used the "interpretation" to make sense out of the text it read. Okay, let's look at the next use case. One of my favorite things to do with code
interpreter is to clean a CSV I have. It's great for filtering rows,
generating columns, formatting data, and nearly everything you can think of. Say you want to upload your Shopify sales
report to an accounting software like QuickBooks, the formats never match. Now all you gotta do is paste the data
format that QuickBooks is expecting. And ask code interpreter to convert it. It's that easy. I'm going to pass this CSV to it and ask
it to perform the following operations: split the name into first and last
name, split the address into city, country, and the rest of the address. For date of birth, there are
multiple formats used in the file. I want to standardize that. And then lastly, create an age
column using date of birth. Okay. It started by reading CSV and
then figured out that there are no middle names in the name column. It then moves on to splitting it
into first, last and middle name. Then it figured out that the
date column is in two formats. And then converted it to
a standardized format. Moving to address, it states that
splitting addresses is tricky because their formats are not standardized,
but then quickly figured out that the last two words in the address column
are city and country, respectively. Oh, it couldn't figure out the city name. Seems like it is Bit tricky. Moving on, it created the age
column using date of birth. Now it's showing the
result in a table format. it seems to be okay, we don't
need to do any more operations. Let's ask it to export the csv now. Here is the resultant in csv. It is exactly as I wanted. Alright, let's move on
to the next use case. For me personally, analyzing data
has never been this much fun. I call it nql, the natural query language. You can upload data in csv, sql,
or any other format, and then ask code interpreter to analyze it. You can combine the data cleaning use case
with this one to get precise inferences. It is that easy. Say you run a Shopify store and
want to know which products have the highest drop rate at checkout, just
upload your products and checkout tables into code interpreter. And ask it questions in natural language. For this use case, we are going to
use the CSV we just cleaned and try to get some inferences out of it. First, let's ask it to read the csv. Now we'll ask it. How many people are above the age of 30? Okay, that was quick. Next, what is the average
salary of people from Europe? Hmm. It is saying that the country
column does not have the valid ISO codes, even though it actually does. It can hallucinate sometimes. Let's tell it that the country
column are valid iSO codes. Okay. It goes on to create a list of
ISO code of countries in Europe according to its existing knowledge. Alright, it finally figured it out. Next up, which country
has the highest earners? All right, Singapore. What is the median salary of
people under the age of 20? Cool. Now, is there a correlation
between age and salary? Okay. The CSV I uploaded does not seem to have
any correlation between age and salary. That was a breeze. Let's move on to the next use case. If you're a dashboard junkie,
you can now create custom dashboards that fit your needs. It can easily plot all kinds of graphs. You can also combine the previous use
cases to create filters on the fly. Say you have a Shopify store and you
want to visualize the sales report. Specifically the sales
versus discount aspect of it. The CSV report looks something like this. Let's run it through code
interpreter and ask it to plot a graph between sales and product. We want the sales versus product graph. Now let's ask it to plot the same graph,
but with the bar divided into two parts. One part showing the actual sales
and the other showing how much discount was given for that product. Nice. Next, showcase the trend of giving
of a discounts over time and also showcase the sales in the same graph. Hmm, this is unreadable. I'm going to ask it to do
a week on week aggregation. Yep, this is better. November is looking good for sales. Let's ask it to zoom on November
and shift to day on day aggregation. Okay, nice. Next, let's create a pie chart of sales
versus product for the top five products. Now let's see the same chart for November. Cool. Just to have some fun. I'll ask it to show the last two charts
side by side for easy comparison. All right. That looks good. I had too much fun doing this one. I hope it helps you as well. Alright, let's move on to the next one. As the name suggests, it can
help you with code as well. You can use it to understand code
and languages that you do not know. For this one, we are going
to use a Haskell file from Leksah's GitHub repository. Leksah is a Haskell IDE. We'll start by asking what
is happening in this file. Alright, so it explained the syntax
a bit and figured out that this is the entry point of the Leksah IDE. Next let's ask it to translate
the code into Python. Alright, looks good. Now like a programmer, we are going
to ask it to test its output code. Alright, it came up with a few
test cases and confirmed that the code works as expected. Awesome. Let's move on to the last use case Code interpreter can help you figure
out your spending patterns and hopefully help you save some money. I wouldn't ask it for
investment advice though. But nothing is stopping you to do so. To showcase this, I uploaded my own
credit card statement and asked it to analyze my spending behavior. Let's start with asking it to
create a pie chart of my spending looks good, but the miscellaneous
category is too big. This is because my bank does not
know categories of all businesses. If you look at the CSV row, you
can understand that this is a food and dining expense because of the
words cafe and espresso in it. So can GPT. Let's use that to our advantage. I'm going to ask it to look at description
and expanded detail columns, use its existing knowledge and try to figure
out categories for each transactions. And then draw by chart again. Hmm. It found some categories,
but nowhere close. I'm going to ask it to try to find more
company names and their categories again. Amazing. That is just magical. Imagine doing this manually, going
through each row and assigning a category and then drawing a pie chart. Using the code interpreter
makes it so easy. That is the power of large language
models, which no finance app can beat. Subscribe to the channel for more videos
related to practical applications of ai, and don't forget to like the video.