Różnice
Różnice między wybraną wersją a wersją aktualną.
Both sides previous revision
Poprzednia wersja
Nowa wersja
|
Poprzednia wersja
|
pl:miw:miw08_rbs_ml:attributchange [2008/06/16 12:10] miw |
pl:miw:miw08_rbs_ml:attributchange [2008/06/16 13:55] miw |
<code="Java"> | |
import java.util.*; | |
| |
/** | |
* Klasa zagreguje wartości porządkowe dla atrybutu o indeksie m_attrIndex | |
* @author Angello | |
* | |
*/ | |
public class AttributChange | |
{ | |
Integer m_attrIndex; | |
ArrayList<Integer> m_list; | |
| |
/** | |
* Konstruktor | |
* @param tresholds | |
* @param attrIndex | |
*/ | |
public AttributChange(ArrayList<Integer> tresholds, Integer attrIndex) | |
{ | |
m_list = new ArrayList<Integer>(tresholds); | |
m_attrIndex = attrIndex; | |
} | |
| |
/** | |
* Zmienia atrybuty dla całej tablicy | |
* @param learning | |
*/ | |
public void Change(Object[][] learning) | |
{ | |
for (Object[] row : learning) | |
{ | |
this.Change(row); | |
} | |
} | |
| |
/** | |
* Funkcja zamienia atrybuty dla jednego przykładu | |
* @param row | |
*/ | |
public void Change(Object[] row) | |
{ | |
Integer pastValue = (Integer) row[m_attrIndex]; // Wartosc pierwotnego atrybutu | |
for (Integer i = 0; i < m_list.size(); i++) | |
{ | |
if (pastValue <= m_list.get(i)) | |
{ | |
row[m_attrIndex] = i; // Przypisanie wartości nowego atrybutu | |
return; | |
} | |
} | |
row[m_attrIndex] = m_list.size(); // Jeśli nie zmieściło się w progach to jest to ostatnia wartość | |
} | |
/** | |
* Zapisuje do pliku informację jak zostały zmienione atrybuty | |
* @param AttrName | |
* @param sw | |
*/ | |
public void WriteOldNewValues(String AttrName, WriteFile sw) | |
{ | |
Object[] obj = new Object[24]; | |
for (int i = 0; i < obj.length; i++) { | |
obj[i]=i; | |
} | |
WriteOldNewValues(AttrName, sw, obj); | |
} | |
} | |
</code> | |