Example #1
0
void PrintNegInstanceList(Substructure *sub, Parameters *parameters)
{
   ULONG i;
   ULONG negEgNo;
   InstanceListNode *instanceListNode;

   // parameters used
   Graph *negGraph = parameters->negGraph;
   ULONG numNegEgs = parameters->numNegEgs;
   ULONG *negEgsVertexIndices = parameters->negEgsVertexIndices;
   LabelList *labelList = parameters->labelList;

   if (sub->negInstances != NULL) 
   {
      instanceListNode = sub->negInstances->head;
      i = 1;
      while (instanceListNode != NULL) 
      {
         printf("\n  Instance %lu", i);
         if (numNegEgs > 1) 
         {
            negEgNo = InstanceExampleNumber(instanceListNode->instance,
                                            negEgsVertexIndices, numNegEgs);
            printf(" in negative example %lu:\n", negEgNo);
         } 
         else 
            printf(":\n");
         PrintInstance(instanceListNode->instance, negGraph, labelList);
         instanceListNode = instanceListNode->next;
         i++;
      }
   }
}
int
WekaClassifier::Classify(std::vector<FeeatureVector *> &instances)
{
    PrintArffHeader();
    for (int i = 0; i < instances.size(); i++) {
        PrintInstance(instances[i]);
    }
    snprintf(cmd, sizeof(cmd), "java -Xmx1024m -cp /usr/share/java/weka.jar
             weka.classifiers.trees.RandomForest -l /var/lib/Clonewise/clones/weka/model2 -T
             %s -p 0", testFilename);
    p = popen(cmd, "r");
    if (p == NULL) {
        fprintf(stderr, "Can't popen (%s): %s\n", strerror(errno), cmd);
        return -1;
    }
    for (int i = 0; i < 5; i++) {
        fgets(str, sizeof(str), p);
    }

    for (int i = 0; i < instances.size(); i++) {
        str[27] = 0;
        fgets(str, sizeof(str), p);

        if (str[27] == 'Y') {
            if (1 || (str[35] == '1' || (str[37] - '0') >= 8))
                FeatureVector.m_Class = true;
        } else {
            FeatureVector.m_Class = false;
        }
    }
    else {
Example #3
0
void PrintInstanceList(InstanceList *instanceList, Graph *graph,
                        LabelList *labelList)
{
   ULONG i = 0;
   InstanceListNode *instanceListNode;

   if (instanceList != NULL) 
   {
      instanceListNode = instanceList->head;
      while (instanceListNode != NULL) 
      {
         printf("\n  Instance %lu:\n", i + 1);
         PrintInstance(instanceListNode->instance, graph, labelList);
         instanceListNode = instanceListNode->next;
         i++;
      }
   }
}
Example #4
0
CIMInstance buildCIMInstanceSourceObject(Boolean display)
{
    // Build an instance of a class that will be embedded within
    // the instance of MyClass
    CIMInstance instembed(CIMName("EmbedClassClass"));
    instembed.addProperty(CIMProperty(CIMName("embedBool"), true));
    instembed.addProperty(CIMProperty(CIMName("embedInt"), Uint32(5)));
    instembed.addProperty(CIMProperty(CIMName("embedStr"), String("Test")));

    // Build an instance that will be the primary test instance
    CIMInstance inst(CIMName("MyClass"));
    inst.addProperty(CIMProperty(CIMName("BoolScal1"), true));
    inst.addProperty(CIMProperty(CIMName("BoolScal2"), false));

    inst.addProperty(CIMProperty(CIMName("IntScal1"), Uint32(5)));
    inst.addProperty(CIMProperty(CIMName("IntScal2"), Uint32(25)));
    inst.addProperty(CIMProperty(CIMName("IntScal3"), Sint32(-25123)));
    inst.addProperty(CIMProperty(CIMName("IntScal4"), Uint32(0)));

    inst.addProperty(CIMProperty(CIMName("Int64Scal5"), Uint64(0x6fffff)));
    inst.addProperty(CIMProperty(CIMName("Int64Scal6"), Uint64(2147483647)));
    inst.addProperty(CIMProperty(CIMName("Int64Scal7"), Uint64(4067)));
    inst.addProperty(CIMProperty(CIMName("Int64Scal8"), Uint64(0)));
    //// TODO add properties max and min integers.

    // Add real properties
    inst.addProperty(CIMProperty(CIMName("DoubleScal1"), Real64(20.9)));
    inst.addProperty(CIMProperty(CIMName("DoubleScal2"), Real64(0.9)));
    inst.addProperty(CIMProperty(CIMName("DoubleScal3"), Real32(20.9)));
    inst.addProperty(CIMProperty(CIMName("DoubleScal4"), Real32(0.9)));

    // add scalar string properties
    inst.addProperty(CIMProperty(CIMName("strScal1"), String("Test")));
    inst.addProperty(CIMProperty(CIMName("strScal2"), String("noTest")));
    inst.addProperty(CIMProperty(CIMName("strScal3"), String("")));
    // add string property with special characters.
    inst.addProperty(CIMProperty(CIMName("strScal4"),
        String("./\\\"\'!@#$%^&*()")));

    // DateTime Scalar properties - TODO create test for
    // additional formats for this field (interval, other offsets.
    CIMDateTime dt1;
    dt1.set("19991224120000.000000+360");
    inst.addProperty(CIMProperty(CIMName("dateTimeScal1"),dt1));
        CIMDateTime dt2;
    dt2.set("19991224120000.0000**+360");
    inst.addProperty(CIMProperty(CIMName("dateTimeScal2"),dt2));

    // reference literal properties
    CIMObjectPath op1 = CIMObjectPath
            ("//atp:77/root/cimv25:"
            "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    inst.addProperty(CIMProperty(CIMName("referenceScal1"),op1));
    CIMObjectPath op2 = CIMObjectPath
            ("root/cimv25:"
            "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    inst.addProperty(CIMProperty(CIMName("referenceScal2"),op2));
    CIMObjectPath op3 = CIMObjectPath
            ("TennisPlayer.first=\"Chris\",last=\"Evert\"");
    inst.addProperty(CIMProperty(CIMName("referenceScal3"),op3));
    CIMObjectPath op4 = CIMObjectPath
            ("myclassname.p1=1");
    inst.addProperty(CIMProperty(CIMName("referenceScal4"),op4));

    // KS_TODO create a Reference array property

    // Embedded instance property
    inst.addProperty(CIMProperty(CIMName("embeddedInstance1"),instembed));

    // Array properties
    // Boolean Array
    Array<Boolean> b1; b1.append(true); b1.append(false); b1.append(true);
    inst.addProperty(CIMProperty(CIMName("BoolArrayProp1"), b1));
    Array<Boolean> b2; b2.append(true); b2.append(false); b2.append(true);
    inst.addProperty(CIMProperty(CIMName("BoolArrayProp2"), b2));
    Array<Boolean> b3; b3.append(false); b3.append(false); b3.append(false);
    inst.addProperty(CIMProperty(CIMName("BoolArrayProp3"), b1));

    // Integer Array
    Array<Sint64> a1; a1.append(4); a1.append(5); a1.append (7);
    inst.addProperty(CIMProperty(CIMName("IntArrayProp1"), a1));
    Array<Sint64> a2; a2.append(7); a2.append(8); a2.append (9);
    inst.addProperty(CIMProperty(CIMName("IntArrayProp2"), a2));
    Array<Sint64> a3; a3.append(7); a3.append(-888); a3.append (-999);
    inst.addProperty(CIMProperty(CIMName("IntArrayProp3"), a3));
    Array<Sint64> a4; a4.append(7);
    inst.addProperty(CIMProperty(CIMName("IntArrayProp4"), a4));
    Array<Sint64> a5;;
    inst.addProperty(CIMProperty(CIMName("IntArrayProp5"), a5));

    // Double Array
    Array<Real64> r1; r1.append(1011.04); r1.append(123456.8); r1.append(0.1);
    inst.addProperty(CIMProperty(CIMName("DoubleArrayProp1"), r1));
    Array<Real64> r2; r2.append(-1.04); r2.append(-123456.8); r2.append(0.1);
    inst.addProperty(CIMProperty(CIMName("DoubleArrayProp2"), r2));

    // String Array
    Array<String> s1; s1.append("zero"); s1.append("one"); s1.append("two");
        s1.append("three");
    inst.addProperty(CIMProperty(CIMName("StrArrayProp1"), s1));
    Array<String> s2; s2.append("zero"); s2.append("one"); s2.append("two");
        s2.append("three");
    inst.addProperty(CIMProperty(CIMName("StrArrayProp2"), s2));

    // DateTime Array
    Array<CIMDateTime> dta1;
    dta1.append(dt1);
    dt1.clear();dt1.set("20131224120000.000000+360"); dta1.append(dt1);
    dt1.clear();dt1.set("20011224120000.000000+360"); dta1.append(dt1);
    inst.addProperty(CIMProperty(CIMName("dateTimeArray1"),dta1));
    if (display)
    {
        VCOUT << "Instance to be used in Test" << endl;
        PrintInstance(cout, inst);
    }
    return inst;
}