7 Steps of Machine Learning

Revise and learn the 7 steps for successful Machine Learning projects

Step #1: Gathering Data

For the purpose of developing our machine learning model, our first step would be to gather relevant data that can be used to differentiate between the 2 fruits. Different parameters can be used to classify a fruit as either an orange or apple. For the sake of simplicity, we would only take 2 features that our model would utilize in order to perform its operation. The first feature would be the color of the fruit itself and the second one being the shape of the fruit. Using these features, we would hope that our model can accurately differentiate between the 2 fruits.

Step #2: Preparing that Data

Once we have gathered the data for the two features, our next step would be to prepare data for further steps. A key focus of this stage is to recognize and minimize any potential biases in our data sets for the 2 features. First, we would randomize the order of our data for the 2 fruits. This is because we do not want the order to have any bearing on the model’s choices. Furthermore, we would examine our data sets for any skewness towards a particular fruit. This again would help in identifying and rectifying a potential bias as it would mean that the model would be adept at identifying one fruit correctly but may struggle with the other fruit.

Step #3: Choosing a Model

The selection of the model type is our next course of action once we are done with the data-centric steps. There are various existing models developed by data scientists which can be used for different purposes. These models are designed with different goals in mind. For instance, some models are more suited to dealing with texts while another model may be better equipped to handle images. With regard to our model, a simple linear regression model is suitable for differentiating between fruits. In this case, the type of fruit would be our dependent variable while the color of the fruit and shape of the fruit would be the 2 predictors or independent variables.

Step #4: Training

At the heart of the machine learning process is the training of the model. Bulk of the “learning” is done at this stage. Here we use the part of the data set allocated for training to teach our model to differentiate between the 2 fruits. If we view our model in mathematical terms, the inputs i.e. our 2 features would have coefficients. These coefficients are called the weights of features. There would also be a constant or y-intercept involved. This is referred to as the bias of the model. The process of determining their values is of trial and error. Initially, we pick random values for them and provide inputs. The achieved output is compared with actual output and the difference is minimized by trying different values of weights and biases. The iterations are repeated using different entries from our training data set until the model reaches the desired level of accuracy.

Step #5: Evaluation

With the model trained, it needs to be tested to see if it would operate well in real world situations. That is why the part of the data set created for evaluation is used to check the model’s proficiency. This puts the model in a scenario where it encounters situations that were not a part of its training. In our case, it could mean trying to identify a type of an apple or an orange that is completely new to the model. However, through its training, the model should be capable enough to extrapolate the information and deem whether the fruit is an apple or an orange.

Step #6: Hyperparameter Tuning

If the evaluation is successful, we proceed to the step of hyperparameter tuning. This step tries to improve upon the positive results achieved during the evaluation step. For our example, we would see if we can make our model even better at recognizing apples and oranges. There are different ways we can go about improving the model. One of them is revisiting the training step and use multiple sweeps of the training data set for training the model. This could lead to greater accuracy as the longer duration of training provides more exposure and improves quality of the model. Another way to go about it is refining the initial values given to the model. Random initial values often produce poor results as they are gradually refined by trial and error. However, if we can come up with better initial values or perhaps initiate the model using a distribution instead of a value then our results could get better. There are other parameters that we could play around with in order to refine the model but the process is more intuitive than logical so there is no definite approach for it.

Step #7: Prediction

The final step of the machine learning process is prediction. This is the stage where we consider the model to be ready for practical applications. Our fruit model should now be able to answer the question whether the given fruit is an apple or an orange. The model gains independence from human interference and draws its own conclusion on the basis of its data sets and training. The challenge for the model remains whether it can outperform or at least match human judgment in different relevant scenarios.


With the help of machine learning we were able to determine how to differentiate between apples and oranges, though it may not sound an impressive model, the steps we took are the same for most machine learning models. This criteria may change in the future as advances in machine learning and AI in general advances, but remember them for the next time you need to work on a ML project:

  1. Preparing that data
  2. Choosing a model
  3. Training
  4. Evaluation
  5. Hyperparameter tuning
  6. Prediction

I’m an entrepreneur, developer, author, speaker, and doer of things. I write about JavaScript, Python, AI, and programming in general.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store