@Override public boolean equalHeaders(Instances arg0) { return super.equalHeaders(arg0); }
/** * Updates the classifier using the given instance. * * @param instance the instance to include * @throws Exception if instance could not be incorporated * successfully */ public void updateClassifier(Instance instance) throws Exception { if (m_Train.equalHeaders(instance.dataset()) == false) { throw new Exception("Incompatible instance types\n" + m_Train.equalHeadersMsg(instance.dataset())); } update(instance); }
/** * Sets a value of a relation-valued attribute. Creates a fresh list of * attribute values before it is set. * * @param index the value's index * @param data the value * @throws IllegalArgumentException if the attribute is not relation-valued. */ final void setValue(int index, Instances data) { if (isRelationValued()) { if (!data.equalHeaders(((RelationalAttributeInfo)m_AttributeInfo).m_Header)) { throw new IllegalArgumentException("Can't set relational value. " + "Headers not compatible.\n" + data.equalHeadersMsg(((RelationalAttributeInfo)m_AttributeInfo).m_Header)); } ((NominalAttributeInfo)m_AttributeInfo).m_Values = Utils.cast(((NominalAttributeInfo)m_AttributeInfo).m_Values.clone()); ((NominalAttributeInfo)m_AttributeInfo).m_Values.set(index, data); } else { throw new IllegalArgumentException("Can only set value for" + " relation-valued attributes!"); } }
/** * Sets the current instance to be the supplied instance * * @param instance instance to be set as the current instance */ public void setInstance(Instance instance) { assert dataset.equalHeaders(instance.dataset()); this.instance = instance; missingAccessed = false; }
/** * Sets a value of a relation-valued attribute. Creates a fresh list of * attribute values before it is set. * * @param index the value's index * @param data the value * @throws IllegalArgumentException if the attribute is not relation-valued. */ final void setValue(int index, Instances data) { if (isRelationValued()) { if (!data.equalHeaders(((RelationalAttributeInfo)m_AttributeInfo).m_Header)) { throw new IllegalArgumentException("Can't set relational value. " + "Headers not compatible.\n" + data.equalHeadersMsg(((RelationalAttributeInfo)m_AttributeInfo).m_Header)); } ((NominalAttributeInfo)m_AttributeInfo).m_Values = Utils.cast(((NominalAttributeInfo)m_AttributeInfo).m_Values.clone()); ((NominalAttributeInfo)m_AttributeInfo).m_Values.set(index, data); } else { throw new IllegalArgumentException("Can only set value for" + " relation-valued attributes!"); } }
/** * Sets the current instance to be the supplied instance * * @param instance instance to be set as the current instance */ public void setInstance(Instance instance) { assert dataset.equalHeaders(instance.dataset()); this.instance = instance; missingAccessed = false; }
if (!m_data.equalHeaders(toAggregate.m_data)) { throw new Exception("Can't aggregate - data headers dont match: " + m_data.equalHeadersMsg(toAggregate.m_data));
@Override public boolean equalHeaders(Instance inst) { return dataset().equalHeaders(inst.dataset()); }
/** * Classifies a given instance. * * @param instance the instance to be classified * @return index of the predicted class as a double * @throws Exception if instance could not be classified * successfully */ public double classifyInstance(Instance instance) throws Exception { /* check the instance */ if (m_Train.equalHeaders(instance.dataset()) == false){ throw new Exception("NNge.classifyInstance : Incompatible instance types !\n" + m_Train.equalHeadersMsg(instance.dataset())); } Exemplar matched = nearestExemplar(instance); if(matched == null){ throw new Exception("NNge.classifyInstance : NNge hasn't been trained !"); } return matched.classValue(); }
/** * Tests if the headers of two instances are equivalent. * * @param inst another instance * @return true if the header of the given instance is equivalent to this * instance's header * @throws UnassignedDatasetException if instance doesn't have access to any * dataset */ // @ requires m_Dataset != null; @Override public/* @pure@ */boolean equalHeaders(Instance inst) { if (m_Dataset == null) { throw new UnassignedDatasetException( "Instance doesn't have access to a dataset!"); } return m_Dataset.equalHeaders(inst.dataset()); }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public NaiveBayes aggregate(NaiveBayes toAggregate) throws Exception { // Highly unlikely that discretization intervals will match between the // two classifiers if (m_UseDiscretization || toAggregate.getUseSupervisedDiscretization()) { throw new Exception("Unable to aggregate when supervised discretization " + "has been turned on"); } if (!m_Instances.equalHeaders(toAggregate.m_Instances)) { throw new Exception("Can't aggregate - data headers don't match: " + m_Instances.equalHeadersMsg(toAggregate.m_Instances)); } ((Aggregateable) m_ClassDistribution) .aggregate(toAggregate.m_ClassDistribution); // aggregate all conditional estimators for (int i = 0; i < m_Distributions.length; i++) { for (int j = 0; j < m_Distributions[i].length; j++) { ((Aggregateable) m_Distributions[i][j]) .aggregate(toAggregate.m_Distributions[i][j]); } } return this; }
/** * Tests if the headers of two instances are equivalent. * * @param inst another instance * @return true if the header of the given instance is equivalent to this * instance's header * @throws UnassignedDatasetException if instance doesn't have access to any * dataset */ // @ requires m_Dataset != null; @Override public/* @pure@ */boolean equalHeaders(Instance inst) { if (m_Dataset == null) { throw new UnassignedDatasetException( "Instance doesn't have access to a dataset!"); } return m_Dataset.equalHeaders(inst.dataset()); }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public NaiveBayes aggregate(NaiveBayes toAggregate) throws Exception { // Highly unlikely that discretization intervals will match between the // two classifiers if (m_UseDiscretization || toAggregate.getUseSupervisedDiscretization()) { throw new Exception("Unable to aggregate when supervised discretization " + "has been turned on"); } if (!m_Instances.equalHeaders(toAggregate.m_Instances)) { throw new Exception("Can't aggregate - data headers don't match: " + m_Instances.equalHeadersMsg(toAggregate.m_Instances)); } ((Aggregateable) m_ClassDistribution) .aggregate(toAggregate.m_ClassDistribution); // aggregate all conditional estimators for (int i = 0; i < m_Distributions.length; i++) { for (int j = 0; j < m_Distributions[i].length; j++) { ((Aggregateable) m_Distributions[i][j]) .aggregate(toAggregate.m_Distributions[i][j]); } } return this; }
/** * Add a plot to the list of plots to display * * @param newPlot the new plot to add * @exception Exception if the plot could not be added */ public void addPlot(PlotData2D newPlot) throws Exception { if (newPlot.m_plotInstances == null) { throw new Exception("No instances in plot data!"); } if (m_masterPlot != null) { if (m_masterPlot.m_plotInstances.equalHeaders(newPlot.m_plotInstances) == false) { throw new Exception("Plot2D :Plot data's instances are incompatable " + " with master plot"); } } else { m_masterPlot = newPlot; m_plotInstances = m_masterPlot.m_plotInstances; } m_plots.add(newPlot); setXindex(m_xIndex); setYindex(m_yIndex); setCindex(m_cIndex); }
/** * Adds the supplied instance to the training set * * @param instance the instance to add * @throws Exception if instance could not be incorporated successfully */ public void updateClassifier(Instance instance) throws Exception { if (m_Train.equalHeaders(instance.dataset()) == false) throw new Exception("Incompatible instance types\n" + m_Train.equalHeadersMsg(instance.dataset())); if ( instance.classIsMissing() ) return; m_Train.add(instance); // update relevant attributes ... update_m_Attributes(); }
/** * Aggregate the supplied reservoir into our reservoir. Does not increase the * size of the sample. * * @param toAggregate the reservoir sample to aggregate * @throws Exception if the structure of the instances in the sample to * aggregate does not match the structure of our sketch */ public void aggregateReservoir(WeightedReservoirSample toAggregate) throws Exception { if (toAggregate.getSample().size() > 0) { Instance structureCheck = toAggregate.getSample().peek().m_instance; if (!m_currentSketch.equalHeaders(structureCheck.dataset())) { throw new Exception( "Can't aggregate - instances structure is different: " + m_currentSketch.equalHeadersMsg(structureCheck.dataset())); } } m_weightedCenterSample.aggregate(toAggregate); }
/** * Updates the classifier. * * @param instance the instance to be put into the classifier * @throws Exception if the instance could not be included successfully */ public void updateClassifier(Instance instance) throws Exception { if (m_Train.equalHeaders(instance.dataset()) == false) { throw new Exception("Incompatible instance types\n" + m_Train.equalHeadersMsg(instance.dataset())); } if (instance.classIsMissing()) { return; } m_Train.add(instance); updateMinMax(instance); }
/** * Adds the supplied instance to the training set. * * @param instance the instance to add * @throws Exception if instance could not be incorporated * successfully */ public void updateClassifier(Instance instance) throws Exception { if (m_Train == null) { throw new Exception("No training instance structure set!"); } else if (m_Train.equalHeaders(instance.dataset()) == false) { throw new Exception("Incompatible instance types\n" + m_Train.equalHeadersMsg(instance.dataset())); } if (!instance.classIsMissing()) { m_NNSearch.update(instance); m_Train.add(instance); } }
/** * Adds the supplied instance to the training set. * * @param instance the instance to add * @throws Exception if instance could not be incorporated * successfully */ public void updateClassifier(Instance instance) throws Exception { if (m_Train == null) { throw new Exception("No training instance structure set!"); } else if (m_Train.equalHeaders(instance.dataset()) == false) { throw new Exception("Incompatible instance types\n" + m_Train.equalHeadersMsg(instance.dataset())); } if (!instance.classIsMissing()) { m_NNSearch.update(instance); m_Train.add(instance); } }
/** * Adds the supplied instance to the training set * * @param instance the instance to add * @throws Exception if instance could not be incorporated successfully */ public void updateClassifier(Instance instance) throws Exception { if (m_Train.equalHeaders(instance.dataset()) == false) throw new Exception("Incompatible instance types\n" + m_Train.equalHeadersMsg(instance.dataset())); if ( instance.classIsMissing() ) return; m_Train.add(instance); // update relevant attributes ... update_m_Attributes(); }