AI/ML Basics

Uday Shankar
5 min readJun 11, 2024

--

Photo by Steve Johnson on Unsplash

What is AI/ML?

Artificial Intelligence and Machine Learning is developed to solve problems which are complex and without obvious scenarios which can be described in basic logical instructions.

What types of problems we solve using Machine Learning?

Identification/classification

Identify spam emails
Identify defective components
Identify fraudulent transaction
Identify objects in images and videos
Assign topics or tags to document or image

Identification

Prediction

Real estate price prediction
Stock prediction
Demand prediction

Grouping/Clustering

Customer segmentation in retails/health

How to implement AI or ML?

To solve a machine learning problems we have follow the following steps

  1. Collect Data : Data needs to collected which we know is the correct data from which the model can infer the desired results. First of all we source of data from different data sources. Then, identify the size of data and frequency of data. Once we have most of the data we also check quality of data as the accuracy of the model will depend on that. We also have to take into consideration the cost of data in case it is externally sourced.
  2. Prepare Data : Once we have the data we can get, we have to convert it to that format we want to train our model on. This depends on the what we can infer from the data, the model restrictions and computation restriction etc. We follow the following strategies for preparing our data.
    Integrate multiple data
    Missing data resolution
    Removing unwanted data
    Segregating data into training and test data
  3. Choose Model : Once we have to data ready we choose the model which best fits our criteria based on the type of AI/ML problem we want to solve and how much accuracy is needed. We have several types of models to choose from which is ever evolving field of research. Some of the common types of models are:
    Decision trees
    Deep learning
    Regression
    Clustering
  4. Train a model : Run the training on the chosen model with the identified training data. This step requires to pass the data to the model implementation along with the hyperparameters specific to the model. These hyperparameters are the properties or flexibility that a model provides which can help the training process to conveniently skew the model to provide better results. This is the step which requires most of the computation power.
  5. Evaluate a model : Now that we have trained model we want to monitor that model to check how good it is for the given scenario. For this step we feed the trained model with our identified testing data and compare the result from the mode with the result which we have. This step will basically tell us how good our trained model is. We will discuss later on the aspects on which the models are monitored.
  6. Hyperparameters tuning : Based on the training and evaluation we can tune some of the hyperparameters which a particular model provides so that we can getter better results. The hyperparameters are mostly model algorithm specific. But can also be other properties of model training like how many layers we want in our deep learning or depth in a decision tree algorithms etc. Others include learning rate (weights) in Neural Networks or number of clusters.
  7. Making predictions : Now we can publish this model so that it can be available for users for making predictions. We can expose it using web services or integration into out data engineering workflow.
  8. Monitoring performance : The is the constant monitoring process of the model on certain parameters which can help us identify the string and weak areas of the model and can help us in future training etc.

How to choose Model?

Following are the types of Machine learning algorithms based on data availability.

Supervised Machine Learning

Supervise ML is when we have labeled datasets with answers. In this case we usually use classification or regression models.
Classification Algorithms

  1. Logistic Regression
  2. Decision Trees
  3. Random forest
  4. Naive Bayes
  5. Neural networks
  6. Nearest Neighbor
  7. Ensemble methods

Regression Algorithms(Fit the results in a graphical line or curve)

  1. Linear Regression
  2. Decision Tree Regression
  3. Polynomial Regression
  4. Evaluation metrics
  5. R Square
  6. Mean square Error (MSE)
  7. Root Mean square error (RMSE)
  8. Mean absolute Error (MAE)

Unsupervised Machine Learning

Unsupervised ML is when we do not have labeled datasets with answers.
Clustering

  1. K Mean Clustering
  2. EM Clustering

Association Rules
How a data is associated with each other(what is bought with what)

  1. A Priori Algo

Dimensionality reduction

  1. Principal component analysis
    Reduce the number of dimensions to club its essential meaning
  2. Autoencoders

Used for

  1. Grouping
  2. Data compression
  3. Anomaly detection

Semi supervised machine learning
Small labeled data and large unlabeled.

Reinforced Learning
Agent makes series of choices in a limited environment and environment provides positive or negative feedback and model train based on trial and error from feedback
Used for

  1. Game like scenarios
  2. Robot complex environment

Agent — Takes Action -> Env — Provides Reward — New State -> Agent takes another action

Reinforced Learning: Shortest path for alien to get to spaceship.

--

--