Git Product home page Git Product logo

accord-net / framework Goto Github PK

View Code? Open in Web Editor NEW
4.5K 388.0 2.0K 417.56 MB

Machine learning, computer vision, statistics and general scientific computing for .NET

Home Page: http://accord-framework.net

License: GNU Lesser General Public License v2.1

Shell 0.01% C# 93.76% Smalltalk 0.82% PowerShell 0.01% F# 0.03% C++ 1.25% C 3.71% Inno Setup 0.01% Batchfile 0.06% Makefile 0.01% M4 0.01% Objective-C 0.01% HTML 0.29% CSS 0.01% Visual Basic .NET 0.03%
machine-learning framework c-sharp nuget visual-studio statistics unity3d neural-network support-vector-machines computer-vision image-processing ffmpeg

framework's Introduction

Accord.NET Framework

This project is currently archived. Please fork the project into your own GitHub account if you would like to continue its development.

Archiving

After 14~15 years of development, the Accord.NET project has finally been archived. I would like to send a big thank you to everyone who has ever comitted, dedicated, or otherwise devoted their time and effort into making this repository better every day. What had started as a project to store knowledge in the form of algorithms and implementations had grown way beyond my expectations since I first joined university and started working on research ~15 years ago.

In the meantime, many things have happened, and the ML landscape had also greatly evolved since then.

However, I pledge you to absolutely not interpret the archiving of this project as a loss. The main goal of this project since day 1 was to crystalize the ML knowledge available at the time in the form of source code and store it under a number of compatible free software licenses. As such, if you would like to, do not feel afraid of copy and pasting portions of this project into your own implementations. If I (Cesar De Souza) am the solely implementor of any of the classes you would like to port, I hereby grant you an irrevocable license to do so. If I am not, and the current license of the file you would like to port does not suit your needs, I can help you contact their original developers to help you with the transition.

"We reject kings, presidents and voting.  We
   believe in rough consensus and running code"
   -- David Clark

All this said. This has been an amazing ride.

Thanks everyone for their ever growing support all those years.

Let's keep in touch,

Cesar

Previous

DOI Build status Build Status NuGet Downloads License NuGet NuGet Pre Release

The Accord.NET project provides machine learning, statistics, artificial intelligence, computer vision and image processing methods to .NET. It can be used on Microsoft Windows, Xamarin, Unity3D, Windows Store applications, Linux or mobile.

After merging with the AForge.NET project, the framework now offers a unified API for learning/training machine learning models that is both easy to use and extensible. It is based on the following pattern:

For more information, please see the getting started guide, and check the classfication wiki. Please do not hesitate to edit the wiki if you would like!

Update (10/05/2020): Please see the current status section below before you start using this library in any new projects.

Installing

To install the framework in your application, please use NuGet. If you are on Visual Studio, right-click on the "References" item in your solution folder, and select "Manage NuGet Packages." Search for Accord.MachineLearning (or equivalently, Accord.Math, Accord.Statistics or Accord.Imaging depending on your initial goal) and select "Install."

If you would like to install the framework on Unity3D applications, download the "libsonly" compressed archive from the framework releases page. Navigate to the Releases/Mono folder, and copy the .dll files to the Plugins folder in your Unity project. Finally, find and add the System.ComponentModel.DataAnnotations.dll assembly that should be available from your system to the Plugin folders as well.

Sample applications

The framework comes with a wide range of sample applications to help get you started quickly. If you downloaded the framework sources or cloned the repository, open the Samples.sln solution file in the Samples folder.

Building

With Visual Studio 2015

Please download and install the following dependencies:

Then navigate to the Sources directory, and open the Accord.NET.sln solution file. Note: the solution includes F# unit test projects that can be disabled/unloaded from the solution in case you do not have support for F# tools in your version of Visual Studio.

With Visual Studio 2017

Please download and install the following dependencies:

Then navigate to the Sources directory, and open the Accord.NET.sln solution file. Note: the solution includes F# unit test projects that can be disabled/unloaded from the solution in case you do not have support for F# tools in your version of Visual Studio.

With Mono in Linux

# Install Mono
sudo apt-get install mono-complete monodevelop monodevelop-nunit git autoconf make

# Clone the repository
git clone https://github.com/accord-net/framework.git

# Enter the directory
cd framework

# Build the framework solution using Mono
./autogen.sh
make build
make samples
make test

With Mono in OS X

# Install Mono
brew update
brew cask install mono-mdk pkg-config automake

# Clone the repository
git clone https://github.com/accord-net/framework.git

# Enter the directory
cd framework

# Set some environment variables with OSX-specific paths
export PKG_CONFIG_PATH=/Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig/
export MONO=/Library/Frameworks/Mono.framework/Versions/Current/bin/mono
export XBUILD=/Library/Frameworks/Mono.framework/Versions/Current/bin/xbuild

# Build the framework solution using Mono
./autogen.sh
make build
make samples
make test

Contributing

If you would like to contribute, please do so by helping us update the project's Wiki pages. While you could also make a donation through PayPal Donate, Flattr Flattr this git repo, or any of the cryptocurrencies shown below, as well as fill-in bug reports and contribute code in the form of pull requests, the most precious donation we could receive would be a bit of your time - please take some minutes to submit us more documentation examples to our Wiki pages 😉

Donate using cryptocurrencies:

  • BTC: 1FC5gxLs2TsvuiHPP1tRLh5mPboQJQghvZ
  • ETH: 0x36FDA635Ef5773d8B376037D7BAfF22FeB987d92
  • LTC: LNjkZkMdSyncUvg5WnnhDNirdux4Q95gdt

Note: all donations are 100% invested towards improving the framework, including, but not limited to, the hiring of extra developers to work on issues currently present at the project's issue tracker. If you would like to donate resources towards the development of a particular issue, please let us know!

Join the chat at https://gitter.im/accord-net/framework - but to have issues and questions answered, post it as an issue.

Current status

Before you decide to use the framework for new projects, please see the following personal note below.

I am writing this note to give an official status for the project.

This project has certainly been the most important thing I have ever created, but I could not keep up with maintaining it as well as I wanted. This project allowed me to achieve the biggest dream I had, and that I never though I would have been able to achieve in my life, which was (some may laugh and possibly not understand - specially if you did not know where I came from): starting a new life, and a new career, here in Europe.

For about 10 years, I had worked on this project almost every day of my life.

But with the new life, there came new steps to be climbed, and I suddently had new responsabilities and things that I absolutely needed to accomplish very well. I started a PhD and had to focus on it so I could not keep up maintaining the library for about three years. I tried to hire freelance developers to help maintain the project in the meantime I had to be absent, and it worked to some extent, but at some point, I did not have the resources to keep up with the development anymore. Eventually, I developed panic-level anxiety since I felt I had left so many people behind by not being able to keep up with the development of the project anymore. I found out that I would always avoid opening up the issues page of the project, or even checking my own personal e-mails, just to avoid receiving new inquiries about the status of the project.

Then, a few months before my PhD defense (which happened very well, actually!), Microsoft announced that they wanted to make ML.net (which I actually fully support), the standard approach for machine learning in .NET. While this is great news (because I fully support MS giving more support for all ML practitioners out there), this eventually meant that Accord.NET would eventually become obsolete as ML.net was on its path to become the de-facto ML library for .NET in the foreseeing future.

I think that the reasons above would have been already enough to explain why I decided to not update Accord.NET anymore after that. However... in addition, I have to say that, as a researcher, and not solely as a developer, I have also published in, and attended to, the most important machine learning conferences in the world to date, and under this context, I need to say that in the academia world, no one has ever heard of the framework or the project itself. Actually, from my experience, people in those conferences can laugh or even mistreat you, if you ever mention you have ever developed anything in C#, specially for machine learning, as everyone [understandably] uses Python nowadays to accomplish tasks in this domain. This happened even when those people were from Microsoft itself.

I could actually understand the reaction, as I myself only use Python to do my day-to-day work, and while I love C#/.NET, I have to say that there is nothing that could even remotely compete with Python/Pytorch at this day and age).

Anyways, therefore, in the past months, I have been pondering about archiving the project. To avoid that, I am willing to make someone who would like, also an administrator of the project.

I am also willing to change the license of any file where I am the single author (you can check the copyright headers in each file) to MIT so people can reuse individual pieces of code more easily. Anyone who becomes administrator is welcome to slice the parts of the project that still make sense to exist (e.g., the FFmpeg wrappers, statistical distributions, statistical tests and the simple transforms like PCA) and even start new libraries (hopefully in .NET Core) providing only them if wanted.

Also, when I started this project back in 2007 (and when the original AForge library started, even way before that), there were almost no other libraries we could built upon, so we had to do start almost everything from scratch. This is not the case anymore. Any new libraries coming out of this project should definitely reuse existing libraries for basic tasks such as matrix operations and image processing.

Cesar De Souza
10-May-2020

Citing

Please cite this work as:

@misc{souza2014accord,
  title={The Accord.NET Framework},
  author={C{\'e}sar Souza and Andrew Kirillov and Marcos Diego Catalano and Accord.NET contributors},
  year={2014},
  doi={10.5281/zenodo.1029480},
  url={http://accord-framework.net}
}

[bibtex]

framework's People

Contributors

anders9ustafsson avatar andrewkirillov avatar catchemal avatar cesarsouza avatar diegocatalano avatar fdncred avatar firedragongamestudio avatar fo40225 avatar glyphard avatar heltonbiker avatar horker avatar hzawary avatar jmerk523 avatar josiahwood avatar justingruenberg avatar kamua avatar kaptenjon avatar kjos avatar konstantinlukaschenko avatar marshmit avatar masoudrahmani avatar michel-carbone avatar mikkelporse avatar milos-simic avatar nikolasmarkou avatar oloolo avatar pinelibg avatar rftemer avatar wanghongqi avatar yakanms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

framework's Issues

Multiple Linear Regression Without Intercept term

Hi all,

First congratulations for this libraries.
I'm new and I'm facing a problem (or bug?) that i don't know what is the issue? When i launch with the sample application "Regression", i load an excel file and i change in the code behind file the boolean to false when i create an new multiple linear regression.. so i have :

mlr = new MultipleLinearRegressionAnalysis(input, output, independentNames, dependentName, false);

But when i call the compute method, i have an ArgumentOutOfRangeException (value must be between 0 and 1), except that the same data works in statsgraphics.

Thanks in advance.
Stéphane.

Merge with AForge.NET

In the early days, Accord.NET was created and designed as an extension framework for AForge.NET. However, since 2012, AForge.NET public support was ended. Thus, the current plan is to incorporate AForge.NET directly in Accord.NET, merging the two.

This will solve accord-net/base#3

C4.5Learning: tree depends on the sorting order when the desicion variable is continuous

For DecisionVariableKind=Continuous, candidates for cut values are determined by this code:
if (o[j] != o[j + 1])
candidates.Add((v[j] + v[j + 1]) / 2.0);

The order of the output values are determined by the sorting order of the actual values thus can change for several equal values.
For example, after sorting:
Values are: 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 24, 24, 26, 26, 28, 29, 30, 30
Labels are: 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1

Candidates for split in this case are: 2, 2, 2, 3, 3, 3

Another option for sorting would be:
Values are: 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 24, 24, 26, 26, 28, 29, 30, 30
Labels are: 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1
(I've just switched the order of two equal values)

In that case, although the values are exactly the same, the candidates for split would be: 2, 2, 2, 3, 3, 3, 3, 13.5.

This behavior may results in the same decision tree no matter if the values are:
2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 24, 24, 26, 26, 28, 29, 30, 30 OR
2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 240, 240, 260, 260, 280, 290, 300, 300 OR
2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 2400, 2400, 2600, 2600, 2800, 2900, 3000, 3000 OR..
Since both the last 3 and the 24 are labeled as 1 (other 3's are labeled as 0)

Any suggestions on what can be done?

Thanks a lot,
Sivan.

GC-4: Blend doesn't fully account for Alpha channel when two 32 bit images are combined

'''What steps will reproduce the problem?'''

  • 1.Create two images with fully transparent areas that can be combined
  • 2.the first image blends properly
  • 3.the second images alpha channel is blended in. if its fully transparent those bits should not copy

'''What is the expected output? What do you see instead?'''
100% transparent bits should not blend int

'''What version of the product are you using? On what operating system?'''
Accord 2.1.4

'''Please provide any additional information below:'''
Attached code fixes for 100% alpha, but doesn't attempt anything fancy for partial transparency
{{{
// validate source pixel's coordinates
if ((ox >= 0) && (oy >= 0) && (ox < width) && (oy < height))
{
int c = oy * srcStride + ox * srcPixelSize;

                        // fill destination image with pixel from source image
                        if (srcPixelSize == 4 && src[c + 3] == 0)
                        {
                            // nothing to copy in
                            //NOP
                        }
                        else if (dst[3] > 0)
                        {
                            // there is a pixel from the other image here, blend
                            double d1 = distance(ox, oy, center1.X, center1.Y);
                            double d2 = distance(ox, oy, center2.X, center2.Y);
                            double f = Accord.Math.Tools.Scale(0, dmax, 0, 1, d1 - d2);

                            if (f < 0) f = 0;
                            if (f > 1) f = 1;
                            double f2 = (1.0 - f);

                            dst[0] = (byte)(src[c] * f2 + dst[0] * f);

}}}

Accord.Extensions class

Newly introduced Extensions class collides with the Accord.NET Extensions Framework which base namespace is Accord.Extensions. This issue produces major problems in usability of these two libraries.

By simply renaming the Extensions class (I see that it only contains extension method) the problem could be resolved and the compatibility would not be broken.

Bug in Singular Value Decomposition

There is example of using svd for lsi at http://nlp.stanford.edu/IR-book/html/htmledition/latent-semantic-indexing-1.html

When i'm using SingularValueDecomposition class to compute svd, i get different results.
Here is program that reproduces example:

    internal class Program
    {
        private static void Main(string[] args)
        {
            SvdTest();
            Console.ReadLine();
        }


        private static void SvdTest()
        {
            var matrix = new double[,]
                         {
                             {1, 0, 1, 0, 0, 0}, 
                             {0, 1, 0, 0, 0, 0},
                             {1, 1, 0, 0, 0, 0},
                             {1, 0, 0, 1, 1, 0},
                             {0, 0, 0, 1, 0, 1},

                         };
            PrintMatrix(matrix, "Original");

            var svd = new SingularValueDecomposition(matrix,true,true,true,true);


            var u = svd.LeftSingularVectors;
            PrintMatrix(u, "U");

            var s = svd.DiagonalMatrix;
            PrintMatrix(s, "S");

            var vt = svd.RightSingularVectors.Transpose();
            PrintMatrix(vt, "Vt");

            var powerOfsigma = svd.Diagonal.Length;
            const int reducedPower = 2;

            var toRemove = powerOfsigma - reducedPower;

            var indexes = GetIndexes(powerOfsigma, toRemove);

            var semanticSpace = s.Remove(indexes, indexes)
                .Multiply(vt.Remove(indexes, null));

            PrintMatrix(semanticSpace, "reduced document semantic space model");
        }


        private static int[] GetIndexes(int value, int nTimes)
        {
            return IterateFromValue(value, nTimes).ToArray();
        }

        private static IEnumerable<int> IterateFromValue(int value, int nTimes)
        {
            for (int i = 0; i < nTimes; i++)
                yield return --value;
        }

        private static void PrintMatrix(double[,] doubles, string name)
        {
            Console.WriteLine(name);
            for (int i = 0; i < doubles.GetLength(0); i++)
            {
                for (int j = 0; j < doubles.GetLength(1); j++)
                    Console.Write(doubles[i, j].ToString("0.00") + "\t");
                Console.WriteLine();
            }
            Console.WriteLine();
        }
}

ComplexSignalConstructor unit test fails

After pulling in the recent commit originally requested by @webner, the ComplexSignalConstructor unit test (in the ComplexSignalTest class and the Accord.Tests.Audio project) fails with the following message:

Test method Accord.Tests.Audio.ComplexSignalTest.ComplexSignalConstructor threw exception:
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Accord.Audio.Windows.WindowBase.Apply(Signal signal, Int32 sampleIndex) in WindowBase.cs: line 125
at Accord.Audio.Windows.Extensions.Split(Signal signal, IWindow window, Int32 step) in Extensions.cs: line 115
at Accord.Tests.Audio.ComplexSignalTest.ComplexSignalConstructor() in ComplexSignalTest.cs: line 106

Now, I cannot judge whether the unit test is not consistent with the WindowsBase commit, or if the code change in the commit is actually incorrect (at first glance it looks reasonable). Nevertheless, I hope someone can shed some light over this issue, and ideally propose a solid fix.

Best regards,
Anders @ Cureos

Multilabel SVM - Different outputs with same SMO learning parameters

Hi Cesar,

I just noticed something weird when training Multilabel SVMs and am not sure if there is a bug involved here. When taking the example code from the documentation to setup the machines

teacher.Algorithm = (svm, classInputs, classOutputs, i, j) =>
    new SequentialMinimalOptimization(svm, classInputs, classOutputs);

for the given examples of [0,3,1,2] i get the following output:

 -1 1 -1
 -1 -1 -1
 -1 1 -1
 -1 -1 -1

When configuring the training algorithm like this (setting the values of complexity, epsilon and tolerance to the same values is just for making the point):

        teacher.Algorithm = (svm, classInputs, classOutputs, a, b) =>
           {
               var smo = new SequentialMinimalOptimization(svm, classInputs, classOutputs);
               smo.Complexity = smo.Complexity;
               smo.Epsilon = smo.Epsilon;
               smo.Tolerance = smo.Tolerance;
               return smo;
           };

the output is now:

-1 1 -1
-1 -1 1
-1 1 -1
-1 -1 -1

(notice the different value in the second row, third value)
even though the configure parameters for the learning algorithm should not have been changed, the output of the machine is different.
is this intended behaviour?

thank you for your great work!

Incorrect calculation of WaveDecoder.AverageBitsPerSecond

In the WaveDecoder class, the AverageBitsPerSecond is derived from the WaveStream.Format.AverageBytesPerSecond, here. However, the AverageBytesPerSecond should be multiplied with 8 to yield the AverageBitsPerSecond, nothing else.

As far as I can tell, this error has very little impact. I have only been able to identify two usages of the AverageBitsPerSecond property in the framework solution, here and here in one WaveEncoder unit test. In these lines, the expected assertion values should be modified to 1411200.

Exception in KPCA

hello cesar,

when applying a transform to a double[] the Transform function throws an exception. try this adapted code from the documentation using jagged arrays:

double[][] sourceMatrix = new double[][]
        {
            new double[] { 2.5,  2.4 },
            new double[] { 0.5,  0.7 },
            new double[] { 2.2,  2.9 },
            new double[] { 1.9,  2.2 },
            new double[] { 3.1,  3.0 },
            new double[] { 2.3,  2.7 },
            new double[] { 2.0,  1.6 },
            new double[] { 1.0,  1.1 },
            new double[] { 1.5,  1.6 },
            new double[] { 1.1,  0.9 }
        };

        // Create a new linear kernel
        IKernel kernel = new Linear();

        // Creates the Kernel Principal Component Analysis of the given data
        var kpca = new KernelPrincipalComponentAnalysis(sourceMatrix, kernel);

        // Compute the Kernel Principal Component Analysis
        kpca.Compute();

        // The following statement throws an exception:
        // An unhandled exception of type 'System.IndexOutOfRangeException' occurred in Accord.Math.dll
        double[] transformed = kpca.Transform(sourceMatrix[0]);

when using a plain PrincipalComponentAnalysis everything runs fine as expected.
is this a bug?

thank you,
matthias

Unexplained Divide By Zero exception

I'm unable to create a code book for the images from the National Data Science bowl; I get a DivideByZero exception during the Compute phase.

The stack trace indicates the problem is in the ProcessImage method of the SURF detector.

I've written an easily runnable linqpad example and posted it as a GIST here: https://gist.github.com/Crisfole/bb636955891327f8b057

To reproduce:

  1. Download the train.zip data files from the National Data Science bowl. (You may have to create a kaggle account to do this, TOS seem to be ok w/ practicing on their data).
  2. Extract the training images somewhere on you computer.
  3. Copy-Paste the Gist into Linq-Pad and replace the directory at the top of the Main() method with yours.
  4. Run.

Term Frequency - Inverse Document Frequency (TF-IDF)

It would be a nice addition for those using Accord.NET in text applications, specially now that more linear optimization algorithms are available.

Kory Becker has created a nice implementation (under a compatible license) which can be used as a basis for the implementation. The current code can be found here:

https://github.com/primaryobjects/TFIDF/blob/master/TFIDFExample/TFIDF.cs

However, it seems the implementation needs a stemmer. In this case, the stemmer could be incorporated in the project by specifying a new ITextStemmer interface. Different stemmers could than be created using the Snowball project:

https://github.com/cesarsouza/snowball

It would be cool to add a new text generator in Snowball for C#. It shouldn't be that difficult given that there are working Java generators available.

Organize unit tests dependencies

In the main project, certain projects don't reference each other for obvious reasons. For example, Accord.Math cannot reference Accord.MachineLearning, but actually it is Accord.MachineLearning that should reference Accord.Math.

However, the same cannot be said for the unit tests. In the current version, the unit tests have references among themselves, which might be a bit confusing, specially if you are trying to disentangle them from the main project.

As such, uncommon dependencies must be removed, and the resulting broken tests and references should be fixed.

KNearestNeighborMatching should accept a main anchor image to create the k-NN model

Currently, the KNearestNeighborMatching class matches two images by creating a k-NN model using the image with the largest number of feature points, to speedup computations. However, this behavior isn't always desired. It would be more interesting to provide the most important image in the class constructor, or offer this swapping as an option.

Distribution issue?

I used the latest installer (Accord.NET-2.13.1-installer) and the Accord.Controls.Audio.dll assembly in the Accord.NET\Framework\Release\net35 folder seems to have been built with .NET 4. Thus, I cannot use it in a project targeting .NET 3.5. I don't know if this applies to other assemblies as well.
gac

Issue with string parsing into Quadratic objective function

Hi,

I'am trying to parse a string into quadratic objective function.

this is the expression : 0.5(63x0.012 + 1.41724668855095x² +39.69)
and there are the constraints : x0.2 + 6.3 = 0 and x + 63- 1 = 100

systematically the parsing does not work.

First I thought it was because my decimal separator was comma instead of point, but after modifications, still does not work.

I have tried to parse a very simple expression as "2x² -5" but does not work too.

I am looking for some help : parsing expression regarding the white space, the signs, the coefficients position ....

Thank you so much for any help.

Regards,

Iris

SVM code that worked with version 2.11.0.0, fails to converge with 2.14.0

I had an F# sample for multiclass SVM that work perfectly with version 2.11.0.0, but when I run the same code upgrading to version 2.14.0, SVM fails to converge.

The sample code I am using is here (relevant code part highlighted) - it's a multi-class SVM model on a subset of the MINST/digit recognition dataset:
https://github.com/mathias-brandewinder/Presentations/blob/master/Machine-Learning-With-FSharp/code/Classification/Script.fsx#L49-67

When I upgraded to 2.14.0, I get the error message below. Was there any significant change to the library that would explain this?

Thanks in advance!

Mathias

System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> Accord.ConvergenceException: Convergence could not be attained. Please reduce the cost of misclassification errors by reducing the complexity parameter C or try a different kernel function.
at Accord.MachineLearning.VectorMachines.Learning.SequentialMinimalOptimization.Run(CancellationToken token, Double[] c)
at Accord.MachineLearning.VectorMachines.Learning.BaseSupportVectorLearning.Run(Boolean computeError, CancellationToken token)
at Accord.MachineLearning.VectorMachines.Learning.MulticlassSupportVectorLearning.<>c__DisplayClass4.<>c__DisplayClass6.b__1(Int32 j)
at System.Threading.Tasks.Parallel.<>c__DisplayClassf1.<ForWorker>b__c() at System.Threading.Tasks.Task.InnerInvoke() at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask) at System.Threading.Tasks.Task.<>c__DisplayClass11.<ExecuteSelfReplicating>b__10(Object param0) --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action1 body, Action2 bodyWithState, Func4 bodyWithLocal, Func1 localInit, Action1 localFinally)
at System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive, Action1 body) at Accord.MachineLearning.VectorMachines.Learning.MulticlassSupportVectorLearning.<>c__DisplayClass4.<Run>b__0(Int32 i) at System.Threading.Tasks.Parallel.<>c__DisplayClassf1.b__c()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
at System.Threading.Tasks.Task.<>c__DisplayClass11.b__10(Object param0)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action1 body, Action2 bodyWithState, Func4 bodyWithLocal, Func1 localInit, Action1 localFinally) at System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive, Action1 body)
at Accord.MachineLearning.VectorMachines.Learning.MulticlassSupportVectorLearning.Run(Boolean computeError, CancellationToken token)
at <StartupCode$FSI_0002>.$FSI_0002.main@() in c:\Users\Mathias Brandewinder\Documents\Visual Studio 2013\Projects\AccordDemo\AccordDemo\Script.fsx:line 59
---> (Inner Exception #0) System.AggregateException: One or more errors occurred. ---> Accord.ConvergenceException: Convergence could not be attained. Please reduce the cost of misclassification errors by reducing the complexity parameter C or try a different kernel function.
at Accord.MachineLearning.VectorMachines.Learning.SequentialMinimalOptimization.Run(CancellationToken token, Double[] c)
at Accord.MachineLearning.VectorMachines.Learning.BaseSupportVectorLearning.Run(Boolean computeError, CancellationToken token)
at Accord.MachineLearning.VectorMachines.Learning.MulticlassSupportVectorLearning.<>c__DisplayClass4.<>c__DisplayClass6.b__1(Int32 j)
at System.Threading.Tasks.Parallel.<>c__DisplayClassf1.<ForWorker>b__c() at System.Threading.Tasks.Task.InnerInvoke() at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask) at System.Threading.Tasks.Task.<>c__DisplayClass11.<ExecuteSelfReplicating>b__10(Object param0) --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action1 body, Action2 bodyWithState, Func4 bodyWithLocal, Func1 localInit, Action1 localFinally)
at System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive, Action1 body) at Accord.MachineLearning.VectorMachines.Learning.MulticlassSupportVectorLearning.<>c__DisplayClass4.<Run>b__0(Int32 i) at System.Threading.Tasks.Parallel.<>c__DisplayClassf1.b__c()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
at System.Threading.Tasks.Task.<>c__DisplayClass11.b__10(Object param0)
---> (Inner Exception #0) Accord.ConvergenceException: Convergence could not be attained. Please reduce the cost of misclassification errors by reducing the complexity parameter C or try a different kernel function.
at Accord.MachineLearning.VectorMachines.Learning.SequentialMinimalOptimization.Run(CancellationToken token, Double[] c)
at Accord.MachineLearning.VectorMachines.Learning.BaseSupportVectorLearning.Run(Boolean computeError, CancellationToken token)
at Accord.MachineLearning.VectorMachines.Learning.MulticlassSupportVectorLearning.<>c__DisplayClass4.<>c__DisplayClass6.b__1(Int32 j)
at System.Threading.Tasks.Parallel.<>c__DisplayClassf`1.b__c()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
at System.Threading.Tasks.Task.<>c__DisplayClass11.b__10(Object param0)<---
<---

---> (Inner Exception #1) System.AggregateException: One or more errors occurred. ---> Accord.ConvergenceException: Convergence could not be attained. Please reduce the cost of misclassification errors by reducing the complexity parameter C or try a different kernel function.
at Accord.MachineLearning.VectorMachines.Learning.SequentialMinimalOptimization.Run(CancellationToken token, Double[] c)
at Accord.MachineLearning.VectorMachines.Learning.BaseSupportVectorLearning.Run(Boolean computeError, CancellationToken token)
at Accord.MachineLearning.VectorMachines.Learning.MulticlassSupportVectorLearning.<>c__DisplayClass4.<>c__DisplayClass6.b__1(Int32 j)
at System.Threading.Tasks.Parallel.<>c__DisplayClassf1.<ForWorker>b__c() at System.Threading.Tasks.Task.InnerInvoke() at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask) at System.Threading.Tasks.Task.<>c__DisplayClass11.<ExecuteSelfReplicating>b__10(Object param0) --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action1 body, Action2 bodyWithState, Func4 bodyWithLocal, Func1 localInit, Action1 localFinally)
at System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive, Action1 body) at Accord.MachineLearning.VectorMachines.Learning.MulticlassSupportVectorLearning.<>c__DisplayClass4.<Run>b__0(Int32 i) at System.Threading.Tasks.Parallel.<>c__DisplayClassf1.b__c()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
at System.Threading.Tasks.Task.<>c__DisplayClass11.b__10(Object param0)
---> (Inner Exception #0) Accord.ConvergenceException: Convergence could not be attained. Please reduce the cost of misclassification errors by reducing the complexity parameter C or try a different kernel function.
at Accord.MachineLearning.VectorMachines.Learning.SequentialMinimalOptimization.Run(CancellationToken token, Double[] c)
at Accord.MachineLearning.VectorMachines.Learning.BaseSupportVectorLearning.Run(Boolean computeError, CancellationToken token)
at Accord.MachineLearning.VectorMachines.Learning.MulticlassSupportVectorLearning.<>c__DisplayClass4.<>c__DisplayClass6.b__1(Int32 j)
at System.Threading.Tasks.Parallel.<>c__DisplayClassf`1.b__c()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
at System.Threading.Tasks.Task.<>c__DisplayClass11.b__10(Object param0)<---
<---

Stopped due to error

Binomial probability mass function result differs from Excel result

I'm trying to implement some functionality that was formerly provided via an Excel sheets into a C# application, but the probability mass function differs for some reason from the excel function.

In excel the probabilty mass function, is used this way

=BINOM.DIST(250; 3779; 0.0638; FALSE)

Result:
0.021944019794458

When I try it with Accord.NET

var binom = new BinomialDistribution(3779, 0.0638);
binom.ProbabilityMassFunction(250);

Result:
Infinity

But the cumulative distribution seems to work properly (except for the last few digits, but I assumed this is just some kind of precision error)

=BINOM.DIST(250; 3779; 0.0638; TRUE)

Result:
0.736156366002849
var binom = new BinomialDistribution(3779, 0.0638);
binom.DistributionFunction(250);

Result:
0.736156366002318

Why are the results so different? And is there a way to get the Excel result with Accord?

EDIT: Extreme.Numerics calculates the same result as Excel, but I don't want to use this library, as the license system of this library always led to trouble in the past.

SauvolaThreshold and NiblackThreshold filter are always making whole black image

the code is very simple :
// var filter = new SauvolaThreshold();
var filter = new NiblackThreshold();
using (var b = new Bitmap(baseDir + "demo.jpg"))
{
//filter.K = 0.1;
//filter.R = 110;
//filter.Radius = 10;
ImageBox.Show(filter.Apply(b));
}
the demo.jpg is just extracted from the link below
http://fiji.sc/wiki/index.php/Auto_Local_Threshold#Try_all (Original image)
I tried default parameter and many others , It does the same thing.

Unsafe index out of range in InfiniteAdaptiveGaussKronrod

The current InfiniteAdaptiveGaussKronrod implementation has been translated/adapted from FORTRAN with the help with a Fortran to C++ converter. It has then been converted to C# using unsafe blocks to make handling pointers (as in the original code) easier.

However, there seems to be an index out of error in the allocated unsafe memory blocks which might have been corrupting the stack and/or the heap. For the time being, the allocated memory is being padded with extra leading and trailing zeros so the out of range accesses don't touch protected memory.

Update NuGet packages

It should be necessary to upgrade the NuGet packages so we can provide framework-specific assembly versions. The Accord.MachineLearning.GPL assembly is also missing from the current distribution, and should be added.

LibBFGSCComparisonTest failures

For a while now, 4 of the 7 unit tests in the LibBFGSCComparisonTest class,

  • ParameterBatchTest
  • ParameterBatchTest2
  • ParameterRangeTest
  • ParameterTest1

are failing with the following failure message:

Assert.AreEqual failed. Expected: <LBFGS_CONVERGENCE>. Actual:<LBFGS_SUCCESS>.

For all but one failing tests the stack trace starts with the following line:

at Accord.Tests.Math.LibBFGSComparisonTest.compute(List`1 problems, LBFGSComparer cmp) in LibBFGSComparisonTest.cs: line 301

For the remaining failing unit test (ParameterRangeTest) this stack trace is displayed:

at Accord.Tests.Math.LibBFGSComparisonTest.ParameterRangeTest() in LibBFGSComparisonTest.cs: line 272

NOTE! These failures have been observed when running unit tests for the PCL version of Accord.NET Framework (I am currently having a few issues when trying to run main repository unit tests). Nevertheless, the code masses should be equivalent and I expect that the failures would show up even for the main repository.

Regards,
Anders @ Cureos

NaiveBayes 5th constructor incorrect check on priors

in NaiveBayes`1.cs:293 we see the following

public NaiveBayes(int classes, int inputs, TDistribution[,] priors, double[] classPriors)
{
    if (classes <= 0) throw new ArgumentOutOfRangeException("classes");
    if (priors == null) throw new ArgumentNullException("priors");
    if (priors.Length != classes) throw new DimensionMismatchException("priors");
    if (classPriors.Length != classes) throw new DimensionMismatchException("classPriors");

The condition in the second line from bottom is incorrect for multidimensional arrays, whose .Length property returns the total number of elements in the array. What we want here instead is .GetLength(0) to get the size of the first dimension.

Pull request with fix & test coming.

HiddenConditionalRandomField is not correctly serialized

How to duplicate the issue,

Process 1,
1, train HiddenConditionalRandomField
2, save HiddenConditionalRandomField

Process 2,
1, Load HiddenConditionalRandomField
2, Lots of fields, such as, HiddenConditionalRandomField.Function.Factors.EdgeParameters, are initialized to 0, which are apparently not correct.

Unable to build 2.13.1

Just downloaded latest version 2.13.1 and attempted to build using Visual Studio 2013. After conversion by VS to 2013 solution, fails to build successfully with 35 errors including:

C#: Several methods are applicable to '(double[][])': 'Accord.Math.Matrix.ToMatrix<T>(T[])' and 'Accord.Math.Matrix.ToMatrix<T>(T[], bool)' and 'Accord.Math.Matrix.ToMatrix<T>(T[][])' MatrixFormatter.cs  Accord.Math 334 35  C#  E:\Development\DevCsharp\Common\Accord.NET 2.13.1\Framework\Sources\Accord.Math\Formats\Base\MatrixFormatter.cs

There are multiple instances of the above error.

C#: Unexpected end of expression    Tools.cs    Accord.Math 555 30  C#  E:\Development\DevCsharp\Common\Accord.NET 2.13.1\Framework\Sources\Accord.Math\Tools.cs

Source: Int32 i = (Int32)&f;

Also same error occurs in
Accord.Neuro.LevenbergMarquardtLearning.cs;
Accord.Neuro.ParallelResilientBackPropagationLearning.cs
in the Parallel.For construction

Any thoughts gratefully received.

K-medoids algorithm

Add the k-medoids algorithm in the clustering module.

A description of the k-medoids algorithm can be found in Wikipedia, alongside with worked examples that would help testing and verifying an actual implementation:

For practical pourposes, there is also a BSD licensed k-medoids implementation available on MATLAB Central. Since this implementation is available under the BSD license, anyone willing to work on this feature can leverage the source code on this page and include the original copyright text for the original author, Mo Chen.

In order to implement a new clustering algorithm, start by copying all the contents of the existent KMeans.cs file, and simply rename the class to KMedoids. Then, replace the core algorithm with the k-medoids one. This will simplify getting the IUnsupervisedLearning interface implementation straight.

GC-18: Normalize Statistic models to use a common convergence controlling mechanism

The learning of Logistic Regression models is done in the same fashion as AForge.NET's Neural Networks: a Run method has to be called to run iterations (or batch of iterations) manually, until the user decides convergence has been reached.

The Cox's models, the Hidden Markov Models and Hidden Conditional Random Fields, on the other hand, control the iteration themselves. You specify the number of iterations and tolerance threshold and call them once.

It is needed to decide which is most appropriated and enforce this as a common standard for all learning methods.

GC-5: Maximum cross-correlation formula

In the correlationMatching.cs, there is a formula for Normalized Cross Correlation matrix like:

               for (int i = 0; i < windowSize; i++)
               {
                   for (int j = 0; j < windowSize; j++)
                   {
                       sum1 += w1[i, j] * w2[i, j];
                       sum2 += w2[i, j] * w2[i, j];
                   }
               }
               matrix[n1, n2] = sum1 / System.Math.Sqrt(sum2);

But in reference pages, I found that sum2 should be like : sum2 += w1[i, j] * w1[i, j] * w2[i, j] * w2[i, j];

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.