Java Reference
In-Depth Information
Listing 9-7 Specify PhysicalDataSet and LogicalData for the input dataset
1. static PhysicalAttributeFactory paFactory = null;
2. static LogicalDataFactory ldFactory = null;
3. static LogicalAttributeFactory laFactory = null;
4. static CategorySetFactory csFactory = null;
5.
6. public static void init() throws JDMException {
7. //Create DME connection other object factories as shown in Listing 9.4
8. //. . .
9. //Create object factories for the new objects not specified in listing 9.4
10. paFactory = (PhysicalAttributeFactory)dmeConn.getFactory(
11. "javax.datamining.data.PhysicalAttribute");
12. ldFactory = (LogicalDataFactory)dmeConn.getFactory(
13. "javax.datamining.data.LogicalData");
14. laFactory = (LogicalAttributeFactory)dmeConn.getFactory(
15. "javax.datamining.data.LogicalAttribute");
16. csFactory = (CategorySetFactory)dmeConn.getFactory(
17. "javax.datamining.data.CategorySet");
18. }
19. //Create input objects
20. public static void input() throws JDMException {
21. . . .
22. PhysicalAttribute paCustID = paFactory.create(
23. "cust_id", AttributeDataType.integerType, PhysicalAttributeRole.caseId);
24. pds.addAttribute(paCustID);
25.
26. LogicalData ld = ldFactory.create( );
27. LogicalAttribute la = laFactory.create("Marital Status",
28. AttributeType.categorical);
29. //Create categoryset
30. CategorySet cs = csFactory.create(AttributeDataType.stringType);
31. cs.addCategory("Married", CategoryProperty.valid);
32. cs.addCategory("Single", CategoryProperty.valid);
33. cs.addCategory("Divorced", CategoryProperty.valid);
34. cs.addCategory("Widowed", CategoryProperty.valid);
35. //Set category set and data preparation status
36. la.setCategorySet(cs);
37. la.setDataPreparationStatus(DataPreparationStatus.prepared);
38. //Add logical attribute
39. ld.addAttribute(la);
40. boolean replaceExistingObject = true;
41. dmeConn.saveObject("attrition_logical_data", ld, replaceExistingObject);
42. cls.setLogicalDataName("attrition_build_logical_data");
43. . . .
44. }
45. //Create build task and execute it to build model
46. public boolean run() throws JDMException {
47. BuildTask btk = btkFactory.create( "attrition_build_data",
48. "attritionBuildSettings", "attrition_model" );
49. HashMap pdaLdaMap = new HashMap();
50. pdaLdaMap.put("mar_status", "Marital Status");
51. btk.setBuildDataMap(pdaLdaMap);
52. . . .
53. }
Search WWH ::




Custom Search