• Practical AI
  • Posts
  • More Than Words - OpenAI's Code Interpreter

More Than Words - OpenAI's Code Interpreter

Understanding OpenAI's Code Interpreter for data analysis super powers

Hey there, teammate! Welcome to the next edition of the most practical newsletter on AI in the world!

Each week, I'll cut through the noise surrounding AI to serve you practical insights that not only help transform your business but also empower you, the business leader, to evolve into a data-driven, AI-enabled visionary.

The AI noise is constant and loud, and you are here for a quiet meal of AI goodness, so let’s get right to it! Bon Appetit!

Today’s Menu:

More Than Words - OpenAI’s Code Interpreter

Action Item - Analyzing Your Favorite Spreadsheet

Learning Cube - Python, Data Analysis Techniques

Tool Spotlight - Looker Studio

Cool Factor - Code Interpreter vs Professional Data Analyst

July 11, 2023

The other day OpenAI released into Beta its Code Interpreter. As you can see from the image at the top of this newsletter, you enable it from your Settings if you are a ChatGPT+ subscriber.

And it is one of the coolest features yet!

It is SO MUCH MORE than its name makes it seem. Yes, under the covers it is a code interpreter…it can read, understand, create and run code for you. It is super powerful!

But it is done without you having to know a single bit of code! In fact, the code it creates is hidden away and you have to expand it to see it!

I uploaded a CSV file of membership data for a gym, and told it to create a bar graph of the new memberships by month for 2023. I did NOT tell ChatGPT what the file structure was, what the data was, how things were related, etc.

Nada. Just “Here’s the data, ChatGPT…see what you can get out of it”

As it figured things out, it generated the code to determine how to read the file, how to extract the data, how to interpret the data, and finally how to graph the data.

As you can see here, it did a great job for a first pass, all in under one minute! Even if I knew every bit of the code by heart it would have taken me longer than that to type it all in!

Took in a CSV file and created a graph out of it!

What is neat is you can see the thought process happening as it does color commentary about what it is solving as it goes.

Each place where it built code you can click on “Show work” and it will drop down the actual code built for the job, and its results:

Showing the code ChatGPT created to do the job, plus the results

As you can see, it created Python code, executed it, and gave the results too.

The graphing is done using a Python library (matplotlib) made for doing graphing and plotting. The bar chart code is so straight-forward:

Bar chart code is so small yet so powerful

I can easily ask it to use month names instead of month numbers:

Notice that it only needed to run ONE block of code this time, since it already held all the other information from earlier in the chat.

Now THAT is cool!

Check out this cheat sheet from Pete Huang that shows even more of what this powerful new tool can do right within ChatGPT! (Yes, yes, I realize Tool A and Tool B and several others already do all this and more…but this is within ChatGPT and is great for when you want a quick and dirty look at your data or documents. Keep finding the tools that suit you best, for sure!)

Today’s Action Item and Tools sections should help you add this sort of power to YOUR day!

Want to feature your service or product in the world’s most practical AI newsletter? Email me at [email protected] for more information.

Action Item

Analyzing Your Favorite Spreadsheet

If you are a ChatGPT+ subscriber, you can use the Code Interpreter right now!

1) Go into Settings
2) Go to the Beta Features
3) Enable Code Interpreter. Easy as that!

Open up a new chat, and mouse over the GPT-4 model to show the Code Interpreter choice. Click it and your prompt will use that model. Also easy!

Click on the plus button on the left side of your prompt box, and you can upload a file to work with! The best ones are CSV or XLSX files (comma-separated or Excel files) for doing data analysis.

JSON data files are also fantastic, and are the default type of data that comes back from APIs. Keep this in mind if you want to explore some external data, as you can have the external data source throw their results to the screen, where you can download it as a file. Then you can upload the file into ChatGPT and analyze the data…to me THIS is the hidden superpower of the Code Interpreter.

Important side note: I build DataGrabs to help people get the JSON data from APIs without having to know how to connect to an API, write all sorts of code, etc. I do all the heavy lifting, and you get a simple web address to hit that will return the data to you. For example, to get a stock quote you would just call:
https://api.gimmee.io/datagrab/stock/quote/|
Contact me for more info on getting DataGrabs into your world!

Once you’ve uploaded a file, you can then begin using prompts to analyze the data found in it.

Just like you would with regular prompts, just ask ChatGPT anything you can think of! Don’t hold back, there are no mistakes here. Nothing happens to the data, nothing can go wrong, and Chat won’t laugh at you and your requests.

Use my example above with a memberships file as a starting point.

  • Think of the RESULT you want first…is it a bar graph, scatter plot, bullet points?

  • What data do you want in it, and how do you want it grouped or categorized? Don’t think x and y axis unless you are fine-tuning the look. Just ask it to show you a type of chart, of a certain type of data, grouped by something else in the file. Use natural language!

  • It will have to think through things and it might take a couple of tries of prompts to get what you want.

  • Experiment like crazy! Never done a scatter plot? Not sure what it would give you? Try one! Just ask for it!

    • This is a great way to experiment over your data to get insights you never knew were possible.

    • Use the cheat sheet above for some ideas

The file you upload only remains for the length of the session. That means that you can keep using that file until you are done with that chat. If you try to come back tomorrow and pick up where you left off, that file will no longer be there.

So, you need to plan out your use of the results or you may find you need to redo things.

Learning Cube

Python

The more you get into AI, the more you will hear about Python. It is a bigger subject than I can fit into one Learning Cube, but it is worth mentioning and really worth your time to dig into it more.

Python is a programming language that is all about scripting. You write scripts to do things…all sorts of things. You can write entire applications in Python, and you can write short, powerful, task-oriented scripts.

Python is the most widely used language in AI tools and code samples. If you will be going beyond the basics in AI tooling, you will be using Python. And Python is what ChatGPT is using behind the scenes in the Code Interpreter!

I have programmed for decades and only recently learned Python due to all of its use in the AI field. And I had ChatGPT teach me! I still ask ChatGPT to fill in the gaps of my learning every week!

Python works by using libraries of code that you attach into your program. Think of it like getting dressed in the morning for work. Your goal is to wear work clothes for an important meeting. So you go to your closet and ignore the bowling shirt and sandals, and go for one of several classy outfits you have.

The sandals are a library, the bowling shirt is a library, etc. Each “library” has things you can do with it that are specific to that thing. Sandals might be slip on only…not good if you want to adjust them. So you can get another pair of sandals (another sandals “library”) that meets your needs for sandals.

But for a fancy work meeting, you won’t use the sandals “library” at all, right? So you start with the end result, and find the pieces that will make that end result possible. The concept is the same whether you are getting dressed, or building an application or mini-program.

One of the best ways to learn Python, is to ask ChatGPT to teach you! And the best things to ask are specific to some result you want to achieve.

  • “Please create code to open and read a PDF file I have on my local machine, and explain the code to me”

  • “Please create a chatbot that can read from an Excel file I have in a Google Drive, and explain the code to me”

Chat will do what you ask and will explain the code well. If you don’t understand the explanation, ask it to explain it to a newbie. Keep asking questions until you get satisfactory results. Absorb the learnings and things will get easier.

But when dealing with Python, let ChatGPT build the code! And let it teach you how to run it, where to deploy it, how it works, etc. Just like I do!

Data Analysis Techniques

Data analysis is a crucial component of practical AI, enabling you to extract valuable insights and make informed decisions. Here are a few key techniques to consider:

1. Data Cleaning: Before diving into analysis, it's important to ensure that your data is clean and free from errors or inconsistencies. This involves removing duplicates, handling missing values, and addressing any outliers that may skew your results. With Code Interpreter it is easy to just upload a file and take the results as is…be aware that your results are only as good as the data you feed it.

2. Descriptive Statistics: Descriptive statistics provide a summary of your data, giving you a snapshot of its central tendencies, dispersion, and distribution. The ChatGPT Code Interpreter can assist in calculating basic statistics such as mean, median, mode, standard deviation, and percentiles.

3. Exploratory Data Analysis (EDA): EDA involves examining your data through visual and statistical methods to uncover patterns, relationships, and anomalies. The ChatGPT Code Interpreter allows you to generate visualizations like histograms, scatter plots, and box plots, aiding in identifying trends and making initial observations.

4. Correlation Analysis: Correlation analysis helps determine the relationship between variables in your dataset. By using the ChatGPT Code Interpreter, you can calculate correlation coefficients, such as Pearson's correlation coefficient, to understand the strength and direction of the relationship between two variables.

5. Hypothesis Testing: Hypothesis testing allows you to make inferences about your data and assess the significance of observed differences. The ChatGPT Code Interpreter can help you perform statistical tests, such as t-tests or chi-square tests, to validate or reject hypotheses. You can avoid the technical jargon and just ask for ChatGPT’s observation on differences between two things. It will do a decent job of starting you down that road.

6. Machine Learning Modeling: With the power of AI, you can leverage machine learning algorithms to predict outcomes or classify data. The ChatGPT Code Interpreter can assist you in implementing and evaluating various models, such as decision trees, logistic regression, or neural networks. Obviously this gets more technical and you may not be ready for this, but the tool can be used for simple and complex tasks nicely. As you get into ML modeling, consider using the Code Interpreter and ChatGPT to lead the way.

Remember, these techniques provide a starting point for your data analysis journey. Experimentation, iteration, and domain expertise are essential for unlocking the full potential of your data. The ChatGPT Code Interpreter and its data visualization capabilities act as powerful tools in this process, allowing you to explore, analyze, and communicate your findings effectively.

Tool Spotlight

Looker Studio

Google's Looker Studio is a powerful data analysis tool that integrates seamlessly with Google Sheets, enabling you to perform advanced analytics and visualization tasks. Similar to what Code Interpreter can give you, but it gives you something more meaty. Looker Studio is a decent (and free) starting point for more advanced analytics.

It is good when you want a multi-page dashboard of information at your fingertips. It does a great job of taking a period of time and comparing it to a previous period of time. Here is a screenshot of one page of an eight-page dashboard for one of my clients. This page enables them to be data-driven in their decisions in their business:

One page of a Looker Studio dashboard hitting a Google Sheet

Here are some key points to understand about Looker Studio and its capabilities for data analysis on Google Sheets:

1. Data Exploration: Looker Studio allows you to connect your Google Sheets data directly to the platform, providing a robust interface for exploring and analyzing your data. You can easily navigate through different sheets, tabs, and ranges to gain insights and understand the underlying patterns.

2. Drag-and-Drop Visualizations: With Looker Studio, you can create stunning visualizations effortlessly by simply dragging and dropping fields from your Google Sheets dataset. The tool offers a wide range of visualization options, including bar charts, line graphs, scatter plots, and more, enabling you to present your data in a meaningful and visually appealing manner.

3. Interactive Dashboards: Looker Studio enables the creation of interactive dashboards that can be shared with others. You can design custom dashboards containing multiple visualizations, filters, and drill-down capabilities to facilitate data exploration and collaboration. Users can interact with the dashboards to gain deeper insights and make data-driven decisions.

4. Data Blending: Looker Studio allows you to blend data from multiple Google Sheets or other data sources, providing a consolidated view for analysis. This feature is particularly useful when you need to combine data from different sheets or integrate data from external systems for a comprehensive analysis.

5. Data Refresh and Scheduling: Looker Studio provides options for automating data refreshes and scheduling updates. This ensures that your analysis remains up-to-date, and you can easily track changes over time without the need for manual intervention.

6. Collaboration and Sharing: Looker Studio facilitates collaboration by allowing you to share your analysis, visualizations, and dashboards with others. You can control access permissions, collaborate in real-time, and enable stakeholders to interact with the data directly, fostering a data-driven culture within your organization.

Looker Studio brings advanced data analysis capabilities to Google Sheets, empowering you to uncover valuable insights and make data-driven decisions. By leveraging its intuitive interface, drag-and-drop visualizations, interactive dashboards, and collaborative features, you can transform your Google Sheets into a robust analytical platform, unlocking the full potential of your data.

If you are interested in learning more about what Looker Studio can do to help you be more data-driven, I’d love to hear more about what your specific situation looks like!

Cool Factor

Code Interpreter vs Professional Data Analyst

This week Brian Julius, a professional data analyst, squared off with Code Interpreter to see what the comparisons were between a solid human skill and a new AI. His results were eye-opening!

He used a standardized “workout” that is used to test data analysis skills. It has you analyze restaurant tip data from a public-facing test dataset.

The results of the test were very similar between Brian and Code Interpreter! It even shows that Code Interpreter thinks about the best ways to view the data and doesn’t always show it the way you might show it. In the following case, Brian found Code Interpreter’s results to be better!

Brian was impressed with the results. I found it interesting that it took him, a seasoned professional, 30 minutes to come up with all of the results of the workout, while Code Interpreter did it all in under 5 minutes.

Not that this will replace humans anytime soon, but it sure leads to the thought that you can speed up your data visualization to make decisions quicker even if you don’t have a professional data analyst on staff, or a math bone in your body.

As you grow in your business, you will need to be data-driven, and results like this show it is possible to get great results with a tool built into ChatGPT. At some point in your transformation to be data-driven, you will need a data analyst to handle all the data you accumulate and want to study. But in the meantime, don’t hesitate…start using this!

Feature your service/product in the world’s most practical AI newsletter

Practical AI is the world’s most practical AI newsletter with subscribers from many different industries and countries, all looking to make use of tools and services to bring AI into their businesses. You can book your ad spot by emailing me at [email protected]

In Closing…

What did you think of this week’s newsletter?

Your feedback helps me create better content for you!

Just reply back to this, or email me directly at [email protected], and let me know what you think:

  • 5 Stars - Loved It!

  • 3 Stars - Meh…not bad

  • 1 Star - This sucks

If you want to sign up for this newsletter or share it with a friend, you can find us right here

Thanks for reading. Let me know if you applied anything from this newsletter!

See you next week!

Greg