Editing
Symbolic Ai
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== <span style="color: #FFFFFF;">Applying</span> == '''Building a rule-based expert system in Python:''' <syntaxhighlight lang="python"> class ExpertSystem: """Simple forward-chaining expert system for loan assessment.""" def __init__(self): self.facts = {} self.conclusions = [] def assert_fact(self, key, value): self.facts[key] = value def run(self): """Apply all rules and collect conclusions.""" # Rule 1: Credit score classification if self.facts.get('credit_score', 0) >= 750: self.assert_fact('credit_rating', 'excellent') elif self.facts.get('credit_score', 0) >= 650: self.assert_fact('credit_rating', 'good') else: self.assert_fact('credit_rating', 'poor') # Rule 2: Debt-to-income ratio dti = self.facts.get('monthly_debt', 0) / max(self.facts.get('monthly_income', 1), 1) self.assert_fact('dti_ratio', dti) if dti <= 0.36: self.assert_fact('dti_status', 'acceptable') else: self.assert_fact('dti_status', 'high') # Rule 3: Employment stability if self.facts.get('employment_years', 0) >= 2: self.assert_fact('employment_status', 'stable') else: self.assert_fact('employment_status', 'unstable') # Rule 4: Final decision (requires ALL conditions) if (self.facts.get('credit_rating') in ['excellent', 'good'] and self.facts.get('dti_status') == 'acceptable' and self.facts.get('employment_status') == 'stable'): return 'APPROVED', self._explain() else: return 'DENIED', self._explain() def _explain(self): return {k: v for k, v in self.facts.items()} # Usage system = ExpertSystem() system.assert_fact('credit_score', 720) system.assert_fact('monthly_debt', 800) system.assert_fact('monthly_income', 3500) system.assert_fact('employment_years', 3) decision, explanation = system.run() print(f"Decision: {decision}") print(f"Reasoning: {explanation}") </syntaxhighlight> ; Symbolic AI tools and languages : '''Prolog''' β Logic programming, backward chaining; used in NLP parsing, planning : '''Clips''' β C Language Integrated Production System; forward-chaining rule engine : '''Drools''' β Java-based business rule management system; widely used in enterprise : '''OWL/RDF''' β Web Ontology Language; semantic web knowledge representation : '''SPARQL''' β Query language for RDF knowledge graphs : '''Planning Domain Definition Language (PDDL)''' β Standard for AI planning problems </div> <div style="background-color: #8B4500; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
Summary:
Please note that all contributions to BloomWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BloomWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information