Examples of TrainingSet


Examples of org.apache.stanbol.enhancer.topic.api.training.TrainingSet

        ResponseBuilder rb;
        if (!classifier.isUpdatable()) {
            rb = Response.status(Response.Status.BAD_REQUEST).entity(
                String.format("Classifier %s is not updateble.\n", classifier.getName()));
        } else {
            TrainingSet trainingSet = classifier.getTrainingSet();
            exampleId = trainingSet.registerExample(exampleId, textContent, concepts);
            // TODO: make example GETable resources and return a 201 to it instead of a simple message.
            rb = Response.ok(String.format(
                "Successfully added or updated example '%s' in training set '%s'.\n", exampleId,
                trainingSet.getName()));
        }
        addCORSOrigin(servletContext, rb, headers);
        return rb.build();
    }
View Full Code Here

Examples of org.apache.stanbol.enhancer.topic.api.training.TrainingSet

        ResponseBuilder rb;
        if (!classifier.isUpdatable()) {
            rb = Response.status(Response.Status.BAD_REQUEST).entity(
                String.format("Classifier %s is not updateble.\n", classifier.getName()));
        } else {
            TrainingSet trainingSet = classifier.getTrainingSet();
            if (exampleIds != null && !exampleIds.isEmpty()) {
                for (String exampleId : exampleIds) {
                    trainingSet.registerExample(exampleId, null, null);
                }
            } else {
                // implement a way to cleanup a complete training set? or is it too dangerous and we should
                // return an error instead?
            }
            rb = Response.ok(String.format("Successfully deleted examples in training set '%s'.\n",
                trainingSet.getName()));
        }
        addCORSOrigin(servletContext, rb, headers);
        return rb.build();
    }
View Full Code Here

Examples of org.apache.stanbol.enhancer.topic.api.training.TrainingSet

    public TrainingSet getTrainingSet() {
        if (trainingSet != null) {
            return trainingSet;
        }
        if (trainingSetTracker != null) {
            TrainingSet trainingsSet = (TrainingSet) trainingSetTracker.getService();
            if(trainingsSet == null){
                for(int i=0; i < 5 && trainingsSet == null; i++){
                    try {
                        trainingsSet = (TrainingSet) trainingSetTracker.waitForService(1000);
                    } catch (InterruptedException e) {/*ignore*/}
 
View Full Code Here

Examples of org.apache.stanbol.enhancer.topic.training.TrainingSet

        ResponseBuilder rb;
        if (!classifier.isUpdatable()) {
            rb = Response.status(Response.Status.BAD_REQUEST).entity(
                String.format("Classifier %s is not updateble.\n", classifier.getName()));
        } else {
            TrainingSet trainingSet = classifier.getTrainingSet();
            exampleId = trainingSet.registerExample(exampleId, textContent, concepts);
            // TODO: make example GETable resources and return a 201 to it instead of a simple message.
            rb = Response.ok(String.format(
                "Successfully added or updated example '%s' in training set '%s'.\n", exampleId,
                trainingSet.getName()));
        }
        addCORSOrigin(servletContext, rb, headers);
        return rb.build();
    }
View Full Code Here

Examples of org.apache.stanbol.enhancer.topic.training.TrainingSet

        ResponseBuilder rb;
        if (!classifier.isUpdatable()) {
            rb = Response.status(Response.Status.BAD_REQUEST).entity(
                String.format("Classifier %s is not updateble.\n", classifier.getName()));
        } else {
            TrainingSet trainingSet = classifier.getTrainingSet();
            if (exampleIds != null && !exampleIds.isEmpty()) {
                for (String exampleId : exampleIds) {
                    trainingSet.registerExample(exampleId, null, null);
                }
            } else {
                // implement a way to cleanup a complete training set? or is it too dangerous and we should
                // return an error instead?
            }
            rb = Response.ok(String.format("Successfully deleted examples in training set '%s'.\n",
                trainingSet.getName()));
        }
        addCORSOrigin(servletContext, rb, headers);
        return rb.build();
    }
View Full Code Here

Examples of org.neuroph.core.learning.TrainingSet

    /**
     * Create and run MLP with XOR training set
     */
    public static void main(String[] args) {
        // create training set (logical XOR function)
        TrainingSet trainingSet = new TrainingSet(2, 1);
        trainingSet.addElement(new SupervisedTrainingElement(new double[]{0, 0}, new double[]{0}));
        trainingSet.addElement(new SupervisedTrainingElement(new double[]{0, 1}, new double[]{1}));
        trainingSet.addElement(new SupervisedTrainingElement(new double[]{1, 0}, new double[]{1}));
        trainingSet.addElement(new SupervisedTrainingElement(new double[]{1, 1}, new double[]{0}));

        MultiLayerPerceptron nnet = new MultiLayerPerceptron( TransferFunctionType.TANH ,2, 3, 1);
        MatrixMultiLayerPerceptron mnet = new MatrixMultiLayerPerceptron(nnet);

        System.out.println("Training network...");
View Full Code Here

Examples of org.neuroph.core.learning.TrainingSet

     * Runs this sample
     */
    public static void main(String args[]) {
            // create training set (logical AND function)
            TrainingSet trainingSet = new TrainingSet(2, 1);
            trainingSet.addElement(new SupervisedTrainingElement(new double[]{0, 0}, new double[]{0}));
            trainingSet.addElement(new SupervisedTrainingElement(new double[]{0, 1}, new double[]{0}));
            trainingSet.addElement(new SupervisedTrainingElement(new double[]{1, 0}, new double[]{0}));
            trainingSet.addElement(new SupervisedTrainingElement(new double[]{1, 1}, new double[]{1}));

            // create perceptron neural network
            NeuralNetwork myPerceptron = new Perceptron(2, 1);
            // learn the training set
            myPerceptron.learnInSameThread(trainingSet);
View Full Code Here

Examples of org.neuroph.core.learning.TrainingSet

  /**
   * Generate the training data for the training sunspot years.
   * @return The training data.
   */
  public TrainingSet generateTraining() {
    TrainingSet result = new TrainingSet(WINDOW_SIZE, 1);

    for (int year = TRAIN_START; year < TRAIN_END; year++) {
      double[] input = new double[WINDOW_SIZE];
      double[] ideal = new double[1];

      int index = 0;
      for (int i = year - WINDOW_SIZE; i < year; i++) {
        input[index++] = this.normalizedSunspots[i];
      }

      ideal[0] = this.normalizedSunspots[year];

      result.addElement(new SupervisedTrainingElement(input, ideal));
    }
    return result;
  }
View Full Code Here

Examples of org.neuroph.core.learning.TrainingSet

     
    normalizeSunspots(0.1, 0.9);
   
    network.getLearningRule().addObserver(this);
   
    TrainingSet training = generateTraining();
    network.learnInSameThread(training);
    predict(network);
   
    Neuroph.getInstance().shutdown();
  }
View Full Code Here

Examples of org.neuroph.core.learning.TrainingSet

     * Runs this sample
     */
    public static void main(String args[]) {

        // create training set (H and T letter in 3x3 grid)
        TrainingSet trainingSet = new TrainingSet();
        trainingSet.addElement(new TrainingElement(new double[]{1, 0, 1,
                                                                1, 1, 1,
                                                                1, 0, 1})); // H letter
       
        trainingSet.addElement(new TrainingElement(new double[]{1, 1, 1,
                                                                0, 1, 0,
                                                                0, 1, 0})); // T letter
 
        // create hopfield network
        Hopfield myHopfield = new Hopfield(9);
        // learn the training set
        myHopfield.learnInSameThread(trainingSet);

        // test hopfield network
        System.out.println("Testing network");

        // add one more 'incomplete' H pattern for testing - it will be recognized as H
        trainingSet.addElement(new TrainingElement(new double[]{1, 0, 0,
                                                                1, 0, 1,
                                                                1, 0, 1}));


        // print network output for the each element from the specified training set.
        for(TrainingElement trainingElement : trainingSet.trainingElements()) {
            myHopfield.setInput(trainingElement.getInput());
            myHopfield.calculate();
            myHopfield.calculate();  
            double[] networkOutput = myHopfield.getOutput();

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.