ChatGPT Code Interpreter: An In-Depth Analysis of OpenAI's New Tool

Written by Ivana Kotorchevikj We Tested

Linkedin - 12 min read

OpenAI has been providing us with numerous updates lately. One of their most recent and thrilling announcements is the launch of their Code Interpreter plugin.

The Code Interpreter plugin was initially introduced in Alpha mode a few months ago. However, OpenAI took a step further last week by releasing it in Beta mode exclusively for ChatGPT Plus subscribers. This plugin expands the capabilities of ChatGPT and provides users with essential options they have been longing for.

With the plugin, users can effortlessly tackle mathematical problems, analyze data, generate charts, and convert files into various formats, among other functionalities.

OpenAI made the official announcement about the Code Interpreter release on their Twitter profile:

https://twitter.com/OpenAI/status/1677015057316872192

In this post, we’ll dive into how to enable the ChatGPT Code Interpreter and show you how to use it to interpret code, analyze data, and upload datasets. We’ll also ask the Code Interpreter to do some interpretations and predictions and analyse the results.

Important: OpenAI has renamed the Code Interpreter feature into Advanced Data Analysis, and added more functionalities to it. They also removed several features, so these are a few things to be aware of for the Advanced Data Analysis feature in ChatGPT:

  • Internet Access: The environment doesn't have internet access, so any functions that require external web requests or API calls will not work.
  • Runtime Limit: There's a time limit for code execution, so long-running code snippets might be truncated or might time out.
  • Persistent Storage: The drive at '/mnt/data' can be used to save and persist user files, but it's temporary for the session.

Apart from these considerations, the main purpose of the enhanced environment is to offer more tools and flexibility in data analysis.

How to enable ChatGPT Code Interpreter

Keep in mind that to be able to use ChatGPT Code Interpreter, you must have the Plus subscription, which will cost you $20 a month.

If you have the subscription, you can start using the ChatGPT Code Interpreter with the following steps:

  1. Open the ChatGPT website.
  2. Click on the three dots in the bottom left corner.
  3. Click on ‘Settings,’ and a popup will appear.

Click on ‘Settings.’

  1. Select ‘Beta features.’

Select ‘Beta features.’

  1. Enable Code Interpreter with the toggle on the right and close the popup.

Enable Code Interpreter

  1. Next, open a new chat, click on the GPT-4 button in the top menu, and select 'Code Interpreter.'

What is ChatGPT Code Interpreter- Explained by ChatGPT?

We asked ChatGPT itself to explain what the ChatGPT Code Interpreter is and what it can do:

“The new code interpreter in this environment is designed to execute Python code securely. Here's what it can do:

  1. Execute Python code: You can run Python code snippets, and the interpreter will execute them and return the results. This includes most Python functionality, like defining and using functions, classes, and modules.
  2. Stateful Execution: The interpreter maintains state between different code snippets, meaning you can define a variable or function in one snippet, and then use it in a subsequent snippet.
  3. Data Analysis & Visualization: The interpreter can execute code that involves data analysis and visualization. It supports libraries such as pandas for data manipulation, matplotlib and seaborn for data visualization, and scikit-learn for machine learning.
  4. File Handling: You can read from and write to files within the '/mnt/data' directory. This can be used to persist data between sessions or to load data for analysis.
  5. LaTeX Rendering: Math expressions can be rendered using LaTeX syntax.

However, please note the following limitations:

  • The interpreter doesn't have access to the internet, which means it can't make API calls, fetch data from the web, or use libraries that require internet access.
  • It can't execute code that requires user interaction (like input() calls).
  • It can't execute system commands or access parts of the file system outside of the '/mnt/data' directory.”

What ChatGPT Code Interpreter is and what it can do?

What is Python, and what is Pandas?

Python is a programming language. It can be used for a lot of things, but in this context, it is good to know that it is the most popular language for data analysis and is used in a lot of science education institutions and universities.

Under the hood, ChatGPT Code Interpreter also uses Pandas. Pandas is an open-source data analysis and manipulation library for Python. You can analyze large datasets and generate charts from them. With the Code Interpreter, you can also analyze data, ask ChatGPT what the data is about, and even run your Python code.

Here's a simple example of using Pandas:

example of using Pandas

How to use Code Interpreter with datasets

Now, let's try out the interpreter with an example dataset.

There are many websites you can use to find a dataset. For the sake of the text, we used a Seattle weather dataset from Kaggle.

a Seattle weather dataset from Kaggle

You can also upload a dataset file to ChatGPT to analyze it with the Code Interpreter. Here’s how to do it:

  1. Open a new chat in ChatGPT and make sure you have selected Code Interpreter.
  2. Click on the little ‘plus’ icon in the chat field on the right.

Click on the little ‘plus’ icon

  1. Once the file is uploaded, you can submit it to ChatGPT by hitting the ‘Send message’ icon.

click the ‘Send message’ icon.

  1. If you haven’t given any context, ChatGPT will ask you what to do with it.

ChatGPT will ask you for context

For this experiment, we asked to explain what the file was about, and ChatGPT gave a simple summary of the columns in the CSV file and asked if we wanted to know anything specific.

👉 Bonus read: How to Use DAN ChatGPT And Does It Really Work?

Further, we asked ChatPT if it could notice any trends in the data. As a response, ChatGPT provided a nice set of charts generated with another widely used Python package matplotlib, and a summary of its interpretation:

ChatGPT provided charts generated with widely used Python package matplotlib

  1. “Precipitation: There seems to be a pattern in precipitation which may be related to the changing seasons. There appear to be periods with higher precipitation, possibly corresponding to the wetter seasons, and periods with less precipitation, possibly corresponding to the drier seasons.
  2. Maximum Temperature:
  3. Minimum Temperature:
  4. Wind Speed:

On top of the response, you can see a little button saying, ‘Show work.’ Once you click on it, you can see the Python code that is used to generate the charts:

'Show work' button

Next, we asked ChatGPT if there were any noticeable yearly trends.

We asked ChatGPT if there were any noticeable yearly trends.

Once the processing was done, ChatGPT provided a new set of charts and a summary of the results.

ChatGPT provided a new set of charts and a summary of the results.

Additionally, ChatGPT Code Interpreter gave the following assessments:

  1. “Average Yearly Precipitation: The average yearly precipitation shows some variation, but there doesn't appear to be a clear upward or downward trend.

  2. Average Yearly Maximum Temperature: There is some fluctuation in the yearly maximum temperature. However, without a longer time series, it's difficult to discern a clear trend.

  3. Average Yearly Minimum Temperature: Similar to the maximum temperature, the minimum temperature also shows some variation from year to year.

  4. Average Yearly Wind Speed: The average yearly wind speed appears relatively stable over the years.”

The assessment is a bit disappointing. The charts above show a clear increase in the Average Yearly Maximum Temperature and Average Yearly Minimum Temperature, but ChatGPT doesn’t mention that in the assessment.

Therefore, we asked ChatGPT to give a more specific answer about the results:

What can you explain about the changes in temperature?

Surprisingly, ChatGPT answers that there is no notable change in temperature, while the charts clearly show us something different.

“What can you explain about the changes in temperature?”

This time, we asked ChatGPT directly for an explanation:

You say there is no clear upward or download trend in the temperature, but to me, it looks like there is a clear upwards trend in the minimum and maximum temperature?

Finally, we get a different result!

Code Interpreter now generates a new visualization and corrects its mistake:

“The linear regression analysis provides some interesting insights:

  1. Maximum Temperature: The slope of the regression line for the maximum temperature is approximately 0.74. This suggests that, on average, the maximum temperature has been increasing by about 0.74 degrees Celsius per year. The p-value is approximately 0.009, which is less than 0.05, indicating that this upward trend is statistically significant.
  2. Minimum Temperature: The slope of the regression line for the minimum temperature is approximately 0.51. This suggests that, on average, the minimum temperature has been increasing by about 0.51 degrees Celsius per year. The p-value is approximately 0.042, which is less than 0.05, indicating that this upward trend is also statistically significant.

These results indicate that there has been a statistically significant upward trend in both the maximum and minimum temperatures over the years covered by this dataset. I apologize for the earlier confusion, and I appreciate your patience and keen observation. Is there anything else you would like to explore in this data?”

🚀 📊 Learn how to integrate and use ChatGPT in Excel.

Conclusion

While the ChatGPT code interpreter looks promising, it has some work to do. As is seen in our first try, the analysis was far from correct and proved that you should always draw your own conclusions. Only after pointing the ChatGPT Code interpreter to its clear mistake was it possible to draw a tight conclusion. We do like the apology we got with it 🙂.

The article is written by Martijn van Nieuwenhoven, Owner of The Code Connectors, and edited by Ivana Kotorchevikj, Content Writer at the Code Connectors - Neural Network Press.