@Override public void batchFinished() throws Exception { pruneDictionary(true); }
@Override public void batchFinished() throws Exception { pruneDictionary(true); }
/** * Call to complete the aggregation process. Allows implementers to do any * final processing based on how many objects were aggregated. * * @throws Exception if the aggregation can't be finalized for some reason */ @Override public void finalizeAggregation() throws Exception { if (m_numModels == 0) { throw new Exception("Unable to finalize aggregation - " + "haven't seen any models to aggregate"); } pruneDictionary(true); Iterator<Map.Entry<String, SGDText.Count>> entries = m_dictionary .entrySet().iterator(); while (entries.hasNext()) { Map.Entry<String, Count> entry = entries.next(); entry.getValue().m_count /= (m_numModels + 1); // plus one for us entry.getValue().m_weight /= (m_numModels + 1); } m_bias /= (m_numModels + 1); // aggregation complete m_numModels = 0; }
/** * Call to complete the aggregation process. Allows implementers to do any * final processing based on how many objects were aggregated. * * @throws Exception if the aggregation can't be finalized for some reason */ @Override public void finalizeAggregation() throws Exception { if (m_numModels == 0) { throw new Exception("Unable to finalize aggregation - " + "haven't seen any models to aggregate"); } pruneDictionary(true); Iterator<Map.Entry<String, SGDText.Count>> entries = m_dictionary .entrySet().iterator(); while (entries.hasNext()) { Map.Entry<String, Count> entry = entries.next(); entry.getValue().m_count /= (m_numModels + 1); // plus one for us entry.getValue().m_weight /= (m_numModels + 1); } m_bias /= (m_numModels + 1); // aggregation complete m_numModels = 0; }
data.randomize(new Random(getSeed())); train(data); pruneDictionary(true);
data.randomize(new Random(getSeed())); train(data); pruneDictionary(true);