Part 3: Core Concepts of AI and Problem-Solving with Python
What Is Intelligence in AI?
In AI, intelligence refers to the ability of a machine to:
- Learn from experience
- Adapt to new inputs
- Perform tasks like reasoning, planning, and decision-making
Core Areas of AI
-
Problem Solving
-
Knowledge Representation
-
Logical Reasoning
-
Learning and Adaptation
Types of AI (By Capability)
Type | Description | Example |
---|---|---|
Narrow AI | AI that performs a specific task | Siri, Alexa |
General AI | AI that mimics human intelligence | Still theoretical |
Super AI | AI smarter than humans | Hypothetical/Future |
Problem-Solving in AI
AI systems often solve problems using one or more of the following strategies:
1. Search Algorithms
Used to explore all possible solutions in a structured way (like in a maze or game).
Example: Breadth-First Search (BFS), Depth-First Search (DFS)
2. Heuristics
A heuristic is a rule of thumb or shortcut that guides decision-making.
# A simple heuristic: Prefer shorter paths
def heuristic(path):
return len(path)
3. Rule-Based Systems
These systems use if-then rules to simulate decision-making.
def chatbot_response(message):
if "hello" in message.lower():
return "Hi there! How can I help you?"
elif "bye" in message.lower():
return "Goodbye!"
else:
return "I don't understand."
print(chatbot_response("Hello"))
Mini Project: A Simple Rule-Based Expert System
Let’s simulate a basic medical diagnosis bot using if-elif
rules:
def diagnose(symptom):
if symptom == "fever":
return "You might have the flu."
elif symptom == "cough":
return "You may have a cold."
elif symptom == "headache":
return "Could be a migraine."
else:
return "Symptom not recognized."
print(diagnose("fever")) # Output: You might have the flu.
Practice Challenge
Try expanding the system to handle multiple symptoms:
def multi_symptom(symptoms):
if "fever" in symptoms and "cough" in symptoms:
return "Flu or COVID-19"
elif "headache" in symptoms and "nausea" in symptoms:
return "Migraine"
else:
return "Please consult a doctor"
print(multi_symptom(["fever", "cough"]))
What You’ve Learned:
- How AI systems approach problem-solving
- The concept of heuristics and rules
- How to implement rule-based systems using Python
What’s Next?
In Part 4, we’ll jump into Machine Learning and use Python’s scikit-learn
to build your first ML model.