Inheritance: RemoteActor
        public void TrainAndEvaluateRanking()
        {
            var mlContext = new MLContext(seed: 1, conc: 1);

            var data = Iris.LoadAsRankingProblem(mlContext,
                                                 GetDataPath(TestDatasets.iris.trainFilename),
                                                 hasHeader: TestDatasets.iris.fileHasHeader,
                                                 separatorChar: TestDatasets.iris.fileSeparator);

            // Create a training pipeline.
            var pipeline = mlContext.Transforms.Concatenate("Features", Iris.Features)
                           .Append(mlContext.Ranking.Trainers.FastTree(new FastTreeRankingTrainer.Options {
                NumThreads = 1
            }));

            // Train the model.
            var model = pipeline.Fit(data);

            // Evaluate the model.
            var scoredData = model.Transform(data);
            var metrics    = mlContext.Ranking.Evaluate(scoredData, label: "Label", groupId: "GroupId");

            // Check that the metrics returned are valid.
            Common.AssertMetrics(metrics);
        }
Exemple #2
0
        public Hierarchy Irises()
        {
            var hierarchyCluster = new KHierarchyClustering(Iris.GetFromFile(), 3, 4);
            var root             = hierarchyCluster.Start();

            return(new Hierarchy(root));
        }
        public void Descriptor_Save_And_Load_Json()
        {
            var data        = Iris.Load();
            var description = Descriptor.Create <Iris>();
            // to populate dictionaries
            var examples = description.ToExamples(data);

            var file = GetPath();

            Register.Type <Iris>();
            var d = SaveAndLoadJson(description);

            Assert.Equal(description.Type, d.Type);
            Assert.Equal(description.Features.Length, d.Features.Length);
            for (int i = 0; i < description.Features.Length; i++)
            {
                Assert.Equal(description.Features[i].Type, d.Features[i].Type);
                Assert.Equal(description.Features[i].Name, d.Features[i].Name);
                Assert.Equal(description.Features[i].Start, d.Features[i].Start);
            }

            Assert.Equal(description.Label.Type, d.Label.Type);
            Assert.Equal(description.Label.Name, d.Label.Name);
            Assert.Equal(description.Label.Start, d.Label.Start);
        }
Exemple #4
0
 public Enter()
 {
     InitializeComponent();
     LbVersion.Text = Program.VERSION;
     PbEnter.Hide();
     iris = new Iris();
 }
        private void MutateClassifier(float mutationDistance)
        {
            int classifiersCount = irisClassifiers.Count;

            classifierIndexToMutate = seed.Next(classifiersCount);
            Iris toMutate = irisClassifiers[classifierIndexToMutate];

            oldClassifier = toMutate.Copy(toMutate);

            switch (seed.Next(4))
            {
            case 0:
                toMutate.PetalLength += GetRandomNumber(-mutationDistance, mutationDistance);
                break;

            case 1:
                toMutate.PetalWidth += GetRandomNumber(-mutationDistance, mutationDistance);
                break;

            case 2:
                toMutate.SepalLength += GetRandomNumber(-mutationDistance, mutationDistance);
                break;

            case 3:
                toMutate.SepalWidth += GetRandomNumber(-mutationDistance, mutationDistance);
                break;
            }
        }
Exemple #6
0
        private void CsvParse(string pathFile)
        {
            using (TextFieldParser csvParser = new TextFieldParser(pathFile))
            {
                csvParser.CommentTokens = new string[] { "#" };
                csvParser.SetDelimiters(new string[] { "," });


                csvParser.ReadLine();
                while (!csvParser.EndOfData)
                {
                    string[] fields = csvParser.ReadFields();

                    Iris iris = new Iris(
                        double.Parse(fields[1]),
                        double.Parse(fields[2]),
                        double.Parse(fields[3]),
                        double.Parse(fields[4]));

                    listOfIris.Add(iris);

                    listString.Add(fields[1]);
                }
            }
        }
        public IActionResult Predict([FromBody] Iris iris)
        {
            var pipeline = new LearningPipeline
            {
                new TextLoader <IrisData>("iris-data.txt", separator: ","),
                new Dictionarizer("Label"),
                new ColumnConcatenator("Features", "SepalLength", "SepalWidth", "PetalLength", "PetalWidth"),
                new StochasticDualCoordinateAscentClassifier(),
                new PredictedLabelColumnOriginalValueConverter {
                    PredictedLabelColumn = "PredictedLabel"
                }
            };

            var data = new IrisData
            {
                PetalLength = iris.PetalLength,
                PetalWidth  = iris.PetalWidth,
                SepalLength = iris.SepalLength,
                SepalWidth  = iris.SepalWidth
            };

            var model      = pipeline.Train <IrisData, IrisPrediction>();
            var prediction = model.Predict(data);

            return(Ok(prediction));
        }
        public void learn_linear_multiclass()
        {
            #region doc_learn_multiclass
            // In this example, we will learn a multi-class SVM using the one-vs-one (OvO)
            // approach. The OvO approacbh can decompose decision problems involving multiple
            // classes into a series of binary ones, which can then be solved using SVMs.

            // Ensure we have reproducible results
            Accord.Math.Random.Generator.Seed = 0;

            // We will try to learn a classifier
            // for the Fisher Iris Flower dataset
            var        iris    = new Iris();
            double[][] inputs  = iris.Instances;   // get the flower characteristics
            int[]      outputs = iris.ClassLabels; // get the expected flower classes

            // We will use mini-batches of size 32 to learn a SVM using SGD
            var batches = MiniBatches.Create(batchSize: 32, maxIterations: 1000,
                                             shuffle: ShuffleMethod.EveryEpoch, input: inputs, output: outputs);

            // Now, we can create a multi-class teaching algorithm for the SVMs
            var teacher = new MulticlassSupportVectorLearning <Linear, double[]>
            {
                // We will use SGD to learn each of the binary problems in the multi-class problem
                Learner = (p) => new StochasticGradientDescent <Linear, double[], LogisticLoss>()
                {
                    LearningRate  = 1e-3,
                    MaxIterations = 1 // so the gradient is only updated once after each mini-batch
                }
            };

            // The following line is only needed to ensure reproducible results. Please remove it to enable full parallelization
            teacher.ParallelOptions.MaxDegreeOfParallelism = 1; // (Remove, comment, or change this line to enable full parallelism)

            // Now, we can start training the model on mini-batches:
            foreach (var batch in batches)
            {
                teacher.Learn(batch.Inputs, batch.Outputs);
            }

            // Get the final model:
            var svm = teacher.Model;

            // Now, we should be able to use the model to predict
            // the classes of all flowers in Fisher's Iris dataset:
            int[] prediction = svm.Decide(inputs);

            // And from those predictions, we can compute the model accuracy:
            var    cm       = new GeneralConfusionMatrix(expected: outputs, predicted: prediction);
            double accuracy = cm.Accuracy; // should be approximately 0.973
            #endregion

            Assert.AreEqual(0.97333333333333338, cm.Accuracy);
            Assert.AreEqual(150, batches.NumberOfSamples);
            Assert.AreEqual(32, batches.MiniBatchSize);
            Assert.AreEqual(213, batches.CurrentEpoch);
            Assert.AreEqual(1001, batches.CurrentIteration);
            Assert.AreEqual(82, batches.CurrentSample);
        }
Exemple #9
0
        public void learn_test_multiclass()
        {
            #region doc_learn_multiclass
            // Ensure results are reproducible
            Accord.Math.Random.Generator.Seed = 0;

            // This is a sample code on how to use Train-Val validation (split-set)
            // to assess the performance of multi-class Support Vector Machines.

            // Let's try to learn a SVM model for the famous Fisher's Iris dataset:
            var        iris    = new Iris();
            double[][] inputs  = iris.Instances;
            int[]      classes = iris.ClassLabels;

            // Create a new Split-Set validation algorithm passing the learning algorithm to be used
            var splitset = new SplitSetValidation <MulticlassSupportVectorMachine <Gaussian, double[]>, double[]>()
            {
                // In this example, we will be learning one-vs-one multi-class machines
                Learner = (s) => new MulticlassSupportVectorLearning <Gaussian, double[]>()
                {
                    Learner = (m) => new SequentialMinimalOptimization <Gaussian, double[]>()
                },

                // Optionally, set the proportion of the dataset that
                // should be used for validation (the default is 20%):
                ValidationSetProportion = 0.2 // this is the default
            };

            // If desired, we can also control paralellism using
            splitset.ParallelOptions.MaxDegreeOfParallelism = 1;

            // Compute the cross-validation
            var result = splitset.Learn(inputs, classes);

            // Finally, access the measured performance.
            double trainingErrors   = result.Training.Value;   // should be 0.016666666666666718 (+/- var. 0)
            double validationErrors = result.Validation.Value; // should be 0.033333333333333326 (+/- var. 0)
            #endregion

            Assert.AreEqual(0.2, splitset.ValidationSetProportion, 1e-10);

            Assert.AreEqual(0.2, splitset.ValidationSetProportion, 1e-6);
            Assert.AreEqual(0.8, splitset.TrainingSetProportion, 1e-6);

            Assert.AreEqual(0.016666666666666718, result.Training.Value, 1e-10);
            Assert.AreEqual(0.033333333333333326, result.Validation.Value, 1e-10);

            Assert.AreEqual(0, result.Training.Variance, 1e-10);
            Assert.AreEqual(0, result.Validation.Variance, 1e-10);

            Assert.AreEqual(0, result.Training.StandardDeviation, 1e-10);
            Assert.AreEqual(0, result.Validation.StandardDeviation, 1e-10);

            Assert.AreEqual(0.8, result.Training.Proportion);
            Assert.AreEqual(0.2, result.Validation.Proportion);

            Assert.AreEqual(150, result.NumberOfSamples);
            Assert.AreEqual(75, result.AverageNumberOfSamples);
        }
Exemple #10
0
    void handleSeparateColors(ColorPicker cpa, UndoInfo fs, Button x)
    {
        Iris lr = cpa.getLeftRight();

        TurnCanvas(lr.transform, true);
        string lt, rt;

        switch (PlayerPrefs.GetInt("Lang"))
        {
        case 1:
            //chinese
            lt = "左"; rt = "右";
            break;

        case 2:
            //ja
            lt = "左"; rt = "右";
            break;

        case 3:
            //rus
            lt = "слева"; rt = "направо";
            break;

        case 4:
            //thai
            lt = "izquierda"; rt = "derecho";
            break;

        case 5:
            //thai
            lt = "ไปทางซ้าย"; rt = "ทางขวา";
            break;

        case 6:
            //thai
            lt = "gauche"; rt = "droite";
            break;

        default:
            //english
            lt = "left"; rt = "right";
            break;
        }

        lr.fillButtons(lt, rt,
                       () => { fs.set.color = cpa.Color; },
                       () => { fs.set2.color = cpa.Color; }
                       );
        cpa.Color = fs.set.color;
        x.onClick.AddListener(() =>
        {
            lr.gameObject.SetActive(false);
            TurnCanvas(lr.transform, false);
        });
        cpa.gameObject.SetActive(true);
        cpa.Reset();
    }
        public double DistanceSquare(Iris another)
        {
            var DD1 = DIM1 - another.DIM1;
            var DD2 = DIM2 - another.DIM2;
            var DD3 = DIM3 - another.DIM3;
            var DD4 = DIM4 - another.DIM4;

            return(DD1 * DD1 + DD2 * DD2 + DD3 * DD3 + DD4 * DD4);
        }
        public int PredictClass(Iris irisToClassify)
        {
            int   predictedClass = int.MaxValue;
            float bestError      = float.MaxValue;

            irisRecords.Add(irisToClassify);

            for (int i = 0; i < irisClassifiers.Count; i++)
            {
                irisRecords[^ 1].ClassificationLabel = irisClassifiers[i].ClassificationLabel;
        public double Get(Iris a, Iris b)
        {
            double dist = Math.Sqrt(((a.sepallen - b.sepallen) * (a.sepallen - b.sepallen) +
                                     (a.sepalwid - b.sepalwid) * (a.sepalwid - b.sepalwid) +
                                     (a.petallen - b.petallen) * (a.petallen - b.petallen) +
                                     (a.petalwid - b.petalwid) * (a.petalwid - b.petalwid)
                                     ));

            return(dist);
        }
        private float CalculateCategoryDistance(Iris classifier, Iris record)
        {
            float sumOfPropDistances = 0;

            sumOfPropDistances += (float)Math.Pow(classifier.PetalLength - record.PetalLength, 2);
            sumOfPropDistances += (float)Math.Pow(classifier.PetalWidth - record.PetalWidth, 2);
            sumOfPropDistances += (float)Math.Pow(classifier.SepalLength - record.SepalLength, 2);
            sumOfPropDistances += (float)Math.Pow(classifier.SepalWidth - record.SepalWidth, 2);
            return(sumOfPropDistances);
        }
Exemple #15
0
        public static void Main(string[] args)
        {
            //getting example data
            Iris iris = new Iris();

            //we are creating training data arrays
            double[][] input  = new double[147][];
            int[]      output = new int[147];

            //we process 'Iris' data and delete 1 from each type for later test purpose
            int j = 0;

            for (int i = 0; i < 147; i++)
            {
                if (i != 0 || i != 50 || i != 100)
                {
                    input[j]  = new double[4];
                    output[j] = iris.ClassLabels[i];
                    for (int k = 0; k < 4; k++)
                    {
                        input[j][k] = iris.Instances[i][k];
                    }
                    j++;
                }
            }

            //learning algorithm for decision tree
            C45Learning teacher = new C45Learning(new[] {
                DecisionVariable.Continuous(iris.VariableNames[0]),
                DecisionVariable.Continuous(iris.VariableNames[1]),
                DecisionVariable.Continuous(iris.VariableNames[2]),
                DecisionVariable.Continuous(iris.VariableNames[3]),
            });

            //model learning
            DecisionTree tree = teacher.Learn(input, output);

            //If we would have some other irises we could just wrote like this
            //DecisionTree tree = teacher.Learn(iris.Instances, iris.ClassLabels);
            //but we prefer to left some for test purpose (to check if our programm is working fine)

            //testing our model
            double[][] test    = { iris.Instances[0], iris.Instances[50], iris.Instances[100] };
            int[]      answers = tree.Decide(test);

            Console.WriteLine("Answer should be as follow:\n0,1,2,\nAnswer is:");

            foreach (int ans in answers)
            {
                Console.Write(ans + ",");
            }

            Console.Write("\nPress any key to continue . . . ");
            Console.ReadKey(true);
        }
        public void Iris_Naive_Bayes_Save_And_Load_Test()
        {
            var data        = Iris.Load();
            var description = Descriptor.Create <Iris>();
            var generator   = new NaiveBayesGenerator(2);
            var model       = generator.Generate(description, data);

            Serialize(model);

            var lmodel = Deserialize <NaiveBayesModel>();
        }
Exemple #17
0
        static void c_Message(Client sender, Iris.Irc.ServerMessages.Message message)
        {
            ircSettings i = iSettings[sender];

            if (i.log == true)
            {

            }
            Console.WriteLine(message.Line);
            Console.Write("> ");
        }
        public HttpResponseMessage Post(Data data)
        {
            JObject    response = new JObject();
            string     logPath  = System.Web.Hosting.HostingEnvironment.MapPath("~/Log/");
            LogUtility ut       = new LogUtility(logPath);

            try
            {
                //if(string.IsNullOrWhiteSpace(data.id) && (string.IsNullOrWhiteSpace(data.photo_one) || string.IsNullOrWhiteSpace(data.photo_two)))
                //{
                //    throw new Exception("id is required");
                //}
                //else
                if (!("iris".Equals(data.type) || "face".Equals(data.type)))
                {
                    throw new Exception("type is required and it should be iris or face.");
                }
                else if (string.IsNullOrWhiteSpace(data.photo_one) || string.IsNullOrWhiteSpace(data.photo_two))
                {
                    throw new Exception("photo_one and photo_two are required");
                }
                //else if("face".Equals(data.type) && string.IsNullOrWhiteSpace(data.photo_one))
                //{
                //    throw new Exception("photo_one is required if you are verifying face");
                //}
                if ("iris".Equals(data.type))
                {
                    Iris iris = new Iris();
                    iris.PhotoOne = data.photo_one;
                    iris.PhotoTwo = data.photo_two;
                    float score = iris.Compare();
                    response.Add("score", score);
                }
                else if ("face".Equals(data.type))
                {
                    Face face = new Face();
                    face.PhotoOne = data.photo_one;
                    face.PhotoTwo = data.photo_two;
                    float score = face.Compare();
                    response.Add("score", score);
                }
                string s = response.ToString(Newtonsoft.Json.Formatting.None, null);
                ut.Write(data.type + " | Success", s, "Post", "/api/v1/compare", "OK");
                return(Request.CreateResponse(HttpStatusCode.OK, response));
            }
            catch (Exception ex)
            {
                response.Add("error", ex.Message);
                string s = response.ToString(Newtonsoft.Json.Formatting.None, null);
                ut.Write(data.type + " | Error", s, "Post", "/api/v1/compare", "Bad Request");
                return(Request.CreateResponse(HttpStatusCode.BadRequest, response));
            }
        }
Exemple #19
0
    public static DataTable Iris()
    {
        var iris = new Iris();

        DataTable dt = ToDataTable(iris.ClassLabels, iris.ClassNames, iris.Instances, iris.VariableNames);

        dt.Rows[37]["sepalwidth"]  = 3.6;
        dt.Rows[37]["petallength"] = 1.4;
        dt.Rows[34]["petalwidth"]  = 0.2;

        return(dt);
    }
        private void MutateIris()
        {
            int irisCount        = irisRecords.Count;
            int classifiersCount = irisClassifiers.Count;

            irisIndexToMutate = seed.Next(irisCount);
            Iris toMutate = irisRecords[irisIndexToMutate];

            oldIris = toMutate.Copy(toMutate);

            toMutate.ClassificationLabel = (toMutate.ClassificationLabel + seed.Next(classifiersCount)) % classifiersCount;
        }
Exemple #21
0
        public IEnumerable <Iris> Irises()
        {
            var         kMeansCluster = new KMeansClustering(Iris.GetFromFile(), 3, 4);
            var         kclusters     = kMeansCluster.Start2();
            List <Iris> irises        = new List <Iris>();

            for (int i = 0; i < 3; i++)
            {
                irises.AddRange(Iris.Convert(kclusters.ElementAt(i), Iris.irisNames[i], ""));
            }
            return(irises);
        }
Exemple #22
0
 public Welcome(Enter enter)
 {
     oEnter = enter;
     InitializeComponent();
     LbVersion.Text = Program.VERSION;
     iris           = new Iris();
     PbLive.Hide();
     Id               = enter.Id;
     License          = enter.License;
     Credits          = enter.Credits;
     LblLincense.Text = "****" + oEnter.License.Substring(4, oEnter.License.Length - 4);
     LblCredits.Text  = Credits.ToString();
 }
        public void Save_And_Load_Iris_DT()
        {
            var data        = Iris.Load();
            var description = Descriptor.Create <Iris>();
            var generator   = new DecisionTreeGenerator(50);
            var model       = generator.Generate(description, data) as DecisionTreeModel;

            Serialize(model);
            var lmodel = Deserialize <DecisionTreeModel>();

            Assert.AreEqual(model.Hint, lmodel.Hint);
            AreEqual(model.Tree, lmodel.Tree, false);
        }
Exemple #24
0
        public void Iris_Naive_Bayes_Save_And_Load_Test_Json()
        {
            var data        = Iris.Load();
            var description = Descriptor.Create <Iris>();
            var generator   = new NaiveBayesGenerator(2);
            var model       = generator.Generate(description, data) as NaiveBayesModel;

            var file = GetPath();

            Register.Type <Iris>();
            var lmodel = SaveAndLoadJson(model);

            Assert.Equal(model.Root, lmodel.Root);
        }
Exemple #25
0
        static void Main(string[] args)
        {
            var Flower1 = new Iris("Pink", 20);
            var Flower2 = new Pion("Red", 22);
            var Flower3 = new Rose("Pink", 78);
            var Flower4 = new Iris("Blue", 23);
            var Flower5 = new Scaevola("Blue", 67);

            var Bouquet = new Bouquet(Flower1, Flower2, Flower3, Flower4, Flower5);

            System.Console.WriteLine("Bouquet information");

            Bouquet.BouqetInfo();
        }
        public void RunAsync()
        {
            LoadData();
            SetupClusterIndicators();
            float oldError = CalculateError();
            float error    = float.PositiveInfinity;

            int   epochs        = 2000000;
            float temperature   = 1f;
            float coolingFactor = .99999f;

            for (int i = 0; i < epochs; i++)
            {
                temperature *= coolingFactor;
                Mutate();
                error = CalculateError();
                if (AcceptanceProbability(oldError, error, temperature) > (float)seed.NextDouble()) // keep solution
                {
                    oldError = error;
                }
                else if (error < oldError)
                {
                    oldError = error;
                }
                else
                {
                    RevertLastMutation();
                }

                Console.WriteLine($"old error: {Math.Sqrt(oldError)} error: {Math.Sqrt(error)} temperature: {temperature}");
            }


            Console.WriteLine("classification label, original label");
            for (int i = 0; i < irisRecords.Count(); i++)
            {
                Console.WriteLine($"{irisRecords[i].ClassificationLabel}, {irisRecords[i].OriginalCategory} ");
            }
            Iris irisToClassify = new Iris
            {//5.0,3.5,1.6,0.6
                OriginalCategory = "Should be a setosa",
                SepalLength      = 5f,
                SepalWidth       = 3.5f,
                PetalLength      = 1.6f,
                PetalWidth       = 0.6f
            };
            int predictedClass = PredictClass(irisToClassify);

            Console.WriteLine($"predicted Class for last iris: {predictedClass}, {irisToClassify.ClassificationLabel}");
        }
Exemple #27
0
        private void CsvParse(string pathFile)
        {
            using (TextFieldParser csvParser = new TextFieldParser(pathFile))
            {
                csvParser.CommentTokens = new string[] { "#" };
                csvParser.SetDelimiters(new string[] { "," });


                csvParser.ReadLine();
                while (!csvParser.EndOfData)
                {
                    string[] fields = csvParser.ReadFields();

                    /*Iris iris = new Iris(
                     *  Convert.ToDouble(fields[1]),
                     *  Convert.ToDouble(fields[2]),
                     *  Convert.ToDouble(fields[3]),
                     *  Convert.ToDouble(fields[4]));
                     */
                    Iris iris = new Iris(
                        double.Parse(fields[1]),
                        double.Parse(fields[2]),
                        double.Parse(fields[3]),
                        double.Parse(fields[4]));

                    /*Iris iris = new Iris(
                     *  double.Parse(fields[1]),
                     *  double.Parse(fields[2]),
                     *  double.Parse(fields[3]),
                     *  double.Parse(fields[4]));*/

                    /*Iris iris = new Iris(
                     *  fields[1],
                     *  fields[2],
                     *  fields[3],
                     *  fields[4]);*/

                    /*Iris iris = new Iris(
                     *  double.Parse(fields[1].Replace('.', ',')),
                     *  double.Parse(fields[2].Replace('.', ',')),
                     *  double.Parse(fields[3].Replace('.', ',')),
                     *  double.Parse(fields[4].Replace('.', ',')));*/


                    //listOfIris.Add(iris);

                    //listString.Add(fields[1]);
                }
            }
        }
        public void Save_And_Load_Iris_DT_Json()
        {
            var data        = Iris.Load();
            var description = Descriptor.Create <Iris>();
            var generator   = new DecisionTreeGenerator(50);
            var model       = generator.Generate(description, data) as DecisionTreeModel;

            var file = GetPath();

            Register.Type <Iris>();
            var lmodel = SaveAndLoadJson(model);

            Assert.Equal(model.Descriptor, lmodel.Descriptor);
            Assert.Equal(model.Hint, lmodel.Hint);
            Assert.Equal(model.Tree, lmodel.Tree);
        }
        public List <Iris> InitData(string filename)
        {
            var         reader = new StreamReader(File.OpenRead(filename));
            List <Iris> output = new List <Iris>();

            reader.ReadLine();
            while (!reader.EndOfStream)
            {
                var line = reader.ReadLine();
                line = line.Replace(",", ".");
                var  values      = line.Split(';');
                Iris result_line = new Iris(Convert.ToDouble(values[0]), Convert.ToDouble(values[1]), Convert.ToDouble(values[2]), Convert.ToDouble(values[3]), values[4]);
                output.Add(result_line);
            }

            return(output);
        }
Exemple #30
0
 public void Iris_Tests()
 {
     // need to run multiple times since
     // this model is a bit more sensitive
     LearnerPrediction <Iris>(
         new NeuralNetworkGenerator(),
         Iris.Load(),
         new Iris
     {
         PetalWidth  = 0.5m,
         PetalLength = 2.3m,
         SepalLength = 2.1m,
         SepalWidth  = 2.1m
     },
         i => "Iris-setosa".Sanitize() == i.Class
         );
 }
        ///<summary>
        ///Cosine similarity between two specific points in the dataset.
        ///</summary>
        public double CosineSimilarity(Iris a, Iris b)
        {
            double dist1 = (a.sepallen * b.sepallen) + (a.sepalwid * b.sepalwid) + (a.petallen * b.petallen) + (a.petalwid * b.petalwid);
            double dist2 = Math.Sqrt(
                (a.sepallen * a.sepallen) +
                (a.sepalwid * a.sepalwid) +
                (a.petallen * a.petallen) +
                (a.petalwid * a.petalwid)
                ) * Math.Sqrt(
                (b.sepallen * b.sepallen) +
                (b.sepalwid * b.sepalwid) +
                (b.petallen * b.petallen) +
                (b.petalwid * b.petalwid)
                );

            return(dist1 / dist2);
        }
 private void sampleing()
 {
     testData_id = getTestData();   // get records randomly
     int count = 0;
     string line;
     // read iris dataset
     System.IO.StreamReader file = new System.IO.StreamReader(filepath);
     while ((line = file.ReadLine()) != null)
     {
         string[] tmparr = line.Split(new Char[] { ',', '\t' });
         if (testData_id.Contains(count))
         {
             Iris test = new Iris();
             test.s_length = Convert.ToSingle(tmparr[0]);
             test.s_width = Convert.ToSingle(tmparr[1]);
             test.p_length = Convert.ToSingle(tmparr[2]);
             test.p_width = Convert.ToSingle(tmparr[3]);
             test.iris_class = tmparr[4];
             testData.Add(test);
             DataGridViewRow Row = new DataGridViewRow();
             Row.CreateCells(dataGridView1);
             Row.Cells[dataGridView1.Columns["s_length"].Index].Value = tmparr[0];
             Row.Cells[dataGridView1.Columns["s_width"].Index].Value = tmparr[1];
             Row.Cells[dataGridView1.Columns["p_length"].Index].Value = tmparr[2];
             Row.Cells[dataGridView1.Columns["p_width"].Index].Value = tmparr[3];
             Row.Cells[dataGridView1.Columns["iris_class"].Index].Value = tmparr[4];
             dataGridView1.Rows.Add(Row);
         }
         Iris data = new Iris();
         data.s_length = Convert.ToSingle(tmparr[0]);
         data.s_width = Convert.ToSingle(tmparr[1]);
         data.p_length = Convert.ToSingle(tmparr[2]);
         data.p_width = Convert.ToSingle(tmparr[3]);
         data.iris_class = tmparr[4];
         dataSet.Add(data);
         count++;
     }
 }
 partial void IndexOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Iris.Model.ForgottenPasswordModel model);
 partial void EditOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Iris.Model.AdminModel.EditLabelModel labelModel);
 partial void DataTableOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string term, int page, int count, Iris.Servicelayer.EFServices.Enums.Order order, Iris.Servicelayer.EFServices.Enums.LabelOrderBy orderBy, Iris.Servicelayer.EFServices.Enums.LabelSearchBy searchBy);
 public override System.Web.Mvc.ActionResult Edit(Iris.DomainClasses.Entities.Category model)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Edit);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "model", model);
     EditOverride(callInfo, model);
     return callInfo;
 }
 public override System.Web.Mvc.ActionResult Add(Iris.DomainClasses.Entities.Category category)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Add);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "category", category);
     AddOverride(callInfo, category);
     return callInfo;
 }
 partial void SubmitOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Iris.Model.ContactUsModel model);
 partial void EditOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Iris.Model.AdminModel.AddUpdateArticleModel model);
 public override System.Web.Mvc.ActionResult Add(Iris.Model.AdminModel.AddUpdateArticleModel model)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Add);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "model", model);
     AddOverride(callInfo, model);
     return callInfo;
 }
 partial void RegisterOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Iris.Model.RegisterModel model);
 partial void GetPostDataTableOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int page, int count, Iris.Servicelayer.EFServices.Enums.Order order, Iris.Servicelayer.EFServices.Enums.PostOrderBy orderBy);
 public override System.Web.Mvc.ActionResult GetPostDataTable(int page, int count, Iris.Servicelayer.EFServices.Enums.Order order, Iris.Servicelayer.EFServices.Enums.PostOrderBy orderBy)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.GetPostDataTable);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "page", page);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "count", count);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "order", order);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "orderBy", orderBy);
     GetPostDataTableOverride(callInfo, page, count, order, orderBy);
     return callInfo;
 }
 partial void AddPostOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Iris.Model.AdminModel.AddPostModel postModel);
Exemple #45
0
Fichier : D.cs Projet : vmail/main
 public byte[] CameraIrisSwitch(uint deviceAddress,Iris action)
 {
     return Message.GetMessage(deviceAddress,(byte)action,0x00,0x00,0x00);
 }
 public override System.Web.Mvc.ActionResult AddUser(Iris.Model.AdminModel.AddUserModel userModel)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.AddUser);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "userModel", userModel);
     AddUserOverride(callInfo, userModel);
     return callInfo;
 }
 partial void EditUserOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Iris.Model.AdminModel.EditUserModel userModel);
 public override System.Web.Mvc.ActionResult UpdateProfile(Iris.Model.EditProfileModel model)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateProfile);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "model", model);
     UpdateProfileOverride(callInfo, model);
     return callInfo;
 }
 public override System.Web.Mvc.ActionResult Submit(Iris.Model.ContactUsModel model)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Submit);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "model", model);
     SubmitOverride(callInfo, model);
     return callInfo;
 }
 partial void UpdateProfileOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Iris.Model.EditProfileModel model);
 partial void EditOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Iris.DomainClasses.Entities.Category model);
 public override System.Web.Mvc.ActionResult LogOn(Iris.Model.LogOnModel model, string returnUrl)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.LogOn);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "model", model);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "returnUrl", returnUrl);
     LogOnOverride(callInfo, model, returnUrl);
     return callInfo;
 }
 private void data_preprocessing()
 {
     System.IO.StreamReader file = new System.IO.StreamReader(filepath);
     int count = 0;
     string line;
     while ((line = file.ReadLine()) != null)      // read iris dataset
     {
         string[] tmparr = line.Split(new Char[] { ',', '\t' });
         Iris data = new Iris();
         data.s_length = Convert.ToSingle(tmparr[0]);
         data.s_width = Convert.ToSingle(tmparr[1]);
         data.p_length = Convert.ToSingle(tmparr[2]);
         data.p_width = Convert.ToSingle(tmparr[3]);
         data.iris_class = tmparr[4];
         dataSet.Add(data);
         count++;
     }
     cal_mean();
     cal_variance();
     showToDatagried();
 }
 partial void LogOnOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Iris.Model.LogOnModel model, string returnUrl);
 public override System.Web.Mvc.ActionResult Send(Iris.Model.AdminModel.SendingMailModel mailModel)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Send);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "mailModel", mailModel);
     SendOverride(callInfo, mailModel);
     return callInfo;
 }
 partial void AutoCompleteSearchOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string term, Iris.Servicelayer.EFServices.Enums.UserSearchBy searchBy);
 public override System.Web.Mvc.ActionResult DataTable(string term, int page, int count, Iris.Servicelayer.EFServices.Enums.Order order, Iris.Servicelayer.EFServices.Enums.LabelOrderBy orderBy, Iris.Servicelayer.EFServices.Enums.LabelSearchBy searchBy)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.DataTable);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "term", term);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "page", page);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "count", count);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "order", order);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "orderBy", orderBy);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "searchBy", searchBy);
     DataTableOverride(callInfo, term, page, count, order, orderBy, searchBy);
     return callInfo;
 }
 public override System.Web.Mvc.ActionResult AutoCompleteSearch(string term, Iris.Servicelayer.EFServices.Enums.UserSearchBy searchBy)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.AutoCompleteSearch);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "term", term);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "searchBy", searchBy);
     AutoCompleteSearchOverride(callInfo, term, searchBy);
     return callInfo;
 }
 public override System.Web.Mvc.ActionResult Edit(Iris.Model.AdminModel.EditLabelModel labelModel)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Edit);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "labelModel", labelModel);
     EditOverride(callInfo, labelModel);
     return callInfo;
 }
 public override System.Web.Mvc.ActionResult Index(Iris.Model.ForgottenPasswordModel model)
 {
     var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Index);
     ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "model", model);
     IndexOverride(callInfo, model);
     return callInfo;
 }