Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 54

Problem Definition, Data, and Metrics

Recommended resources

Welcome to the next phase of your journey! Having explored the entire machine learning workflow—from data manipulation and model training to explainability and API deployment—you are now ready to synthesize these skills into a single, comprehensive portfolio project. This module is designed to guide you through building an end-to-end machine learning solution from scratch, a task that mirrors the daily work of a data scientist.

Today, we'll focus on the most critical and often overlooked phase of any project: the foundation. Before writing a single line of Python, we must define what we're building and why. This lesson covers how to define a clear machine learning problem, select a suitable dataset, and choose an evaluation metric that accurately measures success in a real-world context.

The Machine Learning Project Lifecycle

A successful machine learning project is a structured, iterative process. It doesn't start with modeling; it starts with a question. The following flowchart provides a high-level map of the journey we're about to embark on. Today, we are firmly in the "Problem Definition" stage.

This flowchart illustrates the complete, iterative lifecycle of a machine learning project, starting with Problem Definition and moving through Data Collection, Preparation, Training, Evaluation, and Production. Today's lesson focuses on the crucial first step.

1. Defining the Machine Learning Problem

The first step is to frame a real-world goal in machine learning terms. This means translating a business need or a point of curiosity into a concrete task for a model.

There are generally two ways to approach this:

  1. Problem-First: You start with a question you want to answer (e.g., "Can I predict which customers are likely to churn?") and then search for data to help you answer it.
  2. Data-First: You find an interesting dataset and then explore what questions you can answer with it (e.g., "I have a dataset on housing sales; can I predict a house's price?").

For portfolio projects, the problem-first approach often leads to more compelling and unique work. The following video offers a great demonstration of this process.

Data Science Project from Scratch - Part 1 (Project Planning)

In this video, "Data Science Project from Scratch," data scientist Ken Jee walks through the initial planning and brainstorming phase of a project.

Watch these two key segments: Project approaches: Here, Ken contrasts the data-first and problem-first approaches. Brainstorming session: Observe how he brainstorms ideas based on his interests and what would be valuable to his audience, ultimately deciding to predict data science salaries. This is a perfect example of problem framing in action.

From Ideal Outcome to Model Goal

Once you have a general idea, you need to refine it. The goal is to connect a high-level ideal outcome to a specific model goal.

Framing an ML problem | Machine Learning

This Google Developers article provides a structured way to think about problem framing. It shows how to link a product's purpose to a model's objective.

Read the section titled "Define the ideal outcome and the model's goal." Pay close attention to the table that provides examples for a weather app, video app, and others. This clarifies how to translate a general need into a specific, predictable target.

For example, if you were building a project to help a bank, the:

  • Ideal Outcome: Reduce financial losses from defaulted loans.
  • Model's Goal: Predict whether a given loan applicant will default.

This simple but explicit statement defines the scope of your project and what you will be building.


2. Selecting an Appropriate Dataset

With a problem defined, you need data. For your portfolio, you'll likely use a public dataset. The quality and nature of the dataset will significantly impact your project.

Where to Find Datasets

There are many excellent repositories for public datasets. The video below gives a tour of the most popular ones. Since you're highly proficient with Git and GitHub, pay special attention to the segment on finding datasets within GitHub repositories.

Best Places to Find Datasets for Your Projects

In "Best Places to Find Datasets for Your Projects," Alex The Analyst covers the top sources data scientists use.

Feel free to browse this video as a reference guide. The most relevant platforms he discusses are: Kaggle: A great starting point with a massive variety of clean, ready-to-use datasets. Google Dataset Search: An aggregator that can help you find data from academic, government, and other professional sources. FiveThirtyEight (538): Datasets from data-driven news articles, which often come with great context and a narrative. data.gov: For US-centric government data, often very large and detailed. GitHub: A surprisingly rich source, as many people publish data alongside their public code projects.

What Makes a Good Dataset for a Portfolio Project?

Not all datasets are created equal. For an end-to-end project, you want something that allows you to demonstrate a range of skills. An ideal dataset isn't just a simple, clean CSV file.

Building a Data Science Portfolio: Machine Learning Project

This article from Dataquest discusses the criteria for choosing a dataset for a more advanced, "operational" machine learning project. It uses a real-world example of predicting loan foreclosures.

Read the sections "Finding Good Data Sets" and "Picking an Angle." Focus on the criteria mentioned: a dataset that is large enough for performance to matter and nuanced enough to support an "operational" question (one that could be asked repeatedly, not just once). The discussion of the Fannie Mae loan data is a great case study in picking a problem with sufficient depth.


3. Choosing a Model Type and Evaluation Metric

With a problem and a dataset, the final step is to define how you will build a solution and how you will measure its success.

Classification vs. Regression

Your problem statement naturally leads to a model type.

  • Regression: Predicts a continuous numerical value (e.g., predicting a house price, a salary, or temperature).
  • Classification: Predicts a discrete category (e.g., spam or not_spam, will_churn or will_not_churn, fraud or not_fraud).

Sometimes the choice is subtle. If your problem has fixed numerical thresholds that trigger different actions, a classification model might be better even if the underlying value is a number.

Framing an ML problem | Machine Learning

This part of the Google Developers article provides an excellent scenario about caching videos based on predicted view counts. It demonstrates why a classification model might be superior to a regression model in certain situations.

Find the heading "Regression" and read from there, paying close attention to the video caching example (Figure 5 and the surrounding text). This will help you think critically about which model type truly serves the business logic.

Success Metrics vs. Evaluation Metrics

It's important to distinguish between two types of metrics:

  1. Success Metrics (Business Metrics): Did the project achieve its high-level goal? (e.g., "Reduced customer churn by 5%", "Increased average user session time by 2 minutes"). These are what the business cares about.
  2. Evaluation Metrics (Model Metrics): How well does the model perform its specific task? (e.g., Accuracy, Precision, Recall, RMSE). These are what you use to train and compare models.

Your choice of evaluation metric should be a proxy for your success metric.

Selecting the Right Evaluation Metric

Choosing the right evaluation metric is critical. Using the wrong one can lead you to optimize for a model that is useless in practice. This is especially true for imbalanced datasets, where one class is much rarer than another (e.g., fraud detection, disease diagnosis).

The Dataquest article provides a perfect illustration of this.

Building a Data Science Portfolio: Machine Learning Project

This section of the Dataquest article explains why accuracy is a misleading metric for their imbalanced loan foreclosure problem and how they select a more appropriate one.

Read the section "Finding an Error Metric for Our Machine Learning Project". Focus on the reasoning: Why is accuracy a poor choice when only a tiny fraction of loans are foreclosed on? What is the business cost of a false negative (predicting a loan won't default when it will) versus a false positive? Why do they choose false negative rate as their primary metric?

This thought process—connecting the model's errors to real-world consequences—is a hallmark of a skilled data scientist.


Your Turn: Plan Your Project

Now it's time to apply these concepts and define your own end-to-end project. Choose one of the following domains or propose your own idea.

Project Options:

  1. Customer Churn Prediction (Classification): Use a dataset like the Telco Customer Churn dataset on Kaggle.
  2. Credit Card Fraud Detection (Classification): Use a dataset like the Credit Card Fraud Detection dataset on Kaggle. This is a classic example of an extremely imbalanced problem.
  3. House Price Prediction (Regression): Use a dataset like the Ames Housing dataset. This dataset is rich with features, offering great opportunities for feature engineering.

Task (to be completed in a new README.md file in your project folder):

For your chosen project, write a brief project plan that answers the following questions:

  1. Problem Definition:

    • What is the ideal outcome? (e.g., "Help a telecom company retain more customers.")
    • What is the specific model's goal? (e.g., "Predict whether a customer will churn within the next month based on their account information and usage patterns.")
  2. Model and Target:

    • What is the target variable you will be predicting?
    • Is this a regression or classification problem?
  3. Evaluation Metric:

    • What will be your primary evaluation metric?
    • Justify your choice. For example, in churn prediction, is it more costly to mistakenly offer a retention bonus to a happy customer (a false positive) or to fail to identify a customer who is about to leave (a false negative)? Your choice of Precision, Recall, F1-score, or AUC should reflect this. For regression, will you use RMSE or MAE, and why?

Completing this plan will give you a clear roadmap for the rest of the project.


Conclusion

You've now learned the structured process for beginning any data science project. This foundational work is what separates successful, impactful projects from aimless explorations.

Key Takeaways:

  • Problem framing is key: Start with a clear "ideal outcome" and a specific "model goal."
  • Choose datasets with purpose: Look for data that has enough complexity and nuance to build a compelling portfolio project.
  • Connect metrics to business value: Select an evaluation metric (like Precision, Recall, or RMSE) that serves as a good proxy for the real-world success of your project, especially considering factors like class imbalance.

In our next lesson, you will take the project plan you've just created, acquire the data, and dive into the first hands-on step of the workflow: building a complete feature engineering and preprocessing pipeline.