public void TestWriteParameters()
        {
            var clf = new LogisticRegression <int>(random: new Random(0));

            clf.Fit(X, Y1);
            clf.Coef.MapInplace(v => 0);
            clf.Intercept.MapInplace(v => 0);
            Assert.IsTrue(clf.DecisionFunction(X).Column(0).AlmostEquals(new DenseVector(new double[] { 0, 0, 0 })));
        }
        public void TestSparsify()
        {
            string[] target = iris.Target.Select(t => iris.TargetNames[t]).ToArray();
            var      clf    = new LogisticRegression <string>(random: new Random(0));

            clf.Fit(iris.Data, target);

            Matrix <double> predDD = clf.DecisionFunction(iris.Data);

            clf.Sparsify();
            Assert.IsInstanceOfType(clf.Coef, typeof(SparseMatrix));
            Matrix <double> predSD = clf.DecisionFunction(iris.Data);

            Matrix          spData = SparseMatrix.OfMatrix(iris.Data);
            Matrix <double> predSS = clf.DecisionFunction(spData);

            clf.Densify();
            Matrix <double> predDS = clf.DecisionFunction(spData);

            Assert.IsTrue(predDD.AlmostEquals(predSD));
            Assert.IsTrue(predDD.AlmostEquals(predSS));
            Assert.IsTrue(predDD.AlmostEquals(predDS));
        }
 public void TestWriteParameters()
 {
     var clf = new LogisticRegression<int>(random: new Random(0));
     clf.Fit(X, Y1);
     clf.Coef.MapInplace(v => 0);
     clf.Intercept.MapInplace(v => 0);
     Assert.IsTrue(clf.DecisionFunction(X).Column(0).AlmostEquals(new DenseVector(new double[]{0, 0, 0})));
 }
        public void TestSparsify()
        {
            string[] target = iris.Target.Select(t => iris.TargetNames[t]).ToArray();
            var clf = new LogisticRegression<string>(random: new Random(0));
            clf.Fit(iris.Data, target);

            Matrix<double> predDD = clf.DecisionFunction(iris.Data);

            clf.Sparsify();
            Assert.IsInstanceOfType(clf.Coef, typeof(SparseMatrix));
            Matrix<double> predSD = clf.DecisionFunction(iris.Data);

            Matrix spData = SparseMatrix.OfMatrix(iris.Data);
            Matrix<double> predSS = clf.DecisionFunction(spData);

            clf.Densify();
            Matrix<double> predDS = clf.DecisionFunction(spData);

            Assert.IsTrue(predDD.AlmostEquals(predSD));
            Assert.IsTrue(predDD.AlmostEquals(predSS));
            Assert.IsTrue(predDD.AlmostEquals(predDS));
        }