return;
}
if((m_classIndex >= 0) &&
(m_data.attribute(m_classIndex).isNominal())) {
SparseInstance histClassCounts[];
histClassCounts = new SparseInstance[m_data.attribute(m_attribIndex).numValues()];
/*int histClassCounts[][];
histClassCounts=new int[m_data.attribute(m_attribIndex).numValues()]
[m_data.attribute(m_classIndex).numValues()+1]; */
if (m_as.nominalCounts.length > 0) {
m_maxValue = m_as.nominalCounts[0];
for(int i=0; i<m_data.attribute(m_attribIndex).numValues(); i++) {
if(m_as.nominalCounts[i]>m_maxValue)
m_maxValue = m_as.nominalCounts[i];
}
}
else {
m_maxValue = 0;
}
if(m_colorList.size()==0)
m_colorList.addElement(Color.black);
for(int i=m_colorList.size();
i < m_data.attribute(m_classIndex).numValues()+1; i++) {
Color pc = m_defaultColors[(i-1) % 10];
int ija = (i-1) / 10;
ija *= 2;
for (int j=0;j<ija;j++) {
pc = pc.darker();
}
m_colorList.addElement(pc);
}
// first sort data on attribute values
m_data.sort(m_attribIndex);
double[] tempClassCounts = null;
int tempAttValueIndex = -1;
for(int k=0; k<m_data.numInstances(); k++) {
//System.out.println("attrib: "+
// m_data.instance(k).value(m_attribIndex)+
// " class: "+
// m_data.instance(k).value(m_classIndex));
if(!m_data.instance(k).isMissing(m_attribIndex)) {
// check to see if we need to allocate some space here
if (m_data.instance(k).value(m_attribIndex) != tempAttValueIndex) {
if (tempClassCounts != null) {
// set up the sparse instance for the previous bar (if any)
int numNonZero = 0;
for (int z = 0; z < tempClassCounts.length; z++) {
if (tempClassCounts[z] > 0) {
numNonZero++;
}
}
double[] nonZeroVals = new double[numNonZero];
int[] nonZeroIndices = new int[numNonZero];
int count = 0;
for (int z = 0; z < tempClassCounts.length; z++) {
if (tempClassCounts[z] > 0) {
nonZeroVals[count] = tempClassCounts[z];
nonZeroIndices[count++] = z;
}
}
SparseInstance tempS =
new SparseInstance(1.0, nonZeroVals, nonZeroIndices, tempClassCounts.length);
histClassCounts[tempAttValueIndex] = tempS;
}
tempClassCounts = new double[m_data.attribute(m_classIndex).numValues() + 1];
tempAttValueIndex = (int)m_data.instance(k).value(m_attribIndex);
/* histClassCounts[(int)m_data.instance(k).value(m_attribIndex)] =
new double[m_data.attribute(m_classIndex).numValues()+1]; */
}
if(m_data.instance(k).isMissing(m_classIndex)) {
/* histClassCounts[(int)m_data.instance(k).value(m_attribIndex)]
[0] += m_data.instance(k).weight(); */
tempClassCounts[0] += m_data.instance(k).weight();
} else {
tempClassCounts[(int)m_data.instance(k).value(m_classIndex)+1]
+= m_data.instance(k).weight();
/*histClassCounts[(int)m_data.instance(k).value(m_attribIndex)]
[(int)m_data.instance(k).value(m_classIndex)+1] += m_data.instance(k).weight();*/
}
}
}
// set up sparse instance for last bar?
if (tempClassCounts != null) {
// set up the sparse instance for the previous bar (if any)
int numNonZero = 0;
for (int z = 0; z < tempClassCounts.length; z++) {
if (tempClassCounts[z] > 0) {
numNonZero++;
}
}
double[] nonZeroVals = new double[numNonZero];
int[] nonZeroIndices = new int[numNonZero];
int count = 0;
for (int z = 0; z < tempClassCounts.length; z++) {
if (tempClassCounts[z] > 0) {
nonZeroVals[count] = tempClassCounts[z];
nonZeroIndices[count++] = z;
}
}
SparseInstance tempS =
new SparseInstance(1.0, nonZeroVals, nonZeroIndices, tempClassCounts.length);
histClassCounts[tempAttValueIndex] = tempS;
}
/*for(int k=0; k<m_data.numInstances(); k++) {
//System.out.println("attrib: "+