KhiopsML / khiops

Khiops is an AutoML suite for supervised and unsupervised learning
https://khiops.org
BSD 3-Clause Clear License
26 stars 2 forks source link

multi-tables unsupervised training, one-column root table : khiops assumes wrongly the additional table has no header line #345

Open tramora opened 1 month ago

tramora commented 1 month ago

Description

Our colleague Romain T. raised the issue on automl a few weeks ago. After a few recent tests it seems that the problem is on the khiops side (even on the today latest stable 10.2.2-1 version).

On "a multi-tables unsupervised training with only one column root table : khiops assumes wrongly the additional table has no header line" and treats this line as data even if the HeaderLineUsed flag is set to true (cf minimal_scenario.kh)

It makes the data preparation fail.

Extract of the error logs :

Train unsupervised model
warning : Data table /tmp/S_Adult_by_label.txt : Record 1 : Numerical variable age: value <age> converted to <> (Unconverted string)
warning : Data table /tmp/S_Adult_by_label.txt : Record 1 : Numerical variable fnlwgt: value <fnlwgt> converted to <> (Unconverted string)
warning : Data table /tmp/S_Adult_by_label.txt : Record 1 : Numerical variable education_num: value <education_num> converted to <> (Unconverted end of string)
warning : Data table /tmp/S_Adult_by_label.txt : Record 1 : Numerical variable capital_gain: value <capital_gain> converted to <> (Unconverted string)
warning : Data table /tmp/S_Adult_by_label.txt : Record 1 : Numerical variable capital_loss: value <capital_loss> converted to <> (Unconverted string)
warning : Data table /tmp/S_Adult_by_label.txt : Record 1 : Numerical variable hours_per_week: value <hours_per_week> converted to <> (Unconverted string)
error : Data table /tmp/S_Adult_by_label.txt : Record 2 : Unsorted record Adult_data[1], with key inferior to that of the preceding record Adult_data[Label]
Data preparation interrupted because of errors

Workaround 1 (Thierry)

The first obvious workourand I found is to manually remove the header lines on BOTH the root table and the additional table (removing it on the additional table only is not enough)

Workaround 2 (Romain)

Romain proposed another strange workaround that works :

Question about sorting

If sorting steps are inserted before the training one (cf scenario_with_sorting.kh), the header line is systematically written by khiops in the sorted file and this "breaks" the workaround 1.

Context

Thanks in advance for your explanation and the possible fixes !

marcboulle commented 1 month ago

Le scénario n'est pas minimal

Bug connu dans pykhiops, à corriger

Ce problème provient probablement de pykhiops, pour une issue déjà identifiée:

Bug à corriger dans khiops

Sinon, le DetectFileFormat ne devrait pas échouer dans ce cas, même s'il s'agit d'une heuristique. Dans cet effet de bord, comme la première ligne contient correctement le nom de l'unique champs natif du dictionnaire, on devrait reconnaitre correctement qu'il y a une ligne d'entête.

Amélioration à considérer également:

Question sur le sort

Dans le scénario scenario_with_sorting.kh, une ligne d'entête est explicitement spécifée pour la table en sortie (cf. TargetDataTable.HeaderLineUsed true). Il est possible de spécifier que l'on ne veut pas de ligne d'entête en sortie.

Problème probablement lié à l'utilisation de la fonction sort_data_table de pykhiops, dont le paramètre optionnel output_header_line est à true par défaut. Cf. https://khiopsml.github.io/khiops-python/core/generated/khiops.core.api.html#khiops.core.api.sort_data_table

tramora commented 1 month ago

Merci pour ta réponse détaillée @marcboulle.

khiops-python se fie déjà sur la précédence du DetectFileFormat sur HeaderLineUsed lorsque les 2 sont fournis pour obtenir le comportement attendu mais tu as raison il faut que nous générions des directives non ambiguës pour un lecteur humain. (remarque faite dans khiops-python#208).

Pour résumer dans ce cas précis de defect,