/* /--------------------------------------------------------------------\ | File : Prepare.H | |--------------------------------------------------------------------| | Written by : Umit CATALYUREK | | Date : 1.6.1993 | |--------------------------------------------------------------------| | Description : Implementation of CN2 for Machine Learning Course. | | Header File For Main Data Structure | |--------------------------------------------------------------------| | Last Modification Date : | | By : | | Description : | \____________________________________________________________________/ */ #ifndef _PREPARE_H_ #define _PREPARE_H_ /***** Data Description structures ******/ #define MAXCLASS 50 #define MAXATTRIBUTE 100 #define MAXDISCRETEVAL 50 #define ATTR_CONTINUOUS 0 #define ATTR_DISCRETE 1 #define DATA_VALID 0 /* Invalid data is considered as Unknown data */ #define DATA_UNKNOWN 1 #define INFINITY 1e+30 typedef union TAGValues { char *discr; float value; } Values[MAXDISCRETEVAL]; typedef struct TAGAtribute { char *attrname; char flag; int numofdiscrval; /* if attr is discrete one */ Values vl; int occurs[MAXDISCRETEVAL]; /* occurences of values */ } Attribute; typedef Attribute *PAttribute; typedef struct TAGDescription { int numofclasses; char *classes[MAXCLASS]; int occurs[MAXCLASS]; /* occurences of classes */ double expect[MAXCLASS]; int numofattributes; PAttribute attrs[MAXATTRIBUTE]; } Description; /***** Data structures ******/ typedef union TAGAttrDataCore { float value; int discr; /* Index of discrete value in values field of Attribute */ } AttrDataCore; typedef struct TAGAttrData { AttrDataCore val; char flag; /* 1 : UNKNOWN, 0 : OK */ } AttrData; typedef AttrData *PAttrData; typedef struct TAGInstance { PAttrData head; /* we will allocate space for #attr data for each instance */ int class; char flag; /* 0 : OK, 1 : Has UNKNOWN */ struct TAGInstance *next, *prev; } Instance; typedef Instance *PInstance; typedef struct TAGDataList { int numofinstances; PInstance head, tail; } DataList; #define LINELENGTH 300 typedef char Line[LINELENGTH]; /**** Proto-Types of Data Functions ******/ void Initialize(); void ReadDescrFile(); void ReadDataFile(); void EliminateUnknownData(); void DeleteData( /* PInstance */); void WriteOccurences( /* int : file handle */); void ReadOccurences( /*int : file handle */); /******** Debug Functions *****/ void printdescription(); void printdata(); #endif