7 Steps of Machine Learning

Click on the aboveBeginner’s Guide to Computer Vision”, choose to addStar or Top

Essential knowledge delivered promptly.

7 Steps of Machine Learning

Machine learning is a field of high interest among technology enthusiasts. As a branch of Artificial Intelligence (AI), it is essentially an algorithm or model that can improve itself through “learning,” thus becoming increasingly proficient at executing its tasks. The applications of machine learning are rapidly evolving and have become an indispensable part of various fields such as medicine, e-commerce, and banking. Today, we will break down machine learning into a process and understand all the steps from start to implementation, including its practical applications.

7 Steps of Machine Learning

The process of machine learning will be broken down into the 7 steps listed below. To illustrate the importance and function of each step, we will use a simple model example. This model will be responsible for distinguishing between apples and oranges. Machine learning is capable of handling complex tasks. However, to explain the process simply, we will use a basic example to explain the relevant concepts.

Step 1: Collect Data

To develop our machine learning model, our first step will be to collect relevant data that can be used to distinguish between the two outcomes. Different parameters can be used to classify the fruit as either orange or apple. For simplicity, we will only use 2 features that the model will utilize to perform its operations. The first feature is the color of the fruit itself, and the second feature is the shape of the fruit. Using these features, we hope our model can accurately distinguish between the two types of fruit.

Color Shape Apple or Orange?
Red Conical Apple
Orange Round Orange

A mechanism is needed to collect data on the two features we have chosen. For example, to collect data about the color, we can use a spectrometer, and for shape data, we can use images of the fruit so they can be viewed as 2D graphics. To collect data, we will try to obtain as many different types of apples and oranges as possible to create various datasets for our features. For this, we might try to look for oranges and apples in the market that may come from different regions of the world.

The data collection step is fundamental to the machine learning process. Errors such as choosing the wrong features or focusing on a limited type of entries in the dataset can completely derail the model. This is why it is essential to consider the necessary reasons when collecting data, as mistakes made at this stage will only amplify as we progress to subsequent stages.

Step 2: Prepare the Data

Once we have collected data on these two features, the next step is to prepare the data for further use. The focus of this stage is to identify and minimize any potential biases in our dataset concerning the two features. First, we will randomize the order of the data for the two fruits. This is because we do not want the order to relate to the model’s selection. Additionally, we will check if our dataset is biased towards a particular fruit. This will help identify and correct potential biases, as it would mean that the model could correctly identify one type of fruit but might struggle with another.

Another main component of data preparation is splitting the dataset into two parts. A larger portion (about 80%) will be used to train the model, while a smaller portion (about 20%) will be used for evaluation. This is important because using the same dataset for both training and evaluation would not provide a fair assessment of the model’s performance in real-world scenarios. Besides splitting the data, other measures need to be taken to refine the dataset. This may include removing duplicate entries, discarding incorrect readings, etc.

Preparing sufficient data for the model can enhance its efficiency. It can help reduce the model’s blind spots, thereby increasing the accuracy of predictions. Therefore, it makes sense to deliberate and inspect your dataset so that it can be fine-tuned to produce better and more meaningful results.

Step 3: Select a Model

Once the data-centric steps are complete, selecting the type of model is our next course of action. Various existing models developed by data scientists can be used for different purposes. These models are designed with different objectives in mind. For example, some models are better suited for handling text, while another model might be more suitable for processing images. For our model, a simple linear regression model is appropriate for distinguishing between fruits. In this case, the type of fruit will be our dependent variable, while the color and shape of the fruit will be the two predictor variables or independent variables.

7 Steps of Machine Learning

In our example, the model selection is quite straightforward. In more complex cases, we need to make choices that align with the expected outcomes. Options for machine learning models can be explored in three major categories. The first category is supervised learning models. In such models, the outcomes are known, so we continually refine the model itself until our output reaches the desired level of accuracy. The linear regression model chosen for our fruit model is an example of supervised learning. If the outcome is unknown and we need classification, we use the second category, which is unsupervised learning. Examples of unsupervised learning include K-means and Apriori algorithms. The third category is reinforcement learning, which focuses on learning to make better decisions based on repeated trials. These are often used in business environments. A Markov decision process is an example.

Step 4: Train

The core of the machine learning process is the training of the model. A significant amount of “learning” occurs at this stage. Here, we use a portion of the dataset allocated for training to teach our model to distinguish between the two outcomes. If we look at the model in mathematical terms, the inputs (i.e., our 2 features) will have coefficients. These coefficients are referred to as feature weights. A constant or y-intercept will also be involved. This is referred to as the model’s bias. The process of determining its value is iterative. Initially, we select random values for them and provide inputs. The output obtained is compared to the actual output, and the differences are minimized by trying different weights and bias values.

Training requires patience and experimentation. Knowledge of the area in which the model will be implemented is also useful. For example, if a machine learning model is used to identify high-risk customers for an insurance company, knowledge about how the insurance industry operates will speed up the training process because more informed guesses can be made during the iterations. If the model starts to work successfully, then training will prove to be very beneficial. This is akin to a child learning to ride a bicycle. Initially, they may fall several times, but after a while, they will master the process better and be able to respond more effectively to different situations while riding the bicycle.

Step 5: Evaluate

After training the model, it needs to be tested to see if it can function properly in real-world environments. This is why a portion of the dataset created for evaluation is used to check the model’s proficiency. This places the model in a scenario where the situations encountered are not part of its training. In our case, this might mean trying to determine the type of a brand new apple or orange in the model. However, through training, the model should have sufficient capability to infer information and determine whether the fruit is an apple or an orange.

In business applications, evaluation becomes crucial. Evaluation allows data scientists to check whether they have set achievable goals. If the results are unsatisfactory, it is necessary to revisit previous steps to identify and uncover the root causes of the model’s poor performance. If the evaluation is not properly conducted, the model may fail to excel in achieving its intended business purpose. This could mean that the company designing and selling the model might lose good credibility with its clients. It could also damage the company’s reputation, as future clients may hesitate to trust the company’s acumen regarding machine learning models. Therefore, evaluating the model is essential to avoid the adverse effects mentioned above.

Step 6: Hyperparameter Tuning

If the evaluation is successful, we move on to the hyperparameter tuning step. This step seeks to improve the positive results obtained in the evaluation step. For our example, we will see if we can make our model excel at recognizing apples and oranges. We can take different approaches to enhance the model. One of them is the retraining step, using multiple scans of the training dataset to train the model. This may lead to higher accuracy because the longer the training duration, the more exposure there is, and the quality of the model improves. Another way to address this issue is to optimize the initial values provided to the model. Random initial values often result in poor outcomes that improve gradually through iterations. However, if we can propose better initial values or use distributions instead of values to start the model, our results may be better. We can also use other parameters to refine the model, but this process is more intuitive than logical, so there is no definite method.

Naturally, a question arises: when the model achieves its goals, why do we need to perform hyperparameter tuning in the first place? This can be answered by looking at the competitive nature of machine learning service providers. When clients seek machine learning models to solve their respective problems, they have multiple options to choose from. However, they are more likely to be attracted to the methods that produce the most accurate results. This is why hyperparameter tuning is an essential step to ensure the commercial success of machine learning models.

Step 7: Prediction

The final step of the machine learning process is prediction. At this stage, we consider the model ready for practical applications. Our fruit model should now be able to answer whether a given fruit is an apple or an orange. The model is free from human interference and draws its conclusions based on its dataset and training. The challenge the model faces remains whether its performance can surpass or at least match human judgment in different relevant scenarios.

The prediction step is what the end-users see when using machine learning models in their respective industries. This step highlights why many believe machine learning is the future across various sectors. Complex but well-executed machine learning models can enhance the decision-making processes of their respective owners. When making decisions, humans can only handle a certain amount of data and relevant factors. In contrast, machine learning models can process and link vast amounts of data. These links allow models to gain unique insights that may not be discoverable through conventional manual methods. As a result, valuable human resources are freed from the burden of processing information and then making decisions.

Conclusion

With machine learning, we can determine how to distinguish between apples and oranges. Although this may not sound impressive, the steps we take are the same for most machine learning models. As machine learning evolves and AI becomes more prevalent, this standard may change in the future. However, the next time you need to undertake an ML project, keep these standards in mind:

  1. Collect Data

  2. Prepare the Data

  3. Select a Model

  4. Train

  5. Evaluate

  6. Hyperparameter Tuning

  7. Predict

— — End — —

Download 1: OpenCV-Contrib Extension Module Chinese Tutorial
Reply in the “Beginner’s Guide to Computer Vision” official account backend:Extension Module Chinese Tutorial, to download the first OpenCV extension module tutorial in Chinese, covering installation of extension modules, SFM algorithms, stereo vision, object tracking, biological vision, super-resolution processing and more than twenty chapters.
Download 2: Python Vision Practical Project 52 Lectures
Reply in the “Beginner’s Guide to Computer Vision” official account backend: Python Vision Practical Project, to download 31 vision practical projects including image segmentation, mask detection, lane line detection, vehicle counting, eyeliner addition, license plate recognition, character recognition, emotion detection, text content extraction, facial recognition, etc., to help quickly learn computer vision.
Download 3: OpenCV Practical Project 20 Lectures
Reply in the “Beginner’s Guide to Computer Vision” official account backend: OpenCV Practical Project 20 Lectures, to download 20 practical projects based on OpenCV that achieve advancement in OpenCV learning.

Discussion Group

Welcome to join the official account reader group to communicate with peers. Currently, there are WeChat groups for SLAM, 3D vision, sensors, autonomous driving, computational photography, detection, segmentation, recognition, medical imaging, GAN, algorithm competitions (which will be gradually subdivided in the future), please scan the WeChat ID below to join the group, and note: “Nickname + School/Company + Research Direction”, for example: “Zhang San + Shanghai Jiao Tong University + Vision SLAM”. Please follow the format, otherwise, you will not be approved. After successful addition, you will be invited into the relevant WeChat group based on your research direction. Please do not send advertisements in the group, otherwise, you will be asked to leave the group, thank you for understanding~

7 Steps of Machine Learning

7 Steps of Machine Learning

Leave a Comment