What is the training of machine learning models to make a sequence of decisions

Download PDF

Abstract: We introduce a framework that abstracts Reinforcement Learning (RL) as a sequence modeling problem. This allows us to draw upon the simplicity and scalability of the Transformer architecture, and associated advances in language modeling such as GPT-x and BERT. In particular, we present Decision Transformer, an architecture that casts the problem of RL as conditional sequence modeling. Unlike prior approaches to RL that fit value functions or compute policy gradients, Decision Transformer simply outputs the optimal actions by leveraging a causally masked Transformer. By conditioning an autoregressive model on the desired return (reward), past states, and actions, our Decision Transformer model can generate future actions that achieve the desired return. Despite its simplicity, Decision Transformer matches or exceeds the performance of state-of-the-art model-free offline RL baselines on Atari, OpenAI Gym, and Key-to-Door tasks.

Submission history

From: Lili Chen [view email]
[v1] Wed, 2 Jun 2021 17:53:39 UTC (551 KB)
[v2] Thu, 24 Jun 2021 17:09:59 UTC (561 KB)

Machine Learning is a fantastic new branch of science that is slowly taking over day-to-day life. From targeted ads to even cancer cell recognition, machine learning is everywhere. The high-level tasks performed by simple code blocks raise the question, "How is machine learning done?".

In this tutorial titled ‘The Complete Guide to Understanding Machine Learning Steps’, you will go through the steps involved in making a machine learning model.

What Is Machine Learning?

Machine learning is the process of making systems that learn and improve by themselves, by being specifically programmed. 

The ultimate goal of machine learning is to design algorithms that automatically help a system gather data and use that data to learn more. Systems are expected to look for patterns in the data collected and use them to make vital decisions for themselves.

In general, machine learning is getting systems to think and act like humans, show human-like intelligence, and give them a brain. In the real world, there are existing machine learning models capable of tasks like :

  • Separating spam from actual emails, as seen in Gmail
  • Correcting grammar and spelling mistakes, as seen in autocorrect 

Thanks to machine learning, the world has also seen design systems capable of exhibiting uncanny human-like thinking, which performs tasks like: 

  • Object and image recognition
  • Detecting fake news
  • Understanding written or spoken words
  • Bots on websites that interact with humans, like humans
  • Self-driven cars                     

What is the training of machine learning models to make a sequence of decisions

Figure 1: Machine learning

Machine Learning Steps

The task of imparting intelligence to machines seems daunting and impossible. But it is actually really easy. It can be broken down into 7 major steps :

1. Collecting Data:

As you know, machines initially learn from the data that you give them. It is of the utmost importance to collect reliable data so that your machine learning model can find the correct patterns. The quality of the data that you feed to the machine will determine how accurate your model is. If you have incorrect or outdated data, you will have wrong outcomes or predictions which are not relevant.  

Make sure you use data from a reliable source, as it will directly affect the outcome of your model. Good data is relevant, contains very few missing and repeated values, and has a good representation of the various subcategories/classes present. 

What is the training of machine learning models to make a sequence of decisions

Figure 2: Collecting Data

2. Preparing the Data:

After you have your data, you have to prepare it. You can do this by :

  • Putting together all the data you have and randomizing it. This helps make sure that data is evenly distributed, and the ordering does not affect the learning process.
  • Cleaning the data to remove unwanted data, missing values, rows, and columns, duplicate values, data type conversion, etc. You might even have to restructure the dataset and change the rows and columns or index of rows and columns.
  • Visualize the data to understand how it is structured and understand the relationship between various variables and classes present.
  • Splitting the cleaned data into two sets - a training set and a testing set. The training set is the set your model learns from. A testing set is used to check the accuracy of your model after training.

What is the training of machine learning models to make a sequence of decisions

Figure 3: Cleaning and Visualizing Data

3. Choosing a Model: 

A machine learning model determines the output you get after running a machine learning algorithm on the collected data. It is important to choose a model which is relevant to the task at hand. Over the years, scientists and engineers developed various models suited for different tasks like speech recognition, image recognition, prediction, etc. Apart from this, you also have to see if your model is suited for numerical or categorical data and choose accordingly.

What is the training of machine learning models to make a sequence of decisions

Figure 4: Choosing a model

4. Training the Model:

Training is the most important step in machine learning. In training, you pass the prepared data to your machine learning model to find patterns and make predictions. It results in the model learning from the data so that it can accomplish the task set. Over time, with training, the model gets better at predicting. 

What is the training of machine learning models to make a sequence of decisions

Figure 5: Training a model

5. Evaluating the Model:

After training your model, you have to check to see how it’s performing. This is done by testing the performance of the model on previously unseen data. The unseen data used is the testing set that you split our data into earlier. If testing was done on the same data which is used for training, you will not get an accurate measure, as the model is already used to the data, and finds the same patterns in it, as it previously did. This will give you disproportionately high accuracy. 

When used on testing data, you get an accurate measure of how your model will perform and its speed.

What is the training of machine learning models to make a sequence of decisions

Figure 6: Evaluating a model

6. Parameter Tuning:

Once you have created and evaluated your model, see if its accuracy can be improved in any way. This is done by tuning the parameters present in your model. Parameters are the variables in the model that the programmer generally decides. At a particular value of your parameter, the accuracy will be the maximum. Parameter tuning refers to finding these values.

What is the training of machine learning models to make a sequence of decisions

Figure 7: Parameter Tuning

7. Making Predictions

In the end, you can use your model on unseen data to make predictions accurately.

How to Implement Machine Learning Steps in Python?

You will now see how to implement a machine learning model using Python. 

In this example, data collected is from an insurance company, which tells you the variables that come into play when an insurance amount is set. Using this, you will have to predict the insurance amount for a person. This data was collected from Kaggle.com, which has many reliable datasets.

You need to start by importing any necessary modules, as shown.

What is the training of machine learning models to make a sequence of decisions

Figure 8: Importing necessary modules

Following this, you will import the data. 

What is the training of machine learning models to make a sequence of decisions

 Figure 9: Importing data          

What is the training of machine learning models to make a sequence of decisions

Figure 10: Insurance dataset

Now, clean your data by removing duplicate values, and transforming columns into numerical values to make them easier to work with.                   

What is the training of machine learning models to make a sequence of decisions

Figure 11: Cleaning Data

The final dataset becomes as shown.                     

What is the training of machine learning models to make a sequence of decisions

Figure 12: Cleaned dataset

Now, split your dataset into training and testing sets.

What is the training of machine learning models to make a sequence of decisions

Figure 13: Splitting the dataset

As you need to predict a numeral value based on some parameters, you will have to use Linear Regression. The model needs to learn on your training set. This is done by using the '.fit' command.                                

What is the training of machine learning models to make a sequence of decisions
 

Figure 14: Choosing and training your model

Now, predict your testing dataset and find how accurate your predictions are.        

What is the training of machine learning models to make a sequence of decisions

Figure 15: Predicting using your model

1.0 is the highest level of accuracy you can get. Now, get your parameters.

What is the training of machine learning models to make a sequence of decisions

Figure 16: Model Parameters

The above picture shows the hyperparameters which affect the various variables in your dataset. 

Stay ahead of the tech-game with our PG Program in AI and Machine Learning in partnership with Purdue and in collaboration with IBM. Explore more!

Conclusion

In this tutorial titled ‘The Complete Guide to Understanding Machine Learning Steps’, you took a look at machine learning and the steps involved in creating a machine learning model. You finally implemented these steps using Python.

We hope this article clearly explained the process of creating a machine learning model. To learn more about machine learning and how to make machine learning models, check out Simplilearn’s AI and Machine Learning Course If you have any questions or doubts, mention them in this article's comments section, and we'll have our experts answer them for you at the earliest.

Happy learning!

Which machine learning models are training to make a sequence of decisions?

Reinforcement learning is the training of machine learning models to make a sequence of decisions. The agent learns to achieve a goal in an uncertain, potentially complex environment.

What is training a model in machine learning?

Training a model simply means learning (determining) good values for all the weights and the bias from labeled examples. In supervised learning, a machine learning algorithm builds a model by examining many examples and attempting to find a model that minimizes loss; this process is called empirical risk minimization.

What does machine learning recognize in order to make decisions?

Machine learning algorithms build a model based on sample data, known as training data, in order to make predictions or decisions without being explicitly programmed to do so.

Which of the machine learning models are trained to make a series of decisions based on the rewards and feedback based on the actions?

Reinforcement learning: In this type, the model is trained by interacting with an environment where it receives rewards or punishments for its actions. The model can then be used to make decisions in new situations to maximize its rewards.