Creating Memory ExampleSet
Jacksonhi
New Altair Community Member
Hi,
I am reading an SQL table to create an ExampleSet and also trying to create a matching ExampleSet in memory.
First a question about the sql generated set.
SimpleExampleSet:
59 examples,
8 regular attributes,
special attributes = {
label = #9: RNK (nominal/single_value)/values=[A, B, C, D, E]
id = #8: inc (integer/single_value)
}
SimpleAttributes: sl3, sl5, sl8, sl13, sl21, mvv, hl, mvp, label := RNK, id := inc
Where did the id come from? I manipulated the id so that it became the sql key by adding inc and by placing it next to the label. Before I did this, the double mvp was not a regular expression, it seemed to be left out, becoming id. Could this be a bug?
This is my Memory Example set that has a null pointer exception.
SimpleExampleSet:
59 examples,
8 regular attributes,
special attributes = {
label = #8: RNK (nominal/single_value)/values=[A, B, C, D, E]
}
SimpleAttributes: sl3, sl5, sl8, sl13, sl21, mvv, hl, mvp, label := RNK
I am reading an SQL table to create an ExampleSet and also trying to create a matching ExampleSet in memory.
First a question about the sql generated set.
When I run this on my SQL generated ExampleSet I see in 4.6
System.out.println(exampleSet.toResultString());
Attributes tributes = exampleSet.getAttributes();
System.out.println(tributes.toString());
SimpleExampleSet:
59 examples,
8 regular attributes,
special attributes = {
label = #9: RNK (nominal/single_value)/values=[A, B, C, D, E]
id = #8: inc (integer/single_value)
}
SimpleAttributes: sl3, sl5, sl8, sl13, sl21, mvv, hl, mvp, label := RNK, id := inc
Where did the id come from? I manipulated the id so that it became the sql key by adding inc and by placing it next to the label. Before I did this, the double mvp was not a regular expression, it seemed to be left out, becoming id. Could this be a bug?
This is my Memory Example set that has a null pointer exception.
SimpleExampleSet:
59 examples,
8 regular attributes,
special attributes = {
label = #8: RNK (nominal/single_value)/values=[A, B, C, D, E]
}
SimpleAttributes: sl3, sl5, sl8, sl13, sl21, mvv, hl, mvp, label := RNK
Tagged:
0
Answers
-
Hi,
how did you create the exampleset resulting from the sql query? Did you use the DatabaseExamplesetSource? Please provide the process or code fragment where the exampleset is created. Otherwise I can't see your parameter settings...
The same applies to the second question. Without having the stack trace, the fragment creating the exampleset and the lines, where the null pointer exception occurs, I cannot give you any reasonable advise.
Greetings,
Sebastian0 -
If I remove the attribute inc and also from the query I notice mvp is no longer a regular attribute but becomes id.
Operator inputOperator;
// create operator 1 - IMPORT DATA FROM MYSQL
inputOperator = OperatorService.createOperator("DatabaseExampleSource");
// set parameters
inputOperator.setParameter("database_url", "jdbc:mysql://192.168.0.15:3306/ctl");
inputOperator.setParameter("id_attribute", "sl3");
inputOperator.setParameter("id_attribute", "sl5");
inputOperator.setParameter("id_attribute", "sl8");
inputOperator.setParameter("id_attribute", "sl13");
inputOperator.setParameter("id_attribute", "mvv");
inputOperator.setParameter("id_attribute", "hl");
inputOperator.setParameter("id_attribute", "mvp");
inputOperator.setParameter("id_attribute", "inc");
inputOperator.setParameter("label_attribute", "RNK");
inputOperator.setParameter("query", "SELECT sl3, sl5, sl8, sl13, sl21, mvv, hl, mvp, inc, RNK FROM training where inc < 250");
inputOperator.setParameter("username", "ibt");
inputOperator.setParameter("password", "88bitz");
IOContainer container = inputOperator.apply(new IOContainer());
ExampleSet exampleSet = container.get(ExampleSet.class);
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
System.out.println(exampleSet.size());
System.out.println(exampleSet.toResultString());
Attributes tributes = exampleSet.getAttributes();
System.out.println(tributes.toString());
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>0 -
Hi,
you are setting the same parameter "id_attribute" again and again, each time overwriting it's previous value. So if you remove the line of code, setting inc as id attribute, the line before will be set the parameter to its final value and hence this mvp becomes id_attribute.
Greetings,
Sebastian0 -
Thank you, I see my error is obvious.
0