using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using Accord.MachineLearning; using Accord.Imaging; using Accord.Math; using Accord.Statistics; using System.Windows.Forms; using System.IO; namespace DriverApp { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { KMeans kmeans = new KMeans(3); String line; try { //Pass the file path and file name to the StreamReader constructor StreamReader sr = new StreamReader(@"D:\input.txt"); //Read the first line of text line = sr.ReadLine(); //Continue to read until you reach end of file while (line != null) { //write the lie to console window int[] medoid =kmeans.Compute(line); // here i am getting error //Read the next line line = sr.ReadLine(); } //close the file sr.Close(); Console.ReadLine(); } catch (Exception e) { Console.WriteLine("Exception: " + e.Message); } finally { Console.WriteLine("Executing finally block."); } // KMeans kmeans = new KMeans(3); // Compute the algorithm, retrieving an integer array // containing the labels for each of the observations // int[] medoid = kmeans.Compute(observations); // As a result, the first two observations should belong to the // same cluster (thus having the same label). The same should // happen to the next four observations and to the last three. Console.Write("The most efficient prediction via K-Means is : "); for (int counter = 0; counter < medoid.Length; counter++) { Console.Write(medoid[counter] + " "); } Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)