Java Reference
In-Depth Information
7.
if (lModel null)
8.
JOptionPane.showMessageDialog(this,
9.
"The Model Object for "
10.
lModelName "is null");
11.
MiningFunction lFunction lModel.getMiningFunction();
12.
if (lFunction null)
13.
JOptionPane.showMessageDialog(this,
14.
"The Mining Function for "
15.
lModelName "is null");
16.
if (lFunction MiningFunction.association
17.
|| lFunction MiningFunction.attributeImportance
18.
|| lFunction MiningFunction.clustering) {
19.
JOptionPane.showMessageDialog(this,
20.
"Cannot use Test Metrics on "
21.
lFunction.name());
22.
} else if (lFunction MiningFunction.classification) {
23.
testClassificationModel(lModelName);
24.
} else if (lFunction MiningFunction.regression) {
25.
testRegressionModel(lModelName);
26.
}
27.
} catch (UnexpectedJDMException lException) {
28.
JOptionPane.showMessageDialog(this, "Exception Occured: "
29.
lException.getMessage());
30.
} catch (JDMException lException) {
31.
JOptionPane.showMessageDialog(this,
32.
lException.getMessage(),
33.
"JDMException",
34.
JOptionPane.WARNING_MESSAGE);
35.
}
36.}
First, we retrieve the selected name from the appropriate combo
box and retrieve the model as shown in line 6. Since only supervised
models can be used to compute test metrics, we obtain this informa-
tion, as shown in line 11, and prepare the test metrics task only for
classification or regression models. The code below shows the code
for classification.
1. private void testClassificationModel(String iModelName) {
2.
try {
3.
PhysicalDataSetFactory lPdsFactory
4.
(PhysicalDataSetFactory) mDmeConn.getFactory(
5.
"javax.datamining.data.PhysicalDataSet");
6.
PhysicalDataSet lTestData
7.
lPdsFactory.create(mDataSetTextField.getText(), false);
8.
mDmeConn.saveObject("myTestData", lTestData, true);
9.
ClassificationTestTaskFactory lClassificationTestTaskFactory
10.
(ClassificationTestTaskFactory) mDmeConn.getFactory(
11.
"javax.datamining.supervised.classification."
 
Search WWH ::




Custom Search