Class Ai4r::Classifiers::ZeroR
In: lib/ai4r/classifiers/zero_r.rb
Parent: Classifier

Introduction

The idea behind the ZeroR classifier is to identify the the most common class value in the training set. It always returns that value when evaluating an instance. It is frequently used as a baseline for evaluating other machine learning algorithms.

Methods

build   eval   get_rules  

Attributes

class_value  [R] 
data_set  [R] 

Public Instance methods

Build a new ZeroR classifier. You must provide a DataSet instance as parameter. The last attribute of each item is considered as the item class.

You can evaluate new data, predicting its class. e.g.

  classifier.eval(['New York',  '<30', 'F'])  # => 'Y'

This method returns the generated rules in ruby code. e.g.

  classifier.get_rules
    # =>  marketing_target='Y'

It is a nice way to inspect induction results, and also to execute them:

    marketing_target = nil
    eval classifier.get_rules
    puts marketing_target
      # =>  'Y'

[Validate]