Boost Daily Tasks5 Key ChatGPT Uses for Data Scientists
By Gencay
Published: 2024-02-26
URL: https://www.learnwithmeai.com/p/5-chatgpt-use-cases-that-will-change

\Created with Abidin Dino AI, to reach it, consider being Paid subscriber to LearnAIWithMe,here\
“In God we trust; all others must bring data.”
W. Edwards Deming.
Going to the complexities of Data Science requires more then just experience, it demands now efficiency and communication.
As always, we will leverage ChatGPT, a tool every data scientist needs to know, to make your work not just smart, but also impactful!
Explain Your Codes To No-Code Colleagues

\Photo byKOBU AgencyonUnsplash\
When coding, it’s important to add explanation about what your code does. This makes it easier for others (and you in the future) to understand your work.
ChatGPT can help by generating comments for your code. Just provide a snippet of your code, and ask for an explanation. Imagine you have a Python function that filters out even numbers from a list:
def filter_even_numbers(numbers):
return [num for num in numbers if num % 2 == 0]
You can ask ChatGPT ;
Can you explain what this function does?
Here answer will be like this ;
This function, filter_even_numbers, takes a list of numbers as input and
returns a new list containing only the even numbers from the original list.
It does this by iterating over each number in the input list,
checking if it is divisible by 2 (meaning it's even),
and including it in the output list if it is.
Easy, but effective. Test it.
Convert Codes Between Different Languages!

\Photo byHitesh ChoudharyonUnsplash\
Sometimes, you may need to convert code from one programming language to another. This can be challenging, especially if you’re not familiar with one of the languages.
ChatGPT can assist by translating code snippets between languages for you.Suppose you have a simple Python function that calculates the sum of two numbers:
def add_numbers(a, b):
return a + b
And you need the equivalent in JavaScript. You can ask ChatGPT, “Can you convert this Python function to JavaScript for me?” ChatGPT might then provide a JavaScript version of the function:
function addNumbers(a, b) {
return a + b;
}
This way, ChatGPT helps bridge the gap between different programming languages, making your work more efficient. Just use this template;
Convert this [ ] to [ ].
Here are the rules you must follow
If you plan to do this smooth, you can add rules, which shows differences between those languages.
ChatGPT To Write Comments To Your Code

\Photo byArtur ShamsutdinovonUnsplash\
Adding comments to your code is a great way to explain complex logic to colleagues who may not have a coding background. ChatGPT can assist by generating straightforward comments that make your code more accessible.
Given the machine learning model code snippet:
from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier(n_estimators=100, random_state=42)
model.fit(X_train, y_train)
Let’s use this prompt ;
Add comments to the code, which will explain each line in one sentence
Let’s see the code.
# Import the Random Forest Classifier from scikit-learn
from sklearn.ensemble import RandomForestClassifier
# Initialize the Random Forest model with 100 decision trees and a fixed random state for reproducibility
model = RandomForestClassifier(n_estimators=100, random_state=42)
# Train the model with training data
model.fit(X_train, y_train)
In this version, comments are added to explain each step of the process, making it easier for someone without a deep understanding of code to grasp what’s happening.
- The first comment explains the import statement, highlighting that we’re bringing in a specific tool from a library.
- The second comment describes the initialization of the model, including why certain parameters are chosen.
- The last comment clarifies the training process, indicating that the model is learning from the provided data.
These comments demystify the code for non-technical colleagues, making collaboration smoother across different departments.
Answer Your Colleagues By Using ChatGPT

\Photo bykrakenimagesonUnsplash\
When a colleague doesn’t understand a piece of your code or sometimes your explanation, if the answer will be too long, it might be good to use ChatGPT for it.
I even might wrote a GPT, to answer some of my client’s answers.Let’s say your colleague is puzzled by a line of code, and you have to explain why you did it. Here my prompt template;
Here is my code: [put your code here]
Here is my colleague's comment: [put comment here]
Can you write a both professional and easy to understanding code to my colleague?
Let’s see one example.
Dear John
Thank you for your question regarding the choice of the Random Forest model for our project. The Random Forest algorithm is a powerful ensemble learning method that combines multiple decision trees to produce a more accurate and stable prediction. We chose this model for several reasons:
1. \*\*Versatility:\*\* Random Forest can be used for both classification and regression tasks, making it suitable for our project's needs.
2. \*\*Handling Overfitting:\*\* Unlike individual decision trees which can easily overfit to the training data, Random Forest mitigates this by averaging the predictions of numerous trees, thus providing more generalized results.
3. \*\*Dealing with Missing Values:\*\* It can handle missing data by maintaining accuracy even if a significant portion of the data is missing.
4. \*\*Importance of Features:\*\* Random Forest can also provide insights into which features are most important in predicting the outcome, which can be invaluable for understanding our data better.
5. \*\*Reproducibility:\*\* By setting a fixed random state, we ensure that our results are reproducible, which is crucial for the scientific integrity of our analysis.
In conclusion, Random Forest offers a robust and flexible approach that fits well with the complexity and nature of our data, promising reliable predictions and insightful data analysis.
Best regards
Final Thoughts
Thanks for reading this one. AI is making our lives easier and easier, and our approach is to make Data Science easier too.
“Machine learning is the last invention that humanity will ever need to make.”
Nick Bostrom