/** * Updates the instance info in the underlying search method, once the * instance has been filtered. * * @param ins The instance to add the information of. */ @Override public void addInstanceInfo(Instance ins) { if (m_Instances != null) try { getFilter().input(ins); m_AddID.input(getFilter().output()); m_ModifiedSearchMethod.addInstanceInfo(m_AddID.output()); } catch (Exception ex) { ex.printStackTrace(); } } }
/** * Updates the instance info in the underlying search method, once the * instance has been filtered. * * @param ins The instance to add the information of. */ @Override public void addInstanceInfo(Instance ins) { if (m_Instances != null) try { getFilter().input(ins); m_AddID.input(getFilter().output()); m_ModifiedSearchMethod.addInstanceInfo(m_AddID.output()); } catch (Exception ex) { ex.printStackTrace(); } } }
/** * Updates ranges based on the given instance, once it has been filtered. * * @see weka.core.neighboursearch.NearestNeighbourSearch#update(weka.core.Instance) */ @Override public void update(Instance ins) throws Exception { getFilter().input(ins); m_AddID.input(getFilter().output()); m_ModifiedSearchMethod.update(m_AddID.output()); }
/** * Updates ranges based on the given instance, once it has been filtered. * * @see weka.core.neighboursearch.NearestNeighbourSearch#update(weka.core.Instance) */ @Override public void update(Instance ins) throws Exception { getFilter().input(ins); m_AddID.input(getFilter().output()); m_ModifiedSearchMethod.update(m_AddID.output()); }
/** * Returns the nearest neighbour for the given instance based on distance * measured in the filtered space. * * @param target the instance for which to find the nearest neighbour * @return the nearest neighbour * * @see weka.core.neighboursearch.NearestNeighbourSearch#nearestNeighbour(weka.core.Instance) */ @Override public Instance nearestNeighbour(Instance target) throws Exception { getFilter().input(target); m_AddID.input(getFilter().output()); return getInstances().instance( (int) m_ModifiedSearchMethod.nearestNeighbour(m_AddID.output()).value( m_IndexOfID) - 1); }
/** * Returns the nearest neighbour for the given instance based on distance * measured in the filtered space. * * @param target the instance for which to find the nearest neighbour * @return the nearest neighbour * * @see weka.core.neighboursearch.NearestNeighbourSearch#nearestNeighbour(weka.core.Instance) */ @Override public Instance nearestNeighbour(Instance target) throws Exception { getFilter().input(target); m_AddID.input(getFilter().output()); return getInstances().instance( (int) m_ModifiedSearchMethod.nearestNeighbour(m_AddID.output()).value( m_IndexOfID) - 1); }
/** * Returns the nearest neighbours for the given instance based on distance * measured in the filtered space. * * @param target the instance for which to find the nearest neighbour * @param k the number of nearest neighbours to return * @return the nearest Neighbours * * @see weka.core.neighboursearch.NearestNeighbourSearch#kNearestNeighbours(weka.core.Instance, * int) */ @Override public Instances kNearestNeighbours(Instance target, int k) throws Exception { // Get neighbors in filtered space getFilter().input(target); m_AddID.input(getFilter().output()); Instances neighboursInFilteredSpace = m_ModifiedSearchMethod .kNearestNeighbours(m_AddID.output(), k); // Collect corresponding instances in original space Instances neighbours = new Instances(getInstances(), k); for (Instance inst : neighboursInFilteredSpace) { neighbours .add(getInstances().instance((int) inst.value(m_IndexOfID) - 1)); } return neighbours; }
/** * Returns the nearest neighbours for the given instance based on distance * measured in the filtered space. * * @param target the instance for which to find the nearest neighbour * @param k the number of nearest neighbours to return * @return the nearest Neighbours * * @see weka.core.neighboursearch.NearestNeighbourSearch#kNearestNeighbours(weka.core.Instance, * int) */ @Override public Instances kNearestNeighbours(Instance target, int k) throws Exception { // Get neighbors in filtered space getFilter().input(target); m_AddID.input(getFilter().output()); Instances neighboursInFilteredSpace = m_ModifiedSearchMethod .kNearestNeighbours(m_AddID.output(), k); // Collect corresponding instances in original space Instances neighbours = new Instances(getInstances(), k); for (Instance inst : neighboursInFilteredSpace) { neighbours .add(getInstances().instance((int) inst.value(m_IndexOfID) - 1)); } return neighbours; }