public void reset() { for (int labelIndex = 0; labelIndex < numOfLabels; labelIndex++) { m_Predictions[labelIndex] = new FastVector(); } all_Predictions = new FastVector(); }
/** * Creates a new instance of this class * * @param numOfLabels the number of labels */ public LabelBasedAUC(int numOfLabels) { this.numOfLabels = numOfLabels; m_Predictions = new FastVector[numOfLabels]; for (int labelIndex = 0; labelIndex < numOfLabels; labelIndex++) { m_Predictions[labelIndex] = new FastVector(); } all_Predictions = new FastVector(); }
attVals = new FastVector(); attVals.addElement("dummy"); attVals.addElement("A"); attVals.addElement("B");
/** * Initialize the classes structure */ protected void initClassesList() { this.classesList = new FastVector(); this.classesList.addElement("?"); //this.classesList.addElement("fake_class"); }
FastVector attributes = new FastVector(); attributes.addElement(new Attribute("attr", (FastVector) null));
public ObviousWekaInstances(Table table, String name) { this(table, name, new FastVector(), table.getRowCount()); }
FastVector classAttr = new FastVector(); classAttr .addElement(new Attribute("class", (FastVector) null));
FastVector atts = new FastVector(); // assuming all your eight attributes are numeric for( int i = 1; i <= 8; i++ ) { atts.addElement(new Attribute("att" + i)); // - numeric } Instances data = new Instances("MyRelation", atts, 0); data.add(dataInst);
/** * Gets the attributes for all internal EDAs (n internal EDAs -> n attributes). * The attributes are named after the internal EDAs and an additional index * to prevent ambiguities if more than one EDABasic of the same type is used. * @return a FastVector with the attributes */ private FastVector getAttributes(){ FastVector attrs = new FastVector(); for (int i = 0; i < this.edas.size(); i++){ EDABasic<? extends TEDecision> eda = this.edas.get(i); attrs.addElement(new Attribute(eda.getClass().getSimpleName()+i)); } return attrs; }
protected static FastVector createFastVector(Map<Integer,String> features, Set<String> authors){ FastVector fv = new FastVector(features.size()+1); for (Integer i : features.keySet()){ fv.addElement(new Attribute(features.get(i),i)); } //author names FastVector authorNames = new FastVector(); List<String> authorsSorted = new ArrayList<String>(authors.size()); authorsSorted.addAll(authors); for (String author : authorsSorted){ authorNames.addElement(author); } Attribute authorNameAttribute = new Attribute("authorName", authorNames); fv.addElement(authorNameAttribute); return fv; }
Attribute dateTimeAttribute = new Attribute("dateTime","yyyy-MM-dd HH:mm"); Attribute valueAttribute = new Attribute("value"); FastVector fvWekaAttributesLinear = new FastVector(2); fvWekaAttributesLinear.addElement(dateTimeAttribute); fvWekaAttributesLinear.addElement(valueAttribute); Instances isTrainingSet = new Instances("Relation", fvWekaAttributesLinear, 100000); double[] attValues = new double[isTrainingSet.numAttributes()]; attValues[0] = isTrainingSet.attribute("dateTime").parseDate("2009-07-15 10:00"); attValues[1] = 0.5;
FastVector predictions = new FastVector();
double[][] data = { {4058.0, 4059.0, ... }, /* first instance */ {19.0, 20.0, ... } /* second instance */ }; int numAtts = data[0].length; FastVector atts = new FastVector(numAtts); for (int att = 0; att < numAtts; att++) { atts.addElement(new Attribute("Attribute" + att, att)); } int numInstances = data.length; Instances dataset = new Instances("Dataset", atts, numInstances); for (int inst = 0; inst < numInstances; inst++) { dataset.add(new Instance(1.0, data[inst])); } BufferedWriter writer = new BufferedWriter(new FileWriter("test.arff")); writer.write(dataset.toString()); writer.flush(); writer.close();
FastVector destValues = new FastVector(); destValues.addElement("dummy"); destValues.addElement("tree"); destValues.addElement("flower"); Attribute destClassAttribute = new Attribute("destClass", destValues);
protected Instances createInstances() { FastVector attributes = new FastVector(); for (int i = 0; i < schema.getColumnCount(); i++) { Attribute attribute = createAttribute(schema.getColumnName(i), schema.getColumnType(i)); attributes.addElement(attribute); } return new Instances("test", attributes, 1); }
@Override public void buildClassifier(Instances D) throws Exception { testCapabilities(D); FastVector values = new FastVector(4); values.addElement("00"); values.addElement("10"); values.addElement("01"); values.addElement("11"); classAttribute = new Attribute("TheCLass",values); int L = D.classIndex(); h = new Classifier[L][L]; for(int j = 0; j < L; j++) { for(int k = j+1; k < L; k++) { if (getDebug()) System.out.print("."); Instances D_pair = convert(D,j,k); h[j][k] = (AbstractClassifier)AbstractClassifier.forName(getClassifier().getClass().getName(),((AbstractClassifier)getClassifier()).getOptions()); h[j][k].buildClassifier(D_pair); } if (getDebug()) System.out.println(""); } }
@Override public void buildClassifier(Instances D) throws Exception { testCapabilities(D); FastVector values = new FastVector(4); values.addElement("00"); values.addElement("10"); values.addElement("01"); values.addElement("11"); classAttribute = new Attribute("TheCLass",values); int L = D.classIndex(); h = new Classifier[L][L]; for(int j = 0; j < L; j++) { for(int k = j+1; k < L; k++) { if (getDebug()) System.out.print("."); Instances D_pair = convert(D,j,k); h[j][k] = (AbstractClassifier)AbstractClassifier.forName(getClassifier().getClass().getName(),((AbstractClassifier)getClassifier()).getOptions()); h[j][k].buildClassifier(D_pair); } if (getDebug()) System.out.println(""); } }
/** * Creates attributes vector from an obvious table. * @return vector from attributes */ protected FastVector createAttributes() { FastVector attributes = new FastVector(); for (int i = 0; i < table.getSchema().getColumnCount(); i++) { attributes.addElement(createAttribute(table.getSchema().getColumnName(i), table.getSchema().getColumnType(i))); } return attributes; }
private void trainModel(Map<Long, Double> metricData) throws Exception { //Model has a single metric_value attribute Attribute value = new Attribute("metric_value"); FastVector attributes = new FastVector(); attributes.addElement(value); trainingData = new Instances("metric_value_data", attributes, 0); for (Double val : metricData.values()) { double[] valArray = new double[] { val }; Instance instance = new Instance(1.0, valArray); trainingData.add(instance); } //Create and train the model model = new SimpleKMeans(); model.setNumClusters(k); model.setMaxIterations(20); model.setPreserveInstancesOrder(true); model.buildClusterer(trainingData); clusterCentroids = model.getClusterCentroids(); centroidAssignments = model.getAssignments(); setMeanDistancesToCentroids(); }
private void trainModel(Map<Long, Double> metricData) throws Exception { //Model has a single metric_value attribute Attribute value = new Attribute("metric_value"); FastVector attributes = new FastVector(); attributes.addElement(value); trainingData = new Instances("metric_value_data", attributes, 0); for (Double val : metricData.values()) { double[] valArray = new double[] { val }; Instance instance = new Instance(1.0, valArray); trainingData.add(instance); } //Create and train the model model = new SimpleKMeans(); model.setNumClusters(k); model.setMaxIterations(20); model.setPreserveInstancesOrder(true); model.buildClusterer(trainingData); clusterCentroids = model.getClusterCentroids(); centroidAssignments = model.getAssignments(); setMeanDistancesToCentroids(); }