1484239156 by Unknown
Author:Unknown
Language: eng
Format: epub
Published: 2019-01-24T12:25:06+00:00
159
CHAPTER 7
DATA CLASSIFICATION WITH DECISION TREES
action is a string that is either “train” or “test.” d is the data structure that defines the tree.
t are the inputs for either training or testing. The outputs are the updated data structure and r with the results.
The function is first called with training data and the action is “train.” The main function is short.
switch lower(action)
case 'train'
d = Training( d, t );
d.box(1)
case 'test'
for k = 1:length(d.box)
d.box(k).id = [];
end
[r, d] = Testing( d, t );
for k = 1:length(d.box)
d.box(k)
end
otherwise
error('%s is not an available action',action);
end
We added the error case otherwise for completeness. Note that we use lower to eliminate case sensitivity. Training creates the decision tree. A decision tree is a set of boxes connected by lines. A parent box has two child boxes if it is a decision box. A class box has no children. The subfunction Training trains the tree. It adds boxes at each node.
%% DecisionTree>Training
function d = Training( d, t )
[n,m]
= size(t.x);
nClass
= max(t.m);
box(1)
= AddBox( 1, 1:n*m, [] );
box(1).child = [2 3];
[˜, dH] = HomogeneityMeasure( 'initialize', d, t.m );
class
= 0;
nRow
= 1;
kR0
= 0;
kNR0
= 1; % Next row;
kInRow
= 1;
kInNRow = 1;
while( class < nClass )
k
= kR0 + kInRow;
idK
= box(k).id; % Data that is in the box and to use to compute
the next action
% Enter this loop if it not a non-decision box
if( isempty(box(k).class) )
160
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Sita - Warrior of Mithila (Book 2 of the Ram Chandra Series) by Amish(53324)
The Crystal Crypt by Dick Philip K(36171)
Cat's cradle by Kurt Vonnegut(14490)
Always and Forever, Lara Jean by Jenny Han(14216)
Ready Player One by Cline Ernest(13659)
The Last by Hanna Jameson(9607)
Year One by Nora Roberts(9077)
Persepolis Rising by James S. A. Corey(8662)
The remains of the day by Kazuo Ishiguro(8074)
Red Rising by Pierce Brown(7965)
Never let me go by Kazuo Ishiguro(7945)
Dark Space: The Second Trilogy (Books 4-6) (Dark Space Trilogies Book 2) by Jasper T. Scott(7736)
The handmaid's tale by Margaret Atwood(7246)
The Circle by Dave Eggers(6645)
Frank Herbert's Dune Saga Collection: Books 1 - 6 by Frank Herbert(6441)
The Testaments by Margaret Atwood(6191)
Legacy by Ellery Kane(6190)
Pandemic (The Extinction Files Book 1) by A.G. Riddle(5996)
Six Wakes by Mur Lafferty(5619)
