Data science is a field that promises insights but often delivers a mountain of repetitive tasks. From cleaning messy datasets to tuning hyperparameters, a significant chunk of a data scientist's day is spent on mundane chores that don't require deep thinking. According to a 2021 survey by Anaconda, data scientists spend only 39% of their time on actual model development, with the rest consumed by data preparation, visualization, and deployment tasks. That's a lot of potential wasted. But what if you could delegate those chores to an AI assistant? With the rise of large language models (LLMs) and prompt engineering, it's now possible to automate significant portions of the data science workflow. This article presents a collection of 12 prompts designed to put your analysis on autopilot, from data cleaning to model interpretation. Each prompt is crafted to be actionable, with examples and expected outputs, so you can start using them immediately. Whether you're a seasoned practitioner or a newcomer, these prompts will help you streamline your workflow and focus on what really matters: deriving insights and building better models.
1. Data Cleaning and Preprocessing
Task: Automate the initial exploration and cleaning of a dataset.
Prompt:
You are a data cleaning expert. I will provide a dataset (CSV or JSON) and its metadata. Perform the following steps:
1. Load the data and display the first 5 rows.
2. Identify missing values, duplicates, and inconsistent data types.
3. Suggest and apply appropriate imputation strategies for missing values (mean, median, mode, or advanced methods like KNN).
4. Standardize column names (snake_case) and remove any leading/trailing spaces.
5. Detect and handle outliers using the IQR method or Z-score.
6. Provide a summary of the cleaning steps performed and the final shape of the dataset.
Example Use:
You provide a CSV file containing customer transaction data with missing age values and some duplicate entries. The prompt outputs a cleaned dataset with imputed ages, removed duplicates, and standardized column names, along with a summary report.
Result:
- A Python script that performs all cleaning steps.
- A cleaned CSV file ready for analysis.
- A summary of changes (e.g., "Imputed 12 missing age values with median, removed 3 duplicates, renamed 2 columns").
2. Exploratory Data Analysis (EDA)
Task: Generate a comprehensive EDA report automatically.
Prompt:
You are a data analyst. Given a dataset, perform a thorough EDA:
1. Generate descriptive statistics (mean, median, std, etc.) for all numerical columns.
2. Create visualizations: histograms, boxplots, correlation heatmap, and pairplot.
3. Identify correlations and highlight any strong relationships.
4. For categorical columns, show frequency distributions and bar plots.
5. Summarize key insights in bullet points.
Example Use:
Feed the prompt with a housing dataset. The AI returns a set of matplotlib/seaborn plots and a text summary like "Strong positive correlation between square footage and price (0.85)."
Result:
- A Python script that generates all plots.
- A markdown report with insights.
- An interactive HTML dashboard if requested.
3. Feature Engineering
Task: Automatically create new features from existing data.
Prompt:
You are a feature engineering expert. For the given dataset, propose and implement new features that could improve model performance. Consider:
- Date/time transformations (e.g., day of week, month, hour).
- Text-based features (e.g., length, word count).
- Interaction features between numerical columns.
- Binning or scaling of continuous variables.
Provide code to add these features, and explain the rationale behind each.
Example Use:
For a retail dataset with a 'purchase_date' column, the AI creates features like 'day_of_week', 'month', 'is_weekend', and 'total_spend_per_customer'.
Result:
- A list of new features with descriptions.
- Code to implement them.
- A comparison of model performance with and without new features.
4. Model Selection and Hyperparameter Tuning
Task: Automate the process of choosing the best model and tuning hyperparameters.
Prompt:
You are a machine learning expert. Given a dataset and a target column, perform the following:
1. Split the data into train and test sets (80/20).
2. Evaluate at least 5 different algorithms (e.g., Logistic Regression, Random Forest, XGBoost, SVM, Neural Network) using cross-validation.
3. For the top 3 models, perform hyperparameter tuning using GridSearchCV or RandomizedSearchCV.
4. Compare final models on the test set using appropriate metrics (accuracy, F1, RMSE, etc.).
5. Save the best model using pickle or joblib.
Example Use:
On a classification dataset, the AI runs multiple models and returns a table of performance metrics, selects the best model (e.g., XGBoost with F1=0.92), and saves it.
Result:
- A comparison table of model performances.
- The best model saved to disk.
- A script to reproduce the pipeline.
5. Time Series Forecasting
Task: Automate time series analysis and forecasting.
Prompt:
You are a time series analyst. For the given time series data:
1. Decompose the series into trend, seasonality, and residual components.
2. Check for stationarity using ADF test.
3. Fit an ARIMA model (or Prophet) and forecast future values.
4. Visualize the forecast with confidence intervals.
5. Provide performance metrics (MAE, RMSE) on a holdout set.
Example Use:
For monthly sales data, the AI fits a SARIMA model, forecasts the next 12 months, and plots the prediction with a shaded confidence interval.
Result:
- A forecast plot.
- Model parameters and metrics.
- A script for reproducibility.
6. Natural Language Processing (NLP) for Text Classification
Task: Build a text classification pipeline.
Prompt:
You are an NLP expert. For the given text dataset with labels, perform:
1. Text preprocessing: lowercasing, removing punctuation, stopwords, and stemming/lemmatization.
2. Convert text to numerical features using TF-IDF or word embeddings.
3. Train a classifier (e.g., Logistic Regression, LSTM, or BERT) and evaluate.
4. Show the most informative features or confusion matrix.
5. Provide code to predict new text.
Example Use:
For a sentiment analysis dataset, the AI preprocesses tweets, trains a TF-IDF + Logistic Regression model, and achieves 0.88 accuracy.
Result:
- A trained classifier.
- A script for inference.
- A confusion matrix and feature importance plot.
7. Anomaly Detection
Task: Automate detection of anomalies in data.
Prompt:
You are an anomaly detection specialist. For the given dataset (e.g., network logs, sensor data):
1. Scale the data.
2. Apply Isolation Forest, One-Class SVM, and autoencoder.
3. Compare results and select the best method based on precision/recall.
4. Visualize the anomalies on a scatter plot.
5. Provide a function to flag anomalies in new data.
Example Use:
For server metrics, the AI flags unusual CPU spikes and network latency, saving a list of timestamps for further investigation.
Result:
- A list of anomalies with scores.
- A visualization highlighting outliers.
- A reusable detection function.
8. Explainable AI (XAI)
Task: Generate SHAP or LIME explanations for model predictions.
Prompt:
You are an AI interpretation expert. For the trained model and a test sample, provide:
1. A SHAP summary plot to show feature importance.
2. A SHAP force plot for the sample.
3. A LIME explanation with top features.
4. A plain-language interpretation of the prediction.
Example Use:
For a loan approval model, the AI explains that a particular applicant was rejected due to low credit score and high debt-to-income ratio.
Result:
- SHAP and LIME visualizations.
- A text explanation that can be communicated to stakeholders.
9. Automated Report Generation
Task: Generate a complete data science report in markdown or PDF.
Prompt:
You are a data science report writer. Given the results of the analysis (metrics, plots, insights), create a comprehensive report with:
- An executive summary.
- Methodology.
- Results with charts.
- Conclusions and recommendations.
The report should be in Markdown format, with charts embedded as images.
Example Use:
After running a churn analysis, the AI produces a well-structured report that can be directly shared with management.
Result:
- A markdown file ready for conversion to PDF or HTML.
- A professional narrative of the entire analysis.
10. Code Generation for Data Pipelines
Task: Generate ETL scripts for data pipelines.
Prompt:
You are a data engineer. Write a Python script to extract data from a PostgreSQL database, transform it (e.g., cleaning, aggregations), and load it into a CSV or a data warehouse. Use pandas and SQLAlchemy. Include error handling and logging.
Example Use:
The AI generates a script that connects to a database, pulls customer orders, aggregates by month, and saves to a CSV file.
Result:
- A production-ready ETL script.
- Logging and error handling included.
11. Model Deployment Preparation
Task: Prepare a model for deployment as a REST API.
Prompt:
You are a deployment specialist. Given a trained model file, create a FastAPI application that serves predictions. Include:
- A POST endpoint `/predict` that accepts JSON input.
- Data validation using Pydantic.
- A Dockerfile for containerization.
- Instructions for local testing.
Example Use:
The AI creates a FastAPI app with a health check and prediction endpoint, plus a Dockerfile that packages the model.
Result:
- A ready-to-run API.
- Dockerfile.
- Deployment instructions.
12. Data Visualization Storytelling
Task: Create a compelling data visualization dashboard.
Prompt:
You are a data visualization expert. Given a dataset, create a dashboard using Plotly Dash or Streamlit that includes:
- Key performance indicators (KPIs) at the top.
- Interactive charts (scatter, bar, line) with filters.
- A narrative layout that guides the viewer through the data.
Provide the full code and a brief explanation.
Example Use:
For a sales dataset, the AI generates a Streamlit app with a KPI row (total sales, profit), a filter for region, and interactive plots.
Result:
- A fully functional dashboard.
- A script that can be run locally.
Putting It All Together: An Automated Workflow
These prompts are not isolated; they can be chained to create an end-to-end automated workflow. For instance, you could start with data cleaning (Prompt 1), then EDA (Prompt 2), feature engineering (Prompt 3), model selection (Prompt 4), and finally report generation (Prompt 9). By executing these prompts sequentially, you can go from raw data to a finalized report with minimal manual intervention. The key is to provide clear context and data to the AI at each step.
Advanced Tips for Maximizing Prompt Effectiveness
- Be specific: Include column names, data types, and any domain knowledge.
- Iterate: If the output isn't perfect, refine the prompt with additional constraints.
- Use examples: Show the AI an example of the desired output format.
- Validate: Always verify the AI-generated code and results, especially for critical tasks.
Conclusion
Automation in data science is not about replacing the human, but about freeing up time for higher-level thinking. These 12 prompts act as your personal assistant, handling the grunt work so you can focus on strategy and innovation. Start by trying a few prompts with your own data. You'll soon find that you can accomplish in minutes what used to take hours. The future of data science is not just about models, but about how efficiently you can build and deploy them. With AI-powered prompts, you're well on your way to putting your analysis on autopilot.
Comments