LQF_Machine_Learning_Expert_Guide
|
pinned to #34429a8updated 2 weeks ago
Ask your AI client: “install skills/lqf-machine-learning-expert-guide”.
Requires the metahub MCP server installed in your client. Set up MCP.
mh install skills/lqf-machine-learning-expert-guidemetahub onboarded this repo on the author's behalf.
If you own github.com/foryourhealth111-pixel/Vibe-Skills on GitHub, claim the listing to take over publishing. Your claim preserves the existing eval history and badges; only the curator label is replaced with verified-publisher on your next publish.
Stars
2,381
Last commit
2 weeks ago
Latest release
published
- #agent-framework
- #agent-skills
- #agentic-coding
- #ai-agents
- #ai-scientist
- #ai-skills
- #ai-workflow
- #automation
- #claude-code
- #codex
- #context-engineering
- #developer-tools
- #llm
- #multi-agent
- #prompt-engineering
- #skills
- #vibe-coding
- #vibecoding
- #workflow-automation
About this skill
Pulled from SKILL.md at publish time.
Allowed tools
- [Read
- Write
- Edit
- Bash
- Grep
- Glob]
Evaluation report
WarningsAutomated checks the publisher passed at publish time — structure, docs, safety, and whether the artifact behaves as claimed.34429a8· 2 weeks ago
Documentation
41Description qualitywarn
37 words · 289 chars — manifest description is empty; graded the GitHub repo description instead
A skill's manifest description doubles as its trigger — add one to SKILL.md (15+ words, e.g. “use this skill when …”).
README is present and substantial
34,571 chars · 14 sections · 6 code blocks
Tags / topics declared
19 total — agent-framework, agent-skills, agentic-coding, ai-agents, ai-scientist, ai-skills (+13)
README has usage / example sections
no labeled section but 6 code blocks document usage
Homepage / docs URL declared
no homepage declared (registry will use the repo URL) — info-only, not blocking
Release history
1- releasecurrent34429a8warn2 weeks ago
Contents
When to Use This Skill
Use this skill when:
- Building ML models (classification, regression, clustering, forecasting)
- Evaluating model performance and debugging issues
- Feature engineering and data preprocessing for ML
- Hyperparameter tuning and model optimization
- Debugging overfitting, underfitting, or poor generalization
- Choosing between traditional ML and deep learning approaches
- Establishing baselines and conducting ablation studies
- Performing error analysis and model validation
- Statistical modeling with predictive components
Not For / Boundaries
Out of Scope:
- Pure data visualization without modeling (use data visualization skills)
- Database queries without predictive modeling
- Basic descriptive statistics without ML context
- Production deployment infrastructure (use MLOps/deployment skills)
- Reinforcement learning (specialized domain)
- Time series forecasting with specialized methods (use time series skills)
Required Inputs - Ask User If Missing:
- What is the problem type? (classification, regression, clustering, etc.)
- What does your data look like? (size, number of features, target variable distribution)
- Have you established a baseline yet? (dummy predictor, simple heuristic)
Critical Discussion Protocol
This skill operates in Critical Engagement Mode - every proposal (user's or your own) undergoes systematic critique and iterative refinement.
Core Principles
- No First-Pass Acceptance: Never accept initial proposals without critique
- Minimum 3 Iteration Cycles: Propose → Critique → Refine → Repeat (3x minimum)
- Evidence-Based Critique: Every critique must cite specific ML concerns
- Tiered Information Requirements:
- HIGH-RISK decisions (model selection, data splitting, deployment): Demand complete information
- LOW-RISK exploration (EDA, feature brainstorming): Proceed with stated assumptions
Critique Intensity Levels
Level 1 - Diplomatic (for exploration/brainstorming):
- "Have you considered establishing a baseline first?"
- "It might be worth exploring simpler alternatives..."
- "One potential concern is..."
Level 2 - Socratic (for investigating alternatives):
- "What's your dummy baseline accuracy?"
- "Why not start with logistic regression?"
- "What evidence suggests this feature is causal?"
Level 3 - Direct (for critical mistakes):
- "STOP: You must establish a baseline before building complex models"
- "This approach has data leakage - you're using future information"
- "This assumption is unfounded - show me the data distribution"
Mandatory Information Checklist (HIGH-RISK Decisions)
Before proceeding with model selection or training, DEMAND answers to:
- What is the dummy baseline performance?
- What is the data size (n_samples, n_features)?
- What is the target variable distribution?
- How was the data collected? (potential biases)
- What is the train/test split strategy?
- What is the business metric (not just ML metric)?
Iterative Refinement Cycle
Round 1 - Initial Proposal:
- User or you propose approach
- Immediately identify 3-5 potential issues
- Ask clarifying questions
- Suggest simpler alternatives
Round 2 - First Refinement:
- Critique the refined approach
- Challenge assumptions
- Request evidence (baseline, data distribution)
- Propose counter-examples
Round 3 - Second Refinement:
- Stress test the approach
- Identify edge cases
- Compare against alternatives
- Final critique before acceptance
Acceptance Criteria:
- All HIGH-RISK information provided
- Baseline established and documented
- Simpler alternatives considered and rejected with evidence
- Approach survives 3 rounds of critique
Self-Critique Framework
Before presenting any recommendation, apply this self-critique checklist:
Question Your Own Suggestions
Complexity Check:
- Am I overcomplicating this?
- Did I consider the simplest possible solution?
- Can this be solved without ML?
- What's the Occam's Razor alternative?
Baseline Check:
- Did I establish a dummy baseline?
- Did I compare against a simple heuristic?
- What's the lift over baseline?
- Is the complexity justified by the lift?
Assumption Audit:
- What am I assuming about the data?
- What am I assuming about the problem?
- What evidence contradicts these assumptions?
- What happens if these assumptions are wrong?
Evidence Check:
- What evidence supports this approach?
- What evidence contradicts it?
- Am I cherry-picking evidence?
- Have I considered counter-examples?
Devil's Advocate Mode
For every suggestion you make, immediately provide a counter-argument:
Example:
- Suggestion: "Use Random Forest for this classification task"
- Counter-Argument: "But have you tried logistic regression first? Random Forest is a black box - if logistic regression gets 85% and Random Forest gets 87%, the 2% gain doesn't justify losing interpretability"
Example:
- Suggestion: "Add polynomial features to capture non-linearity"
- Counter-Argument: "But this increases feature space from n to n² - have you checked if the model can overfit? What's the n_samples/n_features ratio?"
Assumption Audit Template
List all assumptions explicitly:
-
Data Assumptions:
- "I'm assuming the data is IID (independent and identically distributed)"
- "I'm assuming no data leakage"
- "I'm assuming the test set comes from the same distribution as training"
-
Problem Assumptions:
- "I'm assuming the target variable is well-defined"
- "I'm assuming the features are causal (not just correlated)"
- "I'm assuming the business metric aligns with the ML metric"
-
Challenge Each Assumption:
- "What if the data has temporal dependencies?" → Use time-based split
- "What if there's data leakage?" → Check for future information
- "What if test distribution differs?" → Check for distribution shift
Self-Critique Dialogue Example
Initial Suggestion: "Let's use a deep neural network with 5 hidden layers"
Self-Critique:
- "Wait - have I established a baseline? No."
- "Have I tried a simple model? No."
- "Why am I jumping to deep learning? Because it's popular? That's novice thinking."
- "What's the data size? If n < 10,000, deep learning will likely overfit."
- "Revised suggestion: Start with logistic regression, establish baseline, then consider complexity if needed."
User Proposal Critique Framework
When a user proposes an approach, apply this systematic critique process:
Step 1: Identify Unstated Assumptions
Common Hidden Assumptions:
- "I want to use deep learning" → Assumes: data is large enough, problem is complex enough, interpretability doesn't matter
- "I have 95% accuracy" → Assumes: baseline is low, classes are balanced, metric is appropriate
- "I need more features" → Assumes: existing features are well-engineered, model isn't overfitting
- "The model isn't working" → Assumes: problem is solvable with ML, data quality is good
Critique Template: "I notice you're proposing [X]. This assumes [Y] and [Z]. Can you confirm these assumptions? Specifically:
- [Assumption 1]?
- [Assumption 2]?
- [Assumption 3]?"
Step 2: Find Potential Failure Modes
Red Flags Checklist:
- No baseline mentioned → "What's your dummy baseline?"
- Complex model first → "Why not start with logistic regression?"
- High accuracy claimed → "What's the class distribution? Is this better than predicting the majority class?"
- Random train/test split with time series → "This causes data leakage - use time-based split"
- Many features, small dataset → "n_features > n_samples/10 risks overfitting"
- No validation set → "How will you tune hyperparameters without overfitting to test set?"
Step 3: Compare Against Simpler Alternatives
Simplicity Ladder (always start at bottom):
- No ML: Can this be solved with rules/heuristics?
- Dummy Baseline: What's the performance of predicting mean/mode?
- Simple Linear: Logistic regression or linear regression
- Simple Non-Linear: Decision tree or Random Forest
- Complex: Gradient boosting, neural networks
Critique Pattern: "You're proposing [complex approach]. Have you tried:
- [Simpler alternative 1]?
- [Simpler alternative 2]? If not, let's establish those baselines first."
Step 4: Request Missing Information
HIGH-RISK Decision Information Requirements:
For model selection, demand:
- Data size (n_samples, n_features)
- Target distribution (class balance, value range)
- Dummy baseline performance
- Simple model baseline performance
For data splitting, demand:
- Data collection timeline
- Temporal dependencies
- Distribution shift concerns
For feature engineering, demand:
- Feature importance analysis
- Correlation with target
- Causal reasoning
Step 5: Challenge Complexity Without Justification
Complexity Challenge Template: "I see you want to use [complex approach]. Let me challenge this:
- What's the lift over a simple baseline?
- If lift < 10%, is the complexity justified?
- What do you lose? (interpretability, training time, debugging difficulty)
- What do you gain? (quantify the improvement)"
Example Critique Dialogues
User: "I want to build a neural network to predict house prices"
Critique: "Let me challenge this proposal:
- Assumption Check: You're assuming the problem requires deep learning. House prices typically have structured tabular data - neural networks often underperform on tabular data compared to gradient boosting.
- Baseline Check: What's your dummy baseline? (predict mean price)
- Simpler Alternative: Have you tried linear regression? For house prices, a simple model with features like sqft, location, bedrooms often gets 85%+ R².
- Information Needed:
- How many samples do you have?
- How many features?
- What's the R² of predicting the mean?
- Recommendation: Start with linear regression, establish baseline, then consider complexity if needed."
Quick Reference
Expert Thinking Framework
Before Starting ANY ML Project:
1. Can this be solved without ML? (rules, heuristics, simple logic)
2. What is the dummy baseline? (mean for regression, mode for classification)
3. What is the business-logic baseline? (yesterday's value, domain rules)
4. Only proceed with ML if: Lift = (Model - Baseline) / Baseline is significant
Phase 1: Problem Definition (Expert Approach)
Novice: Receives task → assumes ML needed → finds SOTA model Expert: Receives task → converts to math → questions necessity → defines success
# Expert Problem Definition Checklist
# 1. Mathematical formulation
# - Classification: P(y|X) where y ∈ {0,1,...,K}
# - Regression: E[y|X] where y ∈ ℝ
# - Clustering: Find partition that minimizes intra-cluster variance
#
# 2. Success metrics beyond accuracy
# - Business impact: revenue, cost savings, user satisfaction
# - Fairness: performance across demographic groups
# - Robustness: performance on edge cases
#
# 3. Negative consequences
# - Optimizing CTR → clickbait
# - Optimizing engagement → filter bubbles
Discussion Checkpoint:
- Have I questioned whether ML is necessary?
- Have I asked about simpler alternatives?
- Have I challenged the problem formulation?
- Have I requested business context?
Phase 2: Baseline Thinking (ALWAYS DO THIS FIRST)
from sklearn.dummy import DummyClassifier, DummyRegressor
from sklearn.metrics import accuracy_score, mean_squared_error
import numpy as np
# STEP 1: Dummy Baseline (statistical guess)
# Classification: predict most frequent class
dummy_clf = DummyClassifier(strategy='most_frequent')
dummy_clf.fit(X_train, y_train)
dummy_acc = accuracy_score(y_test, dummy_clf.predict(X_test))
print(f"Dummy Baseline Accuracy: {dummy_acc:.3f}")
# Regression: predict mean
dummy_reg = DummyRegressor(strategy='mean')
dummy_reg.fit(X_train, y_train)
dummy_mse = mean_squared_error(y_test, dummy_reg.predict(X_test))
print(f"Dummy Baseline MSE: {dummy_mse:.3f}")
# STEP 2: Simple Heuristic Baseline (domain knowledge)
# Example for time series: "tomorrow = today"
heuristic_pred = y_test.shift(1).fillna(y_test.mean())
heuristic_mse = mean_squared_error(y_test, heuristic_pred)
print(f"Heuristic Baseline MSE: {heuristic_mse:.3f}")
# STEP 3: Calculate Lift
# Your complex model MUST beat these baselines significantly
# If lift < 10%, question whether complexity is justified
Discussion Checkpoint:
- Have I demanded dummy baseline results?
- Have I asked about heuristic baselines?
- Have I calculated lift over baseline?
- Have I challenged the need for complexity if lift < 10%?
Phase 3: Data Engineering (Expert Patterns)
Data Archaeology - Understand Generation Mechanism:
# Check missing value patterns (informative vs random)
import pandas as pd
# Are missing values informative?
df['income_missing'] = df['income'].isna().astype(int)
# If income_missing correlates with target, it's informative!
# Check for data leakage (temporal)
# WRONG: Random split when data has time component
# RIGHT: Time-based split
train_data = df[df['date'] < '2023-01-01']
test_data = df[df['date'] >= '2023-01-01']
# Feature engineering: causality over correlation
# NOVICE: Add all possible features
# EXPERT: Add features with causal relationship
df['price_per_sqft'] = df['price'] / df['sqft'] # Causal: price depends on size
# Avoid: df['random_correlation'] = df['feature1'] * df['feature2'] # No causal story
Discussion Checkpoint:
- Have I asked about data collection process?
- Have I questioned potential data leakage?
- Have I challenged feature engineering choices?
- Have I requested causal reasoning for features?
Phase 4: Modeling (Occam's Razor + Ablation)
Start Simple, Add Complexity Only If Justified:
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import roc_auc_score
# STEP 1: Simple model (interpretable baseline)
simple_model = LogisticRegression()
simple_model.fit(X_train, y_train)
simple_auc = roc_auc_score(y_test, simple_model.predict_proba(X_test)[:, 1])
# STEP 2: Complex model
complex_model = RandomForestClassifier(n_estimators=100)
complex_model.fit(X_train, y_train)
complex_auc = roc_auc_score(y_test, complex_model.predict_proba(X_test)[:, 1])
# STEP 3: Justify complexity
improvement = (complex_auc - simple_auc) / simple_auc * 100
print(f"Improvement: {improvement:.1f}%")
# If improvement < 5%, use simple model (interpretability wins)
Ablation Study - Prove Components Are Necessary:
# Remove components one by one to prove they're needed
# Example: Testing if attention mechanism helps
# Full model
full_model_score = 0.85
# Remove attention
no_attention_score = 0.84 # Only 0.01 drop
# Conclusion: Attention adds complexity without benefit → REMOVE IT
# Only keep components where removal causes significant (>2%) drop
Discussion Checkpoint:
- Have I insisted on starting with simple models?
- Have I demanded ablation studies?
- Have I challenged complexity without justification?
- Have I compared against simpler alternatives?
Phase 5: Validation (Adversarial Thinking)
Sanity Check - Overfit on Tiny Dataset:
# Take 10 samples, turn off regularization
# Model MUST achieve 100% training accuracy
# If it can't, you have a bug (not a model problem)
tiny_X = X_train[:10]
tiny_y = y_train[:10]
model = RandomForestClassifier(max_depth=None, min_samples_split=2)
model.fit(tiny_X, tiny_y)
train_acc = accuracy_score(tiny_y, model.predict(tiny_X))
assert train_acc == 1.0, "Bug in code! Model can't overfit 10 samples"
Error Analysis - Study Failures:
# Don't celebrate 95% accuracy, analyze 5% errors
y_pred = model.predict(X_test)
errors = X_test[y_pred != y_test]
# Manually inspect errors
print("Error cases:")
print(errors.head(20))
# Look for patterns:
# - Mislabeled data?
# - Missing features for these cases?
# - Systematic bias?
Stress Testing:
# Test with adversarial inputs
# - Missing values
# - Extreme values
# - Out-of-distribution data
# Example: What if all features are at max?
stress_test = X_test.copy()
stress_test[:] = X_test.max()
stress_pred = model.predict(stress_test)
# Does output make sense?
Discussion Checkpoint:
- Have I requested sanity checks?
- Have I demanded error analysis?
- Have I challenged the validation strategy?
- Have I asked about stress testing?
Examples
Example 1: Building a Classification Model (Novice vs Expert)
Novice Approach:
# Novice: Jump straight to complex model
from sklearn.ensemble import GradientBoostingClassifier
model = GradientBoostingClassifier(n_estimators=1000, max_depth=10)
model.fit(X_train, y_train)
print(f"Accuracy: {model.score(X_test, y_test)}") # 0.87
# "Great! 87% accuracy!"
Expert Approach:
# Expert: Establish baseline first
from sklearn.dummy import DummyClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import GradientBoostingClassifier
# Step 1: Dummy baseline
dummy = DummyClassifier(strategy='most_frequent')
dummy.fit(X_train, y_train)
dummy_acc = dummy.score(X_test, y_test)
print(f"Dummy Baseline: {dummy_acc:.3f}") # 0.82
# Step 2: Simple model
simple = LogisticRegression()
simple.fit(X_train, y_train)
simple_acc = simple.score(X_test, y_test)
print(f"Simple Model: {simple_acc:.3f}") # 0.85
# Step 3: Complex model
complex = GradientBoostingClassifier(n_estimators=100, max_depth=3)
complex.fit(X_train, y_train)
complex_acc = complex.score(X_test, y_test)
print(f"Complex Model: {complex_acc:.3f}") # 0.87
# Analysis: 87% vs 82% dummy = only 6% lift
# 87% vs 85% simple = only 2.4% improvement
# Conclusion: Use simple logistic regression (interpretable, 85% is good enough)
Example 2: Debugging Overfitting (Expert Workflow)
Input: "My model has 99% training accuracy but 70% test accuracy"
Expert Response:
# This is classic overfitting. Let's diagnose systematically.
# Step 1: Check train-val gap
train_acc = 0.99
val_acc = 0.70
gap = train_acc - val_acc # 0.29 - HUGE gap!
# Step 2: Regularization ladder (in order)
# Level 1: Batch Normalization (if deep learning)
# Level 2: Data Augmentation (most effective)
# Level 3: Dropout
# Level 4: L2 regularization
# For traditional ML (e.g., Random Forest):
from sklearn.ensemble import RandomForestClassifier
# Reduce complexity
model = RandomForestClassifier(
max_depth=5, # Limit tree depth
min_samples_split=20, # Require more samples to split
min_samples_leaf=10, # Require more samples in leaves
max_features='sqrt' # Limit features per tree
)
model.fit(X_train, y_train)
# Step 3: Check if gap closes
new_train_acc = model.score(X_train, y_train) # Should drop from 99%
new_val_acc = model.score(X_val, y_val) # Should increase from 70%
print(f"New train: {new_train_acc:.3f}, New val: {new_val_acc:.3f}")
# Goal: Gap < 0.05 (5%)
Example 3: Feature Engineering (Causal vs Correlational)
Novice Approach:
# Novice: Create all possible feature combinations
for col1 in df.columns:
for col2 in df.columns:
df[f'{col1}_times_{col2}'] = df[col1] * df[col2]
df[f'{col1}_div_{col2}'] = df[col1] / (df[col2] + 1e-10)
# Result: 10,000 features, most are noise
Expert Approach:
# Expert: Create features with causal story
import pandas as pd
# Domain: House price prediction
# Causal reasoning: Price depends on size AND location
# Good: Price per square foot (causal relationship)
df['price_per_sqft'] = df['price'] / df['sqft']
# Good: Age of house (older = more depreciation)
df['house_age'] = 2024 - df['year_built']
# Good: Interaction with causal meaning
df['luxury_indicator'] = (df['price_per_sqft'] > df['price_per_sqft'].quantile(0.9)).astype(int)
# Bad: Random multiplication (no causal story)
# df['random_feature'] = df['bedrooms'] * df['bathrooms'] # Why multiply these?
# Validate: Check feature importance
from sklearn.ensemble import RandomForestRegressor
model = RandomForestRegressor()
model.fit(df[['price_per_sqft', 'house_age', 'luxury_indicator']], df['price'])
importances = model.feature_importances_
# If importance < 0.01, remove feature
Example 4: Critical Discussion - User Proposes Deep Learning
User: "I want to use a deep neural network for customer churn prediction"
Round 1 - Initial Critique: "Let me challenge this proposal with some questions:
-
Data Size Check: How many customers do you have in your dataset? Deep learning typically needs 10,000+ samples to avoid overfitting.
-
Baseline Check: What's your dummy baseline? If 80% of customers don't churn, predicting "no churn" for everyone gives 80% accuracy.
-
Simpler Alternative: Have you tried logistic regression or Random Forest? For tabular data (customer features), these often outperform neural networks.
-
Information Needed:
- n_samples, n_features?
- Churn rate (class balance)?
- What's the dummy baseline accuracy?
Let's establish these baselines first before jumping to deep learning."
User: "I have 5,000 customers, 20 features, 15% churn rate. Dummy baseline is 85%."
Round 2 - Refined Critique: "Good - now I have context. Let me refine my critique:
Concerns:
- 5,000 samples is borderline for deep learning (prefer 10,000+)
- 15% churn rate means you have only 750 churn cases - very small for deep learning
- Dummy baseline of 85% is already high - you need significant lift to justify complexity
Recommendation: Start with simpler models first:
- Logistic Regression (interpretable, good for small data)
- Random Forest (handles non-linearity, less prone to overfitting than DL)
- Gradient Boosting (often best for tabular data)
Challenge: Can you get 90%+ accuracy with these simpler models? If yes, deep learning isn't needed. If no, then we can consider DL.
Let's implement this progression and compare."
User: "OK, I tried logistic regression and got 88% accuracy. Should I try deep learning now?"
Round 3 - Final Critique: "Let's analyze this critically:
Lift Calculation:
- Dummy baseline: 85%
- Logistic regression: 88%
- Lift: (88-85)/85 = 3.5%
Questions:
- Is 3.5% lift significant for your business? (e.g., if you have 1M customers, this saves 35,000 false predictions)
- Have you tried Random Forest or Gradient Boosting? These might get you to 90% without deep learning complexity.
- What's the cost of false positives vs false negatives? (Maybe accuracy isn't the right metric)
Recommendation: Before trying deep learning:
- Try Random Forest and XGBoost
- Optimize the metric (maybe use F1-score or precision-recall if classes are imbalanced)
- Do error analysis - what patterns do misclassified customers have?
Only if these simpler models plateau below your business requirement should we consider deep learning."
Example 5: Critical Discussion - "Model Not Working"
User: "My model isn't working. The accuracy is only 70%."
Round 1 - Information Gathering (HIGH-RISK, demand details): "STOP - I need more information before I can help. 'Not working' is too vague. Please provide:
Required Information:
- What is the problem type? (classification, regression, etc.)
- What is the dummy baseline performance?
- What is the target variable distribution?
- What model are you using?
- What is the train/test split?
- What is the train accuracy vs test accuracy?
Without this information, I cannot diagnose the issue."
User: "Binary classification, 60% class 0, 40% class 1. Using Random Forest. Train accuracy 95%, test accuracy 70%."
Round 2 - Diagnosis and Critique: "Now I can diagnose. This is classic overfitting:
Evidence:
- Train accuracy (95%) >> Test accuracy (70%)
- Gap of 25% indicates severe overfitting
Root Cause Analysis:
- Dummy baseline: Predicting majority class gives 60% accuracy
- Your model: 70% test accuracy
- Lift: Only 16.7% over dummy baseline - very small!
Critical Questions:
- How many samples do you have? (If n < 1000, Random Forest will overfit)
- How many features? (If n_features > n_samples/10, you have too many features)
- Did you tune hyperparameters on the test set? (This causes data leakage)
Hypothesis: Your model is overfitting due to:
- Too many features relative to samples
- Too deep trees (max_depth too high)
- No regularization
Let's test this hypothesis."
User: "I have 500 samples, 100 features. I tuned hyperparameters by trying different values and checking test accuracy."
Round 3 - Critical Diagnosis and Solution: "I found two critical issues:
Issue 1 - Data Leakage: You tuned hyperparameters on the test set! This is data leakage. Your test accuracy is artificially inflated. You need a separate validation set:
- Train: 60% (300 samples)
- Validation: 20% (100 samples) - for hyperparameter tuning
- Test: 20% (100 samples) - for final evaluation only
Issue 2 - Curse of Dimensionality: You have 500 samples and 100 features. Rule of thumb: need n_samples > 10 * n_features.
- You need: 1000+ samples
- You have: 500 samples
- You're in the overfitting zone
Solutions (in order of priority):
- Feature Selection: Reduce to 20-30 most important features
- Regularization: Use max_depth=3, min_samples_split=20 in Random Forest
- Simpler Model: Try Logistic Regression with L2 regularization
- Cross-Validation: Use 5-fold CV instead of single train/test split
Challenge: I predict that with proper validation and feature selection, your 'true' test accuracy is closer to 65% (not 70%). Let's verify this."
Example 6: Iterative Refinement - Feature Engineering
User: "I want to add polynomial features to improve my model"
Round 1 - Initial Critique: "Let me challenge this:
Questions:
- What's your current model performance?
- What's the baseline performance?
- How many features do you currently have?
- How many samples?
Concern: Polynomial features increase feature space from n to n². If you have 10 features, you'll get 100 features. This can cause severe overfitting if n_samples is small.
Alternative: Have you tried:
- Feature selection (remove irrelevant features)?
- Simple non-linear model (Random Forest, which captures non-linearity without explicit polynomial features)?
Let's gather information first."
User: "I have 1000 samples, 5 features, using linear regression. Current R² is 0.65, baseline (predict mean) is 0.0."
Round 2 - Refined Analysis: "Good context. Let me refine my analysis:
Positive Signs:
- 1000 samples is decent
- 5 features is small (polynomial will give 15 features - still manageable)
- R² of 0.65 vs 0.0 baseline shows features are useful
Concerns:
- Polynomial features will increase features from 5 to 15 (3x increase)
- This increases overfitting risk
- You'll lose interpretability
Recommendation: Let's try a controlled experiment:
- Baseline: Current linear model (R² = 0.65)
- Alternative 1: Polynomial features with regularization (Ridge regression)
- Alternative 2: Random Forest (captures non-linearity without explicit polynomials)
Hypothesis: Random Forest will outperform polynomial features because:
- It captures non-linearity automatically
- It's less prone to overfitting
- It maintains some interpretability (feature importance)
Let's test this hypothesis."
User: "I tried both. Polynomial + Ridge: R² = 0.72. Random Forest: R² = 0.75."
Round 3 - Final Analysis and Optimization: "Excellent - now we have evidence. Let me analyze:
Results:
- Linear: 0.65
- Polynomial + Ridge: 0.72 (10.8% improvement)
- Random Forest: 0.75 (15.4% improvement)
Analysis:
- Random Forest wins
- But polynomial features did help (0.72 vs 0.65)
Critical Question: Is the Random Forest overfitting?
- Check train R² vs test R²
- If train R² >> test R², you're overfitting
Next Steps:
- Check Random Forest train/test gap
- If gap > 0.1, add regularization (max_depth, min_samples_split)
- Do error analysis - which samples have high residuals?
- Consider ensemble: average predictions from Ridge and Random Forest
Challenge: I hypothesize that an ensemble of Ridge (with polynomial features) and Random Forest will get R² = 0.78. Let's test this."
References
For detailed information, see:
- Expert Thinking Frameworks - Deep dive into novice vs expert mindset
- Full Workflow Guide - Step-by-step process from problem to deployment
- Navigation Index - Complete reference documentation
Maintenance
Sources:
- Primary:
Machine_Learning_Expert_Guide.md(comprehensive ML expert thinking guide) - Verification: scikit-learn documentation, ML best practices literature
Last Updated: 2026-01-24
Version: 2.0.0 - Enhanced with Critical Discussion Mode
- Added Critical Discussion Protocol with 3-round iteration cycle
- Added Self-Critique Framework with Devil's Advocate mode
- Added User Proposal Critique Framework with 5-step process
- Added Discussion Checkpoints to all 5 workflow phases
- Added 3 new critical dialogue examples (Examples 4-6)
Known Limits:
- Focuses on tabular data and perception data (images, text, audio)
- Does not cover reinforcement learning
- Does not cover specialized time series methods (ARIMA, Prophet)
- Assumes Python/scikit-learn ecosystem
Non-Goals:
- Production deployment and MLOps (use deployment skills)
- Distributed training infrastructure
- Model serving and monitoring
Reviews
No reviews yet. Be the first.
Related
orchestration-patterns
>
migration-patterns
>
deployment-sop
>
mh install skills/lqf-machine-learning-expert-guide