The 30 Second Bayesian Classifier #machinelearning #bayes #classification

I’m putting this up as I got a nice email from a reader who was having trouble with running the Britney example. And as developers know, bad examples are enough to put people off…. actually they’re toxic.


See what I did there…


The Classifier4J library is old so it’s not on any Maven repository I’m aware of. So we have to go old school and go old fashion download jar file. You can find the Classifier4J library at

If you don’t have the code for the book you can download it from


Open a terminal window and go to the example code for the book. In chapter2 is the Britney code. Keep a note of where you’ve downloaded the Classifier4J jar file as you’ll need this in the Java compile command.

$ javac -cp /path/to/Classifier4J-0.6.jar


There should be a .class file in your directory now. Running the Java class is a simple matter. Notice we’re referencing the package and class we want to execute.

$ java -cp .:..:/path/to/Classifier4J-0.6.jar chapter2.BritneyDilemma
brittany spears = 0.7071067811865475
brittney spears = 0.7071067811865475
britany spears = 0.7071067811865475
britny spears = 0.7071067811865475
briteny spears = 0.7071067811865475
britteny spears = 0.7071067811865475
briney spears = 0.7071067811865475
brittny spears = 0.7071067811865475
brintey spears = 0.7071067811865475
britanny spears = 0.7071067811865475
britiny spears = 0.7071067811865475
britnet spears = 0.7071067811865475
britiney spears = 0.7071067811865475
christina aguilera = 0.0
britney spears = 0.9999999999999998

About the Book


You can find out more about the book on the Wiley website. As well as machine learning practical examples it also has sections on Hadoop, Streaming Data, Spark and R.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: