Machine Learning Starter · free course

Free course · Lesson 5 of 5

Real-World ML: Ethics, Data Quality & Deployment

In this lesson you will

  • Identify sources of bias in data
  • Explain why human oversight matters

ML is powerful, but it comes with responsibilities. Data quality determines model quality — if your training data is biased, incomplete, or outdated, your model will be too. Ethical ML means ensuring your models are fair, transparent, and accountable.

  • Data quality: Check for missing values, duplicate records, and outliers. Clean data = better predictions. The old saying applies: "garbage in, garbage out."
  • Bias in ML: A hiring model trained on historical data where most hires were men will "learn" to prefer men. Always audit your training data for representativeness.
  • Model interpretability: Can you explain why your model made a certain prediction? Decision Trees are interpretable; deep neural networks are not. For sensitive domains (healthcare, criminal justice), use interpretable models.
  • Deployment: Save trained models with joblib or pickle. Load them in production to make predictions without retraining. Monitor for "model drift" — when real-world data changes over time.

💡 Practical Skill: Before deploying any ML model, ask: "Who could be harmed if this model makes a mistake?" and "Is my training data representative of the people this model will affect?" Use IBM AI Fairness 360 or Google's What-If Tool to audit your models for bias.

Worked exampleData Quality Check & Saving a Model
Python
# Data quality check + save/load a trained model# Install: pip install scikit-learn joblib import numpy as npfrom sklearn.tree import DecisionTreeClassifierimport joblib  # for saving/loading models # Simulate a dataset with quality issuesdata = [    {"math": 85, "english": 78, "passed": 1},    {"math": 92, "english": 88, "passed": 1},    {"math": None, "english": 65, "passed": 0},  # Missing value!    {"math": 45, "english": 50, "passed": 0},    {"math": 70, "english": None, "passed": 1},  # Missing value!    {"math": 95, "english": 92, "passed": 1},    {"math": 30, "english": 40, "passed": 0},    {"math": 88, "english": 85, "passed": 1},] print("=== Data Quality Check ===")missing_math = sum(1 for d in data if d["math"] is None)missing_english = sum(1 for d in data if d["english"] is None)print(f"Missing math scores: {missing_math}")print(f"Missing english scores: {missing_english}") # Clean data: drop rows with missing values (simple approach)clean_data = [d for d in data if d["math"] is not None and d["english"] is not None]print(f"Rows after cleaning: {len(clean_data)} (removed {len(data) - len(clean_data)})") # Prepare features and labelsX = np.array([[d["math"], d["english"]] for d in clean_data])y = np.array([d["passed"] for d in clean_data]) # Train a modelmodel = DecisionTreeClassifier(max_depth=3)model.fit(X, y) # Save the model to a filejoblib.dump(model, "student_pass_model.pkl")print("\n✅ Model saved as 'student_pass_model.pkl'") # Load the model (in a real deployment, this would be a separate script)loaded_model = joblib.load("student_pass_model.pkl") # Predict a new studentnew_student = np.array([[75, 80]])prediction = loaded_model.predict(new_student)[0]print(f"New student (Math: 75, English: 80) => {'PASS' if prediction == 1 else 'FAIL'}") # Feature importanceprint(f"Math importance: {model.feature_importances_[0]:.3f}")print(f"English importance: {model.feature_importances_[1]:.3f}")

Practice exercise

Describe how a model trained only on urban school data could fail rural students, and one check you would run before using it.

Key takeaways

  • Models learn the biases in their data
  • Check performance separately for important groups
  • Use models to support people's decisions, not replace them
In the full program Module 5: Responsible ML and a First Project See how this topic is taught in depth, with practical activities and an assessment.

Free self-study lesson — no certificate. For the full instructor-led program, see registration options.