Package org.apache.mahout.math

Examples of org.apache.mahout.math.Matrix.assignRow()


      if (isComplementary){
        perLabelThetaNormalizer = new DenseVector(VectorWritable.readVector(in));
      }
      weightsPerLabelAndFeature = new SparseRowMatrix(weightsPerLabel.size(), weightsPerFeature.size());
      for (int label = 0; label < weightsPerLabelAndFeature.numRows(); label++) {
        weightsPerLabelAndFeature.assignRow(label, VectorWritable.readVector(in));
      }
    } finally {
      Closeables.close(in, true);
    }
    NaiveBayesModel model = new NaiveBayesModel(weightsPerLabelAndFeature, weightsPerFeature, weightsPerLabel,
View Full Code Here


    Preconditions.checkNotNull(scoresPerLabel);

    Matrix scoresPerLabelAndFeature = new SparseMatrix(scoresPerLabel.size(), scoresPerFeature.size());
    for (Pair<IntWritable,VectorWritable> entry : new SequenceFileDirIterable<IntWritable,VectorWritable>(
        new Path(base, TrainNaiveBayesJob.SUMMED_OBSERVATIONS), PathType.LIST, PathFilters.partFilter(), conf)) {
      scoresPerLabelAndFeature.assignRow(entry.getFirst().get(), entry.getSecond().get());
    }
   
    // perLabelThetaNormalizer is only used by the complementary model, we do not instantiate it for the standard model
    Vector perLabelThetaNormalizer = null;
    if (isComplementary) {
View Full Code Here

   
    Matrix samples = new DenseMatrix( rows, input.numCols() );
   
    for (int x = 0; x < rows; x++ ) {
     
      samples.assignRow(x, input.viewRow(x) );
     
    }
   
   
    return samples;
View Full Code Here

    for (int i = 0; i < examples.size(); i++) {
   
      //inputs.putRow(i, examples.get(i).getFirst());
      inputs.assignRow( i, examples.get(i).getFirst().viewRow(0) );
      //labels.putRow(i,examples.get(i).getSecond());
      labels.assignRow( i, examples.get(i).getSecond().viewRow(0) );
   
    }
   
    curr = new DataSet(inputs,labels);
View Full Code Here

    for (int i = 0; i < data.size(); i++) {
     
      //in.putRow(i,data.get(i).getFirst());
      inputData.assignRow( i, data.get(i).getFirst().viewRow(0) );
      //out.putRow(i,data.get(i).getSecond());
      outputLabels.assignRow( i, data.get(i).getSecond().viewRow(0) );

    }
   
    return new DataSet( inputData, outputLabels );
   
View Full Code Here

        }
        //examples.putRow(i,getFirst().getRow(i));
        examples.assignRow( i, getFirst().viewRow(i) );
        //outcomes.putRow(i,getSecond().getRow(i));
        outcomes.assignRow( i, getSecond().viewRow(i) );

      }
      return new DataSet(examples,outcomes);
    }
  }
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.