How to Build Machine Learning Models

CoreyS Dataiker Alumni, Dataiku DSS Core Designer, Dataiku DSS Core Concepts, Registered Posts: 1,150 ✭✭✭✭✭✭✭✭✭

Originally posted by Dataiku on February 25, 2021 by @MarieD

Machine learning has become more and more accessible in the last few years. Thanks to advancements in automated machine learning (AutoML), collaborative AI, and machine learning platforms (like Dataiku), the use of data — including for predictive modeling — across people of all different job types is on the rise. You don’t have to be an expert coder, data scientist, or engineer to master machine learning anymore. You can build your own ML model by following these five steps.


1. Define the Goal: The first step is defining the business objective of your machine learning project as concretely as possible. This step is key to ensuring the success of your model. In order to have motivation, direction, and purpose to execute and build a machine learning model from start to finish, you have to identify a clear objective for what you want to do with the data, the model, and how it’s going to improve your current processes or performance at a given task. In short, without a clear goal, your model will probably not make it to production so make sure you start here!

To identifying a business problem, start by looking at the different types of prediction and thinking about what exactly it is that you would like to predict. There are two main types of supervised machine learning:

  • Classification — Do you want to predict whether something is one thing or another?

  • Regression — Do you want to predict a specific number of something?

Once you have identified your business problem and the type of supervised machine learning you will be using, you are ready to move on to the next step.

2. Prepare Data for ML: Preparing data for machine learning — in other words, making sure data is consistent, clean, and usable overall — can take up to 80% of the time of an entire data project. So let’s separate this step into four sub-steps to make the process super clear:

  • Getting the data: Mixing and merging data from many different data sources can take a data project to the next level. There are a few ways to get usable data: connecting to a database, using APIs, and/or looking for open data on the web.

  • Analyze, explore, and clean the data: This helps ensure better results, but it also helps avoid serious issues. Start digging to see what data you’re dealing with and ask questions to understand what all variables mean. Keep an eye out for data quality issues, such as missing values or inconsistent data — too many missing or invalid values mean that those variables won’t have any predictive power for your model.

  • Feature Selection: Select the features — also known as independent variables — you’ll use to train your model. This steps reduces complexity and overfitting.

  • Feature Handling & Engineering: Feature engineering relates to building new features from the existing dataset or transforming existing features into more meaningful representations. This step is about making transformations to features to allow them to be better used and positively impact the performance of your model.

Now you’re ready to get into what will occupy the remaining 20% of your work on this model!

3. Build the Model: You can build your model very simply by using Dataiku AutoML. AutoML is a tool that automates the process of applying machine learning and can make quick, baseline modeling simple — even experienced data scientists use AutoML to accelerate their work. In four simple steps, this consists in:

  • Building a baseline: This is a model that is straightforward but with a good chance of providing decent results, through quick modeling.

  • Designing the model: This includes selecting a target variable and prediction type.

  • Training the model: This is done on a subset of the data to evaluate how well it is able to map inputs to outputs and make accurate predictions.

  • Selecting the algorithm and hyperparameters: Decide which algorithm to use for your model based on your business goals and priorities.

4. Tune the Model: How do you know if your model is any good? That’s where tracking and comparing model performance across different algorithms comes in.

  • Evaluate metrics and optimize: For regression models, you want to look at mean squared error and R-squared (R2). For classification models, you can start by looking at the most simple metric for evaluating that type of model: accuracy.

  • Check for overfitting and apply regularization: Regularization, simplifies your model and makes it less specialized to remedy for overfitting.

5. Model Interpretation: This is the degree to which models — and their outcomes — can be understood by humans. Below we will quickly outline three techniques to interpret results and review performance.

  • Partial dependence plots: These help explain the effect an individual feature has on model predictions.

  • Subpopulation analysis: This investigates whether a model performs identically across different subpopulations. If the model is better at predicting outcomes for one group over another, it can lead to biased outcomes and unintended consequences when it is put into production.

  • Individual prediction explanations: Partial dependence plots and subpopulation analyses look at features more broadly, but they don’t provide insight into the factors behind each specific prediction that a model outputs — that’s where individual prediction explanations come in. The explanations are useful for understanding the prediction of an individual row and how certain features impact it.


And that’s how you build a machine learning model! See? It wasn’t that difficult! Alright, I admit we did simplify things a bit to make the process more approachable, but if you take the time to dive deeper into the details, you will see it’s nothing that you can’t follow.

Get Started with Building Your First ML Model

Read the full guidebook for more details and visual demonstrations of these tools and concepts that will help you design your first ML model (and a crash-course refresher on some of the basic machine learning concepts!)


Setup Info
      Help me…