43 #include "EST_String.h" 45 #include "EST_TVector.h" 46 #include "EST_TList.h" 47 #include "EST_simplestats.h" 48 #include "EST_Track.h" 58 #define wagon_error(WMESS) (cerr << WMESS << endl,exit(-1)) 62 #define WGN_HUGE_VAL 1.0e20 68 int get_int_val(
int n)
const {
return (
int)
a_no_check(n); }
69 float get_flt_val(
int n)
const {
return a_no_check(n); }
70 void set_int_val(
int n,
int i) {
a_check(n) = (int)i; }
71 void set_flt_val(
int n,
float f) {
a_check(n) = f; }
79 wndt_binary, wndt_float, wndt_class,
81 wndt_cluster, wndt_vector, wndt_matrix, wndt_trajectory,
93 void load_description(
const EST_String& descfname,LISP ignores);
94 void ignore_non_numbers();
96 int ftype(
const int &i)
const {
return p_type(i);}
97 int ignore(
int i)
const {
return p_ignore(i); }
98 void set_ignore(
int i,
int value) { p_ignore[i] = value; }
99 const EST_String &feat_name(
const int &i)
const {
return p_name(i);}
100 int samples(
void)
const {
return length();}
101 int width(
void)
const {
return dlength;}
103 enum wn_oper {wnop_equal, wnop_binary, wnop_greaterthan,
104 wnop_lessthan, wnop_is, wnop_in, wnop_matches};
118 { feature_pos=s.feature_pos;
119 op=s.op; yes=s.yes; no=s.no; operand1=s.operand1;
120 operandl = s.operandl; score=s.score;}
123 { feature_pos=fp; op=o; operand1=a; }
124 void set_fp(
const int &fp) {feature_pos=fp;}
125 void set_oper(
const wn_oper &o) {op=o;}
126 void set_operand1(
const EST_Val &a) {operand1 = a;}
127 void set_yes(
const int &y) {yes=y;}
128 void set_no(
const int &
n) {no=
n;}
129 int get_yes(
void)
const {
return yes;}
130 int get_no(
void)
const {
return no;}
131 const int get_fp(
void)
const {
return feature_pos;}
132 const wn_oper get_op(
void)
const {
return op;}
133 const EST_Val get_operand1(
void)
const {
return operand1;}
134 const EST_IList &get_operandl(
void)
const {
return operandl;}
135 const float get_score(
void)
const {
return score;}
136 void set_score(
const float &f) {score=f;}
137 const int ask(
const WVector &w)
const;
141 enum wnim_type {wnim_unset, wnim_float, wnim_class,
142 wnim_cluster, wnim_vector, wnim_matrix, wnim_ols,
152 float cluster_impurity();
153 float cluster_member_mean(
int i);
154 float vector_impurity();
155 float trajectory_impurity();
156 float ols_impurity();
165 WImpurity() { t=wnim_unset; a.
reset(); trajectory=0; l=0; width=0; data=0;}
171 t=s.t; a=s.a; p=s.p; members=s.members; member_counts = s.member_counts; l=s.l; width=s.width;
180 for (j=0; j<width; j++)
181 trajectory[i][j] = s.trajectory[i][j];
188 double samples(
void);
189 wnim_type type(
void)
const {
return t;}
190 void cumulate(
const float pv,
double count=1.0);
193 float cluster_distance(
int i);
194 int in_cluster(
int i);
195 float cluster_ranking(
int i);
209 ~
WDlist() {
if (next != 0)
delete next; }
210 void set_score(
float s) { p_score = s; }
211 void set_question(
const WQuestion &q) { p_question = q; }
212 void set_best(
const EST_String &t,
int freq,
int samples)
213 { p_token = t; p_freq = freq; p_samples = samples;}
214 float score()
const {
return p_score;}
215 const EST_String &token(
void)
const {
return p_token;}
216 const WQuestion &question()
const {
return p_question;}
229 void print_out(ostream &s,
int margin);
230 int leaf(
void)
const {
return ((left == 0) || (right == 0)); }
233 WNode() { left = right = 0; }
234 ~
WNode() {
if (left != 0) {
delete left; left=0;}
235 if (right != 0) {
delete right; right=0;} }
237 void set_subnodes(
WNode *l,
WNode *r) { left=l; right=r; }
238 void set_impurity(
const WImpurity &imp) {impurity=imp;}
239 void set_question(
const WQuestion &q) {question=q;}
241 void held_out_prune(
void);
242 WImpurity &get_impurity(
void) {
return impurity;}
243 WQuestion &get_question(
void) {
return question;}
246 int samples(
void)
const {
return data.
n(); }
258 void wgn_load_datadescription(
EST_String fname,LISP ignores);
260 WNode *wgn_build_tree(
float &score);
261 WNode *wgn_build_dlist(
float &score,ostream *output);
262 WNode *wagon_stepwise(
float limit);
266 float summary_results(
WNode &tree,ostream *output);
268 extern int wgn_min_cluster_size;
269 extern int wgn_max_questions;
270 extern int wgn_held_out;
271 extern float wgn_dropout_feats;
272 extern float wgn_dropout_samples;
274 extern int wgn_prune;
275 extern int wgn_quiet;
276 extern int wgn_verbose;
277 extern int wgn_predictee;
278 extern int wgn_count_field;
281 extern float wgn_float_range_split;
282 extern float wgn_balance;
286 #define wgn_ques_feature(X) (get_c_string(car(X))) 287 #define wgn_ques_oper_str(X) (get_c_string(car(cdr(X)))) 288 #define wgn_ques_operand(X) (car(cdr(cdr(X)))) 290 int wagon_ask_question(LISP question, LISP value);
INLINE const float & a_no_check(int n) const
read-only const access operator: without bounds checking
EST_FVector()
Default constructor.
const float & a_check(int n) const
read-only const access operator: with bounds checking
EST_TSimpleVector & operator=(const EST_TSimpleVector< float > &s)
assignment operator
void reset(void)
reset internal values
INLINE int length() const
number of items in vector.
INLINE int n() const
number of items in vector.
friend ostream & operator<<(ostream &st, const EST_TVector< float > &m)
print out vector.