1 / 25

Week 8: Using AI Properly with Prompt Engineering

DATA5000 - Artificial Intelligence Programming in Business Analytics

The art and science of communicating with AI to achieve professional outcomes

Why Prompt Engineering Matters

The New Literacy

In the age of Large Language Models (LLMs) like ChatGPT, Claude, and Gemini, prompt engineering has become as essential as:

Business Impact

  • 80% of Fortune 500 companies are using generative AI tools
  • Proper prompt engineering can improve output quality by 300%
  • Poor prompting leads to hallucinations, bias, and wasted time

What is Prompt Engineering?

Prompt Engineering is the practice of designing and refining inputs (prompts) to generative AI systems to produce desired, accurate, and useful outputs.

Core Components

  1. Input Design: Crafting clear, specific instructions
  2. Context Provision: Giving the AI relevant background information
  3. Output Specification: Defining the format and style you need
  4. Iteration: Refining prompts based on results

Why It's Not Just "Asking Questions"

  • AI models interpret prompts literally
  • Ambiguity leads to inconsistent results
  • Professional outputs require professional inputs
  • Context matters more than you think

From Predictive to Generative AI

Week AI Type Key Capability Prompt Engineering Role
2-3 Predictive ML Pattern recognition in data Data preparation, feature selection
4 Causal ML Understanding cause-effect Hypothesis formulation
7 Generative AI Content creation Prompt engineering
8 Prompt Engineering Controlling AI outputs Today's focus

Moving from correlation to causation to generation requires increasingly sophisticated human-AI interaction

The Anatomy of an Effective Prompt

Six Essential Elements

  1. Role: Who should the AI act as?
  2. Context: What background information is needed?
  3. Task: What specific action should be performed?
  4. Format: How should the output be structured?
  5. Constraints: What limitations or requirements exist?
  6. Examples: What does good output look like?

Example: Poor vs. Good Prompt

❌ Poor Prompt:

Analyze this sales data

✅ Good Prompt:

Role: You are a senior business analyst at a retail company. Context: We have quarterly sales data showing a 15% decline in Q3 2024. Task: Analyze the sales data to identify the top 3 root causes of the decline. Format: Provide your analysis as: 1. Executive summary (3 sentences) 2. Detailed findings for each cause (with data evidence) 3. Recommended actions (prioritized list) Constraints: Focus on actionable insights, not just descriptions. Use business terminology. Examples: Similar to the format used in McKinsey consulting reports.

The CRAFT Method

CRAFT Method - Developed for business analytics

Example: Customer Churn Analysis

C: "Analyze the customer churn patterns in the telecom dataset"

R: "As a data scientist specializing in customer retention"

A: "Identify the top 5 features that predict churn and explain their business significance"

F: "Present as: (1) ranked list with coefficients, (2) business interpretation for each, (3) actionable recommendations"

T: "Use professional language suitable for C-suite presentation"

Common Prompt Patterns for Business Analytics

1. The Analytical Pattern

"Analyze [data/situation] to determine [specific insight]. Consider [relevant factors]. Present findings as [format]."

2. The Synthesis Pattern

"Given [multiple sources/perspectives], synthesize the key insights about [topic]. Focus on [specific aspects]. Output as [structure]."

3. The Comparative Pattern

"Compare [option A] and [option B] based on [criteria]. Evaluate using [framework/metrics]. Recommend [decision] with justification."

4. The Optimization Pattern

"I need to [goal/objective]. Current situation: [context]. Constraints: [limitations]. Suggest [number] strategies ranked by [criteria]."

Advanced Techniques: Chain of Thought

What is Chain of Thought (CoT)?

Asking the AI to "show its work" by reasoning step-by-step, leading to:

  • More accurate outputs
  • Transparent reasoning
  • Easier error identification
  • Better complex problem-solving

Basic Prompt:

"What's the ROI of this marketing campaign?"

Chain of Thought Prompt:

"Calculate the ROI of this marketing campaign. Think through this step-by-step: 1. First, identify all costs involved 2. Then, calculate all revenue generated 3. Next, determine the net profit 4. Finally, compute ROI using the standard formula Show your work for each step."

Advanced Techniques: Few-Shot Learning

Few-Shot Learning: Providing examples of desired input-output pairs to guide the AI's responses.

Pattern:

Here are examples of the task: Example 1: Input: [sample input 1] Output: [sample output 1] Example 2: Input: [sample input 2] Output: [sample output 2] Now complete this: Input: [your actual input] Output:

Few-Shot Learning: Business Example

Customer Feedback Sentiment Classification

You are classifying customer feedback sentiment. Example 1: Feedback: "The product works great but shipping took forever." Classification: Mixed (Positive: product, Negative: shipping) Example 2: Feedback: "Terrible customer service, will never buy again." Classification: Negative (Service issue, churn risk) Now classify this: Feedback: "Love the features but the price is too high for small businesses." Classification:

Ethical Considerations in Prompt Engineering

The Responsibility Framework

1. Bias Amplification

Issue: AI can perpetuate or amplify biases in training data

Action: Explicitly prompt the AI to check for and mitigate bias

2. Data Privacy

Issue: Never input confidential or personally identifiable information

Action: Anonymize data before using in prompts

Rule: Assume everything you input could be seen by others

3. Intellectual Property

Issue: AI-generated content may inadvertently copy protected works

Action: Review outputs for originality; cite AI assistance

4. Accuracy Verification

Issue: AI can "hallucinate" false information confidently

Action: Always verify facts, statistics, and citations

Rule: AI is a tool, not a source of truth

The Hallucination Problem

What Are Hallucinations?

When AI generates false or misleading information presented as fact.

Examples in Business Context

How to Minimize Hallucinations

  1. Be Specific: "Provide only verifiable facts from the dataset I provided"
  2. Request Sources: "Cite the specific data source for each claim"
  3. Acknowledge Uncertainty: "If you're unsure, say 'I don't know' rather than guessing"
  4. Cross-Check: Always verify important facts independently

Prompt Engineering for Data Analysis

The Data Analysis Prompt Pattern

Role: You are a [specific analyst type] Data Context: [describe the dataset, source, timeframe] Analysis Goal: [what insight you're seeking] Methodology: [any specific techniques to use/avoid] Output Requirements: - Statistical summary - Key findings (numbered list) - Visualizations recommended - Business implications - Limitations of the analysis

Prompt Engineering for Code Generation

Best Practices for Coding Prompts

  1. Specify Language & Version: "Python 3.10", "R 4.2"
  2. State Libraries: "Using pandas and scikit-learn"
  3. Describe Input/Output: What data goes in, what comes out
  4. Include Context: What's the broader goal?
  5. Request Comments: "Include detailed comments explaining each step"

Code Style Guidelines

  • Follow PEP 8 style guidelines (for Python)
  • Include error handling
  • Add type hints where appropriate
  • Request unit test examples

Iterative Prompt Refinement

The Refinement Process

Prompt engineering is iterative, not one-and-done:

Initial Prompt → AI Response → Evaluate Quality → Refine Prompt → Better Response

If the output is... Then refine by...
Too generic Adding specific constraints and examples
Too verbose Specifying length limits or bullet points
Missing context Providing more background information
Wrong format Explicitly stating the desired structure
Inaccurate Requesting step-by-step reasoning and sources
Off-topic Narrowing the scope and focus

Business Use Cases - Real Examples

1. Automated Report Generation

Scenario: Weekly sales performance reports

Key Elements:

  • Executive Summary (3 key takeaways)
  • Sales Performance metrics
  • Trends & Insights
  • Recommendations for next week

2. Customer Feedback Analysis

Scenario: Analyzing 1000+ customer reviews

Key Elements:

  • Sentiment Distribution
  • Top 5 Themes
  • Priority Issues
  • Actionable Recommendations

Business Use Cases (Continued)

3. Predictive Analytics Support

Scenario: Interpreting ML model outputs

Explaining feature importances to non-technical stakeholders with business interpretation and retention strategies

4. Data Quality Assessment

Scenario: Evaluating dataset readiness

Provide data quality score, identified issues, impact assessment, and cleaning recommendations with code

Prompt Engineering Anti-Patterns

What NOT to Do

❌ Anti-Pattern 1: The Vague Ask

"Tell me about sales"

Problem: Too broad, no context or goal

Fix: Specify what aspect, time period, and desired insight

❌ Anti-Pattern 2: The Data Dump

[Paste 10 pages of data] "What does this mean?"

Problem: No guidance on what to analyze

Fix: Provide context, specific questions, and analysis goals

More Anti-Patterns to Avoid

❌ Anti-Pattern 3: The Assumption

"Explain why our sales dropped last quarter"

Problem: Assumes facts not in evidence

Fix: "Analyze our sales data to determine IF sales dropped and identify possible causes"

❌ Anti-Pattern 4: The Open-Ended

"Write some Python code for data analysis"

Problem: No specifics on data, goal, or methods

Fix: Specify data structure, analysis type, libraries, and output format

❌ Anti-Pattern 5: The Kitchen Sink

"Analyze this data and tell me everything about it"

Problem: Too many possible directions, unfocused

Fix: Ask specific, targeted questions one at a time

The Ethics of AI-Assisted Work

Academic and Professional Integrity

1. Disclosure Requirements

  • Disclose AI use when it substantially contributes to your work
  • Document your prompts to show your intellectual contribution
  • Verify all outputs - you're accountable for accuracy

✅ Appropriate AI Use:

  • Brainstorming ideas
  • Explaining concepts
  • Drafting outlines
  • Debugging code
  • Formatting and editing

❌ Inappropriate AI Use:

  • Generating entire assignments
  • Copying without verification
  • Bypassing learning objectives
  • Submitting as entirely your own

Practical Framework: The 5-Question Method

Before Using AI for Any Task, Ask:

  1. What is my specific goal?
    • Be precise about what you want to achieve
    • Define success criteria
  2. What context does the AI need?
    • Background information
    • Constraints and requirements
    • Relevant domain knowledge
  3. What format do I need the output in?
    • Structure, length, style
    • Technical level and intended audience
  4. How will I verify the output?
    • What checks will I perform?
    • What domain knowledge will I apply?
  5. How does this serve my learning?
    • What am I learning from this interaction?
    • Am I building skills or avoiding them?

Tools and Platforms

Major LLM Platforms for Business Analytics

Platform Strengths Best For
ChatGPT (GPT-4) Strong general knowledge, code generation Versatile business tasks, Python coding
Claude Strong analytical reasoning, large context Complex analysis, document processing
Google Gemini Integrated with Google Workspace Data analysis with Sheets/Docs
GitHub Copilot Code-specific, IDE integration Software development, coding tasks
Perplexity Research-focused, cites sources Fact-finding, research

Best Practice: Never input confidential or sensitive data. Understand each platform's data usage policies.

Measuring Prompt Quality

The 5-C Framework for Prompt Evaluation

  1. Clarity (0-10): Is the task unambiguous? Could someone else understand what you want?
  2. Completeness (0-10): Have you provided all necessary context? Are constraints and requirements specified?
  3. Concreteness (0-10): Are you specific rather than abstract? Have you included examples where helpful?
  4. Correctness (0-10): Are your instructions logically sound? Will they lead to the desired outcome?
  5. Civility (0-10): Is your tone professional and respectful? Have you structured the prompt readably?

Scoring Guide (Total: /50)

  • 40-50: Excellent prompt
  • 30-39: Good, minor refinements needed
  • 20-29: Needs improvement
  • <20: Revise before using

Integrating AI into Your Analytics Workflow

The Professional Analytics Process with AI

Stage Human Role AI Role
1. Problem Definition Define business question Help refine and scope the problem
2. Data Preparation Gather data, understand quality Suggest cleaning approaches, generate code
3. Exploratory Analysis Direct the exploration Generate visualizations, identify patterns
4. Modeling & Analysis Select approaches, interpret results Implement models, explain outputs
5. Insight Generation Apply business context and judgment Draft explanations, suggest implications
6. Communication Tailor message, make decisions Help structure reports, refine language

Key Principle: AI is a collaborator, not a replacement for human expertise, judgment, and accountability.

Looking Ahead: The Future of Prompt Engineering

Emerging Trends

1. Multimodal Prompting

Combining text, images, data, and voice for holistic analysis

2. Agent-Based AI

AI that can plan and execute multi-step tasks with less prompting

3. Domain-Specialized Models

LLMs fine-tuned for specific industries (Finance AI, Healthcare AI, etc.)

4. Evaluation & Guardrails

AI systems that evaluate other AI outputs with automated fact-checking

Your Role

  • Core prompt engineering skills remain foundational
  • Adaptability to new tools and interfaces
  • Critical thinking about AI capabilities and limitations

Week 8 Key Takeaways

Essential Principles

  1. Prompt engineering is a professional skill that directly impacts output quality
  2. Structure matters: Use frameworks like CRAFT and the 6 essential elements
  3. Context is crucial: The more relevant information you provide, the better
  4. Iteration is normal: Refine prompts based on outputs
  5. Ethics are non-negotiable: Verify, attribute, and use AI responsibly
  6. AI is a tool, not a source of truth: You are accountable for outputs
  7. Learning comes first: Use AI to enhance understanding, not replace it

Practical Actions

  • ✅ Start building your prompt library for common tasks
  • ✅ Experiment with different frameworks and techniques
  • ✅ Practice the 5-Question Method before each AI interaction
  • ✅ Always verify outputs, especially facts and statistics
  • ✅ Document your prompts and learnings

Applying to Assessment 2

How Prompt Engineering Can Help

Assessment 2 (35%): Generative AI Startup Project - Due Week 9

1. Data Understanding

Prompt: "Explain what each column in this dataset likely represents and suggest appropriate data types and potential quality issues."

2. Analysis Strategy

Prompt: "I need to perform predictive and prescriptive analytics on [describe data]. Suggest an appropriate analytical approach."

3. Code Generation

Prompt: "Generate Python code to [specific task] using [libraries]. Include error handling and detailed comments."

4. Interpretation Support

Prompt: "Explain these model results in business terms suitable for a non-technical stakeholder."

Important Reminders

  • ⚠️ You must understand and verify all AI-generated content
  • ⚠️ Document your prompts to show your intellectual contribution
  • ⚠️ AI is a tool to help you learn, not do the work for you