⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gramod.h

📁 数据挖掘中的一算法 ines算法 c下实现的。适合初学习数据挖掘者借鉴
💻 H
字号:
/*----------------------------------------------------------------------  File    : gramod.h  Contents: graphical model management (based on directed graphs)  Author  : Christian Borgelt  History : 23.02.1996 file created as ascons.h from attset.h            09.04.1996 function gm_rand modified (parameter randfn())            15.11.1996 description modes added, gm_dmode extended            27.11.1996 adapted to floating point counters            28.02.1997 adapted to prob./poss. tree types            01.03.1997 function gm_exec added            08.02.1998 function gm_parse transferred from parse.h            01.03.1998 adapted to extended prob./poss. tree structure            05.04.1999 parameters 'attid' and 'conid' added to gm_check            30.04.1999 definition of GM_ALL added            08.02.2002 adapted to changed module ptree            11.03.2002 parse flag GM_DFLT (create default network) added            30.03.2002 function gm_evalx added (from sian.c)            04.04.2002 functions gm_consum and gm_parsum added            11.04.2002 function gm_tree added            16.07.2002 parameter 'delnodes' added to function gm_clear----------------------------------------------------------------------*/#ifndef __GRAMOD__#define __GRAMOD__#if defined(GM_PARSE) && !defined(PT_PARSE)#define PT_PARSE#endif#include "parse.h"#if defined(GM_EVAL) || defined(GM_INDUCE)#include "table.h"#else#include "attset.h"#endif#include "ptree.h"/*----------------------------------------------------------------------  Preprocessor Definitions----------------------------------------------------------------------*//* --- types --- */#define GM_PROB     PT_PROB     /* probabilistic (sum) */#define GM_POSS     PT_POSS     /* possibilistic (maximum) */#define GM_AUTO     PT_AUTO     /* determine type from input file *//* --- description/parse modes --- */#define GM_TITLE    PT_TITLE    /* print a title (as a comment) */#define GM_INFO     PT_INFO     /* print add. info. (as a comment) */#define GM_FULL     PT_FULL     /* print full trees (all branches) */#define GM_REL      PT_REL      /* print relative frequencies */#define GM_CDDS     0x0100      /* parse candidate lists */#define GM_ALL      0x0200      /* parse a complete set of trees */#define GM_DFLT     0x0400      /* create a default network *//* --- search methods --- */#define GM_NONE       0         /* no search, only parameter estim. */#define GM_OWST       1         /* optimum weight spanning tree */#define GM_EXTST      2         /* spanning tree extension */#define GM_TOPORD     3         /* cond. sel. on topological order */#define GM_NOLOOP     4         /* cond. sel. without directed loops */#define GM_UNRES      5         /* cond. sel. without restrictions */#define GM_SIAN       6         /* hypertree simulated annealing */#define GM_UNKNOWN    7         /* unknown search method *//* --- other values --- */#define GM_ERROR    PT_ERROR    /* to indicate an evaluation error *//*----------------------------------------------------------------------  Type Definitions----------------------------------------------------------------------*/typedef struct {                /* --- attribute specific data --- */  ATT    *att;                  /* corresponding attribute */  int    cddvsz;                /* size of candidate attribute vector */  int    cddcnt;                /* number of candidate attributes */  int    *cdds;                 /* candidate attributes */  int    depvsz;                /* size of dependent attribute vector */  int    depcnt;                /* number of dependent attributes */  int    *deps;                 /* dependent attributes */  PTREE  *ptree;                /* current prob./poss. tree */  int    pos;                   /* position in topological order */  float  prob;                  /* probability used in gm_execx() */  double eval;                  /* evaluation result */} GMATT;                        /* (attribute specific data) */typedef struct {                /* --- graphical model --- */  ATTSET *attset;               /* underlying attribute set */  int    type;                  /* type of model (prob./poss.) */  int    attcnt;                /* number of attributes */  int    concnt;                /* number of conditions */  double tplcnt;                /* number of tuples for norm. */  float  lcorr;                 /* Laplace correction */  int    *order;                /* topological order of attributes */  int    *buf;                  /* buffer for execution and parsing */  double eval;                  /* evaluation result */  GMATT  atts[1];               /* vector of attribute specific data */} GRAMOD;                       /* (attribute set conditions) *//*----------------------------------------------------------------------  Functions----------------------------------------------------------------------*/extern GRAMOD* gm_create  (ATTSET *attset, int type);extern void    gm_delete  (GRAMOD *gm, int delas);extern ATTSET* gm_attset  (GRAMOD *gm);extern int     gm_attcnt  (GRAMOD *gm);extern int     gm_type    (GRAMOD *gm);extern double  gm_setnorm (GRAMOD *gm, double tplcnt);extern double  gm_getnorm (GRAMOD *gm);extern float   gm_setlc   (GRAMOD *gm, float lcorr);extern float   gm_getlc   (GRAMOD *gm);extern int     gm_consum  (GRAMOD *gm);extern int     gm_parsum  (GRAMOD *gm);extern int     gm_cddcnt  (GRAMOD *gm, int attid);extern int     gm_cddadd  (GRAMOD *gm, int attid, int cddid);extern void    gm_cddrem  (GRAMOD *gm, int attid, int index);extern int     gm_cddid   (GRAMOD *gm, int attid, int index);extern int     gm_concnt  (GRAMOD *gm, int attid);extern int     gm_conadd  (GRAMOD *gm, int attid, int conid);extern void    gm_conrem  (GRAMOD *gm, int attid, int index);extern int     gm_conid   (GRAMOD *gm, int attid, int index);extern ATT*    gm_con     (GRAMOD *gm, int attid, int index);extern int     gm_depcnt  (GRAMOD *gm, int attid);extern int     gm_depid   (GRAMOD *gm, int attid, int index);extern ATT*    gm_dep     (GRAMOD *gm, int attid, int index);extern PTREE*  gm_ptree   (GRAMOD *gm, int attid);extern void    gm_clear   (GRAMOD *gm, int delnodes);extern int     gm_aggr    (GRAMOD *gm, int distuv);extern int     gm_check   (GRAMOD *gm, int attid, int conid);extern int     gm_rand    (GRAMOD *gm, double randfn(void));extern double  gm_exec    (GRAMOD *gm);extern int     gm_execx   (GRAMOD *gm, double res[]);#ifdef GM_EVALextern int     gm_estim   (GRAMOD *gm, TABLE *table, int distuv);extern double  gm_eval    (GRAMOD *gm, int measure, double *params);extern double  gm_evalx   (GRAMOD *gm, TABLE *table, double res[]);extern double  gm_local   (GRAMOD *gm, int lwise, double minimp);extern CCHAR*  gm_sname   (int search);#endif#ifdef GM_INDUCEextern double  gm_tree    (GRAMOD *gm, TABLE *table, int search,                           int measure, double *params, int maxtest,                           int verbose);extern double  gm_csel    (GRAMOD *gm, TABLE *table, int search,                           int measure, double *params, double minimp,                           int lwise, double mrgimp, int maxcon,                           int maxtest, int verbose);extern double  gm_sian    (GRAMOD *gm, TABLE *table, int trials,                           int maxsz, double keep, double frac,                           double ppwgt, int distuv,                           double randfn (void), int verbose);#endifextern int     gm_desc    (GRAMOD *gm, FILE *file, int mode,int maxlen);#ifdef GM_PARSEextern GRAMOD* gm_parse   (ATTSET *attset, SCAN *scan, int type);#endif/*----------------------------------------------------------------------  Preprocessor Definitions----------------------------------------------------------------------*/#define gm_attset(c)      ((c)->attset)#define gm_attcnt(c)      ((c)->attcnt)#define gm_type(c)        ((c)->type)#define gm_getnorm(c)     ((c)->tplcnt)#define gm_getlc(c)       ((c)->lcorr)#define gm_cddcnt(c,a)    ((c)->atts[a].cddcnt)#define gm_cddid(c,a,i)   ((c)->atts[a].cdds[i])#define gm_concnt(c,a)    ((a) < 0) ? (c)->concnt \                                    : pt_concnt((c)->atts[a].ptree)#define gm_conid(c,a,i)   pt_conid((c)->atts[a].ptree, i)#define gm_con(c,a,i)     pt_con((c)->atts[a].ptree, i)#define gm_ptree(c,a)     ((c)->atts[a].ptree)#define gm_depcnt(c,a)    ((c)->atts[a].depcnt)#define gm_depid(c,a,i)   ((c)->atts[a].deps[i])#define gm_dep(c,a,i)     (as_att((c)->attset, (c)->atts[a].deps[i]))#define gm_tree(g,t,s,m,p,x,v)  gm_csel(g,t,s,m,p,0,-1,0,2,x,v)#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -