/** * Builds the Cover Tree on the given set of instances. * * @param instances The insts on which the Cover Tree is to be built. * @throws Exception If some error occurs while building the Cover Tree */ @Override public void setInstances(Instances instances) throws Exception { super.setInstances(instances); buildCoverTree(instances); }
/** * Builds the KDTree on the given set of instances. * @param instances The insts on which the KDTree is to be * built. * @throws Exception If some error occurs while * building the KDTree */ public void setInstances(Instances instances) throws Exception { super.setInstances(instances); buildKDTree(instances); }
/** * Builds the BallTree based on the given set of instances. * @param insts The insts for which the BallTree is to be * built. * @throws Exception If some error occurs while * building the BallTree */ public void setInstances(Instances insts) throws Exception { super.setInstances(insts); buildTree(); }
/** * Builds the KDTree on the given set of instances. * @param instances The insts on which the KDTree is to be * built. * @throws Exception If some error occurs while * building the KDTree */ public void setInstances(Instances instances) throws Exception { super.setInstances(instances); buildKDTree(instances); }
/** * Builds the BallTree based on the given set of instances. * @param insts The insts for which the BallTree is to be * built. * @throws Exception If some error occurs while * building the BallTree */ public void setInstances(Instances insts) throws Exception { super.setInstances(insts); buildTree(); }
/** * Builds the Cover Tree on the given set of instances. * * @param instances The insts on which the Cover Tree is to be built. * @throws Exception If some error occurs while building the Cover Tree */ @Override public void setInstances(Instances instances) throws Exception { super.setInstances(instances); buildCoverTree(instances); }
m_NNSearch.setInstances(m_Train);
m_NNSearch.setInstances(m_Train);
StringBuffer item; m_NearestNeighbourSearch.setInstances(m_Instances);
/** * 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); m_NNSearch.update(instance); m_kNNValid = false; if ((m_WindowSize > 0) && (m_Train.numInstances() > m_WindowSize)) { boolean deletedInstance=false; while (m_Train.numInstances() > m_WindowSize) { m_Train.delete(0); deletedInstance=true; } //rebuild datastructure KDTree currently can't delete if(deletedInstance==true) m_NNSearch.setInstances(m_Train); } }
/** * 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); m_NNSearch.update(instance); m_kNNValid = false; if ((m_WindowSize > 0) && (m_Train.numInstances() > m_WindowSize)) { boolean deletedInstance=false; while (m_Train.numInstances() > m_WindowSize) { m_Train.delete(0); deletedInstance=true; } //rebuild datastructure KDTree currently can't delete if(deletedInstance==true) m_NNSearch.setInstances(m_Train); } }
super.setInstances(data); m_ModifiedSearchMethod.setInstances(filteredData); } catch (Exception e) { e.printStackTrace();
super.setInstances(data); m_ModifiedSearchMethod.setInstances(filteredData); } catch (Exception e) { e.printStackTrace();
/** * tests whether the number of instances returned by the algorithms is the * same as was requested */ public void testNumberOfNeighbors() { int i; int instIndex; Instances neighbors; try { m_NearestNeighbourSearch.setInstances(m_Instances); } catch (Exception e) { fail("Failed setting the instances: " + e); } for (i = 1; i <= m_NumNeighbors; i++) { instIndex = m_Random.nextInt(m_Instances.numInstances()); try { neighbors = m_NearestNeighbourSearch.kNearestNeighbours( m_Instances.instance(instIndex), i); assertEquals("Returned different number of neighbors than requested", i, neighbors.numInstances()); } catch (Exception e) { fail("Failed for " + i + " neighbors on instance " + (instIndex + 1) + ": " + e); } } }
m_NNSearch.setInstances(m_Train);
m_NNSearch.setInstances(m_Train);
/** * tests whether the number of instances returned by the algorithms is the * same as was requested */ public void testNumberOfNeighbors() { int i; int instIndex; Instances neighbors; try { m_NearestNeighbourSearch.setInstances(m_Instances); } catch (Exception e) { fail("Failed setting the instances: " + e); } for (i = 1; i <= m_NumNeighbors; i++) { instIndex = m_Random.nextInt(m_Instances.numInstances()); try { neighbors = m_NearestNeighbourSearch.kNearestNeighbours( m_Instances.instance(instIndex), i); assertEquals("Returned different number of neighbors than requested", i, neighbors.numInstances()); } catch (Exception e) { fail("Failed for " + i + " neighbors on instance " + (instIndex + 1) + ": " + e); } } }
m_NearestNeighbourSearch.setInstances(m_Instances);
m_NNSearch.setInstances(m_Train);
m_NNSearch.setInstances(m_Train);