How I used ChatGPT to teach me data science

Swift
3 min readAug 16, 2023

--

When I was learning data science for the first time,

I wasn’t leveraging the tools around me properly.

ChatGPT and other AI models can help a lot with your journey.

So here are a few ways that I started using AI to help me learn data science.

(The AI model used in this example is ChatGPT-3.5)

Photo by Carlos Muza on Unsplash

1. Making data sets

There are many sites that provide you with data sets to use such as Kaggle.

But if you want something small to work with while you’re learning,

you can use AI to create it for you.

Prompt

Make me a dataset in SQL for the highest paying degrees

Output

-- Create the table
CREATE TABLE highest_paying_degrees (
degree_name VARCHAR(100),
average_salary DECIMAL(10, 2)
);

-- Insert data into the table
INSERT INTO highest_paying_degrees (degree_name, average_salary)
VALUES
('Doctor of Medicine (MD)', 200000.00),
('Doctor of Dental Surgery (DDS)', 180000.00),
('Pharmacist (PharmD)', 130000.00),
('Doctor of Optometry (OD)', 120000.00),
('Petroleum Engineering', 110000.00),
('Computer Science & Engineering', 100000.00),
('Nuclear Engineering', 95000.00),
('Electrical & Computer Engineering (ECE)', 90000.00),
('Chemical Engineering', 85000.00),
('Computer Science (CS)', 80000.00);

If you want a CSV file output:

Convert to CSV file

Photo by Lukas Blazek on Unsplash

2. Fixing code bugs

When you're new to learning a language, you could find it hard to deal with errors.

Before, you would need to copy the code, paste it to a site such as Stack Overflow, and wait for a response.

But now, just copy and paste the code to an AI model and ask:
What’s wrong with this code?

Prompt

why is this code wrong

SELECT degree, average_salary
FROM highest_paying_degrees;
WHERE average_salary > ?;
it says (Parse Error near “WHERE”: syntax error)

---add here

Output

The code provided has a small syntax error. The WHERE clause should come before the FROM clause in an SQL query. Here's the corrected version of the code:

SELECT degree, average_salary 
FROM highest_paying_degrees
WHERE average_salary > ?;

Much faster. And if you don't understand anything, just ask.

Photo by David Pupăză on Unsplash

3. Projects

So now you’ve learned how to analyze data,

let’s start with a project.

Prompt

Give me a data analysis project using SQL

Output

Sure! Here’s a data analysis project using SQL. Let’s assume you have access to a database containing information about an online retail store’s sales and customer data. The database has the following tables:

  1. orders: Contains information about all the orders made by customers. It includes columns like order_id, customer_id, order_date, total_amount, etc.
  2. customers: Contains details about the customers. It includes columns like customer_id, customer_name, email, phone, address, etc.
  3. order_items: Contains information about individual items in each order. It includes columns like order_item_id, order_id, product_id, quantity, price_per_unit, etc.

Your task is to perform a data analysis on this database using SQL queries. Here are some questions you can explore:

  1. Total Revenue: Calculate the total revenue generated by the online store.
  2. Top 10 Customers: List the top 10 customers who have spent the most money on purchases.
  3. Monthly Sales: Calculate the total sales for each month in the last year.
  4. Average Order Value: Calculate the average order value.

Now you have a project to work on for the next few days.

If you’re stuck, just ask the AI for help

Photo by Firmbee.com on Unsplash

Conclusion

Use AI to create a simple data set,

help you solve bugs,

understand concepts,

and give you a project to work on.

--

--