Closed tomaszb closed 7 years ago
Hi @tomaszb
Nice to see you again. Can you provide some examples? This seems to be an early step (hierarchy creation).
I will look at this later. I don't use the grouping so much. Can you elaborate on your use case ?
In the meantime, if you have a solution or a work-around, you can send me a pull request.
@tomaszb
If you don't feel comfortable with sharing info on github, you can use my email (my email is in the header of pyaf/TS/Signal_Grouping.py )
Hi @antoinecarme
We can recreate the issue from your document by renaming the Grouping structure like so:
# Grouping definition
lGroups = {}
lGroups["ZCountry"] = Countries
lGroups["YVariant"] = Variants
lGroups["XWine"] = Wines
lHierarchy = {};
lHierarchy['Levels'] = None;
lHierarchy['Data'] = None;
lHierarchy['Groups']= lGroups;
# the most important !!!!
lHierarchy['GroupOrder']= ["XWine", "YVariant", "ZCountry"]; # group by Wine first, then by variant, etc
lHierarchy['Type'] = "Grouped";
Now when running:
import pyaf.HierarchicalForecastEngine as hautof
lEngine = hautof.cHierarchicalForecastEngine()
lSignalHierarchy = lEngine.plot_Hierarchy(French_Wine_Export_in_Euros_DF , "Month", "Signal", 1,
lHierarchy, None);
lSignalHierarchy.mStructure
The mStructure object will be empty.
Hi @tomaszb
Can you please test the fix I just pushed and give me your feedback ?
Currently to recreate the hierarchy from the lHierarchy object when running:
lEngine = hautof.cHierarchicalForecastEngine()
lSignalHierarchy = lEngine.plot_Hierarchy()
the groups are sorted in reverse alphabetical order and ignore the actual 'GroupOrder' list of the lHierarchy object. This is because in file pyaf/TS/Signal_Grouping.py it is using the sorted function (line 54):
array1 = [ lGroups[k] for k in sorted(self.mHierarchy['GroupOrder'] , reverse=True) ];
The built in sorted function sorts by alphanumeric order by default.