Java Reference
In-Depth Information
The loop started at line 35 selects the threshold candidate with
the highest expected return at line 40. This expected return is asso-
ciated with the model (it is the best functioning point of a given
model), and the model with the highest expected return is then
selected at line 45. For this, we need to provide the method with an
individual cost (the cost of a mailing to a customer), an individual
profit (how much does HEW get when a customer buys the prod-
uct), and a fixed cost (usually the cost associated with the design/
graphics of the mailing). The fixed cost, being the same for all mod-
els and all threshold candidates, is not taken into account in the
selection of the best model but will be used to compute the
expected profit.
1. public void selectBestModel(double iGlobalCost,
2. double iIndividualCost,
3. double iIndividualProfit)
4. throws JDMException, InterruptedException {
5. mGlobalCost iGlobalCost;
6. mIndividualCost iIndividualCost;
7. mIndividualProfit iIndividualProfit;
8. ClassificationTestTaskFactory lTestTaskFactory
9.
(ClassificationTestTaskFactory) mJDMConnection.getFactory(
10.
"javax.datamining.supervised.classification.ClassificationTestTask");
11.
String lBestModelName null;
12.
double lModelsBestProba 0.0;
13.
double lModelsBestValue 0.0;
14.
for (Iterator lModelNameIter mModelNames.keySet().iterator();
15.
lModelNameIter.hasNext();) {
16.
String lModelName (String) lModelNameIter.next();
17.
ClassificationTestTask lTestTask lTestTaskFactory.create(
18.
lModelName "_DS", lModelName, lModelName "_Metrics");
19.
lTestTask.computeMetric(
20.
ClassificationTestMetricOption.receiverOperatingCharacteristics,
21.
true);
22.
mJDMConnection.saveObject(lModelName "_TT", lTestTask, true);
23.
boolean lSuccess executeTask(lModelName "_TT");
24.
if (!lSuccess) {
25.
return;
26.
}
27.
ClassificationTestMetrics lMetrics
28.
(ClassificationTestMetrics) mJDMConnection
29.
.retrieveObject(lModelName "_Metrics",
30.
NamedObject.testMetrics);
31.
ReceiverOperatingCharacterics lROC lMetrics.getROC();
32.
int lCount lROC.getNumberOfThresholdCandidates();
double lBestValue 0;
33.
34.
double lBestProba 0;
 
Search WWH ::




Custom Search