Cloud

O SpecGold OracleBusIntApps7 clr

 Gcloud

 

   Call us now 

  Manchester Office

  +44 (0) 8450 940 998

 

  

 

John's Blog

This is my blog of various topics, from things that I think might be useful to others, to things that I just find interesting personally. If you have any comments or questions on any of my posts then please do ask - any positive contribution is very much welcomed.

The views expressed in this blog and completely my own and do not reflect those of Beyond Systems Ltd. All content is provided for informational purposes only, and you are solely responsible for how you use this on your own or others systems. We accept no liability for any losses or damages caused.

  • Home
    Home This is where you can find all the blog posts throughout the site.
  • Categories
    Categories Displays a list of categories from this blog.
  • Tags
    Tags Displays a list of tags that have been used in the blog.
  • Bloggers
    Bloggers Search for your favorite blogger from this site.
  • Team Blogs
    Team Blogs Find your favorite team blogs here.
  • Login
    Login Login form

Simple Machine Learning

  • Font size: Larger Smaller
  • Subscribe to this entry
  • Print
Simple Machine Learning

With machine learning being one of te big things at the moment, I thought I'd cast my mind back to my first ever c programming assignment at university - write the game of Pangolins. The game is based on the 20 Questions game, whereby the user thinks of an object and the machine aims to guess that object by asking simple yes/no style questions - ideally less than 20. the system starts off by knowing about only a single object - a small ant-eating mammal called a Pangolin.
Each time a user thinks of something the system isn't aware of, it learns from this. The internal implementation of this is just a simple set of nodes, which can either be a question, or an object. A question node has two pointers to a yes and a no node. It's probably easiest to illustrate with a walkthough. I created a little demo app which can be accessed here on apex.oracle.com. The sample code to create can be found at the bottom of this post.

We start off with a single entry - and we are therefore asked "are you thinking of a Pangolin"?

Step 1

So assume we were actually thinking of a pencil, so we say no. The system then asks us what were we actually thinking of. Let's tell it so.

Step 2

Next we are asked to give a yes/no question that will distinguish between a pencil and a pangolin.

Step 3

And clearly the answer for that is No.

Step 4

 

So now our system knows about both pangolins and pencils. So the next time around it starts off by asking us Does it eat ants?, and then depending on our answer it will decide whether it thinks we're thinking of either a pangolin or an ant. So if I'm now thinking of a telephone, I would click no, and the system would then ask if I was thinking of a pencil. So no again, and now I am asked to provide a question to differentiate between a pencil and a phone. I might say Does it have a screen or simliar.
So now with my three objects, I have a binary tree that looks something like this:

Tree

so you can see very quickly that the more and more information that is fed into the system, the more "intelligent" it becomes. More-so, once we start getting large trees, we can then start to do things like height-balance them, so that we reduce number of questions to each leaf node. We can even eliminate questions completely (i.e. any question trail that doesn't lead to a leaf node that is an object can be removed). For example, given the following tree:

Tree 2

It would take us three questions to determine whether the user was thinking about a phone or a computer monitor. However if we balance that tree as follows, we only ever have to ask a maximum of two questions for each object node.

Tree 3

Now guessing what a user is thinking about isn't all that much use, and in the real world things are a lot more complicated than yes/no answers, however you should be able to see here that even with a massively simple structure and concepts, we can do some reasonably interesting things. Things don't need to be input manually from users all the time - in some systems we could store the states of different signals/sensor value ranges in such a tree structure to arrive at resolution quickly (automating the resolution should the issue arise again). Each time the system experiences an unknown, it can gain a little bit more intelligence.
Flow chart systems similar to this are used in many aspects of life - doctors use them to make diagnosis of conditions etc. However in many cases, new information isn't fed back into the system as it happens.

Please feel free to have a mess around in the APEX Application. Sensible contributions to the knowledge base are welcomed!

Source:

APEX Export: Download
DDL/DML: Download

Last modified on
Tagged in: APEX Machine Learning
in Technical Hits: 589 7 Comments
0

My primary area of interest and expertise is Oracle E-Business Suite, particularly Foundation, Human Resources, Payroll, Time and Labor, Warehouse Management and Inventory. Whilst I prefer to focus on functional aspects I do have a keen interest in technical areas too such as SQL tuning/the optimizer, Application Express (APEX), Unix (particularly Linux) and general development.











  ACE Logo




Cert Logo  
Cert Logo 2

Comments

  • Guest
    John Wednesday, 10 January 2018

    Not too sure where the "Machine Learning" is in this application. It looks like you're implementing a decision tree but that involves a lot more than simply inserting user-submitted values into a database. What did I miss?

  • John Keymer
    John Keymer Thursday, 11 January 2018

    Hi,
    Fair comment, it's not intended to be a demonstration of high level machine learning, more a conceptual example of how information gleamed over time can be stored and utilized, and then optimized (with tree balancing etc) for better results. That said, Wikipedia does consider a Decision Tree to be machine learning (https://en.wikipedia.org/wiki/Decision_tree_learning) however obviously in a lot more complicated guise. This really was intended to be the most simple example I could provide, which then gives the option to build upon in the future.

    Thanks

  • Guest
    John Thursday, 11 January 2018

    Thanks for your response. Decision Trees are considered a Machine Learning (ML) approach, but that process is more involved, including the use of training and test data sets, creating the model, demonstrating the quality of the model, before it is used to "make decisions". That's what I would expect to see in a typical Decision Tree implementation.

  • John Keymer
    John Keymer Friday, 12 January 2018

    Absolutely - the intention was just to have the absolute basics of something as a discussion point more than anything. I'm an absolute beginner in ML (my background is in ERP and the database) so it's more about my learning as well.

    Many thanks

  • Guest
    John Friday, 12 January 2018

    Thanks again for the effort and responding to my comments. Have a great weekend!

  • Guest
    Gregory Thursday, 11 January 2018

    It's impossible to connect to the application
    An error occurs "ORA-01422: exact fetch returns more than requested number of rows" after the login page

  • John Keymer
    John Keymer Friday, 12 January 2018

    Should be ok now - some old test data left behind.

Leave your comment

Guest
Guest Monday, 22 January 2018