DataCareerHub / Machine Learning Foundations

What machine learning can—and cannot—do

Fictional learning case · Attempt the worksheet before opening solutions.

1. Prediction versus explanation

Prediction versus explanation

A prediction estimates an unknown outcome from information available at a defined moment. Explanation asks why something happens; causal explanation asks what would change under an intervention. A model that predicts well does not automatically answer a causal question. Correlation may reflect confounding, selection or a measurement process. Begin with the decision and prediction time rather than an algorithm.

Work through the case

Cedar Parcel Lab asks whether a parcel will take more than 24 hours after dispatch. The prediction is made at dispatch using distance_km, load_ratio and zone. actual_hours and delivered_at become known later. They define or describe the outcome, so including them as predictors would let the model use future information. All parcels here are generated fictional examples, not evidence about a real carrier.

A method you can reproduce

Write a prediction contract: unit is one parcel, prediction time is dispatch, target late is actual_hours > 24, horizon is delivery, and intended action is a review alert. State which features exist at dispatch. Separately write a causal question, such as whether adding a vehicle would reduce delays. That question needs an intervention design or defensible causal assumptions, not just this prediction experiment.

Check your reasoning

Feature importance or a regression coefficient does not establish that changing that feature changes the outcome. A zone association might reflect route mix or omitted operational constraints. Do not turn a prediction score into an explanation of responsibility.

Further reading: NumPy least squares, Preventing leakage, Cross-validation. These official references support the methods; the case and exercises are authored for DataCareerHub.

Exercise

Complete prediction_contract_template.txt. Mark each source field as identifier, available feature, target, timing metadata or prohibited future information. Write one predictive and one causal question.

Write your answer in learner_worksheet.txt and retain the evidence file. Attempt this before opening the solution.

Worked solution

parcel_id identifies a record; dispatch_date controls temporal splitting. distance_km, load_ratio and zone are permitted predictors. actual_hours and late are targets; delivered_at and post_delivery_rating are later information and excluded. A prediction estimates delay risk; a vehicle-allocation effect cannot be established from this synthetic observational exercise.

Independent extension: change one relevant input in a separate copy. Predict the result first, rerun the checks and explain any difference. Keep the supplied source unchanged.

2. Supervised and unsupervised learning

Supervised and unsupervised learning

Supervised learning uses example inputs with known targets to learn a prediction rule. Regression predicts a numeric quantity; classification predicts a category or its probability. Unsupervised methods look for structure without a labelled target, such as clusters of similar observations. A cluster is a mathematical grouping, not automatically a meaningful business segment or an externally validated label.

Work through the case

Cedar can predict actual_hours with regression or late with binary classification. These targets answer different questions. Predicting duration supports error measurement in hours; classifying lateness supports alert trade-offs. Clustering routes by distance and load would describe patterns but would not directly learn late outcomes. It also requires choices about scaling, cluster count and validation of usefulness.

A method you can reproduce

Classify a task by the output and available labels. Identify whether historical targets are observed consistently and whether missing outcomes bias the sample. Choose a simple descriptive report or rule when that answers the decision without ML. Define an evaluation method suited to the task before choosing a model. No unsupervised algorithm is required for the reference prediction workflow; this lesson teaches when that family would apply.

Check your reasoning

Calling a cluster high risk after looking at its average outcome is an interpretation that needs held-out validation. Do not imply that unsupervised learning discovers true categories or eliminates human assumptions.

Further reading: NumPy least squares, Preventing leakage, Cross-validation. These official references support the methods; the case and exercises are authored for DataCareerHub.

Exercise

Classify four requests: predict delivery hours, predict late/not late, group similar routes and summarise last month’s delays. Explain whether each needs labels or ML.

Write your answer in learner_worksheet.txt and retain the evidence file. Attempt this before opening the solution.

Worked solution

Hours is supervised regression; late/not late is supervised classification. Similar-route grouping is unsupervised and needs an explicit similarity definition. Last month’s observed delay summary is descriptive analysis and may need no ML at all. Labels are required for the supervised examples, with timing and coverage checks.

Independent extension: change one relevant input in a separate copy. Predict the result first, rerun the checks and explain any difference. Keep the supplied source unchanged.

3. Deciding whether ML is appropriate

Deciding whether ML is appropriate

ML is appropriate when a useful prediction target exists, examples are representative enough, inputs arrive in time and evaluation can reflect the real decision. A model also needs a plausible action: predicting an outcome nobody can influence or review may add complexity without benefit. Compare against simpler alternatives and consider the cost of errors, maintenance and monitoring.

Work through the case

Cedar’s fictional review alert could help an operations team prioritise attention, but this exercise does not demonstrate that alerts improve delivery. The dataset is small and generated from a known teaching process. It omits operational disruptions, repeated-customer structure and real-world drift. Performance here demonstrates a method, not a commercial service claim.

A method you can reproduce

Complete suitability_checklist.txt with target availability, feature timing, sample coverage, baseline, error cost, human review and monitoring. Specify a no-ML alternative, such as a distance-based rule or historical rate table. State conditions under which you would stop: unreliable labels, leaked features, no action, harmful use or no advantage over a baseline. Define who owns a future decision and how errors can be challenged.

Check your reasoning

A model is not justified by the availability of a library or an impressive score. Avoid high-stakes decisions about employment, credit or health using this teaching example. The course uses a low-stakes operational case and makes no certification or deployment approval claim.

Further reading: NumPy least squares, Preventing leakage, Cross-validation. These official references support the methods; the case and exercises are authored for DataCareerHub.

Exercise

Write a proceed/pause note for the Cedar experiment and a separate note for real deployment. List three missing pieces of evidence and a simpler comparator.

Write your answer in learner_worksheet.txt and retain the evidence file. Attempt this before opening the solution.

Worked solution

Proceed with the local learning experiment because timing, labels and evaluation are explicit. Pause real deployment pending representative operational data, action-impact evidence, error-cost agreement, review procedures and monitoring. A train-only mean/majority baseline is the minimum comparator; a simple operational rule is an additional business comparator.

Independent extension: change one relevant input in a separate copy. Predict the result first, rerun the checks and explain any difference. Keep the supplied source unchanged.

Practice files

Prepared fictional curriculum. Source data and code are supplied for local practice. Payments and public registration remain disabled.