The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
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
Tagged:
0
Answers
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
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.
i hope that i explained my problem.
thanks
you still need to apply the cluster model to the example set. You have just generated the model, now use an apply model operator (ModelApplier.class) to generate the cluster assignments.
Greetings,
Sebastian