AB1989
AB1989

Reputation: 1

NumberFormatException in Mahout while building data model

When I am using a string valued attribute in the training data for a itemBasedRecommender in Mahout, I am getting a NumberFormatException which is thrown during the building of the FileDataModel from the data in a file. If the string attribute value is "1.0" which is basically a number represented as string, then the it is not throwing the NumberFormatException. But if the attribute value is "Washington", then the NumberFormatException is thrown. Is there any solution by which I can pass string attribute values like "Washington" as itemID/userID in the training data for Recommenders in Mahout? I am using Java 1.6SE, Mahout 0.7 and Hadoop 1.2.

Upvotes: 0

Views: 588

Answers (2)

paulscott56
paulscott56

Reputation: 506

I have had success with Long and Float datatypes. Strings are not numbers in a strongly typed langugae such as Java. In some of the data models there are conversion functions to fit Mahout's data types, or you could also use String.toLong() or asLong() values to pass in the values needed

Upvotes: 1

Julian Ortega
Julian Ortega

Reputation: 947

Mahout recommenders don't really work with Strings, typically you would use long numbers instead. Before passing the data to the recommender you'll have to map every user and every item to a unique number and after the recommender you'll have to map back to the originals.

There is a workaround where you can use the IDMigrator class, but if I remember correctly there is no support for this in the distributed version, only the in-memory implementation.

This answer from another question might help you as well (link)

Upvotes: 1

Related Questions