Random classifier (class )disregards the examples and returns random predictions. Curious enough though, the classifier will always predict the same class for the same example. Predictions can be distributed by the prescribed distribution.
Attributes
To verify this miraculous classifier, we shall classify the first ten examples from lenses dataset for three times.
random_classifier.py (uses lenses.tab)
The script always prints
Setting classVar is needed for nicer output. Remove it and see what happens.
OK, how does this really work? Random classifier computes the hash value of example (equivalent to calling hash(ex), where hash is a Python's built-in function), masks it by 0x7fffffff and divides it by 0x7fffffff to get a floating point number between 0 and 1. This value's position in the distribution determines the class. In our example, random values below 0.5 give the first class, those between 0.5 and 0.8 give the second and the rest give the third.
RandomLearner returns the above classifier.
Attributes