/** * Get the classes set size * * @return the classes set size * */ protected int getClassesListSize() { return this.classesList.size(); }
/** * Returns the last element of the vector. * * @return the last element of the vector */ public final E lastElement() { return get(size() - 1); }
/** * Returns the last element of the vector. * * @return the last element of the vector */ public final E lastElement() { return get(size() - 1); }
FastVector[] ass=ap.getAllTheRules(); for (FastVector rule : ass) { if (rule == null) continue; System.out.println("---> " + rule); for (int i = 0; i < rule.size(); ++i) { Object o = rule.elementAt(i); if (o instanceof AprioriItemSet) { System.out.println(((AprioriItemSet) o).toString(data)); } else { System.out.println("rule: "+o); } } }
if (downSampled.size() == numToRetain) { break;
public static Instances instancesFromDataMap(DataMap datamap){ Instances instances = null; FastVector attributes = createFastVector(datamap.getFeatures(),datamap.getDataMap().keySet()); int numfeatures = attributes.size(); instances = new Instances("Instances",attributes,datamap.numDocuments()); //for each author... for (String author : datamap.getDataMap().keySet()){ ConcurrentHashMap<String,DocumentData> authormap = datamap.getDataMap().get(author); //for each document... for (String doctitle : authormap.keySet()){ Instance instance = new SparseInstance(numfeatures); ConcurrentHashMap<Integer,FeatureData> documentData = authormap.get(doctitle).getDataValues(); //for each index we have a value for for (Integer index : documentData.keySet()){ instance.setValue((Attribute)attributes.elementAt(index), documentData.get(index).getValue()); } instance.setValue((Attribute)attributes.elementAt(attributes.size()-1), author); instances.add(instance); } } return instances; }
protected static ExperimentResults resultsFromEvaluation(Evaluation eval, String authorCSV, List<String> documentTitles){ ExperimentResults results = new ExperimentResults(); FastVector predictions = eval.predictions(); String[] authors = getAuthorsFromAttributeString(authorCSV); //for each document for (int i = 0; i<predictions.size(); i++){ NominalPrediction prediction = (NominalPrediction)predictions.elementAt(i); String actual = authors[(int)prediction.actual()]; double[] probabilities = prediction.distribution(); Map<String,Double> probMap = new HashMap<String,Double>(); //for each potential author... for (int j = 0; j< probabilities.length; j++){ probMap.put(authors[j], probabilities[j]); } results.addDocResult(new DocResult(documentTitles.get(i),actual,probMap)); } return results; }
/** * Clones the vector and shallow copies all its elements. The elements have to * implement the Copyable interface. * * @return the new vector */ public final FastVector<E> copyElements() { FastVector<E> copy = copy(); for (int i = 0; i < size(); i++) { copy.set(i, Utils.<E> cast(((Copyable) get(i)).copy())); } return copy; }
/** * Clones the vector and shallow copies all its elements. The elements have to * implement the Copyable interface. * * @return the new vector */ public final FastVector<E> copyElements() { FastVector<E> copy = copy(); for (int i = 0; i < size(); i++) { copy.set(i, Utils.<E> cast(((Copyable) get(i)).copy())); } return copy; }
instance.setValue((Attribute) attrs.elementAt(i), score); instance.setValue((Attribute) attrs.elementAt(attrs.size() - 1), 0); // gold instances.add(instance);
if(getDebug()) System.out.print("Building Classifier "+m_Classifier.getClass()+" with "+ClassValues.size()+" possible classes .. "); m_Classifier.buildClassifier(NewTrain); if(getDebug()) System.out.println("Done");
double[] vals = new double[vector.size()]; for (int i = 0; i < vals.length; i++) { vals[i] = ((Instance) vector.elementAt(i)).value(distAttIndex); FastVector newVector = new FastVector(vector.size()); int[] sortedIndices = Utils.stableSort(vals); for (int i = 0; i < vals.length; i++) { vals[i] = -((Instance) vector.elementAt(i)).value(tfidfAttIndex); newVector = new FastVector(vector.size()); sortedIndices = Utils.stableSort(vals); for (int i = 0; i < vals.length; i++) { vals[i] = 1 - ((Instance) vector.elementAt(i)).value(probsAttIndex); newVector = new FastVector(vector.size()); sortedIndices = Utils.stableSort(vals); for (int i = 0; i < vals.length; i++) {