How can ChatGPT help Data Scientists in day-to-day tasks – 2024

Hey, guys in this blog we will see how can ChatGPT help Data Scientists with day-to-day tasks. ChatGPT can help Data Scientists in day-to-day tasks by providing suggestions, guidance, and solutions to various challenges and tasks they might encounter.

ChatGPT can assist Data Scientists in various aspects of their day-to-day work, such as data cleaning, exploration, modeling, and visualization, by providing suggestions and guidance based on their knowledge and experience in these areas. So without any further due, let’s do it…

1. ChatGPT can write code.

ChatGPT can assist you in writing code but cannot write the entire code for you. You can provide instructions for what you want to achieve, and ChatGPT can provide suggestions or code snippets that can help you achieve your goal. However, it is important to note that the code generated by ChatGPT may not always be error-free or optimized for your specific use case, so reviewing and testing the code thoroughly before using it in a production environment is recommended.

Examples:

Prompt: “Write a code in Python to print the Fibonacci series”.

n = int(input("Enter the number of terms: "))

# initialize the first two terms of the series
a, b = 0, 1

# check if the number of terms is valid
if n <= 0:
    print("Invalid input")
elif n == 1:
    print(a)
else:
    # print the first two terms
    print(a, b, end=" ")
    # loop through the remaining terms and print each one
    for i in range(2, n):
        c = a + b
        print(c, end=" ")
        # update the values of a and b for the next iteration
        a, b = b, c

Prompt: “Write a code in Python to find the factorial of a number using recursion”.

def factorial(n):
    # base case
    if n == 0:
        return 1
    # recursive case
    else:
        return n * factorial(n-1)


# find the factorial of 5
result = factorial(5)
print(result)  # output: 120

Prompt: “Write a code in Python to check if a number is an Armstrong number or not.”.

num = int(input("Enter a number: "))

# calculate the number of digits
num_of_digits = len(str(num))

# calculate the sum of the cubes of each digit
digit_sum = 0
temp = num
while temp > 0:
    digit = temp % 10
    digit_sum += digit ** num_of_digits
    temp //= 10

# check if the sum equals the original number
if num == digit_sum:
    print(num, "is an Armstrong number")
else:
    print(num, "is not an Armstrong number")

Below is the explanation it gave for this prompt…

ChatGPT help Data Scientists

2. ChatGPT can debug code.

ChatGPT can assist in debugging code by providing suggestions or insights based on the information provided. However, it is important to note that debugging code requires a deep understanding of the programming language, its syntax, and its common errors. While ChatGPT has knowledge of programming languages, it may not have the same level of expertise as a professional programmer or developer.

Therefore, if you are facing issues with your code, it is recommended to seek the help of an experienced programmer or developer who can provide more accurate and efficient debugging solutions.

Examples:

Prompt:

ChatGPT help Data Scientists

Response:

ChatGPT help Data Scientists

3. ChatGPT can explain code.

Yes, ChatGPT can explain code by breaking it down into smaller parts and providing an overview of what each part of the code does. You can provide the code you want to understand, and ChatGPT can provide explanations for the different parts of the code, including syntax, variables, functions, and control flow. However, it’s important to note that ChatGPT’s explanations are based on its knowledge of the programming language and the context in which the code is used. Therefore, it may not always provide accurate or complete explanations, especially for complex or highly technical code.

Examples:

Prompt:

ChatGPT help Data Scientists

Response:

ChatGPT help Data Scientists

4. ChatGPT can create Machine Learning Models.

Yes, ChatGPT can help create machine learning models by providing guidance and suggestions based on its knowledge of machine learning algorithms and techniques. You can provide the problem statement and the dataset, and ChatGPT can suggest suitable machine-learning algorithms to use, as well as the necessary steps for data preprocessing, feature engineering, model training, and evaluation.

However, it’s important to note that while ChatGPT can provide valuable insights and suggestions, it’s still up to the user to decide which approach or algorithm to use and how to fine-tune the model for the best performance. It’s also important to validate the results and test the model thoroughly before using it in a production environment.

Examples:

Prompt: “Create a machine learning model which takes a person’s height and weight and predicts its BMI.”.

Response:

import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression

# create a sample dataset with height, weight, and BMI
data = pd.DataFrame({
    'height': [170, 165, 180, 175, 160, 185],
    'weight': [60, 55, 70, 65, 50, 75],
    'bmi': [20.8, 20.2, 21.6, 21.2, 19.5, 21.9]
})

# split the data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(data[['height', 'weight']], data['bmi'], test_size=0.2, random_state=42)

# train a linear regression model
lr = LinearRegression()
lr.fit(X_train, y_train)

# make predictions on the test set
y_pred = lr.predict(X_test)

# evaluate the model performance
mse = mean_squared_error(y_test, y_pred)
print('Mean Squared Error:', mse)

Below is the explanation it gave for this prompt…

ChatGPT help Data Scientists

5. ChatGPT can create dummy data.

Yes, ChatGPT can generate dummy data based on specific criteria or requirements. For example, you can provide the number of rows, columns, and the data types for each column, and ChatGPT can generate a dummy dataset with randomly generated values that match the given criteria.

Examples:

Prompt: “Create dummy data having 3 clusters, ranging from 0 to 1 and having 3 dimensions. The data should have 500 rows”.

Response:

from sklearn.datasets import make_blobs

# generate dummy data with 3 clusters, ranging from 0 to 1 and having 3 dimensions
X, y = make_blobs(n_samples=500, centers=3, n_features=3, random_state=42)

# print the shape of the data
print("Shape of X:", X.shape)
print("Shape of y:", y.shape)

Below is the explanation it gave for this prompt…

ChatGPT help Data Scientists

6. ChatGPT can create basic UI apps using HTML, CSS, and Javascript.

Yes, ChatGPT can provide guidance and suggestions for creating a basic UI app using HTML, CSS, and JavaScript. Here’s an example of a simple web page that displays a “Hello, World!” message using HTML, CSS, and JavaScript.

Examples:

Prompt: “Create a basic calculator app using HTML, CSS, and Javascript”.

Response:

HTML Code

<!DOCTYPE html>
<html>
<head>
	<title>Calculator App</title>
	<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
	<div class="calculator">
		<div class="display">
			<input type="text" id="result" disabled>
		</div>
		<div class="buttons">
			<button onclick="clearScreen()">C</button>
			<button onclick="backspace()">&larr;</button>
			<button onclick="addToScreen('%')">%</button>
			<button onclick="addToScreen('/')">&divide;</button>
			<button onclick="addToScreen('7')">7</button>
			<button onclick="addToScreen('8')">8</button>
			<button onclick="addToScreen('9')">9</button>
			<button onclick="addToScreen('*')">&times;</button>
			<button onclick="addToScreen('4')">4</button>
			<button onclick="addToScreen('5')">5</button>
			<button onclick="addToScreen('6')">6</button>
			<button onclick="addToScreen('-')">&minus;</button>
			<button onclick="addToScreen('1')">1</button>
			<button onclick="addToScreen('2')">2</button>
			<button onclick="addToScreen('3')">3</button>
			<button onclick="addToScreen('+')">+</button>
			<button onclick="addToScreen('0')">0</button>
			<button onclick="addToScreen('.')">.</button>
			<button onclick="calculate()">=</button>
		</div>
	</div>
	<script src="script.js"></script>
</body>
</html>

CSS Code

.calculator {
	margin: auto;
	padding: 10px;
	border: 1px solid #ccc;
	width: 200px;
	text-align: center;
}

.display {
	margin-bottom: 10px;
}

input[type=text] {
	width: 100%;
	padding: 10px;
	box-sizing: border-box;
	border: 1px solid #ccc;
	border-radius: 4px;
	background-color: #f8f8f8;
}

button {
	width: 40px;
	height: 40px;
	margin: 2px;
	font-size: 18px;
	cursor: pointer;
	background-color: #f2f2f2;
	border: none;
	border-radius: 4px;
}

button:hover {
	background-color: #ddd;
}

button:active {
	background-color: #ccc;
}

Javascript Code

var screen = document.getElementById("result");

function addToScreen(value) {
	screen.value += value;
}

function clearScreen() {
	screen.value = "";
}

function backspace() {
	screen.value = screen.value.slice(0, -1);
}

function calculate() {
	screen.value = eval(screen.value);
}

Below is the explanation it provided for the code above…

ChatGPT help Data Scientists

When rendered online on codepen, this is how it looks…

ChatGPT help Data Scientists

7. ChatGPT can perform Exploratory Data Analysis.

Yes, ChatGPT can assist with performing Exploratory Data Analysis (EDA) by suggesting various techniques and tools that can be used to analyze and visualize the data.

Here are some common steps involved in performing EDA:

  1. Data cleaning: ChatGPT can help identify and remove missing values, duplicates, and outliers from the dataset.
  2. Descriptive statistics: ChatGPT can suggest statistical measures such as mean, median, mode, standard deviation, and variance that can be used to summarize the data.
  3. Visualization: ChatGPT can suggest various data visualization techniques such as histograms, scatter plots, box plots, heatmaps, and correlation matrices that can be used to explore the patterns and relationships in the data.
  4. Feature engineering: ChatGPT can suggest techniques for creating new features from existing features, such as scaling, normalization, and feature selection.
  5. Dimensionality reduction: ChatGPT can suggest techniques such as PCA and t-SNE that can be used to reduce the dimensionality of the data and visualize it in a lower-dimensional space.

Overall, ChatGPT can assist in the EDA process by providing suggestions and guidance based on its knowledge of data analysis techniques and best practices.

Examples:

Prompt: “Perform EDA on a Dataset. Dataset consists of Heights, Weights, and BMI of various people”.

Response:

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

df = pd.read_csv("path/to/dataset.csv")


# Let's start with exploring the basic statistics of the dataset.
df.describe()


# Next, we can check the data types and null values present in the dataset.
df.info()


# Now, let's visualize the distribution of the heights, weights, and BMI using histograms.
plt.hist(df["Height"], bins=20)
plt.title("Distribution of Height")
plt.xlabel("Height")
plt.ylabel("Frequency")
plt.show()

plt.hist(df["Weight"], bins=20)
plt.title("Distribution of Weight")
plt.xlabel("Weight")
plt.ylabel("Frequency")
plt.show()

plt.hist(df["BMI"], bins=20)
plt.title("Distribution of BMI")
plt.xlabel("BMI")
plt.ylabel("Frequency")
plt.show()


# We can also check for correlations between variables using a heatmap.
sns.heatmap(df.corr(), annot=True)
plt.title("Correlation Matrix")
plt.show()


# Lastly, we can create scatter plots to visualize the relationship between height, weight, and BMI.
plt.scatter(df["Height"], df["Weight"])
plt.title("Height vs Weight")
plt.xlabel("Height")
plt.ylabel("Weight")
plt.show()

plt.scatter(df["Height"], df["BMI"])
plt.title("Height vs BMI")
plt.xlabel("Height")
plt.ylabel("BMI")
plt.show()

plt.scatter(df["Weight"], df["BMI"])
plt.title("Weight vs BMI")
plt.xlabel("Weight")
plt.ylabel("BMI")
plt.show()

8. ChatGPT can write complex regex in seconds.

Yes, ChatGPT can help write complex regular expressions (regex) for specific use cases. Regular expressions are a powerful tool for matching and manipulating text patterns, but they can be challenging to write and debug, especially for complex patterns.

Examples:

Prompt: “Write a regex code in Python to remove all capital letters”.

import re

string = "Hello World! This Is A Test String."
string = re.sub(r'[A-Z]', '', string)

print(string)  

# Output: "ello orld! his s  est tring."

Below is the explanation it provided for the code above…

ChatGPT help Data Scientists

Prompt: “Write a regex code in Python to validate a number. It should be 10 digits. It should either start from 9 or 8 or 7 or 6”.

import re

number = "9876543210"
pattern = r'^[6-9]\d{9}$'

if re.match(pattern, number):
    print("Valid phone number")
else:
    print("Invalid phone number")

Below is the explanation it provided for the code above…

ChatGPT help Data Scientists

Prompt: “Write a regex code in Python to remove spaces around a comma in a string”.

import re

string = "This is a sample string , with spaces around , the commas ."
string = re.sub(r'\s*,\s*', ',', string)

print(string)  


# Output: "This is a sample string, with spaces around, the commas."

Below is the explanation it provided for the code above…

ChatGPT help Data Scientists

So this is all for this blog folks. These were some new and innovative Best Final-Year Project Ideas for college students. Thanks for reading it and I hope you are taking something with you after reading this and till the next time …

Read my last Blog:  6 Best Final-Year Project Ideas for College Students using Python

Check out my other machine learning projectsdeep learning projectscomputer vision projectsNLP projects, and Flask projects at machinelearningprojects.net.

Leave a Reply

Your email address will not be published. Required fields are marked *