1 | package agents.anac.y2013.MetaAgent.parser.cart.tree;
|
---|
2 |
|
---|
3 | import java.util.Vector;
|
---|
4 |
|
---|
5 | public class MeanNode extends Node {
|
---|
6 | public double _mean;
|
---|
7 | public double _MSE;
|
---|
8 | private MeanNode(int id, int observations, int leftId, int rightId,
|
---|
9 | int leftobs, int rightObs, double complexityParam, double mean,
|
---|
10 | double MSE, Vector<PrimarySplit> primary_splits,
|
---|
11 | Vector<SurrogateSplit> Surrogate_splits) {
|
---|
12 | super(id, observations, leftId, rightId, leftobs, rightObs, complexityParam,primary_splits,Surrogate_splits);
|
---|
13 | this._mean=mean;
|
---|
14 | this._MSE=MSE;
|
---|
15 | }
|
---|
16 |
|
---|
17 | public static MeanNode factory(String text){
|
---|
18 | String [] texts=text.trim().split(" ");
|
---|
19 |
|
---|
20 | int id=Integer.parseInt(texts[0].substring(0,texts[0].indexOf(":")));
|
---|
21 | int observations=Integer.parseInt(texts[1]);;
|
---|
22 | double complex=-1;
|
---|
23 | if(text.contains("complexity"))
|
---|
24 | complex=Double.parseDouble(substring(text,"complexity param="," "));
|
---|
25 | double mean=Double.parseDouble(substring(text,"mean=",","));
|
---|
26 | String m=substring(text,"MSE=","\n");
|
---|
27 | double mse=Double.parseDouble(m);
|
---|
28 | int leftid=-1;
|
---|
29 | if(text.contains("left son"))
|
---|
30 | leftid=Integer.parseInt(substring(text,"left son="," "));
|
---|
31 |
|
---|
32 |
|
---|
33 | int rightId=-1;
|
---|
34 | if(text.contains("right son"))
|
---|
35 | rightId=Integer.parseInt(substring(text,"right son="," "));
|
---|
36 |
|
---|
37 | int leftObs=-1;
|
---|
38 | if(text.contains("left"))
|
---|
39 | leftObs=parseObs(text,"left");
|
---|
40 | int rightObs=-1;
|
---|
41 | if(text.contains("right"))
|
---|
42 | rightObs=parseObs(text,"right");
|
---|
43 |
|
---|
44 | if(text.contains("Surrogate")){
|
---|
45 | String []prims=substring(text,"Primary splits:\n","Surrogate splits:\n").trim().split("\n");
|
---|
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 | MeanNode node=new MeanNode(id, observations, leftid, rightId, leftObs, rightObs, complex, mean, mse, 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 | MeanNode node=new MeanNode(id, observations, leftid, rightId, leftObs, rightObs, complex, mean, mse, primary_splits,null);
|
---|
56 | return node;
|
---|
57 | }
|
---|
58 | return new MeanNode(id, observations, leftid, rightId, leftObs, rightObs, complex, mean, mse, null,null);
|
---|
59 | }
|
---|
60 |
|
---|
61 | @Override
|
---|
62 | public double get_mean() {
|
---|
63 | return this._mean;
|
---|
64 | }
|
---|
65 |
|
---|
66 | @Override
|
---|
67 | public double get_estimated_rate() {
|
---|
68 | // TODO Auto-generated method stub
|
---|
69 | return -1;
|
---|
70 | }
|
---|
71 |
|
---|
72 |
|
---|
73 | }
|
---|