<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8838260210817728728</id><updated>2026-04-12T06:08:37.596-03:00</updated><category term="English"/><category term="C#"/><category term="Computer Science"/><category term="Português"/><category term="Programming"/><category term="Tips"/><category term="Software"/><category term="Mathematics"/><category term="dot-Net"/><category term="Articles"/><category term="Accord.NET"/><category term="Linux"/><category term="Statistics"/><category term="Open Source"/><category term="Hardware"/><category term="Science"/><category term="Technology"/><category term="Guides"/><category term="Windows"/><category term="Google"/><category term="Debian"/><category term="Microsoft"/><category term="Web"/><category term="Fun"/><category term="Notebook"/><category term="Projects"/><category term="Compras"/><category term="Electronics"/><category term="Quotes"/><category term="News"/><category term="Advices"/><category term="Academic"/><category term="Books"/><category term="C++"/><category term="Curiosities"/><category term="Random Thoughts"/><category term="UFSCar"/><category term="Audio"/><category term="Google Insights"/><category term="Neural Networks"/><category term="São Carlos"/><category term="Java"/><category term="PIC"/><category term="Valinhos"/><category term="Videos"/><category term="Bookmarks"/><category term="Copyright"/><category term="Eventos"/><category term="Guidelines"/><category term="JavaScript"/><category term="Law"/><category term="Licenses"/><category term="Misc"/><category term="Security"/><title type='text'>~/cesarsouza/blog</title><subtitle type='html'>Science, computing and machine learning.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://crsouza.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8838260210817728728/posts/default?max-results=6&amp;redirect=false'/><link rel='alternate' type='text/html' href='http://crsouza.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/8838260210817728728/posts/default?start-index=7&amp;max-results=6&amp;redirect=false'/><author><name>César Souza</name><uri>http://www.blogger.com/profile/17553196159647542225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>169</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>6</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8838260210817728728.post-5655794520198581415</id><published>2015-01-09T22:10:00.000-02:00</published><updated>2015-01-09T22:13:36.806-02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="dot-Net"/><category scheme="http://www.blogger.com/atom/ns#" term="Open Source"/><category scheme="http://www.blogger.com/atom/ns#" term="Tips"/><title type='text'>OxyPlot.Axes.LinearAxis is obsolete</title><content type='html'>&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
Warning&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;461&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&#39;OxyPlot.Axes.LinearAxis.LinearAxis(OxyPlot.Axes.AxisPosition, double, double, string)&#39; is obsolete&lt;/blockquote&gt;
If you try to use&amp;nbsp;&lt;a href=&quot;http://oxyplot.org/&quot;&gt;OxyPlot.Axes.LinearAxis&lt;/a&gt;&#39; constructor &lt;i&gt;with parameters&lt;/i&gt;, the compiler will complain telling you the method has been deprecated and shouldn&#39;t be used. I couldn&#39;t find on the web which was the alternative solution to resolve this issue, but then it occurred to me that, what really is being deprecated, is the &lt;i&gt;passage of arguments&lt;/i&gt;&amp;nbsp;through the constructor&#39;s parameters.&lt;br /&gt;
&lt;br /&gt;
As such, the solution is simply to rewrite your code and call the axis&#39; default constructor instead, using C# object initialization syntax to configure your object:&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;  var&lt;/span&gt; dateAxis = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; OxyPlot.Axes.LinearAxis()
  {
      Position = AxisPosition.Bottom,
      Minimum = range.Min,
      Maximum = range.Max,
      Key = &lt;span class=&quot;str&quot;&gt;&quot;xAxis&quot;&lt;/span&gt;,
      MajorGridlineStyle = LineStyle.Solid,
      MinorGridlineStyle = LineStyle.Dot,
      IntervalLength = 80
  };&lt;/pre&gt;
&lt;br /&gt;
Hope it can be of help if you were getting those warnings like me.</content><link rel='replies' type='application/atom+xml' href='http://crsouza.blogspot.com/feeds/5655794520198581415/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8838260210817728728/5655794520198581415?isPopup=true' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8838260210817728728/posts/default/5655794520198581415'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8838260210817728728/posts/default/5655794520198581415'/><link rel='alternate' type='text/html' href='http://crsouza.blogspot.com/2015/01/oxyplotaxeslinearaxis-is-obsolete.html' title='OxyPlot.Axes.LinearAxis is obsolete'/><author><name>César Souza</name><uri>http://www.blogger.com/profile/17553196159647542225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8838260210817728728.post-5391388638571926869</id><published>2014-12-23T18:04:00.001-02:00</published><updated>2014-12-23T18:04:30.769-02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Academic"/><category scheme="http://www.blogger.com/atom/ns#" term="Accord.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Computer Science"/><category scheme="http://www.blogger.com/atom/ns#" term="English"/><category scheme="http://www.blogger.com/atom/ns#" term="Open Source"/><category scheme="http://www.blogger.com/atom/ns#" term="Software"/><category scheme="http://www.blogger.com/atom/ns#" term="Statistics"/><title type='text'>Liblinear algorithms in C#</title><content type='html'>The Accord.NET Framework is not only an image processing and computer vision framework, but also a machine learning framework for .NET. One of its features is to encompass the exact same algorithms that can be found in other libraries, such as LIBLINEAR, but offer them in .NET withing a common interface ready to be incorporated in your application.&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Download the &lt;a href=&quot;http://accord-framework.net/&quot;&gt;machine learning framework&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Browse the &lt;a href=&quot;https://github.com/accord-net/framework/&quot;&gt;source code online&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;h2&gt;
What is LIBLINEAR?&lt;/h2&gt;
As its authors put, LIBLINEAR is a &lt;a href=&quot;http://www.csie.ntu.edu.tw/~cjlin/liblinear/&quot;&gt;library for large linear classification&lt;/a&gt;. It is intended to be used to tackle classification and regression problems with millions of instances and features, although it can only produce linear classifiers, i.e. &lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_SupportVectorMachine.htm&quot;&gt;linear support vector machines&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
The framework now offers &lt;i&gt;almost&amp;nbsp;&lt;/i&gt;all liblinear algorithms in C#, except for one. Those include:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;0 -- &lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_Learning_ProbabilisticNewtonMethod.htm&quot;&gt;L2-regularized logistic regression (primal)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;1 --&lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_Learning_LinearCoordinateDescent.htm&quot;&gt; L2-regularized L2-loss support vector classification (dual)&amp;nbsp;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;2 -- &lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_Learning_LinearNewtonMethod.htm&quot;&gt;L2-regularized L2-loss support vector classification (primal)&amp;nbsp;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;3 -- &lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_Learning_LinearCoordinateDescent.htm&quot;&gt;L2-regularized L1-loss support vector classification (dual)&amp;nbsp;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;4 --&lt;/li&gt;
&lt;li&gt;5 -- &lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_Learning_LinearCoordinateDescent.htm&quot;&gt;L1-regularized L2-loss support vector classification&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;6 -- &lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_Learning_ProbabilisticCoordinateDescent.htm&quot;&gt;L1-regularized logistic regression&amp;nbsp;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;7 -- &lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_Learning_ProbabilisticDualCoordinateDescent.htm&quot;&gt;L2-regularized logistic regression (dual) for regression&amp;nbsp;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;11 -- &lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_Learning_LinearRegressionNewtonMethod.htm&quot;&gt;L2-regularized L2-loss support vector regression (primal)&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;12 -- &lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_Learning_LinearRegressionCoordinateDescent.htm&quot;&gt;L2-regularized L2-loss support vector regression (dual)&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;13 -- &lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_Learning_LinearRegressionCoordinateDescent.htm&quot;&gt;L2-regularized L1-loss support vector regression (dual)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
As it can be seen, the command line option 4 is missing. Mode #4 refers to the&amp;nbsp;Crammer and Singer&#39;s formulation for multi-class classification. However, the framework already provides different ways to obtain both &lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_MulticlassSupportVectorMachine.htm&quot;&gt;multi-class&lt;/a&gt; as well as &lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_MultilabelSupportVectorMachine.htm&quot;&gt;multi-label&lt;/a&gt; classifiers through both &lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_MulticlassComputeMethod.htm&quot;&gt;Voting and Directed Acyclic Graphs (DDAG)&lt;/a&gt; mechanisms.&lt;br /&gt;
&lt;br /&gt;
Additionally, the framework also offers:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_Learning_SequentialMinimalOptimization.htm&quot;&gt;Sequential Minimial Optimization&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_Learning_SequentialMinimalOptimizationRegression.htm&quot;&gt;Sequential Minimal Optimization for Regression&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_Learning_LeastSquaresLearning.htm&quot;&gt;Least-Squares Learning (LS-SVMs)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_Learning_ProbabilisticOutputCalibration.htm&quot;&gt;Probabilistic Output Learning (Platt&#39;s algorithm)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
The framework can equally load data and load and save support vector machines using the &lt;a href=&quot;http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/&quot;&gt;LIBSVM format&lt;/a&gt;. This means it should be straighforward to create or learn your models using one tool and run it on the other, if that would be necessary. For example, given that Accord.NET can run on mobile applications, it is possible to create and learn your models in a computing grid using liblinear and then &lt;a href=&quot;https://github.com/cureos/accord&quot;&gt;integrate it in your Windows Phone application&lt;/a&gt; by loading it in Accord.NET.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The advantages are that:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Learning algorithms &lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_Learning_ISupportVectorMachineLearning.htm&quot;&gt;implement one common interface&lt;/a&gt;, rather than several functions splitted through the code;&lt;/li&gt;
&lt;li&gt;Algorithms are available as a &lt;a href=&quot;http://accord-framework.net/docs/html/R_Project_Accord_NET.htm&quot;&gt;concise library&lt;/a&gt;, ready to be integrated in your existing or new applications, instead of being part of a black-box command line tool (but it can also be used as a command line tool, &lt;a href=&quot;http://accord-framework.net/samples.html&quot;&gt;see sample applications&lt;/a&gt;);&lt;/li&gt;
&lt;li&gt;The algorithms can run in &lt;a href=&quot;http://accord-framework.net/&quot;&gt;Windows&lt;/a&gt;, &lt;a href=&quot;https://github.com/cureos/shim&quot;&gt;Windows RT&lt;/a&gt;, &lt;a href=&quot;http://accord-framework.net/&quot;&gt;ASP.NET&lt;/a&gt;, &lt;a href=&quot;https://github.com/cureos/shim&quot;&gt;Windows Phone&lt;/a&gt;, &lt;a href=&quot;http://www.codeproject.com/Articles/656059/Catalano-Framework&quot;&gt;Android&lt;/a&gt;, &lt;a href=&quot;https://github.com/cureos/shim&quot;&gt;iOS&lt;/a&gt;, &lt;a href=&quot;http://xamarin.com/&quot;&gt;Linux and MacOS (through Mono/Xamarin)&lt;/a&gt;;&lt;/li&gt;
&lt;li&gt;They can be combined with other meta-algorithms available in the framework to create multi-class and multi-label support vector machines, as well as be part of &lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_CrossValidation.htm&quot;&gt;cross-validation&lt;/a&gt;, &lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_Bootstrap.htm&quot;&gt;bootstrapping&lt;/a&gt; and &lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_SplitSetValidation.htm&quot;&gt;split-set validation techniques&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://www.blogger.com/null&quot; name=&quot;l2_regularized_support_vector_regression&quot;&gt;&lt;/a&gt;When studying and porting the algorithms, I have also set up a&amp;nbsp;&lt;a href=&quot;https://github.com/cesarsouza/liblinear&quot;&gt;liblinear GitHub repository page&lt;/a&gt;&amp;nbsp;to track changes between versions. I hope this repository can also be helpful for other people willing to track modifications done the the &lt;a href=&quot;http://www.csie.ntu.edu.tw/~cjlin/liblinear/&quot;&gt;liblinear project&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
Example&lt;/h2&gt;
&lt;h4&gt;
Learning linearly separable problems with a linear machine&lt;/h4&gt;
In the following example we will create a linear machine to learn a simple linearly separable binary AND problem.&lt;br /&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;rem&quot;&gt;// Create a simple binary AND&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;// classification problem:&lt;/span&gt;

&lt;span class=&quot;kwrd&quot;&gt;double&lt;/span&gt;[][] problem =
{
    &lt;span class=&quot;rem&quot;&gt;//             a    b    a + b&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;double&lt;/span&gt;[] { 0,   0,     0    },
    &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;double&lt;/span&gt;[] { 0,   1,     0    },
    &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;double&lt;/span&gt;[] { 1,   0,     0    },
    &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;double&lt;/span&gt;[] { 1,   1,     1    },
};

&lt;span class=&quot;rem&quot;&gt;// Get the two first columns as the problem&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;// inputs and the last column as the output&lt;/span&gt;
            
&lt;span class=&quot;rem&quot;&gt;// input columns&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;double&lt;/span&gt;[][] inputs = problem.GetColumns(0, 1);

&lt;span class=&quot;rem&quot;&gt;// output column&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;[] outputs = problem.GetColumn(2).ToInt32();

&lt;span class=&quot;rem&quot;&gt;// Plot the problem on screen&lt;/span&gt;
ScatterplotBox.Show(&lt;span class=&quot;str&quot;&gt;&quot;AND&quot;&lt;/span&gt;, inputs, outputs).Hold();
&lt;/pre&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&amp;nbsp;&lt;/pre&gt;
&lt;div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://github.com/accord-net/framework/raw/development/Samples/Tutorials/Classification/1.%20Linear%20SVMs/Resources/AND%20%5Bon%20hold%5D.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://github.com/accord-net/framework/raw/development/Samples/Tutorials/Classification/1.%20Linear%20SVMs/Resources/AND%20%5Bon%20hold%5D.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;The binary AND classification problem. As it can be seen, the AND classification problem is a linearly separable problem, as it is possible to draw a line separating the blue points from the red points with ease.&lt;br /&gt;
&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;rem&quot;&gt;// However, SVMs expect the output value to be&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;// either -1 or +1. As such, we have to convert&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;// it so the vector contains { -1, -1, -1, +1 }:&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;//&lt;/span&gt;
outputs = outputs.Apply(x =&amp;gt; x == 0 ? -1 : 1);


&lt;span class=&quot;rem&quot;&gt;// Create a new linear-SVM for two inputs (a and b)&lt;/span&gt;
SupportVectorMachine svm = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SupportVectorMachine(inputs: 2);

&lt;span class=&quot;rem&quot;&gt;// Create a L2-regularized L2-loss support vector classification&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; teacher = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; LinearDualCoordinateDescent(svm, inputs, outputs)
{
    Loss = Loss.L2,
    Complexity = 1000,
    Tolerance = 1e-5
};

&lt;span class=&quot;rem&quot;&gt;// Learn the machine&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;double&lt;/span&gt; error = teacher.Run(computeError: &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;);

&lt;span class=&quot;rem&quot;&gt;// Compute the machine&#39;s answers for the learned inputs&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;[] answers = inputs.Apply(x =&amp;gt; Math.Sign(svm.Compute(x)));

&lt;span class=&quot;rem&quot;&gt;// Plot the results&lt;/span&gt;
ScatterplotBox.Show(&lt;span class=&quot;str&quot;&gt;&quot;SVM&#39;s answer&quot;&lt;/span&gt;, inputs, answers).Hold();&lt;/pre&gt;
&lt;div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://github.com/accord-net/framework/raw/development/Samples/Tutorials/Classification/1.%20Linear%20SVMs/Resources/AND%20SVM&#39;s%20answer%20%5Bon%20hold%5D.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://github.com/accord-net/framework/raw/development/Samples/Tutorials/Classification/1.%20Linear%20SVMs/Resources/AND%20SVM&#39;s%20answer%20%5Bon%20hold%5D.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;The linear SVM&#39;s answer to the linearly separable AND problem. As it can be seen,&amp;nbsp;a linear&amp;nbsp;SVM can correctly predict the colors for each of the points in the original problem. This happens because the &lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_Learning_LinearNewtonMethod.htm&quot;&gt;SVM&amp;nbsp;learning algorithm&lt;/a&gt; is able to find the line that separates the blue points from the red points.&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Learning non-linearly separable problems with a linear machine through kernel expansions&lt;/h4&gt;
Now, we will move a bit further. We will use an explicit kernel expansion to learn&amp;nbsp;the non-linearly separable exclusive or (XOR) problem.&lt;br /&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;rem&quot;&gt;// Create a simple binary XOR&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;// classification problem:&lt;/span&gt;

&lt;span class=&quot;kwrd&quot;&gt;double&lt;/span&gt;[][] problem =
{
    &lt;span class=&quot;rem&quot;&gt;//             a    b    a XOR b&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;double&lt;/span&gt;[] { 0,   0,      0    },
    &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;double&lt;/span&gt;[] { 0,   1,      1    },
    &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;double&lt;/span&gt;[] { 1,   0,      1    },
    &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;double&lt;/span&gt;[] { 1,   1,      0    },
};

&lt;span class=&quot;rem&quot;&gt;// Get the two first columns as the problem&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;// inputs and the last column as the output&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;// input columns&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;double&lt;/span&gt;[][] inputs = problem.GetColumns(0, 1);

&lt;span class=&quot;rem&quot;&gt;// output column&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;[] outputs = problem.GetColumn(2).ToInt32();

&lt;span class=&quot;rem&quot;&gt;// Plot the problem on screen&lt;/span&gt;
ScatterplotBox.Show(&lt;span class=&quot;str&quot;&gt;&quot;XOR&quot;&lt;/span&gt;, inputs, outputs).Hold();&lt;/pre&gt;
&lt;div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://github.com/accord-net/framework/raw/development/Samples/Tutorials/Classification/1.%20Linear%20SVMs/Resources/XOR%20%5Bon%20hold%5D.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://github.com/accord-net/framework/raw/development/Samples/Tutorials/Classification/1.%20Linear%20SVMs/Resources/XOR%20%5Bon%20hold%5D.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;The binary XOR problem. The XOR problem is not a linerly separable problem, because it is not possible to draw a line separating the blue points from the red points. In this setting, we should expect a &lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_Learning_LinearDualCoordinateDescent.htm&quot;&gt;linear SVM learning algorithm&lt;/a&gt;&amp;nbsp;to fail, because it will not be able to find this line that doesn&#39;t exist.&lt;br /&gt;
&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;rem&quot;&gt;// However, SVMs expect the output value to be&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;// either -1 or +1. As such, we have to convert&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;// it so the vector contains { -1, -1, -1, +1 }:&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;//&lt;/span&gt;
outputs = outputs.Apply(x =&amp;gt; x == 0 ? -1 : 1);


&lt;span class=&quot;rem&quot;&gt;// Create a new linear-SVM for two inputs (a and b)&lt;/span&gt;
SupportVectorMachine svm = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SupportVectorMachine(inputs: 2);

&lt;span class=&quot;rem&quot;&gt;// Create a L2-regularized L2-loss support vector classification&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; teacher = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; LinearDualCoordinateDescent(svm, inputs, outputs)
{
    Loss = Loss.L2,
    Complexity = 1000,
    Tolerance = 1e-5
};

&lt;span class=&quot;rem&quot;&gt;// Learn the machine&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;double&lt;/span&gt; error = teacher.Run(computeError: &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;);

&lt;span class=&quot;rem&quot;&gt;// Compute the machine&#39;s answers for the learned inputs&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;[] answers = inputs.Apply(x =&amp;gt; Math.Sign(svm.Compute(x)));

&lt;span class=&quot;rem&quot;&gt;// Plot the results&lt;/span&gt;
ScatterplotBox.Show(&lt;span class=&quot;str&quot;&gt;&quot;SVM&#39;s answer&quot;&lt;/span&gt;, inputs, answers).Hold();&lt;/pre&gt;
&lt;div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://github.com/accord-net/framework/raw/development/Samples/Tutorials/Classification/1.%20Linear%20SVMs/Resources/XOR%20SVM&#39;s%20answer%20%5Bon%20hold%5D.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://github.com/accord-net/framework/raw/development/Samples/Tutorials/Classification/1.%20Linear%20SVMs/Resources/XOR%20SVM&#39;s%20answer%20%5Bon%20hold%5D.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;As we can see, the linear SVM failed to predict the correct colors for each of the points. The problem is that&amp;nbsp;the&amp;nbsp;answers from a&amp;nbsp;&lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_SupportVectorMachine.htm&quot;&gt;linear SVM&lt;/a&gt; are constrained to be hyperplanes (in this 2D case, lines)&amp;nbsp; that separate the points. Because there is no line that separates the blue points from the red points in the XOR problem, the &lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_Learning_LinearDualCoordinateDescent.htm&quot;&gt;linear SVM learning algorithm tries its best&lt;/a&gt;, finding an approximate solution,&amp;nbsp;but&amp;nbsp;not the XOR&amp;nbsp;solution we were looking for.&lt;br /&gt;
&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;rem&quot;&gt;// Use an explicit kernel expansion to transform the &lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;// non-linear classification problem into a linear one&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;//&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;// Create a quadratic kernel&lt;/span&gt;
Quadratic quadratic = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Quadratic(constant: 1);
            
&lt;span class=&quot;rem&quot;&gt;// Project the inptus into a higher dimensionality space&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;double&lt;/span&gt;[][] expansion = inputs.Apply(quadratic.Transform);


            
&lt;span class=&quot;rem&quot;&gt;// Create a new linear-SVM for the transformed input space&lt;/span&gt;
svm = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SupportVectorMachine(inputs: expansion[0].Length);

&lt;span class=&quot;rem&quot;&gt;// Create the same learning algorithm in the expanded input space&lt;/span&gt;
teacher = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; LinearDualCoordinateDescent(svm, expansion, outputs)
{
    Loss = Loss.L2,
    Complexity = 1000,
    Tolerance = 1e-5
};

&lt;span class=&quot;rem&quot;&gt;// Learn the machine&lt;/span&gt;
error = teacher.Run(computeError: &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;); 

&lt;span class=&quot;rem&quot;&gt;// Compute the machine&#39;s answers for the learned inputs&lt;/span&gt;
answers = expansion.Apply(x =&amp;gt; Math.Sign(svm.Compute(x)));

&lt;span class=&quot;rem&quot;&gt;// Plot the results&lt;/span&gt;
ScatterplotBox.Show(&lt;span class=&quot;str&quot;&gt;&quot;SVM&#39;s answer&quot;&lt;/span&gt;, inputs, answers).Hold();&lt;/pre&gt;
&lt;div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://github.com/accord-net/framework/raw/development/Samples/Tutorials/Classification/1.%20Linear%20SVMs/Resources/XOR%20SVM&#39;s%20answer%20%5Bon%20hold%5D-2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://github.com/accord-net/framework/raw/development/Samples/Tutorials/Classification/1.%20Linear%20SVMs/Resources/XOR%20SVM&#39;s%20answer%20%5Bon%20hold%5D-2.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;By using an explicit kernel expansion, we can use a &lt;strong&gt;linear SVM to learn a non-linearly separable problem&lt;/strong&gt;. This is possible because the kernel transformation projects the data into a higher dimensionality space where the data is indeed linearly separable. For an intuition on how this could be possible, please check the blog post &lt;a href=&quot;http://crsouza.blogspot.com.br/2010/03/kernel-functions-for-machine-learning.html&quot;&gt;kernel functions for machine learning applications&lt;/a&gt;.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Learning liblinear problems from&amp;nbsp;libsvm format&lt;/h4&gt;
Now, we move even further, and use a linear machine to load one of the toy LIBLINEAR problems available in LibSVM format using the framework&#39;s&amp;nbsp;&lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_IO_SparseReader.htm&quot;&gt;SparseReader class&lt;/a&gt;.&lt;br /&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;rem&quot;&gt;// Create a new LibSVM sparse format data reader&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;// to read the Wisconsin&#39;s Breast Cancer dataset&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;//&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; reader = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SparseReader(&lt;span class=&quot;str&quot;&gt;&quot;examples-sparse.txt&quot;&lt;/span&gt;);

&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;[] outputs; &lt;span class=&quot;rem&quot;&gt;// Read the classification problem into dense memory&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;double&lt;/span&gt;[][] inputs = reader.ReadToEnd(sparse: &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;, labels: &lt;span class=&quot;kwrd&quot;&gt;out&lt;/span&gt; outputs);

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

&lt;span class=&quot;rem&quot;&gt;// Create a new linear-SVM for the problem dimensions&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; svm = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SupportVectorMachine(inputs: reader.Dimensions);

&lt;span class=&quot;rem&quot;&gt;// Create a learning algorithm for the problem&#39;s dimensions&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; teacher = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; LinearDualCoordinateDescent(svm, inputs, outputs)
{
    Loss = Loss.L2,
    Complexity = 1000,
    Tolerance = 1e-5
};

&lt;span class=&quot;rem&quot;&gt;// Learn the classification&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;double&lt;/span&gt; error = teacher.Run();

&lt;span class=&quot;rem&quot;&gt;// Compute the machine&#39;s answers for the learned inputs&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;[] answers = inputs.Apply(x =&amp;gt; Math.Sign(svm.Compute(x)));

&lt;span class=&quot;rem&quot;&gt;// Create a confusion matrix to show the machine&#39;s performance&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; m = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; ConfusionMatrix(predicted: answers, expected: outputs);

&lt;span class=&quot;rem&quot;&gt;// Show it onscreen&lt;/span&gt;
DataGridBox.Show(&lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; ConfusionMatrixView(m));&lt;/pre&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://github.com/accord-net/framework/raw/development/Samples/Tutorials/Classification/1.%20Linear%20SVMs/Resources/Data%20Grid.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://github.com/accord-net/framework/raw/development/Samples/Tutorials/Classification/1.%20Linear%20SVMs/Resources/Data%20Grid.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;The &lt;a href=&quot;http://accord-framework.net/docs/html/T_Accord_Statistics_Analysis_ConfusionMatrix.htm&quot;&gt;confusion matrix for the binary classification problem&lt;/a&gt;. As it can be seen, the higher values concentrate in the diagonal. Those values&amp;nbsp;indicate how many hits (correct guesses) the machine&amp;nbsp;was able to make. The other values that don&#39;t lie in the diagonal indicate how many errors (and of what kind) the machine made in this classification problem.&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
The last version of this tutorial can also be seen on the &lt;a href=&quot;https://github.com/accord-net/framework/wiki/Classification:-Linear-Support-Vector-Machines&quot;&gt;project&#39;s wiki pages for linear machines&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;R.-E. Fan, K.-W. Chang, C.-J. Hsieh, X.-R. Wang, and C.-J. Lin. LIBLINEAR: A Library for Large Linear Classification, Journal of Machine Learning Research 9(2008), 1871-1874. Software available at http://www.csie.ntu.edu.tw/~cjlin/liblinear&lt;/li&gt;
&lt;/ul&gt;
</content><link rel='replies' type='application/atom+xml' href='http://crsouza.blogspot.com/feeds/5391388638571926869/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8838260210817728728/5391388638571926869?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8838260210817728728/posts/default/5391388638571926869'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8838260210817728728/posts/default/5391388638571926869'/><link rel='alternate' type='text/html' href='http://crsouza.blogspot.com/2014/12/liblinear-algorithms-in-c.html' title='Liblinear algorithms in C#'/><author><name>César Souza</name><uri>http://www.blogger.com/profile/17553196159647542225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8838260210817728728.post-1912217883112601501</id><published>2013-06-18T11:26:00.000-03:00</published><updated>2013-06-18T11:26:00.711-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Academic"/><category scheme="http://www.blogger.com/atom/ns#" term="Accord.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><title type='text'>A Tutorial On Principal Component Analysis with the Accord.NET Framework</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Principal&amp;nbsp;Component&amp;nbsp;Analysis (&lt;a href=&quot;http://crsouza.blogspot.com.br/2009/09/principal-component-analysis-in-c.html&quot;&gt;PCA&lt;/a&gt;) is a technique for exploratory data analysis with many success applications in several research fields. It is often used in image processing, data analysis, data pre-processing,&amp;nbsp;visualization and is often used as one of the most basic building steps in many complex algorithms.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
One of the most popular resources for learning about PCA is the excellent tutorial due to &lt;a href=&quot;http://www.cs.otago.ac.nz/cosc453/student_tutorials/principal_components.pdf&quot;&gt;Lindsay I Smith&lt;/a&gt;. On her tutorial, Lindsay gives an example application for PCA, presenting and discussing the steps involved in the analysis.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://www2.dc.ufscar.br/~cesar.souza/publications/pca-tutorial.pdf&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjer9YeVzW23ahyphenhyphenc6TD1AK0qcXJxVAGV1iD61etpWopYQHEgOp8N21EbPxDjfjPCDnUZ_PzB8QOCvad1q6iT52Yivl4EM8b_kW-pTy3gXztC0E8ZHt4lnGK3rVn_qyJBaPyU0Jq96X47owl/s400/pca-tutorial.png&quot; width=&quot;397&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Souza, C. R. &quot;&lt;a href=&quot;http://www2.dc.ufscar.br/~cesar.souza/publications/pca-tutorial.pdf&quot;&gt;A Tutorial on Principal Component Analysis with the Accord.NET Framework&lt;/a&gt;&quot;. &lt;br /&gt;
Department of Computing, Federal University of São Carlos, Technical Report, 2012.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
This said, the above technical report aims to show, discuss and otherwise present the reader to the Principal Component Analysis while also&amp;nbsp;reproducing all Lindsay&#39;s example calculations using the &lt;a href=&quot;https://code.google.com/p/accord/&quot;&gt;Accord.NET Framework&lt;/a&gt;. The report comes with complete source C# code listings and also has a&amp;nbsp;&lt;a href=&quot;http://www2.dc.ufscar.br/~cesar.souza/publications/pca-tutorial.zip&quot;&gt;companion&amp;nbsp;Visual Studio solution file&lt;/a&gt; containing all sample source codes ready to be tinkered inside a debug application.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
While the text leaves out the more detailed discussions about the exposed concepts to Lindsay and does not addresses them in full details, it presents some practical examples to reproduce most of the calculations given &amp;nbsp;by Lindsay on her tutorial using solely Accord.NET.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
If you like a practical example on how to perform matrix operations in C#, this tutorial may help getting you started.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://crsouza.blogspot.com/feeds/1912217883112601501/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8838260210817728728/1912217883112601501?isPopup=true' title='12 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8838260210817728728/posts/default/1912217883112601501'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8838260210817728728/posts/default/1912217883112601501'/><link rel='alternate' type='text/html' href='http://crsouza.blogspot.com/2013/06/a-tutorial-on-principal-component.html' title='A Tutorial On Principal Component Analysis with the Accord.NET Framework'/><author><name>César Souza</name><uri>http://www.blogger.com/profile/17553196159647542225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjer9YeVzW23ahyphenhyphenc6TD1AK0qcXJxVAGV1iD61etpWopYQHEgOp8N21EbPxDjfjPCDnUZ_PzB8QOCvad1q6iT52Yivl4EM8b_kW-pTy3gXztC0E8ZHt4lnGK3rVn_qyJBaPyU0Jq96X47owl/s72-c/pca-tutorial.png" height="72" width="72"/><thr:total>12</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8838260210817728728.post-3313386989479644154</id><published>2013-06-03T09:20:00.000-03:00</published><updated>2013-06-03T09:20:00.045-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Accord.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Projects"/><category scheme="http://www.blogger.com/atom/ns#" term="Software"/><title type='text'>Sequence Classifiers in C#: Hidden Conditional Random Fields</title><content type='html'>After a preliminary article on hidden Markov models, some months ago I had finally posted the article on &lt;a href=&quot;http://www.codeproject.com/Articles/559535/Sequence-Classifiers-in-Csharp-Part-II-Hidden-Cond&quot;&gt;Hidden Conditional Random Fields (HCRF) on CodeProject&lt;/a&gt;. The HCRF is a discriminative model, forming the generative-discriminative pair with the hidden Markov model classifers.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://www.codeproject.com/Articles/559535/Sequence-Classifiers-in-Csharp-Part-II-Hidden-Cond&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;388&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi96OLpRpyWm4gBosaY6fe5xE3kx3ZJytDw1VkQbVhi00d1mjKd4LdYs27ZTxQQdr-svsZ9eKg0N0T7Hqh4MnINWjcQ9Kkm-JbawWjNrYOaca6l3F6zx5axj9c-sN80B5Qw0Rz0kbxpxt6I/s640/gerative-discriminative.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
This CodeProject article is a second on a series of articles about sequence classification, the first being about &lt;a href=&quot;http://www.codeproject.com/Articles/541428/Sequence-Classifiers-in-Csharp-Part-I-Hidden-Marko&quot;&gt;Hidden Markov Models&lt;/a&gt;. I&#39;ve used this opportunity to write a little about generative versus discriminative models, and also provide a brief discussion on how Vapnik&#39;s ideas apply to these learning paradigms.&lt;br /&gt;
&lt;br /&gt;
All the code available on those articles are also available within the &lt;a href=&quot;https://code.google.com/p/accord/&quot;&gt;Accord.NET Framework&lt;/a&gt;. Those articles provide good examples on how to use the framework and can be regarded as a practical implementation on how to use those models with the framework.&lt;br /&gt;
&lt;br /&gt;
Complete &lt;a href=&quot;http://accord.googlecode.com/svn/docs/Index.html&quot;&gt;framework documentation can be found live at Google Code&lt;/a&gt;. The framework has now been referred on 30+ publications over the years, and several more are already in the works, by me and &lt;a href=&quot;https://code.google.com/p/accord/wiki/Showcase?tm=6&quot;&gt;users around the world&lt;/a&gt;. &lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Academical publications&lt;/h3&gt;
Talking about publications, the framework has been used within my own research on Computer Vision. If you need help in understanding the inner workings of the HCRF, a more visual explanation on the HCRF derivation can also be found at the presentation I gave on Iberamia 2012 about&lt;a href=&quot;http://www2.dc.ufscar.br/~cesar.souza/publications/iberamia2012-slideshow.pptx&quot;&gt; Fingerspelling Recognition with Support Vector Machines and Hidden Conditional Random Fields&lt;/a&gt;&amp;nbsp;[&lt;a href=&quot;http://www2.dc.ufscar.br/~cesar.souza/publications/iberamia2012-csouza.pdf&quot;&gt;pdf&lt;/a&gt;].&lt;br /&gt;
&lt;br /&gt;
An application to a more interesting problem, namely natural words drawn from Sign Languages using a Microsoft Kinect, has also been accepted for publication at the &lt;a href=&quot;http://www.mldm.de/&quot;&gt;9th International Conference on Machine Learning and Data Mining, MLDM 2013&lt;/a&gt;, and will be available publicly shortly.&lt;br /&gt;
&lt;h3&gt;
&lt;br /&gt;&lt;/h3&gt;
As usual, hope you find it interesting!&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://crsouza.blogspot.com/feeds/3313386989479644154/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8838260210817728728/3313386989479644154?isPopup=true' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8838260210817728728/posts/default/3313386989479644154'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8838260210817728728/posts/default/3313386989479644154'/><link rel='alternate' type='text/html' href='http://crsouza.blogspot.com/2013/06/sequence-classifiers-in-c-hidden.html' title='Sequence Classifiers in C#: Hidden Conditional Random Fields'/><author><name>César Souza</name><uri>http://www.blogger.com/profile/17553196159647542225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi96OLpRpyWm4gBosaY6fe5xE3kx3ZJytDw1VkQbVhi00d1mjKd4LdYs27ZTxQQdr-svsZ9eKg0N0T7Hqh4MnINWjcQ9Kkm-JbawWjNrYOaca6l3F6zx5axj9c-sN80B5Qw0Rz0kbxpxt6I/s72-c/gerative-discriminative.png" height="72" width="72"/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8838260210817728728.post-3385660343838262375</id><published>2013-05-06T10:21:00.000-03:00</published><updated>2013-05-28T21:39:10.125-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Accord.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Microsoft"/><category scheme="http://www.blogger.com/atom/ns#" term="Technology"/><category scheme="http://www.blogger.com/atom/ns#" term="Videos"/><title type='text'>Point and Call and the Windows Phone Ecosystem</title><content type='html'>So a few days ago I bought a &lt;a href=&quot;http://www.nokia.com/gb-en/phones/phone/lumia620/&quot;&gt;Windows Phone device&lt;/a&gt;. So far, I am impressed with the Windows Phone ecosystem.&lt;br /&gt;
&lt;br /&gt;
The nicest thing is that I was finally able to test an app I&#39;ve been eager to try for months: &lt;a href=&quot;http://www.windowsphone.com/s?appid=fe1a5891-61de-4553-8741-fcce23a56291&quot;&gt;Point and Call&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;640&#39; height=&#39;480&#39; src=&#39;https://www.youtube.com/embed/Up0F8OdRia0?feature=player_embedded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
Point-and-call in everyday life.&lt;/div&gt;
&lt;br /&gt;
Now, the most interesting part, is that this app uses part of the&lt;a href=&quot;https://code.google.com/p/accord/&quot;&gt; Accord.NET Framework&lt;/a&gt; to do its magic :-)&lt;br /&gt;
&lt;br /&gt;
The app author, Antti Savolainen, was kind enough to share some details about his app. It uses part of the SVMs framelet from Accord.NET to do the digit recognition, mostly based on one of the earlier &lt;a href=&quot;http://www.codeproject.com/Articles/106583/Handwriting-Recognition-Revisited-Kernel-Support-V&quot;&gt;CodeProject articles I&#39;ve posted in the past&lt;/a&gt;. Needless to say, Antti did an &lt;a href=&quot;http://www.wpcentral.com/point-and-call-dialing-alternative-windows-phone-8&quot;&gt;awesome job&lt;/a&gt;, as the SVM part was surely just a tiny fraction of all the work in preprocessing, adjusting, locating, and doing the right things at the right times that I would never be able to figure out alone :-)&lt;br /&gt;
&lt;br /&gt;
Surely, he and his company, &lt;a href=&quot;http://www.windowsphone.com/en-US/store/publishers?publisherId=Sadiga&amp;amp;appId=fe1a5891-61de-4553-8741-fcce23a56291&quot;&gt;Sadiga&lt;/a&gt;, deserves all the credits for this neat app!&lt;br /&gt;
&lt;br /&gt;
If you would like find more interesting uses of the Accord.NET Framework, don&#39;t forget to check the &lt;a href=&quot;https://code.google.com/p/accord/wiki/Showcase&quot;&gt;framework&#39;s Showcase&lt;/a&gt; page for details!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://crsouza.blogspot.com/feeds/3385660343838262375/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8838260210817728728/3385660343838262375?isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8838260210817728728/posts/default/3385660343838262375'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8838260210817728728/posts/default/3385660343838262375'/><link rel='alternate' type='text/html' href='http://crsouza.blogspot.com/2013/05/point-and-call-and-windows-phone.html' title='Point and Call and the Windows Phone Ecosystem'/><author><name>César Souza</name><uri>http://www.blogger.com/profile/17553196159647542225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8838260210817728728.post-5214179566315843200</id><published>2013-02-14T10:12:00.000-02:00</published><updated>2013-02-14T10:12:00.184-02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Accord.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="Articles"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Science"/><category scheme="http://www.blogger.com/atom/ns#" term="Software"/><title type='text'>Sequence Classifiers in C#: Hidden Markov Models</title><content type='html'>&lt;br /&gt;
&lt;br /&gt;
Few days ago&lt;a href=&quot;http://www.codeproject.com/Articles/541428/Sequence-Classifiers-in-Csharp-Part-I-Hidden-Marko&quot;&gt; I published a new article on CodeProject&lt;/a&gt;, about classifiers based on banks of hidden Markov models to accomplish &lt;a href=&quot;http://www.codeproject.com/Articles/541428/Sequence-Classifiers-in-Csharp-Part-I-Hidden-Marko#classification&quot;&gt;sequence classification&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQp6569PgHQ8ba4bwnBz1wyyYcIF9Qp6rGm29Y3R-kr9a_huNRWipZxm6LdF7q0ucvTdj3kwcCMZ7VoktBfYNDyVLPKKeZCLK_mkQaCrqxHyrOWm8XkalQ70LeYuoxwBLx8h94g6ohMCCu/s1600/sample-5.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;465&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQp6569PgHQ8ba4bwnBz1wyyYcIF9Qp6rGm29Y3R-kr9a_huNRWipZxm6LdF7q0ucvTdj3kwcCMZ7VoktBfYNDyVLPKKeZCLK_mkQaCrqxHyrOWm8XkalQ70LeYuoxwBLx8h94g6ohMCCu/s640/sample-5.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
While I have written about &lt;a href=&quot;http://crsouza.blogspot.com.br/2010/03/hidden-markov-models-in-c.html&quot;&gt;this subject in the past on this very blog&lt;/a&gt;, this time the article deals with Gaussian, &lt;a href=&quot;http://accord.googlecode.com/svn/docs/html/T_Accord_Statistics_Models_Markov_HiddenMarkovClassifier_1.htm&quot;&gt;continuous-density hidden Markov&lt;/a&gt; models rather than discrete ones. Plus, at this time the &lt;a href=&quot;https://code.google.com/p/accord/&quot;&gt;Accord.NET Framework&lt;/a&gt; has evolved much since that 2010 post, and the new article reflects &lt;a href=&quot;http://code.google.com/p/accord/wiki/SampleApplications?tm=6&quot;&gt;most of the improvements&lt;/a&gt; and &lt;a href=&quot;http://crsouza.blogspot.com.br/2012/12/deep-neural-networks-and-restricted.html&quot;&gt;additions&lt;/a&gt; in those last two years.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://accord.googlecode.com/svn/wiki/images/Accord.NET%20(logo%20large).png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;297&quot; src=&quot;http://accord.googlecode.com/svn/wiki/images/Accord.NET%20(logo%20large).png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
In the meantime, this article is also serving as a hook to a future article, an article about &lt;a href=&quot;http://accord.googlecode.com/svn/docs/html/T_Accord_Statistics_Models_Fields_HiddenConditionalRandomField_1.htm&quot;&gt;Hidden Conditional Random Fields&lt;/a&gt; (HCRFs). The HCRF models can serve the same purpose as the HMMs but can be generalized to arbitrary graph structures and be trained discriminatively, which could be an advantage on classification tasks.&lt;br /&gt;
&lt;br /&gt;
As always, I hope readers can find it a good read :-)&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://crsouza.blogspot.com/feeds/5214179566315843200/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8838260210817728728/5214179566315843200?isPopup=true' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8838260210817728728/posts/default/5214179566315843200'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8838260210817728728/posts/default/5214179566315843200'/><link rel='alternate' type='text/html' href='http://crsouza.blogspot.com/2013/02/sequence-classifiers-in-c-hidden-markov.html' title='Sequence Classifiers in C#: Hidden Markov Models'/><author><name>César Souza</name><uri>http://www.blogger.com/profile/17553196159647542225</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQp6569PgHQ8ba4bwnBz1wyyYcIF9Qp6rGm29Y3R-kr9a_huNRWipZxm6LdF7q0ucvTdj3kwcCMZ7VoktBfYNDyVLPKKeZCLK_mkQaCrqxHyrOWm8XkalQ70LeYuoxwBLx8h94g6ohMCCu/s72-c/sample-5.png" height="72" width="72"/><thr:total>11</thr:total></entry></feed>