// Définition du domaine : attributs et leurs valeurs possibles.
var ATTRIBUTES = new[] {
"Alternate", // Yes, No
"Bar", // Yes, No
"Fri/Sat", // Yes, No
"Hungry", // Yes, No
"Patrons", // None, Some, Full
"Price", // $, $$, $$$
"Raining", // Yes, No
"Reservation", // Yes, No
"Type", // French, Italian, Thai, Burger
"WaitEstimate", // 0-10, 10-30, 30-60, >60
};
var ATTRIBUTE_VALUES = new Dictionary<string, string[]> {
{"Alternate", new[]{"Yes","No"}},
{"Bar", new[]{"Yes","No"}},
{"Fri/Sat", new[]{"Yes","No"}},
{"Hungry", new[]{"Yes","No"}},
{"Patrons", new[]{"None","Some","Full"}},
{"Price", new[]{"$","$$","$$$"}},
{"Raining", new[]{"Yes","No"}},
{"Reservation", new[]{"Yes","No"}},
{"Type", new[]{"French","Italian","Thai","Burger"}},
{"WaitEstimate", new[]{"0-10","10-30","30-60",">60"}},
};
// Les 12 exemples du restaurant, adaptés de la Table 19.1 d'AIMA.
// (Alternate, Bar, Fri/Sat, Hungry, Patrons, Price, Raining, Reservation,
// Type, WaitEstimate, WillWait)
var RAW_EXAMPLES = new (string Alternate,string Bar,string FriSat,string Hungry,
string Patrons,string Price,string Raining,string Reservation,string Type,
string WaitEstimate,bool WillWait)[] {
("Yes","No","No","Yes","Some","$$$","No","Yes","French","0-10", true),
("Yes","No","No","Yes","Full","$", "No","No", "Thai", "30-60", true),
("No", "Yes","No","No", "Some","$", "No","No", "Burger","0-10", false),
("Yes","No","Yes","Yes","Full","$", "Yes","No","Thai", "10-30", true),
("Yes","No","Yes","No", "Full","$$$","No","Yes","French",">60", false),
("No", "Yes","No","Yes","Some","$$","Yes","Yes","Italian","0-10",true),
("No", "Yes","No","No", "None","$", "Yes","No", "Burger","0-10", false),
("No", "No","No","Yes","Some","$$","Yes","Yes","Thai", "0-10", true),
("No", "Yes","Yes","No", "Full","$", "Yes","No", "Burger","10-30",false),
("Yes","Yes","Yes","Yes","Full","$$$","No","Yes","Italian","10-30",false),
("No", "No","No","No", "None","$", "No","No", "Thai", "0-10", false),
("Yes","Yes","Yes","Yes","Full","$", "No","No", "Burger","30-60",true),
};
// Conversion en dictionnaires { attribut -> valeur }.
List<Dictionary<string,string>> EXAMPLES = RAW_EXAMPLES
.Select(r => {
var d = new Dictionary<string,string>();
d["Alternate"]=r.Alternate; d["Bar"]=r.Bar; d["Fri/Sat"]=r.FriSat;
d["Hungry"]=r.Hungry; d["Patrons"]=r.Patrons; d["Price"]=r.Price;
d["Raining"]=r.Raining; d["Reservation"]=r.Reservation; d["Type"]=r.Type;
d["WaitEstimate"]=r.WaitEstimate; d["WillWait"]=r.WillWait?"Yes":"No";
return d;
}).ToList();
int nPos = EXAMPLES.Count(e => e["WillWait"]=="Yes");
Console.WriteLine($"Domaine : {ATTRIBUTES.Length} attributs");
Console.WriteLine($"Exemples : {EXAMPLES.Count} ({nPos} positifs, {EXAMPLES.Count-nPos} négatifs)");