Comparing AI Paradigms: Reflex, State, Bayseian, and Logic Learning

Comparing AI Paradigms: Reflex, State, Bayseian, and Logic Learning

In my previous post, I discussed categorizing machine learning (ML) based on supervision styles (such as supervised, unsupervised, self-learning, semi-supervised, and reinforcement learning), incremental learning (batch versus offline learning), and generalization abilities (instance-based versus model-based learning). In this post, we'll compare AI paradigms based on their simplicity, starting from the simplest.

Reflex Learning

Reflex learning represents the most basic form of AI, emerging as one of the initial approaches during the early development of the field. Imagine the human reflex system you learned about in biology class. For example, when your knee is tapped, it reflexively jerks without conscious thought. Reflex learning operates similarly, responding swiftly and based on Simple Stimulus-Response Rules: The system is programmed or trained to respond to specific inputs with predetermined outputs.

These rules are typically straightforward, bypassing complex decision-making processes, which is unlike more advanced AI such as ML models and Large Language Models that require contextual understanding. For instance, asking a model whether the sky is blue or black yields a direct response - akin to an established scientific fact that the sky is blue.

Keep in mind that reflex learning typically does not involve a training dataset in the same way supervised machine learning does. Instead, reflex learning relies on predefined rules or hardwired responses to specific stimuli.

In the case of the question "Is the sky blue?", reflex learning doesn't determine that the sky is blue based on any training data. Instead, the system has a predefined rule, which could be set up by a program developer, that associates the percept "sky is blue" with the response "Yes, the sky is blue."

As reflex learning relies on pre-set rules or conditioned responses, it tends to be less flexible or adaptable compared to other learning forms that involve reasoning or adaptation. However, it remains useful in systems requiring rule-based and control mechanisms. For example, reflex learning is crucial in home systems where the electricity needs to be immediately shut off in case of water leakage. Another application is in simple robotic systems like the robot servers in Hai Di Lao (one of my favorite restaurants!). These robots automatically turn away when they encounter an obstacle, like bumping into a table leg.

Let's consider a practical example. Suppose you want to build an electric kettle that displays the water temperature, enhancing safety and user experience, especially in households with children. The rules could be as follows:

  • If the temperature is between 0-30°C, the response is “Low Heat.”
  • If the temperature is between 30°C and 60°C, the response is “Medium Heat.”
  • If the temperature is above 70°C, the response is “High Heat — Be careful when in use.”

To implement this in Python, your code might look as follows:

def reflex_response(temperature):
    """ Respond to temperature using new reflex rules. """
    if 0 <= temperature <= 30:
        return "Low Heat"
    elif 30 < temperature <= 60:
        return "Medium Heat"
    elif temperature > 70:
        return "High Heat — Be careful when use"
    else:
        return "Temperature out of range"        

Now, let's create a vector of example temperatures and apply the reflex learning function defined earlier.

temperatures = [5, 25, 45, 75, -10]        
for temp in temperatures:
    response = reflex_response(temp)
    print(f"Temperature: {temp}°C - Response: {response}")        

When running this code in Jupyter Notebook, the output from the reflexive learning function would look like this:

Article content

State Learning

Unlike reflex learning, where contextual information is not necessary, state learning refers to the process in which an algorithm learns to make decisions based on the state of the environment or the system with which it interacts.

This type of AI is fundamental in various areas, including search problems, Markov Decision Processes (MDPs), and adversarial games. Let's delve into each of these:

1. Search Problems

  • The learning process involves evaluating states and determining the optimal actions to transition from one state to another. This often involves the use of heuristics or optimization techniques.
  • An example is creating a game in which the system is tasked with drawing a hexagon while adhering to certain rules, such as not lifting the "pen" and avoiding retracing lines. In such scenarios, the concept of a search problem comes into play as the model must strategize the best actions to move from one spot to another.

Article content

  • Let's take a look at the Python code below. We'll start by defining a simple graph in which keys represent dots, and values are lists of other connected dots.

# Define the connections between dots in the hexagon
connections = {
    1: [2, 6],
    2: [1, 3],
    3: [2, 4],
    4: [3, 5],
    5: [4, 6],
    6: [1, 5, 7],
    7: [6]
}
        

  • For instance, "1: [2, 6]" means that dot 1 is connected to dots 2 and 6. This graph models the hexagon and an additional dot (7) that serves as the foundation for the search algorithm. The algorithm's objective is to explore paths within this graph to "draw" the hexagon by moving from dot to dot based on the defined connections, all while maintaining continuity (i.e., not breaking the path).
  • Now, define the function to find a path to draw the hexagon.

def find_path(current, path, visited):
    if len(visited) == len(connections) and current == path[0]:
        return path

    for next_dot in connections[current]:
        if next_dot not in visited or (len(visited) == len(connections) and next_dot == path[0]):
            new_path = find_path(next_dot, path + [next_dot], visited | {next_dot})
            if new_path:
                return new_path

    return None        

  • Test the find_path function:

# Start the search from dot 1
path = find_path(1, [1], {1})

if path:
    print("Path to draw the hexagon:", path)
else:
    print("No path found")
        

  • In this section, I demonstrate how to utilize the find_path function. I initiate the search from dot 1 and attempt to find a valid path. If a path is found, it will be printed; otherwise, the output will indicate that no path was found. Keep in mind that this is a simplified example to help you understand the fundamental concept of search problems. The real world out there is likely to be more complex and may involve more sophisticated rules and behaviors.

2. Markov Decision Process (MDP)

  • MDP is a mathematical framework for modeling decision-making when outcomes are partly random and partly under the control of a decision-maker.
  • It comprises states, actions, transition probabilities (the probability of moving from one state to another given an action), and rewards. For instance, consider the classic example of programming a machine to play chess. First, it needs to decide on the initial move (states), then it takes that move (actions). If a human player responds with their first move, the computer must strategize its next move considering the human's response (transition probabilities). If the second move results in a win, the machine learns that this move is rewarding and may choose it again. Conversely, if the second move leads to a loss, the machine learns that its move is unfavorable, possibly avoiding it in the future. Each player's move (action) alters the game's configuration (state).

Article content
Screencapture from chess.com

3. Adversarial Games:

  • Adversarial games involve scenarios where multiple agents (like players in a game) compete against each other.
  • Learning in this context entails understanding how to make optimal moves and counter the opponent’s strategy.
  • Examples include Go or Chess. However, the classification of chess can be debated. If you view chess as state-dependent, considering only the current board arrangement, you could label it as Markov. Yet, many professionals base their strategies on the game's history and its progression. In such cases, chess can be considered adversarial, falling into the category of games with history dependency.
  • Poker is another example of a game with history dependency, where past betting actions can significantly influence a player's strategy.

Probabilistic Learning

As I mentioned at the beginning, I'm organizing the types of AI paradigms today based on simplicity. However, I won't say probabilistic learning is more or less advanced than state learning; it depends on the purpose of using the model.

Probabilistic training involves modeling and reasoning with uncertainty, utilizing methods like Bayesian Networks, probabilistic graphical models, and statistical inference techniques. While it shares some similarities with traditional general linear modeling (GLM), it also incorporates probabilistic relationships and complex interactions among variable

This type of model often involves complex mathematical and statistical foundations, especially when dealing with large-scale or high-dimensional data. On the other hand, state learning is not directly related to GLM or inferential statistics. As mentioned earlier, it involves learning to make decisions based on the state of the environment or system and is commonly used in scenarios where an agent interacts with an environment over time. State learning becomes complex when learning optimal strategies is performed longitudinally.

An example of probabilistic learning is Bayesian Networks. Unlike GLM, which explores and assumes linear relationships between features and outcomes, Bayesian Networks are probabilistic graphical models that represent a set of variables and their conditional dependencies using a directed acyclic graph. They are used to model probabilistic relationships between variables and are particularly useful in situations involving uncertainty and complex interactions among variables, including causal relationships.

To simplify Bayesian Networks, let's think about Bayes' Theorem, which is a fundamental principle in probability theory. Bayes' Theorem describes the probability of an event based on prior knowledge of conditions that might be related to the event. For example, when it's sunny, Oregonians go hiking (although, in reality, Oregonians go hiking all the time — trust me, I lived in Oregon for 8 years!). Mathematically, Bayes' theorem is expressed as:

P(AB)=P(BAP(A)/P(B)

where:

P(AB) is the probability of event A given that B is true,

P(BA) is the probability of event B given that A is true,

P(A) is the probability of event A, and

P(B) is the probability of event B.

In the case of the Oregonian example,

  • Event A: Oregonians go hiking.
  • Event B: It's a sunny day.
  • P(AB): How likely is it that Oregonians are hiking, knowing that the day is sunny?
  • P(BA): If we know Oregonians are hiking, how does this affect the likelihood of the day being sunny?
  • P(A): How often do Oregonians go hiking in general?
  • P(B): How often are there sunny days?

Now that you understand the concept of Bayes' theorem, Bayesian Networks utilize the theorem's concept to find complex joint probability distributions and model the conditional dependencies between variables. This is because in the real world, the probability of event A, such as Oregonians going hiking, could be influenced by factors beyond event B, such as the mood of the day, personal preferences (I am a city person, so even though I loved my time in Oregon, I wouldn't go hiking!), and more.

Logic Learning

Logic learning represents a high level of intelligence that we observe in the current era of AI. Similar to how our mind works, logic learning enables machines to perform operations such as understanding rules, facts, relationships, and constraints expressed in a logical format quite effortlessly. Applications of logic learning span various domains, including natural language processing, bioinformatics, and banking.

However, it's essential to note that logic learning, while powerful, is not as intricate as neural networks or deep learning, which constitute another distinct domain within ML and AI.

A notable example of logic learning is Inductive Logic Programming (ILP), which combines machine learning with logic programming. ILP's primary objective is to construct rules from observed data, a type of learning where the aim is to generalize from specific instances (examples) to broader rules or theories. This approach contrasts with deductive reasoning, where specific conclusions are drawn from general premises. In other words, inductive learning is more akin to a bottom-up approach, while deductive learning follows a top-down approach.

Imagine building a robot capable of distinguishing humans from chimpanzees. You introduce the robot to some humans and inform it, "These are humans" (the positive examples), and you also show it some chimpanzees, saying, "These are chimpanzees" (the negative examples).

Additionally, you provide the robot with background knowledge about human versus chimpanzee evolution to enhance its understanding.

Now, the robot engages in cognitive processing. It carefully examines the humans and chimpanzees you've presented and endeavors to discern a rule, such as "humans are generally taller and have smaller jaws than chimpanzees." This is akin to the robot formulating a hypothesis or educated guess.

Eventually, the robot shares its conclusion: "I believe that humans are typically taller and have smaller jaws than chimpanzees." As a result, when you present the robot with a new image or individual, it can utilize the learned rule to determine whether it's a human or not.

Article content


Alternatively, you can refer to the code below for a better understanding of what a simplified logic learning application might look like. Please note that this example doesn't fully implement ILP but simulates the learning process. The code provides a basic and rudimentary representation of what an ILP system might do: learning rules from examples and then applying these rules to make predictions about new instances. However, real ILP systems are considerably more complex and capable, employing advanced algorithms to extract logical rules from data

# Define examples
humans = [
    {"name": "human1", "tall": True, "small_jaw": True},
    {"name": "human2", "tall": True, "small_jaw": False},
    {"name": "human3", "tall": False, "small_jaw": True}
]

chimpanzees = [
    {"name": "chimp1", "tall": False, "large_jaw": True},
    {"name": "chimp2", "tall": False, "large_jaw": True},
    {"name": "chimp3", "tall": False, "large_jaw": False}
]

# A simple function to guess if the example is a human or chimpanzee
def guess_species(example):
    if example.get("tall", False) and example.get("small_jaw", False):
        return "human"
    elif not example.get("tall", True) and example.get("large_jaw", False):
        return "chimpanzee"
    else:
        return "unknown"

# Test the function
new_example = {"name": "test1", "tall": True, "small_jaw": True}
guess = guess_species(new_example)
print(f"The species of {new_example['name']} is guessed to be {guess}.")
        

Complex concepts made easy to understand. Thanks, Kay!

Like
Reply
Ping Wongphothiphan

UX Researcher | Healthcare and Social Research Scientist | Quantitative and Mixed Method Researcher

1y

Your explanation makes ML world much more simpler for me!

Like
Reply

To view or add a comment, sign in

More articles by Kay Chansiri, Ph.D.

Insights from the community

Others also viewed

Explore topics