1 | package agents.anac.y2013.MetaAgent.parser.cart.tree;
|
---|
2 |
|
---|
3 | import java.util.Vector;
|
---|
4 |
|
---|
5 | public class EstimatedNode extends Node{
|
---|
6 |
|
---|
7 | private double _estimated_rate;
|
---|
8 | protected EstimatedNode(int _id, int _observations, int _leftId,
|
---|
9 | int _rightId, int _leftobs, int _rightObs, double _complexityParam,
|
---|
10 | double estimated_rate, double mean_deviance, Vector<PrimarySplit> _primary_splits,
|
---|
11 | Vector<SurrogateSplit> _Surrogate_splits) {
|
---|
12 | super(_id, _observations, _leftId, _rightId, _leftobs, _rightObs,
|
---|
13 | _complexityParam,_primary_splits, _Surrogate_splits);
|
---|
14 | _estimated_rate=estimated_rate;
|
---|
15 | }
|
---|
16 | public static EstimatedNode factory(String text){
|
---|
17 | String [] texts=text.trim().split(" ");
|
---|
18 |
|
---|
19 | int id=Integer.parseInt(texts[0].substring(0,texts[0].indexOf(":")));
|
---|
20 | int observations=Integer.parseInt(texts[1]);;
|
---|
21 | double complex=-1;
|
---|
22 | if(text.contains("complexity"))
|
---|
23 | complex=Double.parseDouble(substring(text,"complexity param="," "));
|
---|
24 | double estimated=Double.parseDouble(substring(text,"estimated rate=",","));
|
---|
25 | String m=substring(text,"mean deviance=","\n");
|
---|
26 | double meanDeviance=Double.parseDouble(m);
|
---|
27 | int leftid=-1;
|
---|
28 | if(text.contains("left son"))
|
---|
29 | leftid=Integer.parseInt(substring(text,"left son="," "));
|
---|
30 |
|
---|
31 |
|
---|
32 | int rightId=-1;
|
---|
33 | if(text.contains("right son"))
|
---|
34 | rightId=Integer.parseInt(substring(text,"right son="," "));
|
---|
35 |
|
---|
36 | int leftObs=-1;
|
---|
37 | if(text.contains("left"))
|
---|
38 | leftObs=parseObs(text,"left");
|
---|
39 | int rightObs=-1;
|
---|
40 | if(text.contains("right"))
|
---|
41 | rightObs=parseObs(text,"right");
|
---|
42 |
|
---|
43 | if(text.contains("Surrogate")){
|
---|
44 | String []prims=substring(text,"Primary splits:\n","Surrogate splits:\n").trim().split("\n");
|
---|
45 |
|
---|
46 | Vector<PrimarySplit> primary_splits=parsePrimarySplits(prims);
|
---|
47 | String []Surrogate=substring(text,"Surrogate splits:\n",text.length()).trim().split("\n");
|
---|
48 | Vector<SurrogateSplit> Surrogate_splits=parseSurrogateSplits(Surrogate);
|
---|
49 | EstimatedNode node=new EstimatedNode(id, observations, leftid, rightId, leftObs, rightObs, complex, estimated, meanDeviance, primary_splits,Surrogate_splits);
|
---|
50 | return node;
|
---|
51 | }
|
---|
52 | else if(text.contains("Primary")){
|
---|
53 | String []prims=substring(text,"Primary splits:\n",text.length()).trim().split("\n");
|
---|
54 | Vector<PrimarySplit> primary_splits=parsePrimarySplits(prims);
|
---|
55 | EstimatedNode node=new EstimatedNode(id, observations, leftid, rightId, leftObs, rightObs, complex, estimated, meanDeviance, primary_splits,null);
|
---|
56 | return node;
|
---|
57 | }
|
---|
58 | return new EstimatedNode(id, observations, leftid, rightId, leftObs, rightObs, complex, estimated, meanDeviance, null,null);
|
---|
59 | }
|
---|
60 |
|
---|
61 | @Override
|
---|
62 | public double get_mean() {
|
---|
63 | return -1;
|
---|
64 | }
|
---|
65 | @Override
|
---|
66 | public double get_estimated_rate() {
|
---|
67 | return this._estimated_rate;
|
---|
68 | }
|
---|
69 | }
|
---|