generate cluster
Hi togheter, i have a problem.
i don't know how generate the clusters.
this is my code
Thanks a lot
i don't know how generate the clusters.
this is my code
I hope in your help.
public void example() throws NumberFormatException, IOException, ClassNotFoundException, OperatorException
{
BufferedReader input = new BufferedReader(new FileReader("patternss.csv"));
while ((line = input.readLine()) != null)
{
split = line.split(",");
pattern = split[0];
supp = new double[4];
for (int i = 1; i < split.length; i++ )
{
supp[i-1] = Double.parseDouble(split);
}
mapPattern.put(pattern, supp);
}
int j=0;
attributes = new LinkedList<Attribute>();
for (String namePattern : mapPattern.keySet())
{
for ( int a = 1; a < split.length; a++)
{
attributes.add(AttributeFactory.createAttribute ("supp["+j+"]" + " : " + mapPattern.get(namePattern)[a-1], Ontology.REAL));
j++;
}
}
label = AttributeFactory.createAttribute ("label", Ontology.NOMINAL);
attributes.add(label);
// create table
MemoryExampleTable table = new MemoryExampleTable(attributes);
for (int i=1; i<split.length; i++)
{
for (String namePattern : mapPattern.keySet())
{
data = new double[attributes.size()];
for ( int a = 1; a < attributes.size(); a++)
{
// fill with proper data here
data = mapPattern.get(namePattern)[i-1];
}
// maps the nominal classification to a double value
data[data.length - 1] = label.getMapping().mapString(namePattern);
// add data row
table.addDataRow(new DoubleArrayDataRow(data));
}
}
// create example set
ExampleSet exampleSet = table.createExampleSet(label);
exampleSet.getAttributes().setId(label);
System.out.println(exampleSet.getAttributes().getId());
System.out.println(exampleSet.getAttributes());
OperatorDescription opDesc = new OperatorDescription(CreatingExampleTables.class.getClassLoader(), "Cluster", CreatingExampleTables.class.getName(), "Clustering with DBScan", null, "gruppi", null, null);
DBScan scan = new DBScan(opDesc);
scan.setParameter("min_points", Double.toString(5));
scan.setParameter("epsilon", Double.toString(0.1));
ClusterModel cluster = scan.generateClusterModel(exampleSet);
System.out.println(cluster.getClusters());
}
Thanks a lot
Sort by:
1 - 3 of
31
hi sebastian, excuse me if i was unclear.
so, hi take the attributes from a file .csv and then with this attributes i created a table.
then with the object table i created an object ExampleSet.
When i use the object ExampleSet to generate cluster
i hope that i explained my problem.
thanks
so, hi take the attributes from a file .csv and then with this attributes i created a table.
then with the object table i created an object ExampleSet.
When i use the object ExampleSet to generate cluster
the clusters are not generated, and i don't know how to proceed.
// create example set
ExampleSet exampleSet = table.createExampleSet(label);
exampleSet.getAttributes().setId(label);
OperatorDescription opDesc = new OperatorDescription(CreatingExampleTables.class.getClassLoader(), "Cluster", CreatingExampleTables.class.getName(), "Clustering with DBScan", null, "gruppi", null, null);
DBScan scan = new DBScan(opDesc);
scan.setParameter("min_points", Integer.toString(5));
scan.setParameter("epsilon", Double.toString(0.1));
ClusterModel cluster = scan.generateClusterModel(exampleSet);
System.out.println(cluster.getClusters());
i hope that i explained my problem.
thanks
do you want me to guess what your problem is? In general I'm not a god and thus my time is limited. You have to be more specific, otherwise I cannot help you.
Greetings,
Sebastian