GithubHelp home page GithubHelp logo

primaryobjects / knowledgebase Goto Github PK

View Code? Open in Web Editor NEW
73.0 10.0 10.0 97 KB

An expert system using logic-based artificial intelligence and symbolic AI.

JavaScript 96.53% Prolog 3.47%
expert-system expert-systems logic-based-artificial-intelligence logical-knowledge-inference knowledgebase knowledge knowledge-discovery artificial-intelligence ai javascript nodejs symbolic symbolic-ai

knowledgebase's Introduction

Expert System Using Logic-Based Artificial Intelligence

This project is an example of building an expert system, using a knowledge-base constructed with logic-based artificial intelligence, also called symbolic AI.

See also Logical-Based Artificial Intelligence and Expert Systems

Usage

npm install
node app.js

First Example

The first example demonstrates forward-chaining. To use the example, provide the following example inputs below.

stem
woody
position
upright
one main trunk
yes
broad and flat
no
<press enter two times>

You should see the following output.

[ { attribute: 'stem', value: 'woody' },
  { attribute: 'position', value: 'upright' },
  { attribute: 'one main trunk', value: 'yes' },
  { attribute: 'broad and flat', value: 'no' },
  { attribute: 'type', value: 'tree' },
  { attribute: 'class', value: 'gymnosperm' } ]

The first 4 items are our provided inputs. The second two are new attributes deduced from the knowledge-base.

type is tree
class gymnosperm

Why? The first output of tree is because of the original input attributes all being found for "type = tree". The second output of "class gymnosperm" is added due to the addition of "type tree" as a new attribute. In this manner, both the "type" and the "class" were intelligently deduced from the original input query.

Second Example

The second example demonstrates backward-chaining. To use the example, provide the following example inputs below.

class

The program will then prompt you for values for additional attributes as it narrows down on selecting a class for you.

stem: woody
position: upright
one main trunk: yes
broad and flat: yes

You should see the output:

angiosperm

Why? This is the attribute value for the class which satisfies all attributes provided in the input.

About

Logic-based artificial intelligence is a form of classical AI that deals with representing knowledge as human-readable logical statements. In constrast to the machine learning statistical techniques that are currently popular, classical AI uses logical mechanisms for deducing intelligent statements and making decicisons.

One type of system that can be created with logical AI is an expert system.

Expert Systems

An expert system contains its knowledge usually in the form of a database, or, knowledge-base. By decoupling the knowledge from the actual software algorithm, an expert system can navigate through the database of facts to determine classifications and make decisions. The database is typically created by a human expert, and as such, the extent of knowledge that an expert system contains is typically confined to that of the human providing the content.

For example, a medical diagnosis expert system may contain a knowledge-base consisting of many different facts about diseases, symptoms, and conditions. The data can usually be represented by a tree hierarchy, from which one could navigate through the branches of symptoms until a particular conclusion is reached (i.e., disease or condition). By using a logic-based AI algorithm on the knowledge-base, such as forward-chaining and backward-chaining, an algorithm can intelligently traverse the tree, narrowing down the conclusion based upon the patient's provided symptoms.

Forward Chaining

Forward chaining is the process of traversing through the knowledge-base from top to bottom, seeking a rule by which all attributes are satisfied. For example, if every single one of a rule's attributes exist within the set of the patient's condition, then that rule triggers, thus providing a condition. If no rule is found with all of the attributes present from the patient, then a conclusion could not be found.

Backward Chaining

In contrast to forward-chaining, backward-chaining tries to first locate a rule who's conclusion matches one of the patient's provided attributes. When a rule is found, the process repeats, using the discovered rule's attributes as new goals. The user is prompted to enter new values for attributes as they are discovered through the process. Once the algorithm satisfies all attributes for the chain of rules it can return the response to the user's original query.

The Project

This project contains an implementation of forward-chaining and backward-chaining in JavaScript. It also contains two example knowledge-bases, written in JSON.

data/plants.js

A knowledge-base consisting of traits and classifications for plants.

data/etfs.js

A knowledge-base consisting of classes and categories for selecting a stock/bond percentage based upon risk tolerance.

License

MIT

Author

Kory Becker http://www.primaryobjects.com

knowledgebase's People

Contributors

primaryobjects avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.