forked from IF-LK-2020/entscheidungsbaum
Entscheidungsbaum-erstellung fertiggestellt
This commit is contained in:
parent
615d6e5201
commit
b12383df6d
|
@ -5,17 +5,20 @@
|
||||||
public class DecisionTreeBuilder {
|
public class DecisionTreeBuilder {
|
||||||
|
|
||||||
// Wurzel des Entscheidungsbaums
|
// Wurzel des Entscheidungsbaums
|
||||||
|
private BinaryTree<DecisionNode> Vorhersage2;
|
||||||
|
private BinaryTree<DecisionNode> Wind;
|
||||||
|
private BinaryTree<DecisionNode> Feuchtigkeit;
|
||||||
|
private BinaryTree<DecisionNode> Vorhersage;
|
||||||
private BinaryTree<DecisionNode> decisionTree;
|
private BinaryTree<DecisionNode> decisionTree;
|
||||||
|
|
||||||
public DecisionTreeBuilder() {
|
public DecisionTreeBuilder() {
|
||||||
// Vorbereiten der Klassifikationen (Blätter)
|
// Vorbereiten der Klassifikationen (Blätter)
|
||||||
BinaryTree<DecisionNode> classYes = new BinaryTree<>(
|
BinaryTree<DecisionNode> classYes = new BinaryTree<>(
|
||||||
new Classification("ja")
|
new Classification("ja")
|
||||||
);
|
);
|
||||||
BinaryTree<DecisionNode> classNo = new BinaryTree<>(
|
BinaryTree<DecisionNode> classNo = new BinaryTree<>(
|
||||||
new Classification("nein")
|
new Classification("nein")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// TODO: Hier den Entscheidungsbaum aufbauen.
|
// TODO: Hier den Entscheidungsbaum aufbauen.
|
||||||
//
|
//
|
||||||
|
@ -28,11 +31,14 @@ public class DecisionTreeBuilder {
|
||||||
// );
|
// );
|
||||||
// usw...
|
// usw...
|
||||||
// Die Wurzel zuletzt
|
// Die Wurzel zuletzt
|
||||||
decisionTree = new BinaryTree<>(
|
|
||||||
new Decision("vorhersage", "regnerisch"),
|
Feuchtigkeit = new BinaryTree<>(new Decision("feuchtigkeit", "hoch") ,classNo,classYes);
|
||||||
feuchtigkeit,
|
|
||||||
vorhersage
|
Wind = new BinaryTree<>(new Decision("wind","stark"),classNo,classYes);
|
||||||
);
|
|
||||||
|
Vorhersage2 = new BinaryTree<>(new Decision("vorhersage", "regnerisch"),Wind,classYes);
|
||||||
|
|
||||||
|
Vorhersage = new BinaryTree<>(new Decision("vorhersage" , "sonnig"),Feuchtigkeit,Vorhersage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,7 +72,7 @@ public class DecisionTreeBuilder {
|
||||||
|
|
||||||
String result = "";
|
String result = "";
|
||||||
while( result.equals("") || result.equals("left")
|
while( result.equals("") || result.equals("left")
|
||||||
|| result.equals("right") ) {
|
|| result.equals("right") ) {
|
||||||
// TODO: Impementiere den Durchlauf durch den Entschiedungsbaum,
|
// TODO: Impementiere den Durchlauf durch den Entschiedungsbaum,
|
||||||
// indem bei jedem inneren Knoten die Entscheidung getroffen wird,
|
// indem bei jedem inneren Knoten die Entscheidung getroffen wird,
|
||||||
// ob links oder rechts weitergemacht wird.
|
// ob links oder rechts weitergemacht wird.
|
||||||
|
@ -81,21 +87,21 @@ public class DecisionTreeBuilder {
|
||||||
*/
|
*/
|
||||||
public Dataset[] getTestdata() {
|
public Dataset[] getTestdata() {
|
||||||
String[][] testdata = {
|
String[][] testdata = {
|
||||||
{"sonnig", "heiß", "hoch", "schwach"},
|
{"sonnig", "heiß", "hoch", "schwach"},
|
||||||
{"sonnig", "heiß", "hoch", "stark"},
|
{"sonnig", "heiß", "hoch", "stark"},
|
||||||
{"bewölkt", "heiß", "hoch", "schwach"},
|
{"bewölkt", "heiß", "hoch", "schwach"},
|
||||||
{"regnerisch", "mild", "hoch", "schwach"},
|
{"regnerisch", "mild", "hoch", "schwach"},
|
||||||
{"regnerisch", "kalt", "normal", "schwach"},
|
{"regnerisch", "kalt", "normal", "schwach"},
|
||||||
{"regnerisch", "kalt", "normal", "stark"},
|
{"regnerisch", "kalt", "normal", "stark"},
|
||||||
{"bewölkt", "mild", "hoch", "stark"},
|
{"bewölkt", "mild", "hoch", "stark"},
|
||||||
{"sonnig", "mild", "hoch", "schwach"},
|
{"sonnig", "mild", "hoch", "schwach"},
|
||||||
{"sonnig", "kalt", "normal", "schwach"},
|
{"sonnig", "kalt", "normal", "schwach"},
|
||||||
{"regnerisch", "mild", "normal", "schwach"},
|
{"regnerisch", "mild", "normal", "schwach"},
|
||||||
{"sonnig", "mild", "normal", "stark"},
|
{"sonnig", "mild", "normal", "stark"},
|
||||||
{"bewölkt", "heiß", "normal", "schwach"},
|
{"bewölkt", "heiß", "normal", "schwach"},
|
||||||
{"bewölkt", "kalt", "normal", "stark"},
|
{"bewölkt", "kalt", "normal", "stark"},
|
||||||
{"regnerisch", "mild", "hoch", "stark"}
|
{"regnerisch", "mild", "hoch", "stark"}
|
||||||
};
|
};
|
||||||
|
|
||||||
Dataset[] data = new Dataset[testdata.length];
|
Dataset[] data = new Dataset[testdata.length];
|
||||||
for( int i = 0; i < testdata.length; i++ ) {
|
for( int i = 0; i < testdata.length; i++ ) {
|
||||||
|
|
127
package.bluej
127
package.bluej
|
@ -1,44 +1,50 @@
|
||||||
#BlueJ package file
|
#BlueJ package file
|
||||||
dependency1.from=DecisionNode
|
dependency1.from=Classification
|
||||||
dependency1.to=Dataset
|
dependency1.to=Dataset
|
||||||
dependency1.type=UsesDependency
|
dependency1.type=UsesDependency
|
||||||
dependency2.from=Classification
|
dependency10.from=DecisionTreeBuilder
|
||||||
dependency2.to=Dataset
|
dependency10.to=Dataset
|
||||||
|
dependency10.type=UsesDependency
|
||||||
|
dependency2.from=DecisionTreeTest
|
||||||
|
dependency2.to=DecisionTreeBuilder
|
||||||
dependency2.type=UsesDependency
|
dependency2.type=UsesDependency
|
||||||
dependency3.from=Decision
|
dependency3.from=DecisionTreeTest
|
||||||
dependency3.to=Dataset
|
dependency3.to=Dataset
|
||||||
dependency3.type=UsesDependency
|
dependency3.type=UsesDependency
|
||||||
dependency4.from=DecisionTreeBuilder
|
dependency4.from=DecisionNode
|
||||||
dependency4.to=BinaryTree
|
dependency4.to=Dataset
|
||||||
dependency4.type=UsesDependency
|
dependency4.type=UsesDependency
|
||||||
dependency5.from=DecisionTreeBuilder
|
dependency5.from=Decision
|
||||||
dependency5.to=DecisionNode
|
dependency5.to=Dataset
|
||||||
dependency5.type=UsesDependency
|
dependency5.type=UsesDependency
|
||||||
dependency6.from=DecisionTreeBuilder
|
dependency6.from=DecisionTreeBuilder
|
||||||
dependency6.to=Classification
|
dependency6.to=BinaryTree
|
||||||
dependency6.type=UsesDependency
|
dependency6.type=UsesDependency
|
||||||
dependency7.from=DecisionTreeBuilder
|
dependency7.from=DecisionTreeBuilder
|
||||||
dependency7.to=Decision
|
dependency7.to=DecisionNode
|
||||||
dependency7.type=UsesDependency
|
dependency7.type=UsesDependency
|
||||||
dependency8.from=DecisionTreeBuilder
|
dependency8.from=DecisionTreeBuilder
|
||||||
dependency8.to=Dataset
|
dependency8.to=Classification
|
||||||
dependency8.type=UsesDependency
|
dependency8.type=UsesDependency
|
||||||
editor.fx.0.height=722
|
dependency9.from=DecisionTreeBuilder
|
||||||
editor.fx.0.width=800
|
dependency9.to=Decision
|
||||||
editor.fx.0.x=388
|
dependency9.type=UsesDependency
|
||||||
editor.fx.0.y=50
|
editor.fx.0.height=1416
|
||||||
objectbench.height=66
|
editor.fx.0.width=2576
|
||||||
objectbench.width=1201
|
editor.fx.0.x=-8
|
||||||
|
editor.fx.0.y=-8
|
||||||
|
objectbench.height=196
|
||||||
|
objectbench.width=2536
|
||||||
package.divider.horizontal=0.6
|
package.divider.horizontal=0.6
|
||||||
package.divider.vertical=0.8983286908077994
|
package.divider.vertical=0.8457446808510638
|
||||||
package.editor.height=622
|
package.editor.height=1106
|
||||||
package.editor.width=1078
|
package.editor.width=2425
|
||||||
package.editor.x=39
|
package.editor.x=0
|
||||||
package.editor.y=24
|
package.editor.y=0
|
||||||
package.frame.height=776
|
package.frame.height=1416
|
||||||
package.frame.width=1241
|
package.frame.width=2576
|
||||||
package.numDependencies=8
|
package.numDependencies=10
|
||||||
package.numTargets=6
|
package.numTargets=7
|
||||||
package.showExtends=true
|
package.showExtends=true
|
||||||
package.showUses=true
|
package.showUses=true
|
||||||
project.charset=UTF-8
|
project.charset=UTF-8
|
||||||
|
@ -47,45 +53,52 @@ readme.name=@README
|
||||||
readme.width=47
|
readme.width=47
|
||||||
readme.x=10
|
readme.x=10
|
||||||
readme.y=10
|
readme.y=10
|
||||||
target1.height=40
|
target1.height=60
|
||||||
target1.name=Classification
|
target1.name=DecisionTreeBuilder
|
||||||
target1.showInterface=false
|
target1.showInterface=false
|
||||||
target1.type=ClassTarget
|
target1.type=ClassTarget
|
||||||
target1.width=210
|
target1.width=270
|
||||||
target1.x=40
|
target1.x=580
|
||||||
target1.y=460
|
target1.y=230
|
||||||
target2.height=50
|
target2.height=40
|
||||||
target2.name=Decision
|
target2.name=Dataset
|
||||||
target2.showInterface=false
|
target2.showInterface=false
|
||||||
target2.type=ClassTarget
|
target2.type=ClassTarget
|
||||||
target2.width=190
|
target2.width=270
|
||||||
target2.x=300
|
target2.x=430
|
||||||
target2.y=460
|
target2.y=30
|
||||||
target3.height=120
|
target3.height=40
|
||||||
target3.name=BinaryTree
|
target3.name=Classification
|
||||||
target3.showInterface=false
|
target3.showInterface=false
|
||||||
target3.type=ClassTarget
|
target3.type=ClassTarget
|
||||||
target3.width=440
|
target3.width=210
|
||||||
target3.x=890
|
target3.x=40
|
||||||
target3.y=250
|
target3.y=460
|
||||||
target4.height=40
|
target4.height=120
|
||||||
target4.name=Dataset
|
target4.name=BinaryTree
|
||||||
target4.showInterface=false
|
target4.showInterface=false
|
||||||
target4.type=ClassTarget
|
target4.type=ClassTarget
|
||||||
target4.width=270
|
target4.width=440
|
||||||
target4.x=430
|
target4.x=870
|
||||||
target4.y=30
|
target4.y=420
|
||||||
target5.height=50
|
target5.height=50
|
||||||
target5.name=DecisionNode
|
target5.name=DecisionTreeTest
|
||||||
target5.showInterface=false
|
target5.showInterface=false
|
||||||
target5.type=AbstractTarget
|
target5.type=ClassTarget
|
||||||
target5.width=110
|
target5.width=130
|
||||||
target5.x=210
|
target5.x=70
|
||||||
target5.y=290
|
target5.y=10
|
||||||
target6.height=60
|
target6.height=50
|
||||||
target6.name=DecisionTreeBuilder
|
target6.name=DecisionNode
|
||||||
target6.showInterface=false
|
target6.showInterface=false
|
||||||
target6.type=ClassTarget
|
target6.type=AbstractTarget
|
||||||
target6.width=270
|
target6.width=110
|
||||||
target6.x=580
|
target6.x=210
|
||||||
target6.y=230
|
target6.y=290
|
||||||
|
target7.height=50
|
||||||
|
target7.name=Decision
|
||||||
|
target7.showInterface=false
|
||||||
|
target7.type=ClassTarget
|
||||||
|
target7.width=190
|
||||||
|
target7.x=300
|
||||||
|
target7.y=460
|
||||||
|
|
Loading…
Reference in New Issue