/// <summary> /// Initializes this instance. /// </summary> /// protected void Init(IFeatureDetector <TPoint, TFeature> detector, IClusteringAlgorithm <TFeature> algorithm) { this.NumberOfWords = algorithm.Clusters.Count; this.Clustering = algorithm; this.Detector = detector; this.ParallelOptions = new ParallelOptions(); }
public Bitmap Determine( Bitmap source, int clustersNumber, Region[] regions, IClusteringAlgorithmFactory clusteringAlgorithmFactory) { LockableBitmap lockableBitmap = new LockableBitmap(source); lockableBitmap.LockBits(); IClusteringAlgorithm <double> clusteringAlgorithm = clusteringAlgorithmFactory.Create(clustersNumber, lockableBitmap); try { Region[] clusteredRegions = clusteringAlgorithm.Distribute(regions); foreach (Region region in clusteredRegions) { FillRegion(region, lockableBitmap); } } finally { lockableBitmap.UnlockBits(); } return(source); }
private void button4_Click(object sender, EventArgs e) { Random r = new Random(); // grab random sample Int32 sampleSize = (Int32)Math.Sqrt(coordinates.Length); if (sampleSize < numericUpDown2.Value) { sampleSize = (int)numericUpDown2.Value; } //Coordinate[] sample = coordinates.OrderBy((Coordinate c) => { return r.Next(); }).Take(sampleSize).ToArray(); //Coordinate[] sample = coordinates.GetRandomSample(sampleSize); Stopwatch sw = new Stopwatch(); sw.Start(); //processor = new KMedoidsProcessor<Coordinate>((int)numericUpDown2.Value, sample, new RoutingAI.Algorithms.StraightDistanceAlgorithm()); //processor = new KMedoidsSampledProcessor<Coordinate>((int)numericUpDown2.Value, coordinates, sampleSize, 100, new RoutingAI.Algorithms.StraightDistanceAlgorithm(), 2); processor = new CLARAClusteringAlgorithm <Coordinate>(coordinates, (int)numericUpDown2.Value, (int)numericUpDown6.Value, new RoutingAI.Algorithms.StraightDistanceAlgorithm()); processor.Run(); sw.Stop(); lblTime.Text = String.Format("Time Elapsed: {0}ms", sw.ElapsedMilliseconds); panel1.Invalidate(); }
public ClusterBMN(int clustersNumber, ISimilarityMeasure similarityMeasure, IClassificationQualityMeasure classificationMeasure, IClusteringAlgorithm clusteringAlgorithm, IClassificationAlgorithm classificationAlgorithm) { this._similarityMeasure = similarityMeasure; this._clustersNumber = clustersNumber; this._classificationMeasure = classificationMeasure; this._clusteringAlgorithm = clusteringAlgorithm; this._classificationAlgorithm = classificationAlgorithm; }
public ClusterBMN(DataMining.Data.Dataset trainingset, int clustersNumber, ISimilarityMeasure similarityMeasure, IClassificationQualityMeasure classificationMeasure, IClusteringAlgorithm clusteringAlgorithm, IClassificationAlgorithm classificationAlgorithm) { this._trainingset = trainingset; this._similarityMeasure = similarityMeasure; this._clustersNumber = clustersNumber; this._classificationMeasure = classificationMeasure; this._clusteringAlgorithm = clusteringAlgorithm; this._classificationAlgorithm = classificationAlgorithm; }
private void button1_Click(object sender, EventArgs e) { processor = null; Int32 count = (int)numericUpDown1.Value; coordinates = new Coordinate[count]; Random r = new Random(); for (int i = 0; i < coordinates.Length; i++) { coordinates[i] = new Coordinate(r.Next(-10000, 10000) / 100.0f, r.Next(-10000, 10000) / 100.0f); } panel1.Invalidate(); }
private void button2_Click(object sender, EventArgs e) { Random r = new Random(); Stopwatch sw = new Stopwatch(); sw.Start(); //processor = new KMedoidsProcessor<Coordinate>((int)numericUpDown2.Value, coordinates, new RoutingAI.Algorithms.StraightDistanceAlgorithm()); processor = new PAMClusteringAlgorithm <Coordinate>(coordinates, (int)numericUpDown2.Value, new RoutingAI.Algorithms.StraightDistanceAlgorithm()); processor.Run(); sw.Stop(); lblTime.Text = String.Format("Time Elapsed: {0}ms", sw.ElapsedMilliseconds); panel1.Invalidate(); }
/// <summary> /// Constructs a new <see cref="BagOfVisualWords"/>. /// </summary> /// /// <param name="detector">The feature detector to use.</param> /// <param name="algorithm">The clustering algorithm to use.</param> /// public BagOfVisualWords(IFeatureDetector <TPoint> detector, IClusteringAlgorithm <double[]> algorithm) : base(detector, algorithm) { }
public static BayesianClusterMultinetClassifier CreateClusteringBMNClassifier(int seed, int clusterNumber, Dataset dataset, ISimilarityMeasure similarityMeasure, IClassificationQualityMeasure accuracy, IClusteringAlgorithm algorithm, IClassificationAlgorithm naive, bool fireEvents) { DataMining.Utilities.RandomUtility.Initialize(seed); if (fireEvents) { if (algorithm is ACOClustering_IB) { ((ACOClustering_IB)algorithm).OnPostColonyIteration += new EventHandler(antClustering_OnPostColonyIteration); } if (algorithm is ACOClustering_MB) { ((ACOClustering_MB)algorithm).OnPostColonyIteration += new EventHandler(antClustering_OnPostColonyIteration); } } ClusterBMN cBMN = new ClusterBMN(dataset, clusterNumber, similarityMeasure, accuracy, algorithm, naive); return(cBMN.CreateClassifier() as BayesianClusterMultinetClassifier); }
/// <summary> /// Constructs a new <see cref="BagOfVisualWords"/> using a /// <see cref="SpeededUpRobustFeaturesDetector">surf</see> /// feature detector to identify features. /// </summary> /// /// <param name="algorithm">The clustering algorithm to use.</param> /// public BagOfVisualWords(IClusteringAlgorithm <double[]> algorithm) : base(new SpeededUpRobustFeaturesDetector(), algorithm) { }
/// <summary> /// Constructs a new <see cref="BagOfVisualWords"/>. /// </summary> /// /// <param name="detector">The feature detector to use.</param> /// <param name="algorithm">The clustering algorithm to use.</param> /// public BagOfVisualWords(IFeatureDetector <TPoint, TFeature> detector, IClusteringAlgorithm <TFeature> algorithm) { this.NumberOfWords = algorithm.Clusters.Count; this.Clustering = algorithm; this.Detector = detector; }
private void button2_Click(object sender, EventArgs e) { Random r = new Random(); Stopwatch sw = new Stopwatch(); sw.Start(); //processor = new KMedoidsProcessor<Coordinate>((int)numericUpDown2.Value, coordinates, new RoutingAI.Algorithms.StraightDistanceAlgorithm()); processor = new PAMClusteringAlgorithm<Coordinate>(coordinates, (int)numericUpDown2.Value, new RoutingAI.Algorithms.StraightDistanceAlgorithm()); processor.Run(); sw.Stop(); lblTime.Text = String.Format("Time Elapsed: {0}ms", sw.ElapsedMilliseconds); panel1.Invalidate(); }
private void button4_Click(object sender, EventArgs e) { Random r = new Random(); // grab random sample Int32 sampleSize = (Int32)Math.Sqrt(coordinates.Length); if (sampleSize < numericUpDown2.Value) sampleSize = (int)numericUpDown2.Value; //Coordinate[] sample = coordinates.OrderBy((Coordinate c) => { return r.Next(); }).Take(sampleSize).ToArray(); //Coordinate[] sample = coordinates.GetRandomSample(sampleSize); Stopwatch sw = new Stopwatch(); sw.Start(); //processor = new KMedoidsProcessor<Coordinate>((int)numericUpDown2.Value, sample, new RoutingAI.Algorithms.StraightDistanceAlgorithm()); //processor = new KMedoidsSampledProcessor<Coordinate>((int)numericUpDown2.Value, coordinates, sampleSize, 100, new RoutingAI.Algorithms.StraightDistanceAlgorithm(), 2); processor = new CLARAClusteringAlgorithm<Coordinate>(coordinates, (int)numericUpDown2.Value, (int)numericUpDown6.Value, new RoutingAI.Algorithms.StraightDistanceAlgorithm()); processor.Run(); sw.Stop(); lblTime.Text = String.Format("Time Elapsed: {0}ms", sw.ElapsedMilliseconds); panel1.Invalidate(); }
/// <summary> /// Constructs a new <see cref="BagOfVisualWords"/>. /// </summary> /// /// <param name="detector">The feature detector to use.</param> /// <param name="algorithm">The clustering algorithm to use.</param> /// public BagOfVisualWords(IFeatureDetector <TPoint, TFeature> detector, IClusteringAlgorithm <TFeature> algorithm) { Init(detector, algorithm); }