Example #1
0
        public void Regression_logistic_gd_check_accuracy_model_jason_input()
        {
            initData_Jason();
            BuildLogisticSGD lm = new BuildLogisticSGD();

            Dasmic.MLLib.Algorithms.Regression.ModelBase mb = (Dasmic.MLLib.Algorithms.Regression.ModelBase)
                                                              lm.BuildModel(_trainingData,
                                                                            _attributeHeaders, _indexTargetAttribute);

            double [] validateData = new double[2];
            double    crisp;

            for (int idx = 0; idx < _trainingData[0].Length; idx++)
            {
                validateData[0] = _trainingData[0][idx];
                validateData[1] = _trainingData[1][idx];
                double value = mb.RunModelForSingleData(
                    validateData);

                if (value < .5)
                {
                    crisp = 0;
                }
                else
                {
                    crisp = 1;
                }

                Assert.AreEqual(crisp, _trainingData[_indexTargetAttribute][idx]);
            }
        }
Example #2
0
        public void Regression_linear_check_rmse_jason_input()
        {
            Init_dataset_jason_linear_regression();

            BuildLinearSimple lm = new BuildLinearSimple();

            Dasmic.MLLib.Algorithms.Regression.ModelBase mb =
                (Dasmic.MLLib.Algorithms.Regression.ModelBase)lm.BuildModel(_trainingData,
                                                                            _attributeHeaders, _indexTargetAttribute);

            double value = mb.GetModelRMSE(_trainingData);

            Assert.IsTrue(value > .68 && value < .70);
        }
Example #3
0
        public void Regression_linear_check_model_jason_input_row_2()
        {
            Init_dataset_jason_linear_regression();
            BuildLinearSimple lm = new BuildLinearSimple();

            Dasmic.MLLib.Algorithms.Regression.ModelBase mb = (Dasmic.MLLib.Algorithms.Regression.ModelBase)lm.BuildModel(_trainingData,
                                                                                                                          _attributeHeaders, _indexTargetAttribute);

            double[] data  = GetSingleTrainingRowDataForTest(2);
            double   value = mb.RunModelForSingleData(
                data);

            Assert.IsTrue(SupportFunctions.DoubleCompare(value, 3.59));
        }
Example #4
0
        public void Regression_linear_check_model_jason_input()
        {
            Init_dataset_jason_linear_regression();
            BuildLinearSimple lm = new BuildLinearSimple();

            Dasmic.MLLib.Algorithms.Regression.ModelBase mb = (Dasmic.MLLib.Algorithms.Regression.ModelBase)lm.BuildModel(_trainingData,
                                                                                                                          _attributeHeaders, _indexTargetAttribute);

            double[] validateData = { 1 };
            double   value        = mb.RunModelForSingleData(
                validateData);

            Assert.IsTrue(value > 1.1 && value < 1.3);
        }
Example #5
0
        public void Regression_linear_gd_check_rmse_power_input()
        {
            initData_Power();

            BuildLinearSGD lm = new BuildLinearSGD();

            Dasmic.MLLib.Algorithms.Regression.ModelBase mb = (Dasmic.MLLib.Algorithms.Regression.ModelBase)
                                                              lm.BuildModel(_trainingData,
                                                                            _attributeHeaders,
                                                                            _indexTargetAttribute);

            double value = mb.GetModelRMSE(_trainingData);

            //Some issues were seen earlier maybe with parrelization
            Assert.IsTrue(SupportFunctions.DoubleCompare(value, 3.18));
        }
Example #6
0
        public void Regression_linear_gd_check_model_power_input()
        {
            initData_Power();

            BuildLinearSGD lm = new BuildLinearSGD();

            Dasmic.MLLib.Algorithms.Regression.ModelBase mb = (Dasmic.MLLib.Algorithms.Regression.ModelBase)
                                                              lm.BuildModel(_trainingData,
                                                                            _attributeHeaders, _indexTargetAttribute);

            double[] validateData = { 4 };
            double   value        = mb.RunModelForSingleData(
                validateData);

            Assert.IsTrue(value > 17.10 && value < 17.13);
        }
Example #7
0
        public void Regression_linear_gd_check_rmse_power_param()
        {
            initData_Power();

            BuildLinearSGD lm = new BuildLinearSGD();

            lm.SetParameters(.02, 20);

            Dasmic.MLLib.Algorithms.Regression.ModelBase mb = (Dasmic.MLLib.Algorithms.Regression.ModelBase)
                                                              lm.BuildModel(_trainingData,
                                                                            _attributeHeaders,
                                                                            _indexTargetAttribute);

            double value = mb.GetModelRMSE(_trainingData);

            Assert.IsTrue(SupportFunctions.DoubleCompare(value, 3.16));
        }
Example #8
0
        public void Regression_logistic_gd_check_model_jason_input()
        {
            initData_Jason();
            BuildLogisticSGD lm = new BuildLogisticSGD();

            Dasmic.MLLib.Algorithms.Regression.ModelBase mb = (Dasmic.MLLib.Algorithms.Regression.ModelBase)
                                                              lm.BuildModel(_trainingData,
                                                                            _attributeHeaders, _indexTargetAttribute);

            double[] validateData = { 1.465489372, 2.362125076 };
            double   value        = mb.RunModelForSingleData(
                validateData);

            Assert.IsTrue(value > .13 && value < .15);

            validateData[0] = 7.673756466;
            validateData[1] = 3.508563011;
            value           = mb.RunModelForSingleData(
                validateData);
            Assert.IsTrue(value > .8 && value < .99);
        }