Basic decision tree implementation
This is a simple introduction to setting up a decision tree in Ruby. We'll start off with a simple setup. In this section, we're going to build a medical analysis tool. In order to follow along, make sure that you've installed the decisiontree
Ruby gem. If you don't have it on your system, you can install it by running:
gem install decisiontree
To start building a decision tree, let's create a basic application. Begin by pulling in the required gem libraries:
require 'rubygems' require 'decisiontree'
Addition of attributes
The next step is to include a single attribute called Temp
. This attribute will indicate the temperatures of individuals in the database and whether they are sick or healthy. This will give us the tool to decide which person is sick and which one is not:
attributes = ['Temp']
Addition of training data and its values
Now we are going to introduce training data, which is the data that the machine learning algorithm will learn from. This will contain...