Пример #1
0
        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));
            }
        }