jeffheaton / encog-dotnet-core

http://www.heatonresearch.com/encog
Other
430 stars 150 forks source link

EncogAnalyst.Save() Issue with Equilateral Classes #80

Open mdalvi opened 8 years ago

mdalvi commented 8 years ago

It seems that EncogAnalyst.Save(FileInfo) method is not saving the customized data, especially classes.

Eg. With following code:

'Analyst
Dim analyst = New EncogAnalyst()
'Wizard
 Dim wizard = New AnalystWizard(analyst)
 Dim BaseFile As FileInfo = FileUtil.CombinePath(New FileInfo(CSV_EXPORTS_PATH), 'baseFile.csv')
 wizard.Wizard(BaseFile, True, AnalystFileFormat.DecpntComma)

And then customizing one of the fields,

analyst.Script.Normalize.NormalizedFields(0).Classes.Clear()
analyst.Script.Normalize.NormalizedFields(0).Classes.Add(New Encog.Util.Arrayutil.ClassItem("CLASS_1",0))
analyst.Script.Normalize.NormalizedFields(0).Classes.Add(New Encog.Util.Arrayutil.ClassItem("CLASS_2",1))
analyst.Script.Normalize.NormalizedFields(0).Classes.Add(New Encog.Util.Arrayutil.ClassItem("CLASS_3",2))
analyst.Script.Normalize.NormalizedFields(0).Classes.Add(New Encog.Util.Arrayutil.ClassItem("CLASS_4",3))
analyst.Script.Normalize.NormalizedFields(0).Classes.Add(New Encog.Util.Arrayutil.ClassItem("CLASS_5",4))
analyst.Script.Normalize.NormalizedFields(0).Classes.Add(New Encog.Util.Arrayutil.ClassItem("CLASS_6",5))
analyst.Script.Normalize.NormalizedFields(0).Classes.Add(New Encog.Util.Arrayutil.ClassItem("CLASS_7",6))
analyst.Script.Normalize.NormalizedFields(0).Classes.Add(New Encog.Util.Arrayutil.ClassItem("CLASS_8",7))
analyst.Script.Normalize.NormalizedFields(0).Output = False
analyst.Script.Normalize.NormalizedFields(0).Action = Encog.Util.Arrayutil.NormalizationAction.Equilateral

Dim AnalystFile As FileInfo = FileUtil.CombinePath(New FileInfo(ENCOG_ANALYST_PATH), "baseFile_analyst.ega")
'save the analyst file
analyst.Save(AnalystFile)

This results in following config in .ega file

[DATA:CLASSES]
"field","code","name"
"TYPE_CLASS","CLASS_3","CLASS_3",1
"TYPE_CLASS","CLASS_2","CLASS_2",12
"TYPE_CLASS","CLASS_6","CLASS_6",33
"TYPE_CLASS","CLASS_8","CLASS_8",1

As you can see the rest of the classes were ignored and only those classes which were actually present in the baseFile.csv provided to wizard reflect. This results in Can't determine class for: error when this analyst is loaded later and is used to normalize same type of data but having a different class e.g. CLASS_1

Kindly review.