Pages

Introduction to Machine Learning Models (AI) Testing

What is AI ? 

AI, or Artificial Intelligence, is the ability of a computer or machine to perform tasks that normally require human intelligence, such as learning, problem-solving, and decision-making.It uses technologies like machine learning to analyze data, recognize patterns, and act intelligently to achieve specific goals without being explicitly programmed for every single task

Examples: 

chatbots, self-driving cars, facial recognition, and smart home assistants(SIRI , Alexa)

Approaches to AI ?

  • Symbolic/Rule-Based: Traditional coding practices (Expert systems, decision trees, rule engines, logic programming.) -- Legacy​

  • Machine Learning: AI that learn from data,identifying patterns and relationships to make predictions or decisions without rely on rules (like Linear regression, neural networks, support vector machines, random forests.)

  • Evolutionary: Genetic algorithms, evolutionary strategies, ant colony optimization, particle swarm optimization.

  • Hybrid: Combining symbolic reasoning and neural networks like neuro-symbolic AI.


What is ML ?

Machine Learning (ML) is a subfield of AI that allows computers/machines to access data and allow them to learn for themselves instead of explicit program to perform a task, machine is trained on data and it learn patterns and relationships from data to make decisions/predictions.

---> Even if data is not present , it will predict o/p based on pattern of given i/p data.

Examples: seen in recommendation systems, fraud detection, image recognition, and email spam filtering (diagram below)
Netflix,youtube and other platforms
user preferences,history
Industrial settings - dat includes to predict when to maintain, repairs will be needed. 




Types of ML:

Supervised learninguses labeled data to train models to predict outcomes, like email spam detection , image classification

Unsupervised learningfinds patterns or groups in unlabeled data, like customer segmentation , market basket analysis

Reinforcement learning trains models to make a sequence of decisions by rewarding good actions, like Game playing bots, robotics navigation

Semi-supervisedcombines a small amount of labeled data with lots of unlabeled data, like classifying web pages with only a few examples labeled.


 ML | Underfitting and overfitting

Underfitting: (Too Simple model in ML)

Underfitting occurs when a model is too simple to capture the underlying patterns in the training data. It fails to learn the relationships between the input and output variables, resulting in poor performance on both the training data and the test data. (In short - Straight line trying to fit a curved dataset but cannot capture the data's patterns, leading to poor performance on both training and test sets.)

Using a linear model (like Linear Regression) for complex, non-linear data.

An underfit model has high bias and low variance. “Bias” is the error introduced by approximating a real-world problem, which may be complex, with a model that is too simplistic.

Ex: For an exam - You only read the chapter titles. You learn the high-level concepts but have no depth. When you take the exam, you fail because you can’t answer any specific questions. Your model is too simple.

-> underfitting have
Low Accuracy on training data
Low accuracy on test data
over simplified model

Solutions:
Use more complex model
Add more meaningful features
Increase training duration

Overfitting: (Too Complex model in ML)

Overfitting occurs when a model learns the training data too well, capturing not only the underlying patterns but also the noise and random fluctuations. It essentially “memorises” the training set, leading to excellent performance on training data but very poor performance on new, unseen test data. (Inshort - A squiggly curve passing through all training points, failing to generalize performing well on training data but poorly on test data.)

An overfit model has low bias but high variance. “Variance” is the model’s sensitivity to small fluctuations in the training data. High variance means even a small change in the training set could cause the model to change significantly.

Ex: You memorise every single word and punctuation mark in the textbook. You can answer the practice problems perfectly. But when the final exam asks a slightly different question that requires you to apply a concept, you are lost. Your model is too complex and has memorised the noise, not the signal.

 -> Overfitting have 
High accuracy on training data
Poor performance on Testdata
complex model with too many features

solutions:
Reduce model complexity
Apply regularization techniquines
Implement cross valiadtion

Goodfitting:
 
Good fitting is when a model accurately captures patterns without memorizing noise (Inshort - Curve that follows the data trend without overcomplicating to capture the true patterns in the data.)

Ex: You study the textbook to understand the underlying principles and concepts. You work through the practice problems to learn how to apply them. You can now answer both the practice questions and the new exam questions with high accuracy, your model now generalises well.



Supervised Learning vs Unsupervised Learning:

Supervised Learning:

You train the model with labeled examples - data where you already know the correct answer. The model learns to map inputs to outputs based on these examples.(train data with both i/p and o/p)

Common tasks:

  • Classification (spam detection, image recognition)
  • Regression (predicting house prices, stock prices)

Ex: Training a model to recognize cats in photos by showing it thousands of images labeled "cat" or "not cat" (we saw in overfitting ,underfitting)

Unsupervised Learning:

You train the model with unlabeled data - no correct answers provided. The model tries to find patterns, structure, or relationships in the data on its own.(train model only with input, then o/p will decided by ML model)

- Internally, it will create clusters(using clustering algorithms) based on input data and comparision will be done among clusters using Silhouette scores 

Common tasks:

  • Clustering (customer segmentation, grouping similar documents)
  • Dimensionality reduction (data compression, visualization)
  • Anomaly detection (fraud detection, network intrusion)

Example: 

1) Giving a model customer purchase data and letting it discover natural groupings of similar customers, without telling it what those groups should be.

2) Targeting ads in instagram/facebook based on location, age,gender etc.,.where target(o/p) is keep on changing.

Summary:

Supervised learning generally gives more accurate, predictable results for specific tasks but requires the time and expense of labeling data. Unsupervised learning can discover hidden patterns you didn't know to look for, but the results can be harder to interpret and validate.

There's also semi-supervised learning (using a small amount of labeled data with lots of unlabeled data) and reinforcement learning (learning through trial and error with rewards), which combine aspects of both approaches.

What are Silhouette Scores?

Silhouette scores measure how similar an object is to its own cluster compared to other clusters. A high silhouette score(-1 to 1) indicates the object is well-matched to its own cluster and poorly matched to neighboring clusters.

Identifying Overfitting with Silhouette Scores:

If the training clusters have very high silhouette scores but these scores drastically drop when new data is clustered, it might indicate that the model has overfit to the training data and is not generalizing well to new samples.

Reinforcement Learning:

It is a type of ML where An agent learns to make decisions by performing actions in an environment and receiving rewards or penalties, exploring and improving over time. 

 -> Reinforcement learning problems are often formulated as Markov Decision Process(MDPs), where agents decisions depend only on current state not the history

Key Components

  • Agent: The learner/decision maker
  • Environment: The world the agent interacts with
  • State: Current situation of the agent
  • Action: What the agent can do
  • Reward: Feedback signal (positive or negative)
  • Policy: Strategy the agent learns to maximize total rewards

The agent doesn't need labeled examples - it figures out the best strategy by experiencing consequences of its actions over time.

Ex: Game playing (like Chess) , Robots , Autonomous vehicles(tesla cars-self driving cars), recommendation systems (netflix , youtube suggesting ads, news feed learning) , finance & trading , healthcare(Personalized treatment recommendations that adapt based on patient responses), natural language (ChatGPT and similar models fine-tuned using RLHF (Reinforcement Learning from Human Feedback) to generate more helpful responses).

The key advantage is that RL can solve complex problems where the optimal solution isn't known in advance and must be discovered through interaction.






No comments:

Post a Comment

Please comment below to feedback or ask questions.