Skip to content
Snippets Groups Projects
Commit 74c5446a authored by aastorg2's avatar aastorg2
Browse files

adding c5.0 impl

parent 2801b513
No related branches found
No related tags found
No related merge requests found
Showing
with 7231 additions and 0 deletions
<?xml version="1.0"?>
<VisualGDBProjectSettings2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ConfigurationName>Debug</ConfigurationName>
<Project xsi:type="com.visualgdb.project.windows">
<CustomSourceDirectories>
<Directories />
<PathStyle>CygwinCygdrive</PathStyle>
</CustomSourceDirectories>
<MainSourceDirectory>$(ProjectDir)\..</MainSourceDirectory>
</Project>
<Build xsi:type="com.visualgdb.build.custom">
<ToolchainID>
<ID>com.sysprogs.imported.cygwin</ID>
<Version>
<GCC>6.4.0</GCC>
<GDB>(Cygwin</GDB>
<Revision>0</Revision>
</Version>
</ToolchainID>
<BuildCommand>
<SkipWhenRunningCommandList>false</SkipWhenRunningCommandList>
<RemoteHost>
<HostName>BuildMachine</HostName>
<Transport>BuiltinShortcut</Transport>
</RemoteHost>
<Command>$(ToolchainMake)</Command>
<Arguments>$(ToolchainMakeArgs)</Arguments>
<WorkingDirectory>$(BuildDir)</WorkingDirectory>
<BackgroundMode xsi:nil="true" />
</BuildCommand>
<CleanCommand>
<SkipWhenRunningCommandList>false</SkipWhenRunningCommandList>
<RemoteHost>
<HostName>BuildMachine</HostName>
<Transport>BuiltinShortcut</Transport>
</RemoteHost>
<Command>$(ToolchainMake)</Command>
<Arguments>$(ToolchainMakeArgs) clean</Arguments>
<WorkingDirectory>$(BuildDir)</WorkingDirectory>
<BackgroundMode xsi:nil="true" />
</CleanCommand>
<MainBuildDirectory>$(ProjectDir)\..</MainBuildDirectory>
<AbsoluteTargetPath>$(ProjectDir)\..\c5.0dbg</AbsoluteTargetPath>
<AutoUpdateMakefiles>true</AutoUpdateMakefiles>
</Build>
<Debug xsi:type="com.visualgdb.debug.local">
<AdditionalStartupCommands />
<AdditionalGDBSettings>
<Features>
<DisableAutoDetection>false</DisableAutoDetection>
<UseFrameParameter>false</UseFrameParameter>
<SimpleValuesFlagSupported>false</SimpleValuesFlagSupported>
<ListLocalsSupported>false</ListLocalsSupported>
<ByteLevelMemoryCommandsAvailable>false</ByteLevelMemoryCommandsAvailable>
<ThreadInfoSupported>false</ThreadInfoSupported>
<PendingBreakpointsSupported>false</PendingBreakpointsSupported>
<SupportTargetCommand>false</SupportTargetCommand>
<ReliableBreakpointNotifications>false</ReliableBreakpointNotifications>
</Features>
<EnableSmartStepping>false</EnableSmartStepping>
<FilterSpuriousStoppedNotifications>false</FilterSpuriousStoppedNotifications>
<ForceSingleThreadedMode>false</ForceSingleThreadedMode>
<UseAppleExtensions>false</UseAppleExtensions>
<CanAcceptCommandsWhileRunning>false</CanAcceptCommandsWhileRunning>
<MakeLogFile>false</MakeLogFile>
<IgnoreModuleEventsWhileStepping>true</IgnoreModuleEventsWhileStepping>
<UseRelativePathsOnly>false</UseRelativePathsOnly>
<ExitAction>None</ExitAction>
<DisableDisassembly>false</DisableDisassembly>
<ExamineMemoryWithXCommand>false</ExamineMemoryWithXCommand>
<StepIntoNewInstanceEntry>main</StepIntoNewInstanceEntry>
<ExamineRegistersInRawFormat>true</ExamineRegistersInRawFormat>
<DisableSignals>false</DisableSignals>
<EnableAsyncExecutionMode>false</EnableAsyncExecutionMode>
<EnableNonStopMode>false</EnableNonStopMode>
<MaxBreakpointLimit>0</MaxBreakpointLimit>
</AdditionalGDBSettings>
<LaunchGDBSettings xsi:type="GDBLaunchParametersNewInstance">
<DebuggedProgram>$(TargetPath)</DebuggedProgram>
<GDBServerPort>2000</GDBServerPort>
<ProgramArguments>-f data/sum2 -m 1 -I 1</ProgramArguments>
<WorkingDirectory>$(BuildDir)/.</WorkingDirectory>
</LaunchGDBSettings>
<GenerateCtrlBreakInsteadOfCtrlC>true</GenerateCtrlBreakInsteadOfCtrlC>
</Debug>
<CustomBuild>
<PreSyncActions />
<PreBuildActions />
<PostBuildActions />
<PreCleanActions />
<PostCleanActions />
</CustomBuild>
<CustomDebug>
<PreDebugActions />
<PostDebugActions />
<DebugStopActions />
<BreakMode>Default</BreakMode>
</CustomDebug>
<CustomShortcuts>
<Shortcuts />
<ShowMessageAfterExecuting>true</ShowMessageAfterExecuting>
</CustomShortcuts>
<UserDefinedVariables />
<ImportedPropertySheets />
<CodeSense>
<Enabled>Unknown</Enabled>
<ExtraSettings>
<HideErrorsInSystemHeaders>true</HideErrorsInSystemHeaders>
<SupportLightweightReferenceAnalysis>false</SupportLightweightReferenceAnalysis>
</ExtraSettings>
<CodeAnalyzerSettings>
<Enabled>false</Enabled>
</CodeAnalyzerSettings>
</CodeSense>
<ProgramArgumentsSuggestions />
</VisualGDBProjectSettings2>
\ No newline at end of file
<?xml version="1.0"?>
<VisualGDBProjectSettings2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ConfigurationName>Release</ConfigurationName>
<Project xsi:type="com.visualgdb.project.windows">
<CustomSourceDirectories>
<Directories />
<PathStyle>CygwinCygdrive</PathStyle>
</CustomSourceDirectories>
<MainSourceDirectory>$(ProjectDir)\..</MainSourceDirectory>
</Project>
<Build xsi:type="com.visualgdb.build.custom">
<ToolchainID>
<ID>com.sysprogs.imported.cygwin</ID>
<Version>
<GCC>6.4.0</GCC>
<GDB>(Cygwin</GDB>
<Revision>0</Revision>
</Version>
</ToolchainID>
<BuildCommand>
<SkipWhenRunningCommandList>false</SkipWhenRunningCommandList>
<RemoteHost>
<HostName>BuildMachine</HostName>
<Transport>BuiltinShortcut</Transport>
</RemoteHost>
<Command>$(ToolchainMake)</Command>
<Arguments>$(ToolchainMakeArgs)</Arguments>
<WorkingDirectory>$(BuildDir)</WorkingDirectory>
<BackgroundMode xsi:nil="true" />
</BuildCommand>
<CleanCommand>
<SkipWhenRunningCommandList>false</SkipWhenRunningCommandList>
<RemoteHost>
<HostName>BuildMachine</HostName>
<Transport>BuiltinShortcut</Transport>
</RemoteHost>
<Command>$(ToolchainMake)</Command>
<Arguments>$(ToolchainMakeArgs) clean</Arguments>
<WorkingDirectory>$(BuildDir)</WorkingDirectory>
<BackgroundMode xsi:nil="true" />
</CleanCommand>
<MainBuildDirectory>D:\prex2\popl16ae\popl16ae\C50VS\C50</MainBuildDirectory>
<AbsoluteTargetPath>D:\prex2\popl16ae\popl16ae\C50VS\C50\c5.0dbg</AbsoluteTargetPath>
<AutoUpdateMakefiles>true</AutoUpdateMakefiles>
</Build>
<Debug xsi:type="com.visualgdb.debug.local">
<AdditionalStartupCommands />
<AdditionalGDBSettings>
<Features>
<DisableAutoDetection>false</DisableAutoDetection>
<UseFrameParameter>false</UseFrameParameter>
<SimpleValuesFlagSupported>false</SimpleValuesFlagSupported>
<ListLocalsSupported>false</ListLocalsSupported>
<ByteLevelMemoryCommandsAvailable>false</ByteLevelMemoryCommandsAvailable>
<ThreadInfoSupported>false</ThreadInfoSupported>
<PendingBreakpointsSupported>false</PendingBreakpointsSupported>
<SupportTargetCommand>false</SupportTargetCommand>
<ReliableBreakpointNotifications>false</ReliableBreakpointNotifications>
</Features>
<EnableSmartStepping>false</EnableSmartStepping>
<FilterSpuriousStoppedNotifications>false</FilterSpuriousStoppedNotifications>
<ForceSingleThreadedMode>false</ForceSingleThreadedMode>
<UseAppleExtensions>false</UseAppleExtensions>
<CanAcceptCommandsWhileRunning>false</CanAcceptCommandsWhileRunning>
<MakeLogFile>false</MakeLogFile>
<IgnoreModuleEventsWhileStepping>true</IgnoreModuleEventsWhileStepping>
<UseRelativePathsOnly>false</UseRelativePathsOnly>
<ExitAction>None</ExitAction>
<DisableDisassembly>false</DisableDisassembly>
<ExamineMemoryWithXCommand>false</ExamineMemoryWithXCommand>
<StepIntoNewInstanceEntry>main</StepIntoNewInstanceEntry>
<ExamineRegistersInRawFormat>true</ExamineRegistersInRawFormat>
<DisableSignals>false</DisableSignals>
<EnableAsyncExecutionMode>false</EnableAsyncExecutionMode>
<EnableNonStopMode>false</EnableNonStopMode>
<MaxBreakpointLimit>0</MaxBreakpointLimit>
</AdditionalGDBSettings>
<LaunchGDBSettings xsi:type="GDBLaunchParametersNewInstance">
<DebuggedProgram>$(TargetPath)</DebuggedProgram>
<GDBServerPort>2000</GDBServerPort>
<ProgramArguments>-f data/sum2 -m 1 -I 1</ProgramArguments>
<WorkingDirectory>$(BuildDir)/.</WorkingDirectory>
</LaunchGDBSettings>
<GenerateCtrlBreakInsteadOfCtrlC>true</GenerateCtrlBreakInsteadOfCtrlC>
</Debug>
<CustomBuild>
<PreSyncActions />
<PreBuildActions />
<PostBuildActions />
<PreCleanActions />
<PostCleanActions />
</CustomBuild>
<CustomDebug>
<PreDebugActions />
<PostDebugActions />
<DebugStopActions />
<BreakMode>Default</BreakMode>
</CustomDebug>
<CustomShortcuts>
<Shortcuts />
<ShowMessageAfterExecuting>true</ShowMessageAfterExecuting>
</CustomShortcuts>
<UserDefinedVariables />
<CodeSense>
<Enabled>Unknown</Enabled>
<ExtraSettings>
<HideErrorsInSystemHeaders>true</HideErrorsInSystemHeaders>
<SupportLightweightReferenceAnalysis>false</SupportLightweightReferenceAnalysis>
</ExtraSettings>
<CodeAnalyzerSettings>
<Enabled>false</Enabled>
</CodeAnalyzerSettings>
</CodeSense>
</VisualGDBProjectSettings2>
\ No newline at end of file
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2003
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "C50", "C50.vcxproj", "{E0AD4FF9-EE0C-4143-A080-A8FDB1981B69}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E0AD4FF9-EE0C-4143-A080-A8FDB1981B69}.Debug|x64.ActiveCfg = Debug|Win32
{E0AD4FF9-EE0C-4143-A080-A8FDB1981B69}.Debug|x86.ActiveCfg = Debug|Win32
{E0AD4FF9-EE0C-4143-A080-A8FDB1981B69}.Debug|x86.Build.0 = Debug|Win32
{E0AD4FF9-EE0C-4143-A080-A8FDB1981B69}.Release|x64.ActiveCfg = Release|Win32
{E0AD4FF9-EE0C-4143-A080-A8FDB1981B69}.Release|x86.ActiveCfg = Release|Win32
{E0AD4FF9-EE0C-4143-A080-A8FDB1981B69}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {90F1712C-94D7-4161-BB25-23EB51BA9471}
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{E0AD4FF9-EE0C-4143-A080-A8FDB1981B69}</ProjectGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Label="VisualGDBPackageDefinitions">
<ToolchainID>com.sysprogs.imported.cygwin</ToolchainID>
<ToolchainVersion>6.4.0/(Cygwin/r0</ToolchainVersion>
</PropertyGroup>
<ImportGroup Label="VisualGDBFindComponents">
<Import Project="$(LOCALAPPDATA)\VisualGDB\FindComponents.props" />
</ImportGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<NMakeIncludeSearchPath>C:\cygwin64\lib\gcc\x86_64-pc-cygwin\6.4.0\include\c++;C:\cygwin64\lib\gcc\x86_64-pc-cygwin\6.4.0\include\c++\x86_64-pc-cygwin;C:\cygwin64\lib\gcc\x86_64-pc-cygwin\6.4.0\include\c++\backward;C:\cygwin64\lib\gcc\x86_64-pc-cygwin\6.4.0\include;C:\cygwin64\usr\include;C:\cygwin64\usr\include\w32api;$(NMakeIncludeSearchPath)</NMakeIncludeSearchPath>
<NMakeForcedIncludes>$(ProjectDir)\gcc_Debug.h;$(VISUALGDB_DIR)\gcc_compat.h;$(NMakeForcedIncludes)</NMakeForcedIncludes>
<NMakePreprocessorDefinitions>__VisualGDB_CFG_Debug;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<NMakeBuildCommandLine>"$(VISUALGDB_DIR)\VisualGDB.exe" /build "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)"</NMakeBuildCommandLine>
<NMakeCleanCommandLine>"$(VISUALGDB_DIR)\VisualGDB.exe" /clean "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)"</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>"$(VISUALGDB_DIR)\VisualGDB.exe" /rebuild "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)"</NMakeReBuildCommandLine>
<NMakeOutput>$(ProjectDir)C50-Debug.vgdbsettings</NMakeOutput>
<IncludePath />
<ReferencePath />
<LibraryPath />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<NMakeIncludeSearchPath>C:\cygwin64\lib\gcc\x86_64-pc-cygwin\6.4.0\include\c++;C:\cygwin64\lib\gcc\x86_64-pc-cygwin\6.4.0\include\c++\x86_64-pc-cygwin;C:\cygwin64\lib\gcc\x86_64-pc-cygwin\6.4.0\include\c++\backward;C:\cygwin64\lib\gcc\x86_64-pc-cygwin\6.4.0\include;C:\cygwin64\usr\include;C:\cygwin64\usr\include\w32api;$(NMakeIncludeSearchPath)</NMakeIncludeSearchPath>
<NMakeForcedIncludes>$(ProjectDir)\gcc_Release.h;$(VISUALGDB_DIR)\gcc_compat.h;$(NMakeForcedIncludes)</NMakeForcedIncludes>
<NMakePreprocessorDefinitions>__VisualGDB_CFG_Release;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<NMakeBuildCommandLine>"$(VISUALGDB_DIR)\VisualGDB.exe" /build "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)"</NMakeBuildCommandLine>
<NMakeCleanCommandLine>"$(VISUALGDB_DIR)\VisualGDB.exe" /clean "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)"</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>"$(VISUALGDB_DIR)\VisualGDB.exe" /rebuild "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)"</NMakeReBuildCommandLine>
<NMakeOutput>$(ProjectDir)C50-Release.vgdbsettings</NMakeOutput>
<IncludePath />
<ReferencePath />
<LibraryPath />
</PropertyGroup>
<ItemDefinitionGroup>
</ItemDefinitionGroup>
<ItemGroup>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<ItemGroup>
<ClCompile Include="..\attwinnow.c" />
<ClCompile Include="..\c50.c" />
<ClCompile Include="..\classify.c" />
<ClCompile Include="..\confmat.c" />
<ClCompile Include="..\construct.c" />
<ClCompile Include="..\contin.c" />
<ClCompile Include="..\debug.c" />
<ClCompile Include="..\discr.c" />
<ClCompile Include="..\formrules.c" />
<ClCompile Include="..\formtree.c" />
<ClCompile Include="..\getdata.c" />
<ClCompile Include="..\getnames.c" />
<ClCompile Include="..\global.c" />
<ClCompile Include="..\implicitatt.c" />
<ClCompile Include="..\info.c" />
<ClCompile Include="..\mcost.c" />
<ClCompile Include="..\modelfiles.c" />
<ClCompile Include="..\p-thresh.c" />
<ClCompile Include="..\prune.c" />
<ClCompile Include="..\report.c" />
<ClCompile Include="..\rules.c" />
<ClCompile Include="..\ruletree.c" />
<ClCompile Include="..\siftrules.c" />
<ClCompile Include="..\sort.c" />
<ClCompile Include="..\subset.c" />
<ClCompile Include="..\trees.c" />
<ClCompile Include="..\update.c" />
<ClCompile Include="..\utility.c" />
<ClCompile Include="..\xval.c" />
<ClCompile Include="..\cpp_wrapper\array.c" />
<ClCompile Include="..\cpp_wrapper\clist.cpp" />
<ClCompile Include="..\cpp_wrapper\cmap.cpp" />
<ClCompile Include="..\cpp_wrapper\file_tools.cpp" />
<ClCompile Include="..\cpp_wrapper\tree_serializer.cpp" />
<ClInclude Include="..\cpp_wrapper\array.h" />
<ClInclude Include="..\cpp_wrapper\clist.h" />
<ClInclude Include="..\cpp_wrapper\cmap.h" />
<ClInclude Include="..\cpp_wrapper\file_tools.h" />
<ClInclude Include="..\cpp_wrapper\tree_serializer.h" />
<None Include="C50-Debug.vgdbsettings" />
<None Include="C50-Release.vgdbsettings" />
</ItemGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source files">
<UniqueIdentifier>{4717493a-2088-4178-b5a3-817273bbc503}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header files">
<UniqueIdentifier>{efcbcded-194c-41fb-91d8-b2f237eddf70}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource files">
<UniqueIdentifier>{b0366cf7-011d-4e47-bf6a-7b5eaf07225f}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
<Filter Include="Source files\cpp_wrapper">
<UniqueIdentifier>{b501ecdd-6e43-4074-b1b2-c8c665b7a6cc}</UniqueIdentifier>
</Filter>
<Filter Include="Header files\cpp_wrapper">
<UniqueIdentifier>{30123d79-d366-48de-9284-93124cbfa565}</UniqueIdentifier>
</Filter>
<Filter Include="VisualGDB settings">
<UniqueIdentifier>{80eecf9c-d2c1-4efe-bfc7-7344e60c80de}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\attwinnow.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\c50.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\classify.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\confmat.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\construct.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\contin.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\debug.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\discr.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\formrules.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\formtree.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\getdata.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\getnames.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\global.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\implicitatt.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\info.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\mcost.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\modelfiles.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\p-thresh.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\prune.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\report.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\rules.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\ruletree.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\siftrules.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\sort.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\subset.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\trees.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\update.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\utility.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\xval.c">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\cpp_wrapper\array.c">
<Filter>Source files\cpp_wrapper</Filter>
</ClCompile>
<ClCompile Include="..\cpp_wrapper\clist.cpp">
<Filter>Source files\cpp_wrapper</Filter>
</ClCompile>
<ClCompile Include="..\cpp_wrapper\cmap.cpp">
<Filter>Source files\cpp_wrapper</Filter>
</ClCompile>
<ClCompile Include="..\cpp_wrapper\file_tools.cpp">
<Filter>Source files\cpp_wrapper</Filter>
</ClCompile>
<ClCompile Include="..\cpp_wrapper\tree_serializer.cpp">
<Filter>Source files\cpp_wrapper</Filter>
</ClCompile>
<ClInclude Include="..\cpp_wrapper\array.h">
<Filter>Header files\cpp_wrapper</Filter>
</ClInclude>
<ClInclude Include="..\cpp_wrapper\clist.h">
<Filter>Header files\cpp_wrapper</Filter>
</ClInclude>
<ClInclude Include="..\cpp_wrapper\cmap.h">
<Filter>Header files\cpp_wrapper</Filter>
</ClInclude>
<ClInclude Include="..\cpp_wrapper\file_tools.h">
<Filter>Header files\cpp_wrapper</Filter>
</ClInclude>
<ClInclude Include="..\cpp_wrapper\tree_serializer.h">
<Filter>Header files\cpp_wrapper</Filter>
</ClInclude>
<None Include="C50-Debug.vgdbsettings">
<Filter>VisualGDB settings</Filter>
</None>
<None Include="C50-Release.vgdbsettings">
<Filter>VisualGDB settings</Filter>
</None>
</ItemGroup>
</Project>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
#*************************************************************************#
#* *#
#* Makefile for the C5.0 system *#
#* ---------------------------- *#
#* *#
#*************************************************************************#
.PHONY: clean
GCC = "/usr/bin/gcc"
MAKE = "/usr/bin/make"
RM = "/bin/rm"
ECHO = "/bin/echo"
CC = $(GCC) -g -ffloat-store
CFLAGS = -g -Wall -DVerbOpt -O0
LFLAGS = $(S) -static-libgcc -static-libstdc++
SHELL = /bin/bash
# Debug (uncomment if desired)
CFLAGS += -DDEBUG
# Definitions of file sets
# New file ordering suggested by gprof
src =\
global.c\
c50.c\
construct.c\
formtree.c\
info.c\
discr.c\
contin.c\
subset.c\
prune.c\
p-thresh.c\
trees.c\
siftrules.c\
ruletree.c\
rules.c\
getdata.c\
implicitatt.c\
mcost.c\
confmat.c\
sort.c\
update.c\
attwinnow.c\
classify.c\
formrules.c\
getnames.c\
modelfiles.c\
utility.c\
xval.c\
debug.c
obj =\
c50.o global.o\
construct.o formtree.o info.o discr.o contin.o subset.o prune.o\
p-thresh.o trees.o\
formrules.o siftrules.o ruletree.o rules.o\
xval.o\
getnames.o getdata.o implicitatt.o\
mcost.o classify.o confmat.o sort.o\
update.o utility.o\
modelfiles.o\
attwinnow.o\
debug.o\
all:
$(ECHO) $(CC)
$(MAKE) -C cpp_wrapper
$(MAKE) c5.0dbg
# make c5.0dbg c5.0.dt_penalty c5.0.dt_entropy
$(CC) $(LFLAGS) -o report report.c -lm
# debug version (including verbosity option)
c5.0dbg:\
$(obj) defns.i extern.i text.i Makefile
$(CC) $(CFLAGS) -g -o c5.0dbg $(obj) cpp_wrapper/cpp_wrapper.a -lm -lstdc++
# production version
# c5.0.dt_penalty:\
# $(src) defns.i text.i Makefile
# cat defns.i $(src)\
# | egrep -v 'defns.i|extern.i' >c50gt.c
# $(CC) $(LFLAGS) -DPENALTY -O3 -o c5.0.dt_penalty c50gt.c cpp_wrapper/cpp_wrapper.a -lm -lstdc++
# strip c5.0.dt_penalty
# rm c50gt.c
# c5.0.dt_entropy:\
# $(src) defns.i text.i Makefile
# cat defns.i $(src)\
# | egrep -v 'defns.i|extern.i' >c50gt.c
# $(CC) $(LFLAGS) -O3 -o c5.0.dt_entropy c50gt.c cpp_wrapper/cpp_wrapper.a -lm -lstdc++
# strip c5.0.dt_entropy
# rm c50gt.c
$(obj): Makefile defns.i extern.i text.i
.c.o:
$(CC) $(CFLAGS) -c $<
clean:
$(MAKE) -C cpp_wrapper clean
$(RM) -rf *.o c5.0dbg report report.exe
# -rm -rf *.o c5.0.dt_penalty c5.0.dt_entropy c5.0dbg report
/*************************************************************************/
/* */
/* Copyright 2010 Rulequest Research Pty Ltd. */
/* */
/* This file is part of C5.0 GPL Edition, a single-threaded version */
/* of C5.0 release 2.07. */
/* */
/* C5.0 GPL Edition is free software: you can redistribute it and/or */
/* modify it under the terms of the GNU General Public License as */
/* published by the Free Software Foundation, either version 3 of the */
/* License, or (at your option) any later version. */
/* */
/* C5.0 GPL Edition is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
/* General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* (gpl.txt) along with C5.0 GPL Edition. If not, see */
/* */
/* <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* Routines for winnowing attributes */
/* --------------------------------- */
/* */
/*************************************************************************/
#include "defns.i"
#include "extern.i"
float *AttImp=Nil; /* att importance */
Boolean *Split=Nil, /* atts used in unpruned tree */
*Used=Nil; /* atts used in pruned tree */
/*************************************************************************/
/* */
/* Winnow attributes by constructing a tree from half the data. */
/* Remove those that are never used as splits and those that */
/* increase error on the remaining data, and check that the new */
/* error cost does not increase */
/* */
/*************************************************************************/
void WinnowAtts()
/* ---------- */
{
Attribute Att, Removed=0, Best;
CaseNo i, Bp, Ep;
float Base;
Boolean First=true, *Upper;
ClassNo c;
extern Attribute *DList;
extern int NDList;
/* Save original case order */
SaveCase = Alloc(MaxCase+1, DataRec);
ForEach(i, 0, MaxCase)
{
SaveCase[i] = Case[i];
}
/* Split data into two halves with equal class frequencies */
Upper = AllocZero(MaxClass+1, Boolean);
Bp = 0;
Ep = MaxCase;
ForEach(i, 0, MaxCase)
{
c = Class(SaveCase[i]);
if ( Upper[c] )
{
Case[Ep--] = SaveCase[i];
}
else
{
Case[Bp++] = SaveCase[i];
}
Upper[c] = ! Upper[c];
}
Free(Upper);
/* Use first 50% of the cases for building a winnowing tree
and remaining 50% for measuring attribute importance */
AttImp = AllocZero(MaxAtt+1, float);
Split = AllocZero(MaxAtt+1, Boolean);
Used = AllocZero(MaxAtt+1, Boolean);
Base = TrialTreeCost(true);
/* Remove attributes when doing so would reduce error cost */
ForEach(Att, 1, MaxAtt)
{
if ( AttImp[Att] < 0 )
{
SpecialStatus[Att] ^= SKIP;
Removed++;
}
}
/* If any removed, rebuild tree and reinstate if error increases */
if ( Removed && TrialTreeCost(false) > Base )
{
ForEach(Att, 1, MaxAtt)
{
if ( AttImp[Att] < 0 )
{
AttImp[Att] = 1;
SpecialStatus[Att] ^= SKIP;
Verbosity(1, fprintf(Of, " re-including %s\n", AttName[Att]))
}
}
Removed=0;
}
/* Discard unused attributes */
ForEach(Att, 1, MaxAtt)
{
if ( Att != ClassAtt && ! Skip(Att) && ! Split[Att] )
{
SpecialStatus[Att] ^= SKIP;
Removed++;
}
}
/* Print summary of winnowing */
if ( ! Removed )
{
fprintf(Of, T_NoWinnow);
}
else
{
fprintf(Of, T_AttributesWinnowed, Removed, Plural(Removed));
/* Print remaining attributes ordered by importance */
while ( true )
{
Best = 0;
ForEach(Att, 1, MaxAtt)
{
if ( AttImp[Att] >= 1 &&
( ! Best || AttImp[Att] > AttImp[Best] ) )
{
Best = Att;
}
}
if ( ! Best ) break;
if ( First )
{
fprintf(Of, T_EstImportance);
First = false;
}
if ( AttImp[Best] >= 1.005 )
{
fprintf(Of, "%7d%% %s\n",
(int) ((AttImp[Best] - 1) * 100 + 0.5),
AttName[Best]);
}
else
{
fprintf(Of, " <1%% %s\n", AttName[Best]);
}
AttImp[Best] = 0;
}
}
if ( Removed )
{
Winnowed = true;
/* Reset DList */
NDList = 0;
ForEach(Att, 1, MaxAtt)
{
if ( DFreq[Att] && ! Skip(Att) )
{
DList[NDList++] = Att;
}
}
}
/* Restore case order and clean up */
ForEach(i, 0, MaxCase)
{
Case[i] = SaveCase[i];
}
FreeUnlessNil(SaveCase); SaveCase = Nil;
FreeUnlessNil(AttImp); AttImp = Nil;
FreeUnlessNil(Split); Split = Nil;
FreeUnlessNil(Used); Used = Nil;
Now = 0;
}
/*************************************************************************/
/* */
/* Build trial tree and check error cost on remaining data. */
/* If first time, note split attributes and check effect of */
/* removing every attribute */
/* */
/*************************************************************************/
float TrialTreeCost(Boolean FirstTime)
/* ------------- */
{
Attribute Att;
float Base, Cost, SaveMINITEMS;
CaseNo SaveMaxCase, Cut;
int SaveVERBOSITY;
Verbosity(1,
fprintf(Of, ( FirstTime ? "\nWinnow cycle:\n" : "\nCheck:\n" )))
/* Build and prune trial tree */
SaveMaxCase = MaxCase;
SaveVERBOSITY = VERBOSITY;
SaveMINITEMS = MINITEMS;
MINITEMS = Max(MINITEMS / 2, 2.0);
Cut = (MaxCase+1) / 2 - 1;
InitialiseWeights();
LEAFRATIO = 0;
VERBOSITY = 0;
MaxCase = Cut;
memset(Tested, 0, MaxAtt+1); /* reset tested attributes */
SetMinGainThresh();
// Daniel: Remove this part of code as it conflicts with the modifications
//assert(false);
exit(1);
//FormTree(0, Cut, 0, &WTree);
if ( FirstTime )
{
/* Find attributes used in unpruned tree */
ScanTree(WTree, Split);
}
Prune(WTree);
VERBOSITY = SaveVERBOSITY;
MaxCase = SaveMaxCase;
MINITEMS = SaveMINITEMS;
Verbosity(2,
PrintTree(WTree, "Winnowing tree:");
fprintf(Of, "\n training error cost %g\n", ErrCost(WTree, 0, Cut)))
Base = ErrCost(WTree, Cut+1, MaxCase);
Verbosity(1,
fprintf(Of, " initial error cost %g\n", Base))
if ( FirstTime )
{
/* Check each attribute used in pruned tree */
ScanTree(WTree, Used);
ForEach(Att, 1, MaxAtt)
{
if ( ! Used[Att] )
{
Verbosity(1,
if ( Att != ClassAtt && ! Skip(Att) )
{
fprintf(Of, " %s not used\n", AttName[Att]);
})
if ( Split[Att] )
{
AttImp[Att] = 1;
}
continue;
}
/* Determine error cost if this attribute omitted */
SpecialStatus[Att] ^= SKIP;
Cost = ErrCost(WTree, Cut+1, MaxCase);
AttImp[Att] = ( Cost < Base ? -1 : Cost / Base );
Verbosity(1,
fprintf(Of, " error cost without %s = %g%s\n",
AttName[Att], Cost,
( Cost < Base ? " - excluded" : "" )))
SpecialStatus[Att] ^= SKIP;
}
}
if ( WTree )
{
FreeTree(WTree); WTree = Nil;
}
return Base;
}
/*************************************************************************/
/* */
/* Determine the error rate or cost of T on cases Fp through Lp */
/* */
/*************************************************************************/
float ErrCost(Tree T, CaseNo Fp, CaseNo Lp)
/* ------- */
{
CaseNo i;
float ErrCost=0;
ClassNo Pred;
if ( MCost )
{
ForEach(i, Fp, Lp)
{
if ( (Pred = TreeClassify(Case[i], T)) != Class(Case[i]) )
{
ErrCost += MCost[Pred][Class(Case[i])];
}
}
}
else
{
ForEach(i, Fp, Lp)
{
if ( TreeClassify(Case[i], T) != Class(Case[i]) )
{
ErrCost += 1.0;
}
}
}
return ErrCost;
}
/*************************************************************************/
/* */
/* Find attributes used in tree T */
/* */
/*************************************************************************/
void ScanTree(Tree T, Boolean *Used)
/* -------- */
{
DiscrValue v;
if ( T->NodeType )
{
Used[T->Tested] = true;
ForEach(v, 1, T->Forks)
{
ScanTree(T->Branch[v], Used);
}
}
}
File added
File added
/*************************************************************************/
/* */
/* Copyright 2010 Rulequest Research Pty Ltd. */
/* */
/* This file is part of C5.0 GPL Edition, a single-threaded version */
/* of C5.0 release 2.07. */
/* */
/* C5.0 GPL Edition is free software: you can redistribute it and/or */
/* modify it under the terms of the GNU General Public License as */
/* published by the Free Software Foundation, either version 3 of the */
/* License, or (at your option) any later version. */
/* */
/* C5.0 GPL Edition is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
/* General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* (gpl.txt) along with C5.0 GPL Edition. If not, see */
/* */
/* <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* Main routine, C5.0 */
/* ------------------ */
/* */
/*************************************************************************/
#include "defns.i"
#include "extern.i"
#include "cpp_wrapper/cmap.h"
//#include <signal.h>
//#include <sys/unistd.h>
//#include <sys/time.h>
//#include <sys/resource.h>
#define SetFOpt(V) V = strtod(OptArg, &EndPtr);\
if ( ! EndPtr || *EndPtr != '\00' ) break;\
ArgOK = true
#define SetIOpt(V) V = strtol(OptArg, &EndPtr, 10);\
if ( ! EndPtr || *EndPtr != '\00' ) break;\
ArgOK = true
// Daniel
int select_rhs_if_lhs_is_positive(int lhs, int rhs) {
assert (0 <= lhs && lhs <= MaxCase && 0 <= rhs && rhs <= MaxCase);
assert (Class(Case[lhs]) == DVal(Case[lhs], ClassAtt));
assert (Class(Case[rhs]) == DVal(Case[rhs], ClassAtt));
// Consistency check of the sample
if (Class(Case[lhs]) == 1 && Class(Case[rhs]) == 2) {
fprintf(Of, "Found inconsistency in sample, exiting");
exit (1);
}
return (Class(Case[lhs]) == 1 && Class(Case[rhs]) == 0);
}
int select_rhs_if_lhs_is_negative(int lhs, int rhs) {
assert (0 <= lhs && lhs <= MaxCase && 0 <= rhs && rhs <= MaxCase);
assert (Class(Case[lhs]) == DVal(Case[lhs], ClassAtt));
assert (Class(Case[rhs]) == DVal(Case[rhs], ClassAtt));
// Consistency check of the sample
if (Class(Case[lhs]) == 1 && Class(Case[rhs]) == 2) {
fprintf(Of, "Found inconsistency in sample, exiting");
exit (1);
}
return (Class(Case[lhs]) == 2 && Class(Case[rhs]) == 0);
}
// End Daniel
int main(int Argc, char *Argv[])
/* ---- */
{
int o;
extern String OptArg, Option;
char *EndPtr;
Boolean FirstTime=true, ArgOK;
double StartTime;
FILE *F;
CaseNo SaveMaxCase;
Attribute Att;
// Pranav:
// struct rlimit RL;
/* Make sure there is a largish runtime stack */
/* Pranav:
getrlimit(RLIMIT_STACK, &RL);
RL.rlim_cur = Max(RL.rlim_cur, 20 * 1024 * 1024);
if ( RL.rlim_max > 0 ) // -1 if unlimited
{
RL.rlim_cur = Min(RL.rlim_max, RL.rlim_cur);
}
setrlimit(RLIMIT_STACK, &RL);
*/
/* Check for output to be saved to a file */
if ( Argc > 2 && ! strcmp(Argv[Argc-2], "-o") )
{
Of = fopen(Argv[Argc-1], "w");
Argc -= 2;
}
if ( ! Of )
{
Of = stdout;
}
KRInit = time(0) & 07777;
PrintHeader("");
/* Process options */
while ( (o = ProcessOption(Argc, Argv, "f+bpv+t+sm+c+S+I+ru+egX+wh")) )
{
if ( FirstTime )
{
fprintf(Of, T_OptHeader);
FirstTime = false;
}
ArgOK = false;
switch (o)
{
case 'f': FileStem = OptArg;
fprintf(Of, T_OptApplication, FileStem);
ArgOK = true;
break;
case 'b': BOOST = true;
fprintf(Of, T_OptBoost);
if ( TRIALS == 1 ) TRIALS = 10;
ArgOK = true;
break;
case 'p': PROBTHRESH = true;
fprintf(Of, T_OptProbThresh);
ArgOK = true;
break;
#ifdef VerbOpt
case 'v': SetIOpt(VERBOSITY);
fprintf(Of, "\tVerbosity level %d\n", VERBOSITY);
ArgOK = true;
break;
#endif
case 't': SetIOpt(TRIALS);
fprintf(Of, T_OptTrials, TRIALS);
Check(TRIALS, 3, 1000);
BOOST = true;
break;
case 's': SUBSET = true;
fprintf(Of, T_OptSubsets);
ArgOK = true;
break;
case 'm': SetFOpt(MINITEMS);
fprintf(Of, T_OptMinCases, MINITEMS);
Check(MINITEMS, 1, 1000000);
break;
case 'c': SetFOpt(CF);
fprintf(Of, T_OptCF, CF);
Check(CF, 0, 100);
CF /= 100;
break;
case 'r': RULES = true;
fprintf(Of, T_OptRules);
ArgOK = true;
break;
case 'S': SetFOpt(SAMPLE);
fprintf(Of, T_OptSampling, SAMPLE);
Check(SAMPLE, 0.1, 99.9);
SAMPLE /= 100;
break;
case 'I': SetIOpt(KRInit);
fprintf(Of, T_OptSeed, KRInit);
KRInit = KRInit & 07777;
break;
case 'u': SetIOpt(UTILITY);
fprintf(Of, T_OptUtility, UTILITY);
Check(UTILITY, 2, 10000);
RULES = true;
break;
case 'e': NOCOSTS = true;
fprintf(Of, T_OptNoCosts);
ArgOK = true;
break;
case 'w': WINNOW = true;
fprintf(Of, T_OptWinnow);
ArgOK = true;
break;
case 'g': GLOBAL = false;
fprintf(Of, T_OptNoGlobal);
ArgOK = true;
break;
case 'X': SetIOpt(FOLDS);
fprintf(Of, T_OptXval, FOLDS);
Check(FOLDS, 2, 1000);
XVAL = true;
break;
}
if ( ! ArgOK )
{
if ( o != 'h' )
{
fprintf(Of, T_UnregnizedOpt,
Option,
( ! OptArg || OptArg == Option+2 ? "" : OptArg ));
fprintf(Of, T_SummaryOpts);
}
fprintf(Of, T_ListOpts);
Goodbye(1);
}
}
if ( UTILITY && BOOST )
{
fprintf(Of, T_UBWarn);
}
StartTime = ExecTime();
/* Get information on training data */
if ( ! (F = GetFile(".names", "r")) ) Error(NOFILE, "", "");
GetNames(F);
if ( ClassAtt )
{
fprintf(Of, T_ClassVar, AttName[ClassAtt]);
}
NotifyStage(READDATA);
Progress(-1.0);
/* Allocate space for SomeMiss[] and SomeNA[] */
SomeMiss = AllocZero(MaxAtt+1, Boolean);
SomeNA = AllocZero(MaxAtt+1, Boolean);
/* Read data file */
if ( ! (F = GetFile(".data", "r")) ) Error(NOFILE, "", "");
#if false
// Pranav: Now allow even the class attribute to be unknown
GetData(F, true, false);
#else
GetData(F, true, true);
#endif
fprintf(Of, TX_ReadData(MaxCase+1, MaxAtt, FileStem));
#if false
{
int i = 62;
printf("datapoint in Case %i: %f,%f,%f,%d\n", i, Case[i][1]._cont_val, Case[i][2]._cont_val, Case[i][3]._cont_val, Case[i][ClassAtt]._discr_val);
}
#endif
// Daniel: Read implications
GetImplications(".implications");
fprintf( Of, "Read %d implications\n", cmap_number_of_implications (Implications));
//cmap_print(Implications);
// Daniel: Read intervals
// Needs to be called after reading the data!
GetIntervals(".intervals");
if (IntervalsUpperBounds) {
fprintf( Of, "Read %d intervals\n", IntervalsUpperBounds->size);
#ifdef DEBUG
int i;
for (i = 0; i<IntervalsUpperBounds->size; i++) {
printf ("Bounds for attribute value %s (%d): [%d, %d]\n", AttValName[1][i+2], (i+2), IntervalsLowerBounds->entries[i], IntervalsUpperBounds->entries[i]);
}
#endif
}
#ifdef DEBUG
// Save implications and original data for later verification
DebugImplications = cmap_copy (Implications);
fprintf( Of, "Copied %d implications\n", cmap_number_of_implications (DebugImplications));
DebugCase = (DataRec *) malloc((MaxCase + 1) * sizeof (DataRec));
int my_MaxCase = MaxCase;
int my_MaxAtt = MaxAtt;
int loop;
ForEach (loop, 0, MaxCase) {
DebugCase[loop] = (DataRec)malloc((MaxAtt + 1) * sizeof (AttValue));
int k;
ForEach (k, 0, MaxAtt) {
memcpy (&(DebugCase[loop][k]), &(Case[loop][k]), sizeof (AttValue));
}
}
if (! are_equal (Case, DebugCase, my_MaxCase, my_MaxAtt)) {
printf ("Copy was not successful!\n");
return 1;
} else {
printf ("Copying of Cases successful\n");
}
#endif
// Daniel: Initial implication propagation
// Forward
struct array * forward = cmap_select_rhs (Implications, & select_rhs_if_lhs_is_positive);
cmap_propagate (forward, Implications, 1, & assignClass);
delete_array (forward);
forward = NULL;
// Backward
struct array * backward = cmap_select_lhs (Implications, & select_rhs_if_lhs_is_negative);
cmap_propagate (backward, Implications, 2, & assignClass);
delete_array (backward);
backward = NULL;
// End
if ( XVAL && (F = GetFile(".test", "r")) )
{
//assert (false);
SaveMaxCase = MaxCase;
GetData(F, false, false);
fprintf(Of, TX_ReadTest(MaxCase-SaveMaxCase, FileStem));
}
/* Check whether case weight attribute appears */
if ( CWtAtt )
{
fprintf(Of, T_CWtAtt);
}
if ( ! NOCOSTS && (F = GetFile(".costs", "r")) )
{
//assert (false);
GetMCosts(F);
if ( MCost )
{
fprintf(Of, T_ReadCosts, FileStem);
}
}
/* Note any attribute exclusions/inclusions */
if ( AttExIn )
{
//assert (false);
fprintf(Of, "%s", ( AttExIn == -1 ? T_AttributesOut : T_AttributesIn ));
ForEach(Att, 1, MaxAtt)
{
if ( Att != ClassAtt &&
Att != CWtAtt &&
( StatBit(Att, SKIP) > 0 ) == ( AttExIn == -1 ) )
{
fprintf(Of, " %s\n", AttName[Att]);
}
}
}
/* Build decision trees */
if ( ! BOOST )
{
TRIALS = 1;
}
InitialiseTreeData();
if ( RULES )
{
//assert (false);
RuleSet = AllocZero(TRIALS+1, CRuleSet);
}
if ( WINNOW )
{
//assert (false);
NotifyStage(WINNOWATTS);
Progress(-MaxAtt);
WinnowAtts();
}
if ( XVAL )
{
//assert (false);
CrossVal();
}
else
{
ConstructClassifiers();
/* Evaluation */
fprintf(Of, T_EvalTrain, MaxCase+1);
NotifyStage(EVALTRAIN);
Progress(-TRIALS * (MaxCase+1.0));
Evaluate(CMINFO | USAGEINFO);
if ( (F = GetFile(( SAMPLE ? ".data" : ".test" ), "r")) )
{
//assert (false);
NotifyStage(READTEST);
fprintf(Of, "\n");
FreeData();
GetData(F, false, false);
fprintf(Of, T_EvalTest, MaxCase+1);
NotifyStage(EVALTEST);
Progress(-TRIALS * (MaxCase+1.0));
Evaluate(CMINFO);
}
}
fprintf(Of, T_Time, ExecTime() - StartTime);
#ifdef DEBUG
if (! are_equal (Case, DebugCase, my_MaxCase, my_MaxAtt)) {
printf ("There has been reorganization of data in Cases!\n");
} else {
printf ("There has been NO reorganization of data in Cases\n");
}
#endif
#ifdef VerbOpt
Cleanup();
#endif
// Daniel
delete_cmap (Implications);
if (IntervalsUpperBounds) {
delete_array (IntervalsUpperBounds);
}
if (IntervalsLowerBounds) {
delete_array (IntervalsLowerBounds);
}
#ifdef DEBUG
delete_cmap (DebugImplications);
ForEach (loop, 0, my_MaxCase) {
free (DebugCase[loop]);
}
free (DebugCase);
#endif
return 0;
}
File added
/*************************************************************************/
/* */
/* Copyright 2010 Rulequest Research Pty Ltd. */
/* */
/* This file is part of C5.0 GPL Edition, a single-threaded version */
/* of C5.0 release 2.07. */
/* */
/* C5.0 GPL Edition is free software: you can redistribute it and/or */
/* modify it under the terms of the GNU General Public License as */
/* published by the Free Software Foundation, either version 3 of the */
/* License, or (at your option) any later version. */
/* */
/* C5.0 GPL Edition is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
/* General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* (gpl.txt) along with C5.0 GPL Edition. If not, see */
/* */
/* <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* Determine the class of a case from a decision tree or ruleset */
/* */
/*************************************************************************/
#include "defns.i"
#include "extern.i"
/* Local data used by MarkActive and RuleClassify.
Note: Active is never deallocated, just grows as required */
RuleNo *Active=Nil, /* rules that fire while classifying case */
NActive, /* number ditto */
ActiveSpace=0; /* space allocated */
/*************************************************************************/
/* */
/* Classify a case using a decision tree */
/* */
/*************************************************************************/
ClassNo TreeClassify(DataRec Case, Tree DecisionTree)
/* ------------ */
{
ClassNo c;
ForEach(c, 0, MaxClass)
{
ClassSum[c] = 0;
}
FindLeaf(Case, DecisionTree, Nil, 1.0);
return SelectClass(1, (Boolean)(MCost != Nil));
}
/*************************************************************************/
/* */
/* Classify a case using the given subtree. */
/* Adjust the value ClassSum for each class */
/* */
/*************************************************************************/
void FindLeaf(DataRec Case, Tree T, Tree PT, float Fraction)
/* -------- */
{
DiscrValue v, Dv;
ClassNo c;
float NewFrac, BrWt[4];
/* Special case for winnowing cycles */
if ( T->NodeType && Skip(T->Tested) )
{
FollowAllBranches(Case, T, Fraction);
return;
}
if ( T->NodeType && Tested )
{
Tested[T->Tested] = true; /* for usage */
}
switch ( T->NodeType )
{
case 0: /* leaf */
LeafUpdate:
/* Use parent node if effectively no cases at this node */
// Pranav: Handle the case when the leaf has only data points with UNKNOWN class value.
// Cases = 0 in this case and we want the tre to predict based on the Class value of this node.
//if ( T->Cases < Epsilon )
if ( T->Cases < 0 )
{
T = PT;
}
/* Update from all classes */
ForEach(c, 1, MaxClass)
{
ClassSum[c] += Fraction * T->ClassDist[c] / T->Cases;
}
return;
case BrDiscr: /* test of discrete attribute */
Dv = DVal(Case, T->Tested); /* > MaxAttVal if unknown */
if ( Dv <= T->Forks ) /* Make sure not new discrete value */
{
FindLeaf(Case, T->Branch[Dv], T, Fraction);
}
else
{
FollowAllBranches(Case, T, Fraction);
}
return;
case BrThresh: /* test of continuous attribute */
if ( Unknown(Case, T->Tested) )
{
FollowAllBranches(Case, T, Fraction);
}
else
if ( NotApplic(Case, T->Tested) )
{
FindLeaf(Case, T->Branch[1], T, Fraction);
}
else
{
/* Find weights for <= and > branches, interpolating if
probabilistic thresholds are used */
BrWt[2] = Interpolate(T, CVal(Case, T->Tested));
BrWt[3] = 1 - BrWt[2];
ForEach(v, 2, 3)
{
if ( (NewFrac = Fraction * BrWt[v]) >= 0.01 )
{
FindLeaf(Case, T->Branch[v], T, NewFrac);
}
}
}
return;
case BrSubset: /* subset test on discrete attribute */
Dv = DVal(Case, T->Tested); /* > MaxAttVal if unknown */
if ( Dv <= MaxAttVal[T->Tested] )
{
ForEach(v, 1, T->Forks)
{
if ( In(Dv, T->Subset[v]) )
{
FindLeaf(Case, T->Branch[v], T, Fraction);
return;
}
}
/* Value not found in any subset -- treat as leaf */
goto LeafUpdate;
}
else
{
FollowAllBranches(Case, T, Fraction);
}
}
}
/*************************************************************************/
/* */
/* Follow all branches from a node, weighting them in proportion */
/* to the number of training cases they contain */
/* */
/*************************************************************************/
void FollowAllBranches(DataRec Case, Tree T, float Fraction)
/* ----------------- */
{
DiscrValue v;
ForEach(v, 1, T->Forks)
{
if ( T->Branch[v]->Cases > Epsilon )
{
FindLeaf(Case, T->Branch[v], T,
(Fraction * T->Branch[v]->Cases) / T->Cases);
}
}
}
/*************************************************************************/
/* */
/* Classify a case using a ruleset */
/* */
/*************************************************************************/
ClassNo RuleClassify(DataRec Case, CRuleSet RS)
/* ------------ */
{
ClassNo c, Best;
float TotWeight=0;
int a, u=1, d;
CRule R;
RuleNo r;
ForEach(c, 0, MaxClass)
{
ClassSum[c] = 0;
MostSpec[c] = Nil;
}
/* Find active rules */
NActive = 0;
if ( RS->RT )
{
MarkActive(RS->RT, Case);
}
else
{
ForEach(r, 1, RS->SNRules)
{
R = RS->SRule[r];
if ( Matches(R, Case) )
{
Active[NActive++] = r;
}
}
}
/* Must sort rules if using utility bands */
if ( UtilBand )
{
SortActive();
}
/* Vote active rules */
ForEach(a, 0, NActive-1)
{
r = Active[a];
R = RS->SRule[r];
if ( Tested )
{
ForEach(d, 1, R->Size)
{
Tested[R->Lhs[d]->Tested] = true; /* for usage */
}
}
if ( UtilBand ) CheckUtilityBand(&u, r, Class(Case), RS->SDefault);
ClassSum[R->Rhs] += R->Vote;
TotWeight += 1000.0;
/* Check whether this is the most specific rule for this class;
resolve ties in favor of rule with higher vote */
if ( ! MostSpec[R->Rhs] ||
R->Cover < MostSpec[R->Rhs]->Cover ||
( R->Cover == MostSpec[R->Rhs]->Cover &&
R->Vote > MostSpec[R->Rhs]->Vote ) )
{
MostSpec[R->Rhs] = R;
}
}
/* Flush any remaining utility bands */
if ( UtilBand )
{
CheckUtilityBand(&u, RS->SNRules+1, Class(Case), RS->SDefault);
}
/* Check for default and normalise ClassSum */
if ( ! TotWeight )
{
Confidence = 0.5;
return RS->SDefault;
}
ForEach(c, 1, MaxClass)
{
ClassSum[c] /= TotWeight;
}
Best = SelectClass(RS->SDefault, false);
/* Set Confidence to the vote for the most specific rule of class Best */
Confidence = MostSpec[Best]->Vote / 1000.0;
return Best;
}
/*************************************************************************/
/* */
/* Determine outcome of a test on a case. */
/* Return -1 if value of tested attribute is unknown */
/* */
/*************************************************************************/
int FindOutcome(DataRec Case, Condition OneCond)
/* ----------- */
{
DiscrValue v, Outcome;
Attribute Att;
Att = OneCond->Tested;
/* Determine the outcome of this test on this case */
switch ( OneCond->NodeType )
{
case BrDiscr: /* test of discrete attribute */
v = XDVal(Case, Att);
Outcome = ( v == 0 ? -1 : v );
break;
case BrThresh: /* test of continuous attribute */
Outcome = ( Unknown(Case, Att) ? -1 :
NotApplic(Case, Att) ? 1 :
CVal(Case, Att) <= OneCond->Cut ? 2 : 3 );
break;
case BrSubset: /* subset test on discrete attribute */
v = XDVal(Case, Att);
Outcome = ( v <= MaxAttVal[Att] && In(v, OneCond->Subset) ?
OneCond->TestValue : 0 );
}
return Outcome;
}
/*************************************************************************/
/* */
/* Determine whether a case satisfies a condition */
/* */
/*************************************************************************/
Boolean Satisfies(DataRec Case, Condition OneCond)
/* --------- */
{
return ( FindOutcome(Case, OneCond) == OneCond->TestValue );
}
/*************************************************************************/
/* */
/* Determine whether a case satisfies all conditions of a rule */
/* */
/*************************************************************************/
Boolean Matches(CRule R, DataRec Case)
/* ------- */
{
int d;
ForEach(d, 1, R->Size)
{
if ( ! Satisfies(Case, R->Lhs[d]) )
{
return false;
}
}
return true;
}
/*************************************************************************/
/* */
/* Make sure that Active[] has space for at least N rules */
/* */
/*************************************************************************/
void CheckActiveSpace(int N)
/* ---------------- */
{
if ( ActiveSpace <= N )
{
Realloc(Active, (ActiveSpace=N+1), RuleNo);
}
}
/*************************************************************************/
/* */
/* Use RT to enter active rules in Active[] */
/* */
/*************************************************************************/
void MarkActive(RuleTree RT, DataRec Case)
/* ---------- */
{
DiscrValue v;
int ri;
RuleNo r;
if ( ! RT ) return;
/* Enter any rules satisfied at this node */
if ( RT->Fire )
{
for ( ri = 0 ; (r = RT->Fire[ri]) ; ri++ )
{
Active[NActive++] = r;
}
}
if ( ! RT->Branch ) return;
/* Explore subtree for rules that include condition at this node */
if ( (v = FindOutcome(Case, RT->CondTest)) > 0 && v <= RT->Forks )
{
MarkActive(RT->Branch[v], Case);
}
/* Explore default subtree for rules that do not include condition */
MarkActive(RT->Branch[0], Case);
}
/*************************************************************************/
/* */
/* Sort active rules for utility band error rates */
/* */
/*************************************************************************/
void SortActive()
/* ---------- */
{
RuleNo r;
int a, aa, aLow;
ForEach(a, 0, NActive-1)
{
aLow = a;
ForEach(aa, a+1, NActive-1)
{
if ( Active[aa] < Active[aLow] ) aLow = aa;
}
r = Active[a];
Active[a] = Active[aLow];
Active[aLow] = r;
}
}
/*************************************************************************/
/* */
/* Update utility band error rates for all bands before rule r */
/* that have not been competed yet. Update current band. */
/* */
/*************************************************************************/
void CheckUtilityBand(int *u, RuleNo r, ClassNo Actual, ClassNo Default)
/* ---------------- */
{
ClassNo c;
while ( *u < UTILITY && r > UtilBand[*u] )
{
c = SelectClass(Default, false);
if ( c != Actual )
{
UtilErr[*u]++;
if ( MCost ) UtilCost[*u] += MCost[c][Actual];
}
(*u)++;
}
}
/*************************************************************************/
/* */
/* Classify a case using boosted tree or rule sequence. */
/* Global variable Default must have been set prior to call */
/* */
/* Note: boosting with costs is complicated. With trees, */
/* complete class distributions are accumulated and then a class */
/* selected to minimize expected cost. This cannot be done with */
/* rulesets since a single ruleset does not give a reliable */
/* class distribution; instead, the votes from all cost-adjusted */
/* rulesets are combined without reference to costs. */
/* */
/*************************************************************************/
ClassNo BoostClassify(DataRec Case, int MaxTrial)
/* ------------- */
{
ClassNo c, Best;
int t;
float Total=0;
ForEach(c, 1, MaxClass)
{
Vote[c] = 0;
}
ForEach(t, 0, MaxTrial)
{
Best = ( RULES ? RuleClassify(Case, RuleSet[t]) :
TreeClassify(Case, Pruned[t]) );
Vote[Best] += Confidence;
Total += Confidence;
TrialPred[t] = Best;
}
/* Copy votes into ClassSum */
ForEach(c, 1, MaxClass)
{
ClassSum[c] = Vote[c] / Total;
}
return SelectClass(Default, false);
}
/*************************************************************************/
/* */
/* Select the best class to return. Take misclassification costs */
/* into account if they are defined. */
/* */
/*************************************************************************/
ClassNo SelectClass(ClassNo Default, Boolean UseCosts)
/* ----------- */
{
ClassNo c, cc, BestClass;
float ExpCost, BestCost=1E38, TotCost=0;
BestClass = Default;
if ( UseCosts )
{
ForEach(c, 1, MaxClass)
{
ExpCost = 0;
ForEach(cc, 1, MaxClass)
{
if ( cc == c ) continue;
ExpCost += ClassSum[cc] * MCost[c][cc];
}
TotCost += ExpCost;
if ( ExpCost < BestCost )
{
BestClass = c;
BestCost = ExpCost;
}
}
Confidence = 1 - BestCost / TotCost;
}
else
{
ForEach(c, 1, MaxClass)
{
if ( ClassSum[c] > ClassSum[BestClass] ) BestClass = c;
}
Confidence = ClassSum[BestClass];
}
return BestClass;
}
/*************************************************************************/
/* */
/* General classification routine */
/* */
/*************************************************************************/
ClassNo Classify(DataRec Case)
/* -------- */
{
return ( TRIALS > 1 ? BoostClassify(Case, TRIALS-1) :
RULES ? RuleClassify(Case, RuleSet[0]) :
TreeClassify(Case, Pruned[0]) );
}
/*************************************************************************/
/* */
/* Interpolate a single value between Lower, Mid and Upper */
/* (All these have the same value unless using probabilistic */
/* thresholds.) */
/* */
/*************************************************************************/
float Interpolate(Tree T, ContValue Val)
/* ----------- */
{
return ( Val <= T->Lower ? 1.0 :
Val >= T->Upper ? 0.0 :
Val <= T->Mid ?
1 - 0.5 * (Val - T->Lower) / (T->Mid - T->Lower + 1E-6) :
0.5 - 0.5 * (Val - T->Mid) / (T->Upper - T->Mid + 1E-6) );
}
/*************************************************************************/
/* */
/* Free data structures for one classifier */
/* */
/*************************************************************************/
void FreeClassifier(int Trial)
/* -------------- */
{
if ( Raw )
{
FreeTree(Raw[Trial]); Raw[Trial] = Nil;
}
if ( Pruned )
{
FreeTree(Pruned[Trial]); Pruned[Trial] = Nil;
}
if ( RULES && RuleSet && RuleSet[Trial] )
{
FreeRules(RuleSet[Trial]); RuleSet[Trial] = Nil;
}
}
File added
/*************************************************************************/
/* */
/* Copyright 2010 Rulequest Research Pty Ltd. */
/* */
/* This file is part of C5.0 GPL Edition, a single-threaded version */
/* of C5.0 release 2.07. */
/* */
/* C5.0 GPL Edition is free software: you can redistribute it and/or */
/* modify it under the terms of the GNU General Public License as */
/* published by the Free Software Foundation, either version 3 of the */
/* License, or (at your option) any later version. */
/* */
/* C5.0 GPL Edition is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
/* General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* (gpl.txt) along with C5.0 GPL Edition. If not, see */
/* */
/* <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* Routine for printing confusion matrices and attribute usage */
/* ----------------------------------------------------------- */
/* */
/*************************************************************************/
#include "defns.i"
#include "extern.i"
void PrintConfusionMatrix(CaseNo *ConfusionMat)
/* -------------------- */
{
int Row, Col, Entry, EntryWidth=10000;
/* For more than 20 classes, use summary instead */
if ( MaxClass > 20 )
{
PrintErrorBreakdown(ConfusionMat);
return;
}
/* Find maximum entry width in chars */
ForEach(Row, 1, MaxClass)
{
ForEach(Col, 1, MaxClass)
{
EntryWidth = Max(EntryWidth, ConfusionMat[Row*(MaxClass+1) + Col]);
}
}
EntryWidth = floor(Log(EntryWidth + 100.0) / Log(10.0)) + 2;
/* Print the heading, then each row */
fprintf(Of, "\n\n\t");
ForEach(Col, 1, MaxClass)
{
fprintf(Of, "%*s(%c)", EntryWidth-3, " ", 'a' + Col-1);
}
fprintf(Of, " <-" T_classified_as "\n\t");
ForEach(Col, 1, MaxClass)
{
fprintf(Of, "%*.*s", EntryWidth, EntryWidth-2, "----------");
}
fprintf(Of, "\n");
ForEach(Row, 1, MaxClass)
{
fprintf(Of, "\t");
ForEach(Col, 1, MaxClass)
{
if ( (Entry = ConfusionMat[Row*(MaxClass+1) + Col]) )
{
fprintf(Of, " %*d", EntryWidth-1, Entry);
}
else
{
fprintf(Of, "%*s", EntryWidth, " ");
}
}
fprintf(Of, " (%c): " T_class " %s\n", 'a' + Row-1, ClassName[Row]);
}
}
void PrintErrorBreakdown(CaseNo *ConfusionMat)
/* ------------------- */
{
CaseNo *TruePos, *FalsePos, *FalseNeg, Entry;
int Row, Col, EntryWidth=100000, ClassWidth=5;
TruePos = AllocZero(MaxClass+1, CaseNo);
FalsePos = AllocZero(MaxClass+1, CaseNo);
FalseNeg = AllocZero(MaxClass+1, CaseNo);
ForEach(Row, 1, MaxClass)
{
ForEach(Col, 1, MaxClass)
{
Entry = ConfusionMat[Row*(MaxClass+1) + Col];
if ( Col == Row )
{
TruePos[Row] += Entry;
}
else
{
FalseNeg[Row] += Entry;
FalsePos[Col] += Entry;
}
}
EntryWidth = Max(EntryWidth, TruePos[Row] + FalseNeg[Row]);
ClassWidth = Max(ClassWidth, strlen(ClassName[Row]));
}
EntryWidth = floor(Log(EntryWidth + 100.0) / Log(10.0)) + 2;
/* Print heading (tricky spacing) */
fprintf(Of, "\n\n\t %-*s %*s %*s %*s\n\t %*s %*s %*s %*s\n",
ClassWidth, "Class",
EntryWidth, "Cases",
EntryWidth, "False",
EntryWidth, "False",
ClassWidth, "",
EntryWidth, "",
EntryWidth, "Pos",
EntryWidth, "Neg");
fprintf(Of, "\t %-*s %*s %*s %*s\n",
ClassWidth, "-----",
EntryWidth, "-----",
EntryWidth, "-----",
EntryWidth, "-----");
ForEach(Row, 1, MaxClass)
{
fprintf(Of, "\t %-*s %*d %*d %*d\n",
ClassWidth, ClassName[Row],
EntryWidth, TruePos[Row] + FalseNeg[Row],
EntryWidth, FalsePos[Row],
EntryWidth, FalseNeg[Row]);
}
Free(TruePos);
Free(FalsePos);
Free(FalseNeg);
}
void PrintUsageInfo(CaseNo *Usage)
/* -------------- */
{
Attribute Att, Best;
float Tests;
Boolean First=true;
Tests = Max(1, MaxCase+1);
while ( true )
{
Best = 0;
ForEach(Att, 1, MaxAtt)
{
if ( Usage[Att] > Usage[Best] ) Best = Att;
}
if ( ! Best || Usage[Best] < 0.01 * Tests ) break;
if ( First )
{
fprintf(Of, T_Usage);
First = false;
}
fprintf(Of, "\t%7d%% %s\n",
(int) ((100 * Usage[Best]) / Tests + 0.5), AttName[Best]);
Usage[Best] = 0;
}
}
File added
This diff is collapsed.
File added
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment