Example usage for weka.classifiers.functions LibLINEAR LibLINEAR

List of usage examples for weka.classifiers.functions LibLINEAR LibLINEAR

Introduction

In this page you can find the example usage for weka.classifiers.functions LibLINEAR LibLINEAR.

Prototype

LibLINEAR

Source Link

Usage

From source file:gr.ntua.sentimentanalysis.TrainingThread.java

License:Open Source License

public void run() {
    //Display info about this particular thread
    System.out.println(Thread.currentThread());
    String[] inputPaths = {//from  ww  w  .  jav  a  2 s .c o  m
            "C:\\FOT\\SentimentAnalysisServiceGraphs\\standfordTrainingSet\\trainingNegativeTweets",
            "C:\\FOT\\SentimentAnalysisServiceGraphs\\standfordTrainingSet\\trainingPositiveTweets" };
    String[][] documents = new String[inputPaths.length][];
    for (int i = 0; i < inputPaths.length; i++) {
        documents[i] = (String[]) SerializationUtilities.loadSerializedObject(inputPaths[i]);
        System.out.println("Documents\t:\t" + documents[i].length);
    }

    System.out.println("Preparing instances...");
    a.vmcl = new VectorModels(0.5, 0.0, documents);
    a.vmcl.prepareData(true, a.REP_MODEL);
    a.instances = a.vmcl.getInstances();

    System.out.println("Training classifier...");
    a.classifier = new LibLINEAR();
    try {

        a.classifier.buildClassifier(a.instances);
    } catch (Exception e) {
        e.printStackTrace();
    }
    System.out.println("Classifier was trained!");
}