private static bool TrainOnDataSet(IList <float[]> dataSet, IList <int[]> expectedClusters)
        {
            var competativeNeuralNet = new UnsupervisedCompetativeNeuralNet(dataSet.First().Length,
                                                                            expectedClusters.Count(), LearningRate, BiasLearningRate);

            for (var i = 0; i < MaxTries; i++)
            {
                competativeNeuralNet.Train(dataSet);

                if (ValidateClusters(dataSet, expectedClusters, competativeNeuralNet))
                {
                    return(true);
                }
            }

            foreach (var item in dataSet)
            {
                var cluster = competativeNeuralNet.GetCluster(item);
                Console.WriteLine("{0} = {1}", item, cluster);
            }

            return(false);
        }
 private static bool ValidateClusters(IList <float[]> dataSet, IEnumerable <int[]> expectedClusters, UnsupervisedCompetativeNeuralNet neuralNet)
 {
     return(expectedClusters
            .All(expectedCluster =>
                 expectedCluster.GroupBy(x => neuralNet.GetCluster(dataSet[x])).Count() == 1));
 }