On July 6, 2023, OpenAI made an announcement stating that the ChatGPT Code Interpreter model is now available for all ChatGPT Plus users.
What is Code Interpreter model?
Code Interpreter model provides an environment in ChatGPT where you can run Python code in a secure, isolated execution environment. This environment includes a restricted Python interpreter and temporary storage space.
The code you execute using Code Interpreter is evaluated within a continuous session that remains active during your chat conversation. You can also upload files to ChatGPT with this model.
Learn more: A Complete ChatGPT Guide, From 0 to Hero
It assists with tasks involving data analysis, image conversions, or code editing.
How to enable Code Interpreter model in ChatGPT?
To activate the ChatGPT code interpreter model, you need to be a ChatGPT Plus member. You can only use this model on desktop devices for now. Below, we have explained step by step how you can activate this model.
- Go to the ChatGPT website chat.openai.com.
- Log in to your account.
- On the homepage, click on the settings option in the menu on the left side of the screen.
- In the window that opens, enable the “Code Interpreter” option under the “Beta Features” section.
- Go back to the homepage or open a new chat window. Hover over the GPT-4 option in the model options at the top of the screen and select the Code Interpreter model to activate it.
Activating the Code Interpreter model is similar to enabling ChatGPT plugins.
How to upload a file to Code Interpreter of ChatGPT?
Once you’ve enabled the Code Interpreter in the settings section, uploading files becomes straightforward. You can follow the steps below:
- Open a new window and activate the GPT-4 model by selecting it.
- When the Code Interpreter model is active, you will see a plus sign (+) in the text box where we normally submit questions. Click on this plus sign to upload the desired file.
- Currently, we can only upload a single file. Once the file is uploaded, you can prepare your question or the sentence you want to work with related to that file and submit it.
How to use Code Interpreter model?
Now, let’s perform some example operations to demonstrate how to use this model.
Analyzing AirTravel.csv file
I have a CSV file named “Air Travel” that contains data about monthly transatlantic air travel passenger numbers (in thousands) for the years 1958-1960. The file has four fields: “Month”, “1958”, “1959”, and “1960”, with 12 records from “JAN” to “DEC”. The file includes an initial header line. My goal is to upload this file to the Code Interpreter and analyze it using ChatGPT.
The model quickly analyzed the file and provided information about the columns it consists of. It also gave the values within those columns, and the code snippet to read and process the data in Python.
Similarly, the model performed a detailed evaluation of the data in the file, conducting a comprehensive analysis using Python code. It provided mathematical statistics, such as mean, median, standard deviation, and other relevant metrics, to offer insights into the data.
I also aimed to calculate the percentage of data in this file that falls outside of statistical control, as part of advancing the analysis.
Now, I will use a different dataset. I will ask ChatGPT to create a graphical representation of my dataset and perform this task using Python.
Analyzing hurricanes.csv file
My new dataset is “hurricanes.csv”, which contains information about hurricane and tropical storm counts from 2005 to 2015.
Each record in the dataset consists of 13 values, including the month, historical average, and counts for each year from 2005 to 2015.
Let’s ask ChatGPT code interpreter to prepare a visual representation for this file.
I uploaded my data to ChatGPT and requested it to visualize the data. The Code Interpreter model successfully created visualizations for the data I provided in a short period.
We explained how to activate and utilize the Code Interpreter model in ChatGPT. This model allows us to upload files, request Python code generation, perform image conversions, and analyze large datasets.
With the ability to interpret and modify our code, this model enables us to quickly generate Python code and accomplish tasks like a data scientist.