Open In App

Learn-One-Rule Algorithm

Last Updated : 01 Jul, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

Prerequisite: Rule-Based Classifier 

Learn-One-Rule: 

This method is used in the sequential learning algorithm for learning the rules. It returns a single rule that covers at least some examples (as shown in Fig 1). However, what makes it really powerful is its ability to create relations among the attributes given, hence covering a larger hypothesis space.  

For example:
IF Mother(y, x) and Female(y), THEN Daughter(x, y). 
Here, any person can be associated with the variables x and y

Fig 1: Learn-One-Rule Example

Learn-One-Rule Algorithm

The Learn-One-Rule algorithm follows a greedy searching paradigm where it searches for the rules with high accuracy but its coverage is very low. It classifies all the positive examples for a particular instance. It returns a single rule that covers some examples.

Learn-One-Rule(target_attribute, attributes, examples, k):

    Pos = positive examples
    Neg = negative examples
      best-hypothesis = the most general hypothesis
      candidate-hypothesis = {best-hypothesis}
      
      while candidate-hypothesis:     
      //Generate the next more specific candidate-hypothesis

            constraints_list = all constraints in the form "attribute=value"
            new-candidate-hypothesis = all specializations of candidate-
                           hypothesis by adding all-constraints
            remove all duplicates/inconsistent hypothesis from new-candidate-hypothesis. 
            //Update best-hypothesis
            best_hypothesis = argmax(h∈CHs) Performance(h,examples,target_attribute)
            
            //Update candidate-hypothesis

            candidate-hypothesis = the k best from new-candidate-hypothesis 
                           according to Performance.
      prediction = most frequent value of target_attribute from examples that match best-hypothesis
      IF best_hypothesis:
          return prediction 

It involves a PERFORMANCE method that calculates the performance of each candidate hypothesis. (i.e. how well the hypothesis matches the given set of examples in the training data.

Performance(NewRule,h):
    h-examples = the set of rules that match h
      return (h-examples)

It starts with the most general rule precondition, then greedily adds the variable that most improves performance measured over the training examples. 

Learn-One-Rule Example

Let us understand the working of the algorithm using an example: 

Day Weather Temp Wind Rain PlayBadminton
D1 Sunny Hot Weak Heavy No
D2 Sunny Hot Strong Heavy No
D3 Overcast Hot Weak Heavy No
D4 Snowy Cold Weak Light Yes
D5 Snowy Cold Weak Light Yes
D6 Snowy Cold Strong Light Yes
D7 Overcast Mild Strong Heavy No
D8 Sunny Hot Weak Light Yes
Step 1 - best_hypothesis = IF h THEN PlayBadminton(x) = Yes
Step 2 - candidate-hypothesis = {best-hypothesis}
Step 3 - constraints_list = {Weather(x)=Sunny, Temp(x)=Hot, Wind(x)=Weak, ......}
Step 4 - new-candidate-hypothesis = {IF Weather=Sunny THEN PlayBadminton=YES, 
                      IF Weather=Overcast THEN PlayBadminton=YES, ...}
Step 5 - best-hypothesis = IF Weather=Sunny THEN PlayBadminton=YES 
Step 6 - candidate-hypothesis = {IF Weather=Sunny THEN PlayBadminton=YES, 
                 IF Weather=Sunny THEN PlayBadminton=YES...} 
Step 7 - Go to Step 2 and keep doing it till the best-hypothesis is obtained.

You can refer to Fig 1. for a better understanding of how the best-hypothesis is obtained. [Step 5 & 6]

Sequential Learning Algorithm uses this algorithm, improving on it and increasing the coverage of the hypothesis space. It can be modified to accept an argument that specifies the target value of interest. 


Similar Reads

Association Rule
Association rule mining finds interesting associations and relationships among large sets of data items. This rule shows how frequently a itemset occurs in a transaction. A typical example is a Market Based Analysis. Market Based Analysis is one of the key techniques used by large relations to show associations between items.It allows retailers to
3 min read
Rule-Based Classifier - Machine Learning
Rule-based classifiers are just another type of classifier which makes the class decision depending by using various "if..else" rules. These rules are easily interpretable and thus these classifiers are generally used to generate descriptive models. The condition used with "if" is called the antecedent and the predicted class of each rule is called
4 min read
Association Rule Mining in R Programming
Association Rule Mining in R Language is an Unsupervised Non-linear algorithm to uncover how the items are associated with each other. In it, frequent Mining shows which items appear together in a transaction or relation. It's majorly used by retailers, grocery stores, an online marketplace that has a large transactional database. The same way when
3 min read
Hebbian Learning Rule with Implementation of AND Gate
Hebbian Learning Rule, also known as Hebb Learning Rule, was proposed by Donald O Hebb. It is one of the first and also easiest learning rules in the neural network. It is used for pattern classification. It is a single layer neural network, i.e. it has one input layer and one output layer. The input layer can have many units, say n. The output lay
3 min read
Rule-Based Tokenization in NLP
Natural Language Processing (NLP) is a subfield of artificial intelligence that aims to enable computers to process, understand, and generate human language. One of the critical tasks in NLP is tokenization, which is the process of splitting text into smaller meaningful units, known as tokens. Dictionary-based tokenization is a common method used i
4 min read
Battle of AI Chatbots: Which ChatBot Will Rule the Present and Future?
Do you know how many days Facebook and Instagram took to reach a 1 million user audience? Well, around 2 to 3 months! Incredible growth speed, right? Now let’s see how many days does AI chatbot ChatGPT took to hit the 1 million user count – 5 days! That’s how popular AI chatbots are! [caption width="800"] [/caption] As we move towards the AI-influe
6 min read
Rule Based Approach in NLP
Natural Language Processing serves as an interrelationship between human language and computers. It is a subfield of Artificial Intelligence that helps machines process, understand and generate natural language intuitively. Common tasks done by NLP are text and speech processing, language translation, sentiment analysis, etc. The use cases include
8 min read
Optimization Rule in Deep Neural Networks
In machine learning, optimizers and loss functions are two components that help improve the performance of the model. By calculating the difference between the expected and actual outputs of a model, a loss function evaluates the effectiveness of a model. Among the loss functions are log loss, hinge loss, and mean square loss. By modifying the mode
14 min read
Rule Based System Vs Machine Learning System
There are two main approaches in Artificial intelligence they are rule-based systems and machine-learning systems. Rule-based systems follow explicit rules created by human experts. They're like a set of instructions given to a computer that follows to make decisions. These systems are good for problems with clear rules and paths. On the other hand
8 min read
Rule Engine vs Machine Learning?
Answer: Rule engines use predefined logic to make decisions, while machine learning algorithms learn from data to make predictions or decisions.Rule engines and machine learning represent two fundamentally different approaches to decision-making and prediction in computer systems. While rule engines operate on explicit, pre-defined rules set by hum
2 min read
Article Tags :
Practice Tags :