Online expert system/decision tree software?
May 20, 2008 9:46 AM   Subscribe

I'm looking for a script (ideally PHP) to run a website which asks various questions and then suggests the 'best fit' answer, in the manner of an expert system. Examples of the sort of thing I have in mind are the Search by Sight facility at or the 20 Questions game at (the latter uses some sort of neural network simulation, I think). Even just a decision tree tool would be good, though I guess that's more rigid. (I've seen this thread but that doesn't seem to answer my question.) Any ideas?
posted by hatmandu to Computers & Internet (2 answers total) 3 users marked this as a favorite
Best answer: I don't know of any pre-written utilities that will do what you want. What makes 20Q so fascinating is that it is right and it's not a "simple" right.

Here's the key with 20Q. (And I'm guessing from analysis on how it works). It has a large database back-end with items listed and special characteristics assigned to each item. So say there's 20 million items in 20Q (I'm picking a random number). Each of those items has distinguishing characteristics.

Then as you"Play" 20Q you're just defining a WHERE clause in a SQL statement. When it gets down to a certain number of items it provides a "guess".

I'm also thinking that the WHERE clause must have some flexibility (not all questions are necessarily limiting as there are times I play 20Q and think "maybe") so perhaps it does an 80/20 rule or a 90/10 rule.

Either way, the programming of this in PHP is easy. The database and, more importantly, populating the data in the database...that's hard.

So I'd start by looking at your decisions and use a binary tree format. If you use Yes/No questions, then start with the highest possible category that would divide your items into 2 groups, then divide into 2 more, etc. You may end up choosing ternary choices or more, but the goal is to start with every item in the set before question 1, and narrowing it down to 1 item by question 20.

I also tend to think 20Q updates its database for every "wrong" guess. if it doesn't get your item in 20 questions it asks you what the item was. I'd guess that's reviewed by a data admin and determined if items in the database need to be changed or if items need to be added.

I mean, think about it...with 20Qs popularity you start with 10 items but 20 GREAT questions. Have alpha testers guess wrong but update your database with their items.

Then move to beta testing with 500 items from alpha testers. Open beta, populate to thousands of items.

Then move to release with 2000 items but IIRC 20Q started as a free web application. A little viral madness of everyone e-mailing everyone about 20Q and you have millions of items. Then you release a toy.

1. Write database.
2. ??????????
3. Profit!


Sorry if this isn't specifically helpful in a "Look here to get what you want" way, but maybe it will help you to parse down your problem and write what you need.
posted by arniec at 8:57 AM on June 2, 2008

Response by poster: Thanks for your interesting thoughts, arniec (though I think you'll find 20Q uses a neural net-based algorithm of some kind rather than a decision tree) - food for thought!
posted by hatmandu at 8:01 AM on June 5, 2008

« Older Uninstalling A Bootleg Copy of Photoshop CS3 (Mac)   |   What is the best overall pitch-shifting plug-in... Newer »
This thread is closed to new comments.