|
|
pl:miw:miw08_rbs_ml:attrchangecollection [2017/07/17 10:08] |
pl:miw:miw08_rbs_ml:attrchangecollection [2019/06/27 15:50] (aktualna) |
| <code ="Java"> |
| package MachineLearning; |
| |
| import java.util.*; |
| |
| public class AttrChangeCollection |
| { |
| |
| private HashMap<Integer, AttributChange> m_attrChangeCollection; |
| |
| |
| public AttrChangeCollection() |
| { |
| m_attrChangeCollection = new HashMap<Integer, AttributChange>(); |
| } |
| |
| |
| public void Add(ArrayList<Integer> tresholds, Integer attrIndex) |
| { |
| if (!m_attrChangeCollection.containsKey(attrIndex)) |
| { |
| AttributChange attrChange = new AttributChange(tresholds,attrIndex); |
| m_attrChangeCollection.put(attrIndex, attrChange); |
| } |
| } |
| |
| public void Change(Object[][] examples, Integer attrIndex) |
| { |
| if(m_attrChangeCollection.containsKey(attrIndex)) |
| { |
| m_attrChangeCollection.get(attrIndex).Change(examples); |
| } |
| } |
| |
| public void Change(Object[][] examples) |
| { |
| for (AttributChange attrChange : m_attrChangeCollection.values()) |
| { |
| attrChange.Change(examples); |
| } |
| } |
| |
| public void Change(Object[] example) |
| { |
| for (AttributChange attrChange : m_attrChangeCollection.values()) |
| { |
| attrChange.Change(example); |
| } |
| } |
| |
| public void WriteAggregateValues() |
| { |
| if (m_attrChangeCollection.size() > 0) |
| { |
| WriteFile sw = new WriteFile(); |
| sw.open("Aggregate.txt"); |
| |
| sw.writeLine("Nowy atrybut"); |
| sw.writeLine("\tStary atrybut"); |
| |
| m_attrChangeCollection.get(0).WriteOldNewValues("DaysOfWeek", sw, Days.values()); |
| |
| m_attrChangeCollection.get(1).WriteOldNewValues("Hour", sw); |
| |
| m_attrChangeCollection.get(2).WriteOldNewValues("Month", sw, Month.values()); |
| |
| sw.close(); |
| } |
| } |
| } |
| </code> |