Hi,
I am currently working on P. Giacomelli's great Mahout Cookbook and I am
stuck with a problem of deprecated code.
I am building the Text NaiveBayesClassifier using the code and It is
written:
final BayesParameters params = new BayesParameters();
params.setGramSize( 1 );
params.set( "verbose", "true" );
params.set( "classifierType", "bayes" );
params.set( "defaultCat", "OTHER" );
params.set( "encoding", "UTF-8" );
params.set( "alpha_i", "1.0" );
params.set( "dataSource", "hdfs" );
params.set( "basePath", "/tmp/output" );
try {
Path input = new Path( "/tmp/input" );
TrainClassifier.trainNaiveBayes( input, "/tmp/output",params );
Algorithm algorithm = new BayesAlgorithm();
Datastore datastore = new InMemoryBayesDatastore( params );
ClassifierContext classifier = new ClassifierContext(
algorithm, datastore );
classifier.initialize();
final BufferedReader reader = new BufferedReader( new
FileReader( args[ 0 ] ) );
String entry = reader.readLine();
while( entry != null ) {
List< String > document = new NGrams( entry,
Integer.parseInt( params.get( "gramSize" ) ) ).generateNGramsWithoutLabel();
ClassifierResult result =
classifier.classifyDocument(document.toArray( new String[
document.size() ]),params.get( "defaultCat" ) );
entry = reader.readLine();
} catch( final IOException ex ) {
ex.printStackTrace();
} catch( final InvalidDatastoreException ex ) {
ex.printStackTrace();}
My problem is that I can't find the classes BayesParameters, Datastore,
TrainClassifier etc... Looks like they are deprecated. Can someone write
me the equivalent with the modern classes, would be awesome?! Or is
there a link to find the updated version?
I am currently working on P. Giacomelli's great Mahout Cookbook and I am
stuck with a problem of deprecated code.
I am building the Text NaiveBayesClassifier using the code and It is
written:
final BayesParameters params = new BayesParameters();
params.setGramSize( 1 );
params.set( "verbose", "true" );
params.set( "classifierType", "bayes" );
params.set( "defaultCat", "OTHER" );
params.set( "encoding", "UTF-8" );
params.set( "alpha_i", "1.0" );
params.set( "dataSource", "hdfs" );
params.set( "basePath", "/tmp/output" );
try {
Path input = new Path( "/tmp/input" );
TrainClassifier.trainNaiveBayes( input, "/tmp/output",params );
Algorithm algorithm = new BayesAlgorithm();
Datastore datastore = new InMemoryBayesDatastore( params );
ClassifierContext classifier = new ClassifierContext(
algorithm, datastore );
classifier.initialize();
final BufferedReader reader = new BufferedReader( new
FileReader( args[ 0 ] ) );
String entry = reader.readLine();
while( entry != null ) {
List< String > document = new NGrams( entry,
Integer.parseInt( params.get( "gramSize" ) ) ).generateNGramsWithoutLabel();
ClassifierResult result =
classifier.classifyDocument(document.toArray( new String[
document.size() ]),params.get( "defaultCat" ) );
entry = reader.readLine();
} catch( final IOException ex ) {
ex.printStackTrace();
} catch( final InvalidDatastoreException ex ) {
ex.printStackTrace();}
My problem is that I can't find the classes BayesParameters, Datastore,
TrainClassifier etc... Looks like they are deprecated. Can someone write
me the equivalent with the modern classes, would be awesome?! Or is
there a link to find the updated version?