{ "cells": [ { "cell_type": "markdown", "id": "35f8b5a0", "metadata": {}, "source": [ "# Week 12: Capstone Project Guide\n", "\n", "*Kmex Consult — Data Science Fundamentals Course*\n", "\n", "Work through each code cell in order. Edit and re-run to experiment." ] }, { "cell_type": "markdown", "id": "a0560117", "metadata": {}, "source": [ "*Integrating All Data Science Fundamentals into a Comprehensive Project*" ] }, { "cell_type": "markdown", "id": "41570c9b", "metadata": {}, "source": [ "## Week 12 Overview\n", "Week 12 is your culminating experience - a comprehensive capstone project that integrates everything you've learned throughout the 12-week course. This is your opportunity to:\n", "\n", "✓ Demonstrate mastery of statistical analysis\n", "✓ Apply machine learning techniques\n", "✓ Show real-world data science skills\n", "✓ Build a professional portfolio piece\n", "✓ Practice communication of technical findings\n", "\n", "PROJECT GOALS:\n", "1. End-to-End Analysis: From raw data to insights\n", "2. Multiple Approaches: Statistical AND machine learning\n", "3. Professional Quality: Code, documentation, presentation\n", "4. Business Impact: Translate technical findings to business value\n", "\n", "CAPSTONE PROJECT STRUCTURE:\n", "- Choose or receive dataset\n", "- Exploratory Data Analysis (Weeks 1-5)\n", "- Statistical Analysis (Week 6-8)\n", "- Machine Learning (Weeks 9-10)\n", "- Time Series (if applicable, Week 11)\n", "- Professional Report & Presentation\n", "- Code Repository\n", "\n", "DELIVERABLES:\n", "1. Cleaned Dataset (with documentation)\n", "2. Exploratory Data Analysis Report\n", "3. Statistical Analysis Results\n", "4. Machine Learning Models\n", "5. Code (Well-commented, reproducible)\n", "6. Professional Report (5-10 pages)\n", "7. Presentation (10-15 minutes)\n", "8. GitHub Repository (if possible)\n", "\n", "By the end of Week 12, you will:\n", "- Complete a full data science project\n", "- Have a professional portfolio piece\n", "- Demonstrate all course competencies\n", "- Present findings professionally\n", "- Understand end-to-end workflow\n", "\n", "This week covers:\n", "- Project planning and scope\n", "- Best practices for reproducible research\n", "- Professional documentation\n", "- Presentation skills\n", "- Evaluation and grading criteria" ] }, { "cell_type": "markdown", "id": "eb085ec7", "metadata": {}, "source": [ "## 1. Capstone Project Framework" ] }, { "cell_type": "markdown", "id": "6b37844b", "metadata": {}, "source": [ "### 1.1 Project Phases" ] }, { "cell_type": "code", "execution_count": null, "id": "444a6f8f", "metadata": {}, "outputs": [], "source": [ "PHASE 1: PLANNING AND SETUP (Days 1-2)\n", "\n", "Step 1: Choose or Receive Dataset\n", "- Option A: Provided dataset from instructor\n", "- Option B: Self-selected from Kaggle/UCI/government sources\n", "- Option C: Your own collected data\n", "\n", "Dataset Criteria:\n", "✓ 100-10,000+ observations (enough data)\n", "✓ 5-30+ features (interesting complexity)\n", "✓ Mix of data types (continuous, categorical)\n", "✓ Real-world problem (not toy dataset)\n", "✓ Approachable scope (finishable in week)\n", "\n", "Examples:\n", "- Housing price prediction\n", "- Customer churn prediction\n", "- Iris classification (classic)\n", "- Titanic survival prediction\n", "- Crime data analysis by city\n", "- Stock price forecasting\n", "- Customer satisfaction survey\n", "- Medical diagnosis prediction\n", "\n", "Step 2: Define Problem Statement\n", "- What's the business question?\n", "- What decisions will data inform?\n", "- Who's the audience (stakeholders)?\n", "- What's success look like?\n", "\n", "Template:\n", "\"The goal of this project is to [prediction/classification/analysis]\n", "in order to [business objective]. We will use [data source]\n", "containing [n] observations and [p] features to [specific task].\"\n", "\n", "Step 3: Exploratory Analysis Plan\n", "- What patterns to look for?\n", "- Which visualizations to create?\n", "- Hypotheses to test?\n", "\n", "Step 4: Set Up Repository\n", "✓ Create GitHub repository (optional but recommended)\n", "✓ Folder structure:\n", "/data (raw and cleaned datasets)\n", "/notebooks (Jupyter notebooks)\n", "/scripts (Python modules)\n", "/results (outputs, visualizations)\n", "/report (final documentation)\n", "✓ README.md explaining project\n", "✓ .gitignore file (exclude large files)\n", "\n", "PHASE 2: EXPLORATORY DATA ANALYSIS (Days 2-3)\n", "\n", "Step 1: Data Loading and Initial Inspection\n", "```python\n", "import pandas as pd\n", "import numpy as np\n", "\n", "# Load data\n", "data = pd.read_csv('data/raw/dataset.csv')\n", "\n", "# Initial checks\n", "print(f\"Shape: {data.shape}\")\n", "print(f\"\\nData types:\\n{data.dtypes}\")\n", "print(f\"\\nMissing values:\\n{data.isnull().sum()}\")\n", "print(f\"\\nBasic statistics:\\n{data.describe()}\")\n", "print(f\"\\nFirst rows:\\n{data.head()}\")\n", "```\n", "\n", "Step 2: Data Cleaning\n", "- Identify and handle missing values\n", "- Remove duplicates\n", "- Fix data type inconsistencies\n", "- Detect and address outliers\n", "- Standardize formatting (dates, categories)\n", "\n", "Step 3: Exploratory Visualizations\n", "- Histograms for distributions\n", "- Box plots for outliers\n", "- Scatterplots for relationships\n", "- Heatmaps for correlations\n", "- Time series plots if temporal\n", "\n", "Step 4: Summary Statistics\n", "- Descriptive statistics\n", "- Correlation analysis\n", "- Grouped statistics\n", "- Patterns and anomalies\n", "\n", "Step 5: Document Findings\n", "- What's surprising?\n", "- Data quality issues?\n", "- Missing patterns?\n", "- Initial hypotheses?\n", "\n", "PHASE 3: STATISTICAL ANALYSIS (Days 4-5)\n", "\n", "Choose and implement 3-5 relevant statistical tests:\n", "\n", "Example 1 (Classification):\n", "- Test difference between groups using t-test/ANOVA\n", "- Chi-square for categorical relationships\n", "- Effect sizes and confidence intervals\n", "\n", "Example 2 (Regression):\n", "- Linear regression with multiple predictors\n", "- Test assumptions (normality, linearity)\n", "- Interpret coefficients and R²\n", "\n", "Example 3 (Relationships):\n", "- Correlation analysis\n", "- Test for statistical significance\n", "- Spurious correlations check\n", "\n", "PHASE 4: MACHINE LEARNING (Days 5-6)\n", "\n", "Build Multiple Models:\n", "1. Baseline model (simple, easy to interpret)\n", "2. Intermediate model (balanced)\n", "3. Advanced model (complex, high accuracy)\n", "\n", "Workflow:\n", "- Data preprocessing (scaling, encoding, feature engineering)\n", "- Train/test split\n", "- Model training\n", "- Hyperparameter tuning\n", "- Model evaluation\n", "- Feature importance analysis\n", "\n", "Compare Models:\n", "- Accuracy, precision, recall, F1 (classification)\n", "- RMSE, R², MAE (regression)\n", "- Cross-validation scores\n", "- ROC curves if applicable\n", "\n", "PHASE 5: SYNTHESIS AND INTERPRETATION (Days 6-7)\n", "\n", "Integration:\n", "- How do statistical findings relate to ML?\n", "- Do they tell the same story?\n", "- Any contradictions to resolve?\n", "- What patterns emerge?\n", "\n", "Deeper Analysis:\n", "- Feature importance from multiple models\n", "- Business implications\n", "- Practical significance (not just p-values)\n", "- Actionable insights\n", "\n", "PHASE 6: DOCUMENTATION AND PRESENTATION (Days 7-8)\n", "\n", "Professional Report:\n", "1. Executive Summary (1 page)\n", "2. Problem Statement (½ page)\n", "3. Data Description (1 page)\n", "4. Methodology (1 page)\n", "5. Results (2-3 pages)\n", "6. Conclusions and Recommendations (1 page)\n", "7. Appendix (code, tables)\n", "\n", "Presentation:\n", "1. Opening: Problem and motivation (2 min)\n", "2. Data overview (2 min)\n", "3. Methods and approach (3 min)\n", "4. Key findings (5 min)\n", "5. Conclusions and recommendations (2 min)\n", "6. Q&A (1 min)\n", "\n", "PHASE 7: POLISH AND SUBMIT (Day 8)\n", "\n", "Final Checklist:\n", "- Code is clean and commented\n", "- All outputs reproducible\n", "- Visualizations professional\n", "- Report proofread\n", "- Presentation rehearsed\n", "- Repository organized\n", "- README complete" ] }, { "cell_type": "markdown", "id": "25fdafe6", "metadata": {}, "source": [ "### 1.2 Best Practices for Reproducible Research" ] }, { "cell_type": "code", "execution_count": null, "id": "73749f94", "metadata": {}, "outputs": [], "source": [ "REPRODUCIBILITY FUNDAMENTALS:\n", "\n", "\"Code and analysis should produce same results if re-run on same data\"\n", "\n", "WHY REPRODUCIBILITY MATTERS:\n", "- Verify results are correct\n", "- Build trust in findings\n", "- Allow others to extend your work\n", "- Professional standard\n", "- Catches bugs and errors\n", "\n", "PRACTICES:\n", "\n", "1. RANDOM SEEDS\n", "```python\n", "import random\n", "import numpy as np\n", "\n", "# Set seed once at beginning of notebook\n", "random.seed(42)\n", "np.random.seed(42)\n", "\n", "# Then all random operations are reproducible\n", "train, test = train_test_split(data, test_size=0.2) # Same split every time\n", "model = RandomForestClassifier(random_state=42) # Reproducible model\n", "```\n", "\n", "2. DOCUMENT ENVIRONMENT\n", "Create requirements.txt:\n", "```\n", "pandas==1.5.2\n", "numpy==1.23.5\n", "scikit-learn==1.2.0\n", "matplotlib==3.6.3\n", "jupyter==1.0.0\n", "statsmodels==0.13.5\n", "```\n", "\n", "Or use environment file:\n", "```\n", "conda env export > environment.yml\n", "```\n", "\n", "3. VERSION CONTROL\n", "- Use Git to track changes\n", "- Meaningful commit messages\n", "- Tag versions: v1.0, v2.0, etc.\n", "- Document major changes\n", "\n", "4. COMMENTS AND DOCUMENTATION\n", "```python\n", "# Bad:\n", "df['new_col'] = df['col1'] * 2 + df['col2']\n", "\n", "# Good:\n", "# Calculate customer lifetime value as:\n", "# 2 × average purchase + total transactions\n", "df['customer_lifetime_value'] = df['avg_purchase'] * 2 + df['total_transactions']\n", "```\n", "\n", "5. FUNCTION ABSTRACTION\n", "```python\n", "# Instead of repeating code:\n", "def process_column(data, column, method='zscore'):\n", "\"\"\"\n", "Standardize a column using specified method.\n", "\n", "Parameters:\n", "-----------\n", "data : DataFrame\n", "column : str, column name\n", "method : str, 'zscore', 'minmax', or 'log'\n", "\n", "Returns:\n", "--------\n", "DataFrame with processed column\n", "\"\"\"\n", "if method == 'zscore':\n", "mean = data[column].mean()\n", "std = data[column].std()\n", "data[column] = (data[column] - mean) / std\n", "return data\n", "```\n", "\n", "6. NOTEBOOK ORGANIZATION\n", "```\n", "1. Import all libraries at top\n", "2. Set random seeds\n", "3. Load data\n", "4. Section 1: Data Cleaning\n", "5. Section 2: EDA\n", "6. Section 3: Statistical Analysis\n", "7. Section 4: ML Models\n", "8. Section 5: Summary and Conclusions\n", "```\n", "\n", "7. DATA HANDLING\n", "- Keep raw data separate and read-only\n", "- Save intermediate datasets with version\n", "- Document data transformations\n", "- Track what data you used\n", "\n", "8. ASSUMPTIONS DOCUMENTATION\n", "```python\n", "# Clearly state assumptions\n", "print(\"ASSUMPTIONS:\")\n", "print(\"1. Missing data (5%) removed via listwise deletion\")\n", "print(\"2. Outliers (|z| > 3) removed: 12 observations\")\n", "print(\"3. Features scaled using z-score normalization\")\n", "print(\"4. Train/test split: 80/20, random_state=42\")\n", "```\n", "\n", "9. ERROR HANDLING\n", "```python\n", "try:\n", "model.fit(X_train, y_train)\n", "except Exception as e:\n", "print(f\"Model fitting failed: {e}\")\n", "# Handle error appropriately\n", "```\n", "\n", "10. TESTING (Optional but Professional)\n", "```python\n", "def test_data_loading():\n", "\"\"\"Test that data loads correctly\"\"\"\n", "data = pd.read_csv('data/raw/dataset.csv')\n", "assert data.shape[0] > 0, \"No data loaded\"\n", "assert data.shape[1] > 0, \"No features loaded\"\n", "\n", "def test_preprocessing():\n", "\"\"\"Test preprocessing function\"\"\"\n", "data = load_data()\n", "processed = preprocess(data)\n", "assert not processed.isnull().any().any(), \"Missing values remain\"\n", "```\n", "\n", "BEST PRACTICES CHECKLIST:\n", "\n", "Before Submission:\n", "☑ Code runs without errors\n", "☑ Results reproducible (set seeds)\n", "☑ All data paths relative (not hardcoded)\n", "☑ Functions documented with docstrings\n", "☑ Comments explain \"why\", not \"what\"\n", "☑ No hardcoded values (use variables)\n", "☑ Libraries documented in requirements.txt\n", "☑ Data processing documented\n", "☑ Assumptions clearly stated\n", "☑ Visualizations labeled clearly\n", "☑ Code follows naming conventions\n", "☑ Variables have meaningful names\n", "☑ Notebooks organized with headings\n", "☑ README explains how to run" ] }, { "cell_type": "markdown", "id": "c8a5e415", "metadata": {}, "source": [ "## 2. Comprehensive Project Checklist\n", "PRE-PROJECT (Before you start):\n", "☑ Choose or receive dataset\n", "☑ Understand problem statement\n", "☑ Set up folder structure\n", "☑ Create GitHub repository (optional)\n", "☑ Install required packages\n", "\n", "EXPLORATORY DATA ANALYSIS:\n", "☑ Load data and check shape\n", "☑ Identify data types\n", "☑ Check for missing values\n", "☑ Identify outliers\n", "☑ Calculate descriptive statistics\n", "☑ Create distribution plots (histograms)\n", "☑ Create relationship plots (scatter plots)\n", "☑ Calculate correlations\n", "☑ Create correlation heatmap\n", "☑ Identify potential data quality issues\n", "☑ Document all findings\n", "\n", "DATA CLEANING:\n", "☑ Handle missing values (document strategy)\n", "☑ Remove or fix duplicates\n", "☑ Standardize data types\n", "☑ Fix data inconsistencies\n", "☑ Handle outliers (investigate, document)\n", "☑ Transform variables if needed\n", "☑ Create clean dataset\n", "☑ Document all transformations\n", "\n", "FEATURE ENGINEERING:\n", "☑ Create new features from existing ones\n", "☑ Encode categorical variables\n", "☑ Scale/normalize continuous variables\n", "☑ Handle categorical variables (one-hot, label)\n", "☑ Deal with multicollinearity\n", "☑ Select important features\n", "☑ Document all feature engineering steps\n", "\n", "STATISTICAL ANALYSIS:\n", "☑ Test for normality (Shapiro-Wilk)\n", "☑ Test for equal variance (Levene's)\n", "☑ Check independence of observations\n", "☑ Identify relevant statistical tests (3-5 tests)\n", "☑ Run hypothesis tests\n", "☑ Calculate effect sizes\n", "☑ Interpret p-values and confidence intervals\n", "☑ Document assumptions checked\n", "☑ Create summary statistics table\n", "☑ Report findings professionally\n", "\n", "MACHINE LEARNING:\n", "☑ Split data into train/test (time-based if time series)\n", "☑ Build baseline model (simple)\n", "☑ Build intermediate model\n", "☑ Build advanced model\n", "☑ Evaluate each model (multiple metrics)\n", "☑ Perform hyperparameter tuning\n", "☑ Use cross-validation\n", "☑ Analyze feature importance\n", "☑ Create ROC curves if applicable\n", "☑ Compare models side-by-side\n", "☑ Select best model\n", "\n", "SYNTHESIS:\n", "☑ Connect statistical findings to ML results\n", "☑ Identify key insights\n", "☑ Determine business implications\n", "☑ Quantify impact (if possible)\n", "☑ Document limitations\n", "☑ Note areas for future work\n", "\n", "DOCUMENTATION:\n", "☑ Write executive summary\n", "☑ Document problem statement\n", "☑ Describe data clearly\n", "☑ Explain methodology\n", "☑ Present results with visualizations\n", "☑ Draw conclusions\n", "☑ Make recommendations\n", "☑ Add appendix with code/tables\n", "\n", "PRESENTATION:\n", "☑ Create slides (5-10 slides)\n", "☑ Include key visualizations\n", "☑ Explain findings clearly\n", "☑ Keep technical level appropriate\n", "☑ Practice presentation\n", "☑ Prepare for questions\n", "☑ Have backup slides\n", "\n", "CODE QUALITY:\n", "☑ All code commented\n", "☑ Functions have docstrings\n", "☑ Variable names are meaningful\n", "☑ No hardcoded paths (use relative paths)\n", "☑ Random seeds set for reproducibility\n", "☑ No print statements for debugging\n", "☑ Code follows consistent style\n", "☑ Error handling where appropriate\n", "☑ Code is DRY (Don't Repeat Yourself)\n", "\n", "REPOSITORY:\n", "☑ README.md explains project\n", "☑ Folder structure is clear\n", "☑ .gitignore excludes large files\n", "☑ requirements.txt or environment.yml included\n", "☑ All necessary files included\n", "☑ No personal information in data\n", "☑ Large files not committed to Git\n", "\n", "FINAL CHECKS:\n", "☑ All outputs reproducible\n", "☑ Code runs without errors\n", "☑ Visualizations are clear and labeled\n", "☑ Report is professional\n", "☑ Spelling and grammar checked\n", "☑ Presentation is prepared\n", "☑ Submitted on time\n", "☑ All deliverables included" ] }, { "cell_type": "markdown", "id": "3d5a0c2d", "metadata": {}, "source": [ "## 3. Example Project Workflow" ] }, { "cell_type": "code", "execution_count": null, "id": "d1f1e6ff", "metadata": {}, "outputs": [], "source": [ "PROJECT EXAMPLE: PREDICTING CUSTOMER CHURN\n", "\n", "PHASE 1: PLANNING\n", "\n", "Problem Statement:\n", "\"Identify which customers are likely to churn (leave) so we can\n", "implement retention strategies. Success means building a model\n", "that predicts churn with 80%+ accuracy.\"\n", "\n", "Dataset:\n", "- 7,043 customers\n", "- 21 features (demographics, usage, billing)\n", "- Target: Churn (Yes/No)\n", "\n", "Success Criteria:\n", "- Accuracy > 80%\n", "- Precision > 75% (minimize false positives)\n", "- Identify top 3 churn drivers\n", "- Actionable business recommendations\n", "\n", "PHASE 2: EXPLORATION\n", "\n", "Initial Exploration:\n", "```python\n", "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import seaborn as sns\n", "\n", "data = pd.read_csv('data/raw/customer_churn.csv')\n", "print(data.shape) # (7043, 21)\n", "print(data.info())\n", "print(data.describe())\n", "print(data['Churn'].value_counts())\n", "# Output: No: 5174 (73.5%), Yes: 1869 (26.5%)\n", "\n", "# Visualize\n", "plt.figure(figsize=(12, 5))\n", "plt.subplot(1, 2, 1)\n", "data['Churn'].value_counts().plot(kind='bar')\n", "plt.title('Churn Distribution')\n", "\n", "plt.subplot(1, 2, 2)\n", "data.groupby('Churn')['Monthly_Charges'].mean().plot(kind='bar')\n", "plt.title('Average Monthly Charges by Churn')\n", "plt.show()\n", "\n", "# Check missing data\n", "print(data.isnull().sum())\n", "```\n", "\n", "Key Findings:\n", "- Imbalanced target (26.5% churn)\n", "- 3 missing values in TotalCharges\n", "- Churn customers have higher monthly charges\n", "- Mix of continuous and categorical features\n", "\n", "PHASE 3: DATA CLEANING\n", "\n", "```python\n", "# Handle missing values\n", "data['TotalCharges'] = pd.to_numeric(data['TotalCharges'], errors='coerce')\n", "data = data.dropna() # Remove 3 rows with missing TotalCharges\n", "\n", "# Remove duplicates\n", "data = data.drop_duplicates()\n", "\n", "# Encode categorical variables\n", "categorical_cols = ['Gender', 'InternetService', 'OnlineSecurity']\n", "for col in categorical_cols:\n", "data[col] = pd.Categorical(data[col]).codes\n", "\n", "# Scale continuous variables\n", "from sklearn.preprocessing import StandardScaler\n", "scaler = StandardScaler()\n", "continuous_cols = ['Age', 'Monthly_Charges', 'TotalCharges']\n", "data[continuous_cols] = scaler.fit_transform(data[continuous_cols])\n", "\n", "print(f\"Cleaned data shape: {data.shape}\")\n", "data.to_csv('data/processed/churn_cleaned.csv', index=False)\n", "```\n", "\n", "PHASE 4: STATISTICAL ANALYSIS\n", "\n", "```python\n", "from scipy.stats import chi2_contingency, ttest_ind\n", "\n", "# Test 1: Chi-square for gender vs churn\n", "table = pd.crosstab(data['Gender'], data['Churn'])\n", "chi2, pval, dof, expected = chi2_contingency(table)\n", "print(f\"Gender vs Churn: χ²={chi2:.2f}, p={pval:.4f}\")\n", "# Result: p < 0.05, significant relationship\n", "\n", "# Test 2: T-test for age vs churn\n", "churn_yes = data[data['Churn'] == 'Yes']['Age']\n", "churn_no = data[data['Churn'] == 'No']['Age']\n", "t_stat, p_val = ttest_ind(churn_yes, churn_no)\n", "print(f\"Age vs Churn: t={t_stat:.2f}, p={p_val:.4f}\")\n", "# Result: p < 0.05, churners are younger on average\n", "\n", "# Test 3: Correlation of monthly charges\n", "corr = data['Monthly_Charges'].corr(data['Churn_numeric'])\n", "print(f\"Correlation (Charges-Churn): r={corr:.3f}\")\n", "# Result: r = 0.31, moderate positive relationship\n", "```\n", "\n", "PHASE 5: MACHINE LEARNING\n", "\n", "```python\n", "from sklearn.model_selection import train_test_split\n", "from sklearn.preprocessing import StandardScaler\n", "from sklearn.linear_model import LogisticRegression\n", "from sklearn.ensemble import RandomForestClassifier\n", "from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score\n", "\n", "# Prepare data\n", "X = data.drop('Churn', axis=1)\n", "y = (data['Churn'] == 'Yes').astype(int) # 1=churn, 0=no churn\n", "\n", "X_train, X_test, y_train, y_test = train_test_split(\n", "X, y, test_size=0.2, random_state=42, stratify=y\n", ")\n", "\n", "# Model 1: Baseline - Logistic Regression\n", "model_lr = LogisticRegression(max_iter=1000, random_state=42)\n", "model_lr.fit(X_train, y_train)\n", "pred_lr = model_lr.predict(X_test)\n", "\n", "print(\"\\nLogistic Regression Results:\")\n", "print(f\"Accuracy: {accuracy_score(y_test, pred_lr):.3f}\")\n", "print(f\"Precision: {precision_score(y_test, pred_lr):.3f}\")\n", "print(f\"Recall: {recall_score(y_test, pred_lr):.3f}\")\n", "print(f\"F1: {f1_score(y_test, pred_lr):.3f}\")\n", "# Output: Accuracy: 0.810, Precision: 0.652, Recall: 0.564\n", "\n", "# Model 2: Advanced - Random Forest\n", "model_rf = RandomForestClassifier(n_estimators=100, max_depth=10,\n", "random_state=42, class_weight='balanced')\n", "model_rf.fit(X_train, y_train)\n", "pred_rf = model_rf.predict(X_test)\n", "\n", "print(\"\\nRandom Forest Results:\")\n", "print(f\"Accuracy: {accuracy_score(y_test, pred_rf):.3f}\")\n", "print(f\"Precision: {precision_score(y_test, pred_rf):.3f}\")\n", "print(f\"Recall: {recall_score(y_test, pred_rf):.3f}\")\n", "print(f\"F1: {f1_score(y_test, pred_rf):.3f}\")\n", "# Output: Accuracy: 0.837, Precision: 0.721, Recall: 0.612\n", "\n", "# Feature Importance\n", "feature_importance = pd.DataFrame({\n", "'Feature': X.columns,\n", "'Importance': model_rf.feature_importances_\n", "}).sort_values('Importance', ascending=False)\n", "\n", "print(\"\\nTop 5 Churn Drivers:\")\n", "print(feature_importance.head())\n", "```\n", "\n", "PHASE 6: SYNTHESIS\n", "\n", "Key Findings:\n", "1. Younger customers more likely to churn\n", "2. Customers with higher monthly charges more likely to churn\n", "3. Tenure is strongest predictor (loyalty matters)\n", "4. Month-to-month contracts have higher churn\n", "5. Fiber optic internet users churn more\n", "\n", "Business Recommendations:\n", "1. Develop retention program for new customers (first 6 months critical)\n", "2. Investigate fiber optic service quality issues\n", "3. Offer long-term contract incentives\n", "4. Implement early warning system (flag high-risk customers)\n", "5. Target outreach to customers with high charges\n", "\n", "Model Recommendation:\n", "- Deploy Random Forest (83.7% accuracy, better precision)\n", "- Use monthly retraining with new customer data\n", "- Set threshold for flagging high-risk customers\n", "- Monitor model performance quarterly\n", "\n", "PHASE 7: PROFESSIONAL REPORT STRUCTURE\n", "\n", "1. Executive Summary (1 page)\n", "- Business problem\n", "- Key findings\n", "- Recommendations\n", "- Expected impact\n", "\n", "2. Introduction\n", "- Company context\n", "- Problem statement\n", "- Project objectives\n", "\n", "3. Data Description\n", "- Source and collection method\n", "- 7,043 customers, 21 features\n", "- Data cleaning steps\n", "- Final dataset characteristics\n", "\n", "4. Methodology\n", "- Statistical tests performed\n", "- ML models implemented\n", "- Evaluation metrics\n", "- Validation approach\n", "\n", "5. Results\n", "- Statistical findings\n", "- Model comparisons\n", "- Feature importance\n", "- Visualizations\n", "\n", "6. Conclusions\n", "- Key insights\n", "- Business implications\n", "- Model limitations\n", "\n", "7. Recommendations\n", "- Actionable next steps\n", "- Implementation roadmap\n", "- Expected ROI\n", "\n", "PHASE 8: PRESENTATION\n", "\n", "Slide Deck:\n", "1. Title slide\n", "2. Problem statement\n", "3. Data overview\n", "4. Statistical findings\n", "5. Model comparison\n", "6. Top churn drivers\n", "7. Business recommendations\n", "8. Implementation plan\n", "9. Questions\n", "\n", "Key talking points:\n", "- \"We identified churn drivers using data science\"\n", "- \"Our model is 84% accurate at predicting churn\"\n", "- \"If we implement retention for flagged customers, we'll save $X\"\n", "- \"Next steps: test with pilot group, then full deployment\"" ] }, { "cell_type": "markdown", "id": "68c964a9", "metadata": {}, "source": [ "## 4. Evaluation Criteria and Grading\n", "CAPSTONE PROJECT GRADING RUBRIC:\n", "\n", "EXPLORATORY DATA ANALYSIS (15%):\n", "Excellent (13-15):\n", "✓ Thorough data exploration\n", "✓ Multiple visualizations (8+)\n", "✓ Insightful observations\n", "✓ Clear summary of findings\n", "\n", "Good (10-12):\n", "✓ Adequate exploration\n", "✓ Several visualizations (5-7)\n", "✓ Some insights noted\n", "✓ Summary provided\n", "\n", "Acceptable (7-9):\n", "✓ Basic exploration\n", "✓ Few visualizations (3-4)\n", "✓ Limited insights\n", "✓ Basic summary\n", "\n", "Poor (0-6):\n", "✗ Minimal exploration\n", "✗ Few visualizations\n", "✗ No insights\n", "✗ No summary\n", "\n", "DATA CLEANING AND PREPROCESSING (15%):\n", "Excellent (13-15):\n", "✓ Thorough cleaning documented\n", "✓ Missing data handled appropriately\n", "✓ Outliers investigated\n", "✓ Feature engineering applied\n", "✓ All transformations documented\n", "\n", "Good (10-12):\n", "✓ Good cleaning process\n", "✓ Missing data addressed\n", "✓ Some feature engineering\n", "✓ Documentation adequate\n", "\n", "Acceptable (7-9):\n", "✓ Basic cleaning done\n", "✓ Missing data handled simply\n", "✓ Minimal feature engineering\n", "✓ Some documentation\n", "\n", "Poor (0-6):\n", "✗ Incomplete cleaning\n", "✗ Missing data ignored\n", "✗ No feature engineering\n", "✗ No documentation\n", "\n", "STATISTICAL ANALYSIS (20%):\n", "Excellent (18-20):\n", "✓ 5+ relevant tests applied\n", "✓ Assumptions checked\n", "✓ Results interpreted correctly\n", "✓ Effect sizes reported\n", "✓ Significance vs importance discussed\n", "\n", "Good (14-17):\n", "✓ 4 relevant tests\n", "✓ Most assumptions checked\n", "✓ Results mostly correct\n", "✓ Some effect sizes\n", "\n", "Acceptable (10-13):\n", "✓ 3 relevant tests\n", "✓ Basic assumption checking\n", "✓ Basic interpretation\n", "✓ Limited effect sizes\n", "\n", "Poor (0-9):\n", "✗ Few tests\n", "✗ No assumption checking\n", "✗ Misinterpretation\n", "✗ No effect sizes\n", "\n", "MACHINE LEARNING MODELS (20%):\n", "Excellent (18-20):\n", "✓ 3+ models built and compared\n", "✓ Hyperparameter tuning done\n", "✓ Cross-validation used\n", "✓ Multiple metrics evaluated\n", "✓ Feature importance analyzed\n", "✓ Best model selected with justification\n", "\n", "Good (14-17):\n", "✓ 3 models built\n", "✓ Some tuning\n", "✓ Cross-validation attempted\n", "✓ Multiple metrics\n", "✓ Model selection justified\n", "\n", "Acceptable (10-13):\n", "✓ 2 models built\n", "✓ Basic evaluation\n", "✓ One metric used\n", "✓ Limited comparison\n", "\n", "Poor (0-9):\n", "✗ 1 or fewer models\n", "✗ No evaluation\n", "✗ Single metric only\n", "✗ No comparison\n", "\n", "CODE QUALITY (15%):\n", "Excellent (13-15):\n", "✓ Well-commented code\n", "✓ Functions and modularity used\n", "✓ Reproducible (seeds set)\n", "✓ No errors or warnings\n", "✓ Professional style\n", "\n", "Good (10-12):\n", "✓ Mostly commented\n", "✓ Some functions\n", "✓ Mostly reproducible\n", "✓ Few errors\n", "✓ Good style\n", "\n", "Acceptable (7-9):\n", "✓ Basic comments\n", "✓ Limited functions\n", "✓ Basic reproducibility\n", "✓ Some errors\n", "✓ Inconsistent style\n", "\n", "Poor (0-6):\n", "✗ No comments\n", "✗ No functions\n", "✗ Not reproducible\n", "✗ Many errors\n", "✗ Poor style\n", "\n", "REPORT AND PRESENTATION (15%):\n", "Excellent (13-15):\n", "✓ Professional report (5-10 pages)\n", "✓ Clear writing\n", "✓ Good visualizations\n", "✓ Compelling presentation (10-15 min)\n", "✓ Good public speaking\n", "✓ Handles questions well\n", "\n", "Good (10-12):\n", "✓ Good report\n", "✓ Clear writing\n", "✓ Adequate visualizations\n", "✓ Good presentation\n", "✓ Competent speaking\n", "\n", "Acceptable (7-9):\n", "✓ Basic report\n", "✓ Understandable writing\n", "✓ Few visualizations\n", "✓ Adequate presentation\n", "✓ Nervous but clear\n", "\n", "Poor (0-6):\n", "✗ Poor report\n", "✗ Unclear writing\n", "✗ No visualizations\n", "✗ Poor presentation\n", "✗ Incoherent speaking\n", "\n", "TOTAL SCORE: 0-100%\n", "90-100%: A (Excellent)\n", "80-89%: B (Good)\n", "70-79%: C (Acceptable)\n", "<70%: F (Poor)\n", "\n", "COMMON DEDUCTIONS:\n", "- Missing documentation: -10%\n", "- Code not reproducible: -15%\n", "- Incorrect statistical interpretation: -10%\n", "- Limited exploration: -5%\n", "- Poor visualization quality: -5%\n", "- Unprofessional report: -10%" ] }, { "cell_type": "markdown", "id": "fddd342e", "metadata": {}, "source": [ "## 5. Common Mistakes to Avoid\n", "ANALYSIS MISTAKES:\n", "\n", "1. IGNORING MISSING DATA\n", "✗ Don't: Silently ignore missing values\n", "✓ Do: Investigate missingness, document approach\n", "✗ Don't: Assume MCAR (Missing Completely at Random)\n", "✓ Do: Check if missingness related to other variables\n", "\n", "2. NOT CHECKING ASSUMPTIONS\n", "✗ Don't: Run t-test without checking normality\n", "✓ Do: Test assumptions, use alternatives if violated\n", "✗ Don't: Assume linear regression assumptions hold\n", "✓ Do: Check residuals, linearity, independence\n", "\n", "3. P-HACKING\n", "✗ Don't: Try many tests until one is significant\n", "✓ Do: Pre-specify tests before looking at data\n", "✗ Don't: Report only significant results\n", "✓ Do: Report all tests (even null findings)\n", "\n", "4. MULTIPLE COMPARISON PROBLEM\n", "✗ Don't: Do 20 tests without correction\n", "✓ Do: Apply Bonferroni or similar correction\n", "✗ Don't: Assume 5% significance level with many tests\n", "✓ Do: Adjust alpha level based on number of tests\n", "\n", "5. OVERFITTING\n", "✗ Don't: Train and test on same data\n", "✓ Do: Use train/test split\n", "✗ Don't: Build complex model with small data\n", "✓ Do: Use appropriate complexity for sample size\n", "\n", "6. DATA LEAKAGE\n", "✗ Don't: Use target-derived features\n", "✓ Do: Only use features available at prediction time\n", "✗ Don't: Use future information\n", "✓ Do: Strict temporal ordering in train/test\n", "\n", "7. IGNORING CLASS IMBALANCE\n", "✗ Don't: Use accuracy for imbalanced classification\n", "✓ Do: Use F1, precision, recall, ROC-AUC\n", "✗ Don't: Build model that predicts majority class always\n", "✓ Do: Use class weights or resampling\n", "\n", "8. NOT INTERPRETING EFFECT SIZES\n", "✗ Don't: Report only p-values\n", "✓ Do: Report effect sizes (Cohen's d, r, R²)\n", "✗ Don't: Claim large effect with p<0.05\n", "✓ Do: Check actual magnitude of effect\n", "\n", "PRESENTATION MISTAKES:\n", "\n", "1. UNCLEAR VISUALIZATIONS\n", "✗ Don't: Use default plot colors and labels\n", "✓ Do: Add titles, labels, legends\n", "✗ Don't: 3D plots when 2D works\n", "✓ Do: Simple, clear visualizations\n", "\n", "2. JARGON OVERLOAD\n", "✗ Don't: Assume audience knows terminology\n", "✓ Do: Explain technical terms\n", "✗ Don't: Use \"statistically significant\" without context\n", "✓ Do: Explain what it means for business\n", "\n", "3. MISSING CONTEXT\n", "✗ Don't: Report \"R² = 0.73\" without interpretation\n", "✓ Do: \"Model explains 73% of variance\"\n", "✗ Don't: Show p-value without explaining\n", "✓ Do: \"Result unlikely by chance (p=0.03)\"\n", "\n", "4. IGNORING LIMITATIONS\n", "✗ Don't: Claim certainty with small sample\n", "✓ Do: Acknowledge limitations\n", "✗ Don't: Generalize beyond your data\n", "✓ Do: Specify scope of findings\n", "\n", "5. POOR STORYTELLING\n", "✗ Don't: Jump between random findings\n", "✓ Do: Tell coherent narrative\n", "✗ Don't: Show all analysis (too much)\n", "✓ Do: Highlight key findings\n", "\n", "CODE QUALITY MISTAKES:\n", "\n", "1. MAGIC NUMBERS\n", "✗ Don't: if value > 100: ...\n", "✓ Do: THRESHOLD = 100; if value > THRESHOLD: ...\n", "\n", "2. UNCLEAR VARIABLES\n", "✗ Don't: x, y, df1, data2\n", "✓ Do: customer_data, feature_importance\n", "\n", "3. NO COMMENTS\n", "✗ Don't: Code with no explanation\n", "✓ Do: Comment why, not what\n", "\n", "4. NOT TESTING\n", "✗ Don't: Assume code is correct\n", "✓ Do: Run through manually first\n", "\n", "5. HARDCODED PATHS\n", "✗ Don't: '/Users/myname/Desktop/project/data.csv'\n", "✓ Do: 'data/raw/data.csv' (relative path)\n", "\n", "6. NO VERSION CONTROL\n", "✗ Don't: Final_v2_REAL_final_actualfinal.py\n", "✓ Do: Use Git with meaningful commits\n", "\n", "7. MIXED CONCERNS\n", "✗ Don't: Data loading + cleaning + analysis in one script\n", "✓ Do: Separate scripts/functions for each step\n", "\n", "DOCUMENTATION MISTAKES:\n", "\n", "1. MISSING README\n", "✗ Don't: Upload files without explanation\n", "✓ Do: Clear README explaining project\n", "\n", "2. NO DATA DOCUMENTATION\n", "✗ Don't: Assume others understand data\n", "✓ Do: Document each feature (type, source, meaning)\n", "\n", "3. UNCLEAR FOLDER STRUCTURE\n", "✗ Don't: Random files scattered\n", "✓ Do: Organized /data, /notebooks, /results\n", "\n", "4. UNFINISHED WORK\n", "✗ Don't: Submit notebook with TODO comments\n", "✓ Do: Complete all work before submission\n", "\n", "5. BROKEN LINKS/PATHS\n", "✗ Don't: References to files that don't exist\n", "✓ Do: Check all paths work" ] }, { "cell_type": "markdown", "id": "15cad0ae", "metadata": {}, "source": [ "## 6. Resources and Next Steps\n", "USEFUL TOOLS AND LIBRARIES:\n", "\n", "Data Science Stack:\n", "- Pandas: Data manipulation\n", "- NumPy: Numerical computation\n", "- Scikit-learn: Machine learning\n", "- Matplotlib/Seaborn: Visualization\n", "- Statsmodels: Statistical modeling\n", "- Jupyter: Interactive notebooks\n", "\n", "Project Management:\n", "- Git/GitHub: Version control\n", "- Trello: Project tracking\n", "- Notion: Documentation\n", "- Slack: Team communication\n", "\n", "Dataset Sources:\n", "- Kaggle (kaggle.com): Competition datasets\n", "- UCI Machine Learning (archive.ics.uci.edu): Classic datasets\n", "- Google Dataset Search (datasetsearch.research.google.com)\n", "- Government data (data.gov, data.world)\n", "- Academic repositories\n", "\n", "Learning Resources:\n", "- Coursera: DS specializations\n", "- edX: University courses\n", "- Fast.ai: Practical deep learning\n", "- Towards Data Science: Medium blog\n", "- Papers With Code: Research + code\n", "\n", "AFTER CAPSTONE - NEXT STEPS:\n", "\n", "Short Term (Next month):\n", "1. Clean up project code\n", "2. Write blog post about project\n", "3. Share on GitHub/LinkedIn\n", "4. Get feedback from peers\n", "5. Iterate based on feedback\n", "\n", "Medium Term (Next 3 months):\n", "1. Pick another dataset\n", "2. Try advanced techniques learned\n", "3. Specialize in area of interest:\n", "- Deep learning (Neural Networks)\n", "- NLP (Natural language processing)\n", "- Computer Vision (Images)\n", "- Reinforcement Learning\n", "- Causal Inference\n", "\n", "Long Term (Next 6-12 months):\n", "1. Build portfolio with 3-5 projects\n", "2. Contribute to open source\n", "3. Publish blog posts or papers\n", "4. Consider formal education:\n", "- Master's degree in Data Science\n", "- Online specializations\n", "- Bootcamps\n", "5. Network with data scientists\n", "6. Look for internships/jobs\n", "\n", "POTENTIAL SPECIALIZATIONS:\n", "\n", "Data Science (General):\n", "→ Learn statistical inference, experimental design, A/B testing\n", "\n", "Machine Learning Engineering:\n", "→ Learn model deployment, MLOps, production systems\n", "\n", "Deep Learning:\n", "→ Learn PyTorch/TensorFlow, computer vision, NLP\n", "\n", "Data Engineering:\n", "→ Learn databases, Spark, pipelines, cloud platforms\n", "\n", "Analytics:\n", "→ Learn business metrics, dashboarding, SQL\n", "\n", "Business Analytics:\n", "→ Learn business strategy, storytelling, domain knowledge\n", "\n", "INTERVIEW PREPARATION:\n", "\n", "Technical:\n", "- SQL queries (joins, aggregations, window functions)\n", "- Python/R coding challenges\n", "- Statistics and probability\n", "- ML algorithm implementation\n", "- Data structure and algorithms\n", "\n", "Behavioral:\n", "- Walk through past project\n", "- Explain technical decisions\n", "- Handle ambiguous problems\n", "- Communicate findings\n", "- Ask good questions\n", "\n", "Resources:\n", "- LeetCode: Coding challenges\n", "- DataCamp: DS skills\n", "- Mock interviews with mentors\n", "- Practice explaining projects\n", "\n", "BUILDING YOUR PORTFOLIO:\n", "\n", "Online Presence:\n", "1. GitHub profile\n", "- 3-5 complete projects\n", "- Well-documented code\n", "- Clear READMEs\n", "\n", "2. LinkedIn profile\n", "- Professional photo\n", "- Clear headline\n", "- Summary highlighting skills\n", "- Recommendations from others\n", "- Project links\n", "\n", "3. Blog (optional)\n", "- Write about projects\n", "- Explain techniques\n", "- Share insights\n", "- Build audience\n", "\n", "4. Portfolio website (optional)\n", "- Showcase projects\n", "- List skills\n", "- Contact information\n", "\n", "FINAL THOUGHTS:\n", "\n", "Success in data science requires:\n", "1. Technical Skills: Statistics, coding, ML\n", "2. Communication: Explain findings to non-technical audience\n", "3. Domain Knowledge: Understand business context\n", "4. Curiosity: Always learning, trying new things\n", "5. Rigor: Attention to detail, reproducibility\n", "6. Creativity: Novel insights, creative solutions\n", "7. Persistence: Projects have dead ends, keep trying\n", "\n", "The skills you've learned in this 12-week course are:\n", "- Foundational and essential\n", "- Applicable to many fields\n", "- Constantly evolving (keep learning)\n", "- Highly valued in job market\n", "- Enable meaningful work\n", "\n", "This capstone project represents:\n", "- Culmination of 12 weeks of learning\n", "- First step in data science career\n", "- Proof of ability to do real work\n", "- Confidence in tackling new problems\n", "- Beginning of lifelong learning\n", "\n", "Congratulations on completing this course!\n", "You now have skills to:\n", "- Analyze data scientifically\n", "- Build predictive models\n", "- Make data-driven decisions\n", "- Communicate technical findings\n", "- Continue learning independently\n", "\n", "Good luck with your capstone project and future data science endeavors!" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.11" } }, "nbformat": 4, "nbformat_minor": 5 }