private static void dbSQLite() { // Connect to the database var path = Path.GetFullPath("./database.sqlite"); var db = new SqliteDb(path); db.Connect(); // Populate a list of iris from the database List <Iris> listPredict = new List <Iris>(); db.Command <Iris>("SELECT * FROM Iris", (iris) => { listPredict.Add(iris); }); // Perform the clustering data mining operation based on attribute(s) var clusterer = new Clustering <Iris>(5, listPredict); clusterer.BuildModel("SepalLengthCm"); // For each item, predict and output which cluster it's in foreach (var item in listPredict) { // Each item is tested against the test data set var result = clusterer.Evaluate(item); Console.WriteLine(result.SelectedClusterId); Console.WriteLine(string.Join(" ", result.Distance)); } }
static void Main(string[] args) { // Choose the data mining operation from input Console.WriteLine("Input BC for binary classification, MC for multiclass classification, or C for clustering"); var userInput = Console.ReadLine(); if (userInput == "BC") { Console.WriteLine("BC selected"); // Connect to the binary classification DB var path = Path.GetFullPath("./binaryclassification.db"); var db = new SqliteDb(path); db.Connect(); // Setup a tokenizer, parser, and SQL converter var handler = new FUSQLHandler(); var query = handler.ParseQuery("CHECK 'PRETTY GOOD!' FROM imdblabelled\n"); var translation = Translator.TranslateQuery <Text>(query); var result = translation.RunBinaryClassification(db); Console.WriteLine($"Sentiment: {translation.Operation.Text} | Prediction: {(Convert.ToBoolean(result.Prediction) ? "Positive" : "Negative")} | Probability: {result.Probability} "); Console.ReadLine(); } else if (userInput == "MC") { Console.WriteLine("MC selected"); // Connect to the multiclass classification DB var path = Path.GetFullPath("./multiclass.db"); var db = new SqliteDb(path); db.Connect(); // Setup a tokenizer, parser, and SQL converter var handler = new FUSQLHandler(); var query = handler.ParseQuery("IDENTIFY '404 error not found' 'Cant find webpage!' FROM issuestrain\n"); var translation = Translator.TranslateQuery <IssueDesc>(query); var result = translation.RunMulticlassClassification(db); //var resultView = new MulticlassClassification(); //resultView.BuildModel(); //MulticlassClassificationData issue = new MulticlassClassificationData() //{ // Title = "WebSockets communication is slow in my machine", // Description = "The WebSockets communication used under the covers by SignalR looks like is going slow in my development machine.." //}; Console.WriteLine($"=============== Single Prediction just-trained-model - Result: {result.Area} ==============="); Console.ReadLine(); } else if (userInput == "C") { Console.WriteLine("C selected"); // Connect to the database var path = Path.GetFullPath("./database.sqlite"); var db = new SqliteDb(path); db.Connect(); // Setup a tokenizer, parser, and SQL converter var handler = new FUSQLHandler(); var query = handler.ParseQuery("FIND 5 GROUPS irisClusters USING SepalLengthCm PetalLengthCm FROM Iris\n"); var translation = Translator.TranslateQuery <Iris>(query); var resultView = translation.RunClustering(db); // Perform a data mining query operation // dbSQLite(); foreach (var key in (resultView as ClusterResultView <Iris>).Clusters.Keys) { Console.WriteLine("Cluster " + key + " count : " + (resultView as ClusterResultView <Iris>).Clusters[key].Count); } Console.ReadLine(); } else { Console.WriteLine("\nInvalid input."); } }