📄 defns.h
字号:
{ Attribute Tested; /* split attribute for KD-tree */ ContValue Cut, /* threshold for continuous atts */ MinDRef, /* min reference distance */ MaxDRef; /* max ditto */ ItemNo IFp, ILp; /* first and last item at leaf */ Index *SubIndex; /* subtrees */ } IndexRec;typedef struct _nnrec { int BestI[MAXN]; /* numbers of best instances */ float BestD[MAXN], /* distances to best instances */ *WorstBest, /* points to worst BestD */ *AttMinD; /* min attribute distance from case */ } NNEnvRec, *NNEnv;typedef union _def_val { String _s_val; /* att val for comparison */ ContValue _n_val; /* number for arith */ } DefVal;typedef struct _def_elt { short _op_code; /* type of element */ DefVal _operand; /* string or numeric value */ } DefElt, *Definition;typedef struct _elt_rec { int Fi, /* index of first char of element */ Li; /* last ditto */ char Type; /* 'B', 'S', or 'N' */ } EltRec;#define DefOp(DE) DE._op_code#define DefSVal(DE) DE._operand._s_val#define DefNVal(DE) DE._operand._n_val#define OP_ATT 0 /* opcodes */#define OP_NUM 1#define OP_STR 2#define OP_MISS 3#define OP_AND 10#define OP_OR 11#define OP_EQ 20#define OP_NE 21#define OP_GT 22#define OP_GE 23#define OP_LT 24#define OP_LE 25#define OP_SEQ 26#define OP_SNE 27#define OP_PLUS 30#define OP_MINUS 31#define OP_UMINUS 32#define OP_MULT 33#define OP_DIV 34#define OP_MOD 35#define OP_POW 36#define OP_SIN 40#define OP_COS 41#define OP_TAN 42#define OP_LOG 43#define OP_EXP 44#define OP_INT 45#define OP_END 99/*************************************************************************//* *//* Function prototypes *//* *//*************************************************************************/Boolean ReadName(FILE *f, String s, int n, char ColonOpt);void GetNames(FILE *Nf);void ExplicitAtt(FILE *Nf);int Which(String Val, String *List, int First, int Last);void FreeNamesData();int InChar(FILE *f);void ImplicitAtt(FILE *Nf);void ReadDefinition(FILE *f);void Append(char c);Boolean Expression();Boolean Conjunct();Boolean SExpression();Boolean AExpression();Boolean Term();Boolean Factor();Boolean Primary();Boolean Atom();Boolean Find(String S);int FindOne(String *Alt);Attribute FindAttName();void DefSyntaxError(String Msg);void DefSemanticsError(int Fi, String Msg, int OpCode);void Dump(char OpCode, ContValue F, String S, int Fi);void DumpOp(char OpCode, int Fi);Boolean UpdateTStack(char OpCode, ContValue F, String S, int Fi);AttValue EvaluateDef(Definition D, Description Case);void GetData(FILE *Df, Boolean Train, Boolean AllowUnknownTarget);Boolean ReplaceUnknowns(Description Case, Boolean *AttMsg);Description GetDescription(FILE *Df, Boolean Train);int StoreIVal(String S);void CheckValue(Description Case, Attribute Att);void FreeCases(Description *Case, ItemNo MaxCase);void FreeCase(Description DVec);void CheckFile(String Extension, Boolean Write);void ReadFilePrefix(String Extension);void ReadHeader();RRuleSet *GetCommittee(String Extension);RRuleSet InRules();CRule InRule();Condition InCondition();void FreeCttee(RRuleSet *Cttee);int ReadProp(char *Delim);String RemoveQuotes(String S);Set MakeSubset(Attribute Att);void BinRecoverDiscreteNames();RRuleSet BinInRules();void StreamIn(String S, int n);void ReleaseRule(CRule R);void PrintRules(RRuleSet RS, String Msg);void PrintRule(CRule R);void PrintCondition(Condition C);Boolean Satisfies(Description CaseDesc, Condition OneCond);float PredictValue(RRuleSet *Cttee, Description CaseDesc);float RuleSetPrediction(RRuleSet RS, Description CaseDesc);Boolean Matches(CRule R, Description Case);void InitialiseInstances(RRuleSet *Cttee);float NNEstimate(RRuleSet *Cttee, Description Case, NNEnv E);float Distance(Description Case1, Description Case2, float Thresh);void CheckDistance(Description Case, ItemNo Saved, NNEnv E);void FindNearestNeighbors(Description Case, NNEnv E);float AverageNeighbors(RRuleSet *Cttee, Description Case, NNEnv E);Index BuildIndex(Attribute Att, ItemNo Fp, ItemNo Lp);void ScanIndex(Description Case, Index Node, float MinD, NNEnv E);void SwapInstance(ItemNo A, ItemNo B);void FreeIndex(Index Node);char ProcessOption(int Argc, char *Argv[], char *Options);void *Pmalloc(size_t Bytes);void *Prealloc(void *Present, size_t Bytes);void *Pcalloc(size_t Number, unsigned int Size);void FreeVector(void **V, int First, int Last);void Error(int ErrNo, String S1, String S2);FILE *GetFile(String Extension, String RW);int Denominator(ContValue Val);int FracBase(Attribute Att);int GetInt(String S, int N);int DateToDay(String DS);void DayToDate(int Day, String Date);int TimeToSecs(String TS);void SecsToTime(int Secs, String Time);void SetTSBase(int y);int TStampToMins(String TS);void CValToStr(ContValue CV, Attribute Att, String DS);#ifdef WIN32double posrint(double);double rint(double);#endif/*************************************************************************//* *//* Text strings *//* *//*************************************************************************/#define T_IgnoreNATarget "*** Ignoring instances with N/A target value\n"#define T_IgnoreBadTarget "*** Ignoring instances with unknown or N/A"\ " target value\n"#define T_NoCases "*** No instances with known target values\n"#define T_ReplaceUnknowns "\n Replacing unknown attribute values:\n"#define T_NoAppVals "ignoring (no applicable values)"#define T_By "by"#define T_Rule "Rule"#define TX_RInfo(c,p,m,l,h,e) ": [%d cases, mean %.*f, range %.7g to %.7g, "\ "est err %.*f]\n\n",c,p,m,l,h,p,e#define T_If "if"#define T_Then "then"#define T_ElementOf "in"#define T_InRange "in"#define T_IsUnknown " is unknown\n"#define TX_Line(l,f) "\n*** line %d of `%s': ", l, f#define E_NOFILE(f,e) "cannot open file %s%s\n", f, e#define E_BADATTNAME "`:' or `:=' expected after attribute name"\ " `%s'\n"#define E_EOFINATT "unexpected eof while reading attribute `%s'\n"#define E_SINGLEATTVAL(a,v) "attribute `%s' has only one value `%s'\n",\ a, v#define E_DUPATTNAME "multiple attributes with name `%s'\n"#define E_CWTATTERR "case weight attribute must be continuous\n"#define E_BADATTVAL(v,a) "bad value of `%s' for attribute `%s'\n", v, a#define E_BADNUMBER(a) "value of `%s' changed to `?'\n", a#define E_NOMEM "unable to allocate sufficient memory\n"#define E_TOOMANYVALS(a,n) "too many values for attribute `%s'"\ " (max %d)\n", a, n#define E_BADDISCRETE "bad number of discrete values for attribute"\ " `%s'\n"#define E_NOTARGET "target attribute `%s' not found\n"#define E_BADTARGET "target attribute `%s' is not numeric\n"#define E_LONGNAME "overlength name: check data file formats\n"#define E_HITEOF "unexpected end of file\n"#define E_MISSNAME "missing name or value before `%s'\n"#define E_BADTSTMP(d,a) "bad timestamp `%s' for attribute `%s'\n", d, a#define E_BADDATE(d,a) "bad date `%s' for attribute `%s'\n", d, a#define E_BADTIME(d,a) "bad time `%s' for attribute `%s'\n", d, a#define E_UNKNOWNATT "unknown attribute name `%s'\n"#define E_BADDEF1(a,s,x) "in definition of attribute `%s':\n"\ "\tat `%.12s': expect %s\n", a, s, x#define E_BADDEF2(a,s,x) "in definition of attribute `%s':\n"\ "\t`%s': %s\n", a, s, x#define E_SAMEATT(a,b) "attribute `%s' is identical to attribute"\ " `%s'\n", a, b#define E_BADDEF3 "cannot define target attribute `%s'\n"#define E_BADDEF4 "target attribute appears in definition"\ " of attribute `%s':\n"#define EX_MODELFILE(f) "file %s incompatible with .names file\n", f#define E_MFATT "undefined or excluded attribute"#define E_MFATTVAL "undefined attribute value"#define E_MFEOF "unexpected eof"#define T_ErrorLimit "Error limit exceeded\n"#ifdef _CONSOLE#define finite(x) _finite(x)#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -