AI/ML Basics
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
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
- 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.
- 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 - 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 - 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.
- 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.
- 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.
- 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.
- 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
- Logistic Regression
- Decision Trees
- Random forest
- Naive Bayes
- Neural networks
- Nearest Neighbor
- Ensemble methods
Regression Algorithms(Fit the results in a graphical line or curve)
- Linear Regression
- Decision Tree Regression
- Polynomial Regression
- Evaluation metrics
- R Square
- Mean square Error (MSE)
- Root Mean square error (RMSE)
- Mean absolute Error (MAE)
Unsupervised Machine Learning
Unsupervised ML is when we do not have labeled datasets with answers.
Clustering
- K Mean Clustering
- EM Clustering
Association Rules
How a data is associated with each other(what is bought with what)
- A Priori Algo
Dimensionality reduction
- Principal component analysis
Reduce the number of dimensions to club its essential meaning - Autoencoders
Used for
- Grouping
- Data compression
- 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
- Game like scenarios
- Robot complex environment
Agent — Takes Action -> Env — Provides Reward — New State -> Agent takes another action