Exemple #1
0
        private void CancelRentButton_Click(object sender, RoutedEventArgs e)
        {
            if (DataGridBox.SelectedItem != null)
            {
                Warning warn = new Warning("Are you sure?");
                warn.ShowDialog();

                if (isRemoved)
                {
                    WSCalendar temp = (WSCalendar)DataGridBox.SelectedItem;
                    calendarService.deleteRent(temp.id);
                }
            }

            DataGridBox.ClearValue(ItemsControl.ItemsSourceProperty);
            DataGridBox.Items.Clear();
            if (RenterToggle.IsChecked == true)
            {
                RenterCombobox.IsEnabled = true;
                loadLandlordColumns();
            }
            else
            {
                RenterCombobox.IsEnabled = false;
                loadTenantColumns();
            }
        }
Exemple #2
0
        private static void sparseMachine(Sparse <double>[] inputs, double[] doubleOutputs)
        {
            // The dataset has output labels as 4 and 2. We have to convert them
            // into negative and positive labels so they can be properly processed.
            //
            bool[] outputs = doubleOutputs.Apply(x => x == 2.0 ? false : true);

            // Create a learning algorithm for Sparse data. The first generic argument
            // of the learning algorithm below is the chosen kernel function, and the
            // second is the type of inputs the machine should accept. Note that, using
            // those interfaces, it is possible to define custom kernel functions that
            // operate directly on double[], string[], graphs, trees or any object:
            var teacher = new LinearDualCoordinateDescent <Linear, Sparse <double> >()
            {
                Loss       = Loss.L2,
                Complexity = 1000, // Create a hard-margin SVM
                Tolerance  = 1e-5
            };

            // Use the learning algorithm to Learn
            var svm = teacher.Learn(inputs, outputs);

            // Compute the machine's answers
            bool[] answers = svm.Decide(inputs);

            // Create a confusion matrix to show the machine's performance
            var m = new ConfusionMatrix(predicted: answers, expected: outputs);

            // Show it onscreen
            DataGridBox.Show(new ConfusionMatrixView(m)).Hold();
        }
Exemple #3
0
 private void ItemHome_Selected(object sender, RoutedEventArgs e)
 {
     DataGridBox.ClearValue(ItemsControl.ItemsSourceProperty);
     DataGridBox.Items.Clear();
     StartDateDP.SelectedDate = null;
     EndDateDP.SelectedDate   = null;
     KitchenCB.IsChecked      = false;
     AnimalsCB.IsChecked      = false;
     ParkingCB.IsChecked      = false;
     CityTB.Text     = "";
     BedCountTB.Text = "";
     PriceTB.Text    = "";
 }
Exemple #4
0
 private void RenterToggle_Click(object sender, RoutedEventArgs e)
 {
     DataGridBox.ClearValue(ItemsControl.ItemsSourceProperty);
     DataGridBox.Items.Clear();
     if (RenterToggle.IsChecked == true)
     {
         RenterCombobox.IsEnabled = true;
         loadLandlordColumns();
     }
     else
     {
         RenterCombobox.IsEnabled = false;
         loadTenantColumns();
     }
 }
Exemple #5
0
        private static void sparseMachineProbabilistic(Sparse <double>[] inputs, double[] doubleOutputs)
        {
            // The dataset has output labels as 4 and 2. We have to convert them
            // into negative and positive labels so they can be properly processed.
            //
            bool[] outputs = doubleOutputs.Apply(x => x == 2.0 ? false : true);

            // Create a learning algorithm for Sparse data. The first generic argument
            // of the learning algorithm below is the chosen kernel function, and the
            // second is the type of inputs the machine should accept. Note that, using
            // those interfaces, it is possible to define custom kernel functions that
            // operate directly on double[], string[], graphs, trees or any object:
            var teacher = new LinearDualCoordinateDescent <Linear, Sparse <double> >()
            {
                Loss       = Loss.L2,
                Complexity = 1000, // Create a hard-margin SVM
                Tolerance  = 1e-5
            };

            // Use the learning algorithm to Learn
            var svm = teacher.Learn(inputs, outputs);

            // Create a probabilistic calibration algorithm based on Platt's method:
            var calibration = new ProbabilisticOutputCalibration <Linear, Sparse <double> >()
            {
                Model = svm
            };

            // Let's say that instead of having our data as bool[], we would
            // have received it as double[] containing the actual probabilities
            // associated with each sample:
            doubleOutputs.Apply(x => x == 2.0 ? 0.05 : 0.87, result: doubleOutputs);

            // Calibrate the SVM using Platt's method
            svm = calibration.Learn(inputs, doubleOutputs);

            // Compute the machine's answers
            bool[] answers = svm.Decide(inputs);

            // Compute the machine's probabilities
            double[] prob = svm.Probability(inputs);

            // Create a confusion matrix to show the machine's performance
            var m = new ConfusionMatrix(predicted: answers, expected: outputs);

            // Show it onscreen
            DataGridBox.Show(new ConfusionMatrixView(m)).Hold();
        }
Exemple #6
0
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            DataGridBox.ClearValue(ItemsControl.ItemsSourceProperty);
            DataGridBox.Items.Clear();
            DataLayer.Classes.FlatSearchCriteria criteria = new DataLayer.Classes.FlatSearchCriteria();
            criteria.startDate = StartDateDP.SelectedDate.GetValueOrDefault();
            criteria.endDate   = EndDateDP.SelectedDate.GetValueOrDefault();
            if (!BedCountTB.Text.Equals(""))
            {
                int parsed;
                if (int.TryParse(BedCountTB.Text, out parsed))
                {
                    criteria.bedCount = parsed;
                }
            }
            if (!PriceTB.Text.Equals(""))
            {
                int parsed;
                if (int.TryParse(PriceTB.Text, out parsed))
                {
                    criteria.price = parsed;
                    if (PriceCB.SelectedIndex == 0)
                    {
                        criteria.over = true;
                    }
                    else
                    {
                        criteria.over = false;
                    }
                }
            }
            criteria.city    = CityTB.Text;
            criteria.animals = AnimalsCB.IsChecked.GetValueOrDefault();
            criteria.kitchen = KitchenCB.IsChecked.GetValueOrDefault();
            criteria.parking = ParkingCB.IsChecked.GetValueOrDefault();

            rents = flatsService.getAvailableRooms(criteria);

            LoadGrid(rents);
        }
Exemple #7
0
        private static void cancer()
        {
            // Create a new LibSVM sparse format data reader
            // to read the Wisconsin's Breast Cancer dataset
            //
            var reader = new SparseReader("examples-sparse.txt");

            int[]      outputs; // Read the classification problem into dense memory
            double[][] inputs = reader.ReadToEnd(sparse: false, labels: out outputs);

            // The dataset has output labels as 4 and 2. We have to convert them
            // into negative and positive labels so they can be properly processed.
            //
            outputs = outputs.Apply(x => x == 2 ? -1 : +1);

            // Create a new linear-SVM for the problem dimensions
            var svm = new SupportVectorMachine(inputs: reader.Dimensions);

            // Create a learning algorithm for the problem's dimensions
            var teacher = new LinearDualCoordinateDescent(svm, inputs, outputs)
            {
                Loss       = Loss.L2,
                Complexity = 1000,
                Tolerance  = 1e-5
            };

            // Learn the classification
            double error = teacher.Run();

            // Compute the machine's answers for the learned inputs
            int[] answers = inputs.Apply(x => Math.Sign(svm.Compute(x)));

            // Create a confusion matrix to show the machine's performance
            var m = new ConfusionMatrix(predicted: answers, expected: outputs);

            // Show it onscreen
            DataGridBox.Show(new ConfusionMatrixView(m));
        }
        public void ComputeTest1()
        {
            double[,] data = Matrix.Identity(5);

            DataGridBox.Show(data).Hold();
        }