Function to obtain the best attribute subset on training samples. |
Inputs: samples (a set of training samples), potAttr (set of potential attributes), algorithm (MLR, |
M5′ or ANN), minYear, maxYear (minimum and maximum year in the training dataset). |
resultList is a dynamic list and a global variable. Each entry in this list has the form <testAttr, |
metricMeasures>, |
where testAttr is an attribute subset and metricMeasures are the metrics results obtained from an |
model’s evaluation made with attributescontained in testAttr |
Function findBestAttrSubset(samples, potAttr, algorithm, minYear, maxYear) { |
clearList(resultList) |
localSamples = extract samples from samples in the range minYear, maxYear − 1 |
validSamples = extract samples from samples with year equals to maxYear |
for i = 0 to sizeOf(potentialAttr) begin |
testAttr = create an empty set of attributes |
testAttr = testAttr |
// call a recursive procedure to evaluate all attribute subsets starting from the attribute in |
potAttr |
testAttrCombination(potAttr, testAttr, localSamples, validSamples, algorithm) |
end_for |
return the results at the top of resultList |
end_function |
|
// Recursive procedure to evaluate an attribute combination |
// Inputs: potAttr, testAttr (a set of attributes); trainSamples, validSamples (a set of samples), |
algorithm (a regression algorithm). |
procedure testAttrCombination(potAttr, testAttr, trainSamples, validSamples, algorithm) |
Begin |
// make a regression model of algorithm type using trainSamples and testAttr |
model = makeRegressionModel(algorithm, trainSamples, testAttr) |
// evaluate a regression model using validSamples |
metricMeasures = evalModel(model, validSamples) |
// add the attribute subset and the metric measures in the sorted result list |
addResults(resultList, ) |
index = obtain the highest position of one element of testAttr in potAttr |
for i = index + 1 to length(potAttr) begin |
// add the potential attribute to testAttr |
testAttr = testAttr |
// recursive call |
testAttrCombination(potAttr, testAttr, trainSamples, validSamples, algorithm) |
// remove the potential attribute i from testAttr |
testAttr = testAttr − |
end_for |
end_procedure |