Package org.apache.mahout.classifier.bayes.exceptions

Examples of org.apache.mahout.classifier.bayes.exceptions.InvalidDatastoreException


  public void initialize() throws InvalidDatastoreException {
    config = new HBaseConfiguration(new Configuration());
    try {
      table = new HTable(config, hbaseTable);
    } catch (IOException e) {
      throw new InvalidDatastoreException(e.getMessage());
    }
    Collection<String> labels = getKeys("thetaNormalizer");
    for (String label : labels) {
      thetaNormalizer = Math.max(thetaNormalizer, Math.abs(getWeightFromHbase(
        BayesConstants.LABEL_THETA_NORMALIZER, label)));
View Full Code Here


      r = getRowFromHbase(name);
    }
   
    if (r == null) {
      log.error("Encountered NULL");
      throw new InvalidDatastoreException("Encountered NULL");
    }
   
    Set<byte[]> labelBytes = r.getNoVersionMap().get(Bytes.toBytes(BayesConstants.HBASE_COLUMN_FAMILY))
        .keySet();
    Set<String> keySet = new HashSet<String>();
View Full Code Here

        return getSigmaJFromHbase(row);
      } else {
        return getWeightFromHbase(row, column);
      }
    } else {
      throw new InvalidDatastoreException();
    }
  }
View Full Code Here

      if ("vocabCount".equals(index)) {
        return getVocabCountFromHbase();
      } else if ("sigma_jSigma_k".equals(index)) {
        return getSigmaJSigmaKFromHbase();
      } else {
        throw new InvalidDatastoreException();
      }
     
    } else if ("labelWeight".equals(vectorName)) {
      return getWeightFromHbase(BayesConstants.LABEL_SUM, index);
    } else if ("thetaNormalizer".equals(vectorName)) {
      return getWeightFromHbase(BayesConstants.LABEL_THETA_NORMALIZER, index) / thetaNormalizer;
    } else if ("params".equals(vectorName)) {
      if ("alpha_i".equals(index)) {
        return alphaI;
      } else {
        throw new InvalidDatastoreException();
      }
    } else {
     
      throw new InvalidDatastoreException();
    }
  }
View Full Code Here

    String basePath = params.get("basePath");
    try {
      SequenceFileModelReader.loadModel(this, FileSystem.get(new Path(basePath)
          .toUri(), conf), params, conf);
    } catch (IOException e) {
      throw new InvalidDatastoreException(e.getMessage());
    }
    updateVocabCount();
    Collection<String> labels = getKeys("thetaNormalizer");
    for (String label : labels) {
      thetaNormalizer = Math.max(thetaNormalizer, Math.abs(vectorGetCell(
View Full Code Here

      throws InvalidDatastoreException {
    if (vectorName.equals("thetaNormalizer"))
      return vectorGetCell(vectorName, index) / thetaNormalizer;
    else if (vectorName.equals("params")) {
      if(index.equals("alpha_i")) return alpha_i;
      else throw new InvalidDatastoreException();
    }
    return vectorGetCell(vectorName, index);
  }
View Full Code Here

  private double matrixGetCell(String matrixName, String row, String col)
      throws InvalidDatastoreException {
    Map<String, Map<String, Double>> matrix = matrices.get(matrixName);
    if (matrix == null) {
      throw new InvalidDatastoreException();
    }
    Map<String, Double> rowVector = matrix.get(row);
    if (rowVector == null) {
      return 0.0;
    }
View Full Code Here

  private double vectorGetCell(String vectorName, String index)
      throws InvalidDatastoreException {

    Map<String, Double> vector = vectors.get(vectorName);
    if (vector == null) {
      throw new InvalidDatastoreException();
    }
    return nullToZero(vector.get(index));
  }
View Full Code Here

  public void initialize() throws InvalidDatastoreException {
    config = new HBaseConfiguration(new Configuration());
    try {
      table = new HTable(config, hbaseTable);
    } catch (IOException e) {
      throw new InvalidDatastoreException(e.getMessage());
    }
    Collection<String> labels = getKeys("thetaNormalizer");
    for (String label : labels) {
      thetaNormalizer = Math.max(thetaNormalizer, Math.abs(getWeightFromHbase(
          BayesConstants.LABEL_THETA_NORMALIZER, label)));
View Full Code Here

    } else
      r = getRowFromHbase(name);

    if (r == null) {
      log.error("Encountered NULL");
      throw new InvalidDatastoreException("Encountered NULL");
    }

    Set<byte[]> labelBytes = r.getNoVersionMap().get(Bytes.toBytes(BayesConstants.HBASE_COLUMN_FAMILY))
        .keySet();
    Set<String> keySet = new HashSet<String>();
View Full Code Here

TOP

Related Classes of org.apache.mahout.classifier.bayes.exceptions.InvalidDatastoreException

Copyright © 2018 www.massapicom. 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.