smartyfy.mrindigi.com

Python Master Course V2 — 191. Portfolio Planning and Problem Scoping

Lesson 191: Portfolio Planning and Problem Scoping

A portfolio project is an argument supported by runnable evidence: a problem mattered, a method was appropriate and the result has known limits. A smaller finished project with honest evaluation is more persuasive than a long list of technologies. This lesson produces an executable project brief before implementation. Choose one primary track from lessons 192–197; those six lessons are alternatives, not six mandatory capstones.

Estimated study time: 100 minutes, including the practical work. Use a local Python 3.11+ environment; no paid service, API key or public deployment is required.

Before you start

  • 120, 130, 140, 150, 160, 170, 180 and 190: completed module capstones

Learning objectives

  • Select a bounded problem with a real evaluation question
  • Define data rights, baselines, constraints and acceptance criteria
  • Plan reproducible evidence and a manageable delivery schedule

Concepts and worked implementation

Scope an answerable question

Start with a user or workflow and an observable question. “Use machine learning on operations” is too broad. “On generated maintenance records from previously unseen machines, does a bounded classifier improve precision-recall performance over a constant baseline?” identifies data, generalization target and comparison. A data-analysis track might instead estimate a difference with uncertainty, while a retrieval track asks whether relevant source IDs appear among the first three results.

The portfolio cannot demonstrate impact on a real business from synthetic data alone. Synthetic data is valuable because you can publish the generator, control failure cases and avoid privacy or license ambiguity. Explain the generating assumptions and what they omit. If you later use an external dataset, verify its license, permitted uses, provenance and redistribution restrictions separately. A download link is not permission to repackage the data.

Choose a smaller comparison project from another track to study one contrasting decision. For example, pair tabular prediction with a short forecasting-baseline exercise to explain why grouped and temporal splits differ. The comparison can be a bounded experiment and a one-page note. It does not require a second full capstone, and lessons 198–200 require one completed primary track.

Create a concrete brief with validation

Save this as plan.py. The schema forces the main decisions into an explicit record. A list of acceptance checks is more actionable than a promise to achieve a flattering score. CPU and time budgets below are planning ceilings to measure locally, not claims about universal runtime.

import json
from pathlib import Path

brief = {
    'project_id': 'synthetic-maintenance-v1',
    'primary_track': 193,
    'comparison_track': 194,
    'question': 'Can held-out machines be ranked better than a constant baseline?',
    'data_rights': 'Locally generated synthetic records; generator included',
    'unit': 'machine-day',
    'split_unit': 'machine_id',
    'baseline': 'DummyClassifier with training prevalence',
    'selection_metric': 'validation average precision',
    'final_metrics': ['average precision', 'Brier score', 'confusion counts'],
    'cpu_budget_minutes': 10,
    'max_candidates': 3,
    'acceptance': [
        'train, validation and test machine IDs are disjoint',
        'preprocessing is fit on training data only',
        'threshold is selected without test labels',
        'test report includes baseline and candidate even if candidate loses',
        'fresh setup reproduces commands and test outcomes'
    ],
    'out_of_scope': ['real maintenance decisions', 'cloud deployment',
                     'collecting real personal or operational data'],
    'evidence': ['generator.py', 'run.py', 'test_contracts.py',
                 'results.json', 'README.md', 'model-card.json']
}


def validate_plan(plan):
    tracks = set(range(192, 198))
    if plan['primary_track'] not in tracks:
        raise ValueError('choose one primary track from 192 to 197')
    if plan['comparison_track'] not in tracks or plan['comparison_track'] == plan['primary_track']:
        raise ValueError('choose a different, smaller comparison')
    if not 1 <= plan['max_candidates'] <= 10:
        raise ValueError('bound the candidate search')
    if plan['cpu_budget_minutes'] <= 0 or len(plan['acceptance']) < 4:
        raise ValueError('budget and acceptance checks required')
    for key in ('question', 'data_rights', 'split_unit', 'baseline'):
        if not isinstance(plan[key], str) or not plan[key].strip():
            raise ValueError('missing planning field: ' + key)
    return plan


if __name__ == '__main__':
    validate_plan(brief)
    Path('project-brief.json').write_text(json.dumps(brief, indent=2), encoding='utf-8')
    print('Validated brief:', brief['project_id'])

Expected outcome: a project-brief.json file with a single primary track, a distinct comparison track and explicit checks. Validation cannot determine whether your scientific question is meaningful; it prevents certain omissions so a reviewer can examine the remaining judgment calls.

Pick a track by its evidence, not its prestige

Data quality and analysis emphasizes schema contracts, lineage, uncertainty and defensible conclusions. Tabular prediction emphasizes leakage-safe splits, baselines, threshold choices and error analysis. Demand forecasting emphasizes available-at-prediction-time features, horizon definitions and failed periods. Document search and triage distinguishes retrieval from classification and includes abstention. Visual inspection emphasizes controlled generation, nuisance shifts and failure galleries. The AI evaluation harness emphasizes fixture honesty, supported answers, safety boundaries and regressions.

Write a risk register before implementation. For each risk, record a trigger and a fallback. If neural training exceeds the local budget, retain the classical baseline and document the omitted comparison. If positive labels are too rare to evaluate, revise the synthetic design before opening the final test set. If a dataset’s license is unclear, use authored or generated data. These are controlled scope decisions, not failures to hide.

Plan milestones that leave usable artifacts

Use four milestones: establish a small valid dataset and baseline; implement one bounded improvement; freeze evaluation and inspect failures; package and reproduce. Assign a time box and deliverable to each. Reserve time for documentation and clean installation rather than treating them as optional polish. Every milestone should leave something a reviewer can inspect even if the next one is delayed.

Acceptance criteria should separate correctness from performance. A valid project can conclude that the baseline wins. An invalid split cannot be rescued by a high score. Define non-negotiable gates such as no leakage, traceable data rights and reproducible commands. Then define descriptive performance goals and explain what you will do if they are not met. This prevents late pressure from turning the final test set into another tuning set.

Keep a decision log with date, question, alternatives, chosen option and evidence. It should capture consequential changes, such as switching from random rows to grouped machines, rather than every minor edit. This log becomes material for the technical defense in lesson 199. It also makes the portfolio easier to continue later without relying on memory.

Guided lab and evidence

Adapt the brief to one chosen track and validate it. Create a six-row evidence checklist covering data origin, schema, baseline, evaluation split, failure analysis and reproducible setup. For each row, specify the filename that will prove completion. Then allocate a manageable schedule and a measurable local compute budget.

Produce the smaller comparison plan in five sentences: what differs, what stays fixed, which metric answers the question, how much work is allowed and what would stop the experiment. Ask a reviewer, or act as your own skeptical reviewer, to identify one ambiguous acceptance criterion. Rewrite it into a command, assertion or observable report item. A complete plan can proceed directly to its selected capstone without taking every track.

Questions worth reasoning through

Must a portfolio model beat every baseline?

No. The project should use an appropriate baseline and report the comparison honestly. Explaining why a simpler method wins can demonstrate strong judgment. The non-negotiable requirement is a valid evaluation, not a predetermined favorable result.

Why choose one primary track?

A focused scope leaves enough time for tests, error analysis and reproducibility. Six unfinished demonstrations usually offer less evidence than one complete project. Additional tracks are optional extensions after the primary release is sound.

What makes an acceptance criterion testable?

It names an observable condition and an evidence source. “High quality data” is vague; “no duplicate event IDs after cleaning, with rejected IDs retained in a quality report” can be checked by code and inspected by a reviewer.

Can synthetic data support a real-world effectiveness claim?

It supports claims about the documented generator and experiment. Real effectiveness requires suitable real-world evidence and appropriate authorization. Use synthetic projects to demonstrate method and engineering quality while clearly bounding external validity.

Why plan a fallback before training?

A predefined fallback protects the schedule and evaluation integrity. Without one, disappointing results can tempt unbounded tuning or test-set reuse. A simpler documented result is preferable to hidden changes made until a metric looks good.

Exercises and worked answers

Exercise 1

Rewrite “Build the best forecast model” as a bounded project question.

Worked answer and reasoning

For generated daily demand, compare persistence, a seven-day seasonal baseline and one regularized lag model at a fixed seven-day horizon over specified rolling origins. Report MAE by origin, including the regime-change period. Limit model choices before evaluation and state the available information at each origin.

Exercise 2

Your primary project is text retrieval. Propose a small comparison without building another full system.

Worked answer and reasoning

Compare the same held-out queries under TF-IDF unigrams and unigrams plus bigrams using the same authored corpus and relevance labels. If the comparison must come from another track, perform one brief data-quality audit from lesson 192 on the query metadata and explain how invalid IDs affect evaluation. Keep the primary deliverable unchanged and document the limited scope.

Recap

A portfolio brief connects a bounded question, lawful data source, credible baseline and verifiable evidence. Choose one main track and a small comparison, preserve an honest evaluation boundary and reserve time for release and review.

Official references

Finish the exercises and mastery checkpoint before marking this lesson complete. Completion is stored on this browser.