Hello and welcome to the first installment of posts on solving common programming challenges using functional programming in F#.
I've been in software development professionally for over ten years now. I've gained a lot of experience with many different programming languages. Object oriented design was my main tool of choice. Object oriented design while effective is not the only software design methodology available to you as a programmer. One of the most important lessons to be learned in software development in my opinion is to use the best tool for the job.
I've decided to learn functional programming in order to improve my problem solving skills. F# and functional programming requires a different approach to solving problems than other methodologies. Trying to solve problems using a new way of thinking is a great way to stimulate neuroplasticity and learn a new skill.
The 3n+1 programming challenge
The programming challenge that I chose to begin learning F# is called the 3n+1 problem. I discovered the challenge in the book "Programming Challenges: The Programming Contest Training Manual" by Steven S. Skiena and Miguel A. Revilla which you can find on amazon.com here
Here's the gist:
You start by creating an algorithm that accepts integer n as input. The algorithm will generate a sequence of numbers based on it's input. Starting with n, the algorithm will check to see if n is odd or even. if n is odd, then you will generate the next value in the sequence by calculating n * 3 + 1. If n is even, the next value in the sequence is n / 2. You will then repeat the process for each new value added to the sequence until n = 1.
Here is an example of the sequence generated when n = 22;
22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1
The cycle length is the length of the sequence generated for a given number. In this case, the cycle length is 16 because the sequence has 16 integers (including the input as well as the number 1).
Given two numbers i and j, you are to determine the maximum cycle length over all numbers between i and j including both start and end points.
Here are some examples:
i j max cycle length
1 10 20
100 200 125
201 210 89
900 1000 174
Let's start by discussing some of the fundamental differences between between the two solutions.
The C# solution
I've been working in C# for over a decade now. Naturally my instincts tell me to try to tackle this problem using object oriented design principles. So here is a solution that I design using C# and OOP.
CalculationResult.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ThreePlusOneCSharp
{
public class CalculationResult
{
public int InputValue { get; set; }
public List<int> ResultList { get; set; }
public int CycleLength
{
get
{
return ResultList.Count;
}
}
public CalculationResult()
{
this.ResultList = new List<int>();
}
}
}
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ThreePlusOneCSharp
{
class Program
{
static void Main(string[] args)
{
int startRange = int.Parse(args[0]);
int endRange = int.Parse(args[1]);
int maxCycleLength = _CalculateMaxCycleLengthForRange(startRange, endRange);
Console.WriteLine("The max Cycle length for {0}..{1} is = '{2}'", args[0], args[1], maxCycleLength.ToString());
}
private static int _CalculateMaxCycleLengthForRange(int startRange, int endRange)
{
var cycleLengths = new List<int>();
for (int rangeIndex = startRange; rangeIndex <= endRange; rangeIndex++)
{
var calcResult = new CalculationResult();
calcResult.InputValue = rangeIndex;
calcResult.ResultList.Add(rangeIndex);
var result = _CalculateNextInput(calcResult);
cycleLengths.Add(result.CycleLength);
}
return cycleLengths.Max();
}
private static CalculationResult _CalculateNextInput(CalculationResult result)
{
result.ResultList.Add(result.InputValue);
if (result.InputValue % 2 == 0)
result.InputValue = (result.InputValue / 2);
else
result.InputValue = (result.InputValue * 3) + 1;
if (result.InputValue == 1)
return result;
return _CalculateNextInput(result);
}
}
}
As you can see, I created a class to hold the input value as well as a list of all new inputs generated for the specified input. I created a property called CycleLength which returns the count of the list of inputs generated. We use recursion to call _CalculateNextInput which allows us to keep up with the cycle length for the given input. The _CalculateMaxCycleLengthForRange routine will iterate through all numbers between i and j and keep a list of each cycle length. Once all integers in the range have been processed, we return the max cycle length from all cycle lengths in the list.
The F# solution
let rec generateSequence num =
seq {
yield num
if num <> 1 then
match num with
| x when x % 2 = 0 -> yield! generateSequence (x / 2)
| x -> yield! generateSequence ((x * 3) + 1)
}
let getMaxCycleLength range =
let valueSequences =
seq {
for number in range
do yield seq {
yield! generateSequence number
}
}
let cycleLengthSequence =
seq {
for sequence in valueSequences
do yield Seq.toList(sequence).Length
}
Seq.max(cycleLengthSequence)
[<EntryPoint>]
let main args =
let low, high =
int args.[0], int args.[1]
let input = [low .. high]
let cycleLength =
getMaxCycleLength input
System.Console.Write(" {0} ", cycleLength)
0
Conclusion
Join me for my next article where I will discuss in detail the two different implementations.

In one of my previous posts called Machine learning resources for .NET developers, I introduced a machine learning library called numl.net. numl.net is a machine learning library for .NET created by Seth Juarez. You can find the library here and Seth's blog here. When I began researching the library, I learned quickly that one of Seth's goals in writing numl.net was to abstract away the complexities that stops many software developers from trying their hand at machine learning. I must say that in my opinion, he has done a wonderful job in accomplishing this goal!
Tutorial
I've decided to throw together a small tutorial to show you just how easy it is to use numl.net to perform predictions. This tutorial will use structured learning by way of a decision tree to perform predictions. I will use the infamous Iris Data set which contains data 3 different types of Iris flowers and the data that defines them. Before we get into code, let's look at some basic terminology first.
With numl.net you create a POCO (plain old CLR object) to use for training as well as predictions. There will be properties that you will specify known values (features) so that you can predict the value of an unknown property value (label). numl.net makes identifying features and labels easy, you simply mark your properties with the [Feature] attribute or the [Label] attribute (there is also a [StringLabel] attribute as well). Here is an example of the Iris class that we will use in this tutorial.
using numl.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NumlDemo
{
/// <summary>
/// Represents an Iris in the infamous Iris classification dataset (Fisher, 1936)
/// Each feature property will be used for training as well as prediction. The label
/// property is the value to be predicted. In this case, it's which type of Iris we are dealing with.
/// </summary>
public class Iris
{
//Length in centimeters
[Feature]
public double SepalLength { get; set; }
//Width in centimeters
[Feature]
public double SepalWidth { get; set; }
//Length in centimeters
[Feature]
public double PetalLength { get; set; }
//Width in centimeters
[Feature]
public double PetalWidth { get; set; }
//-- Iris Setosa
//-- Iris Versicolour
//-- Iris Virginica
public enum IrisTypes
{
IrisSetosa,
IrisVersicolour,
IrisVirginica
}
[Label]
public IrisTypes IrisClass { get; set; } //This is the label or value that we wish to predict based on the supplied features
}
}
As you can see, we have a simple POCO Iris class, which defines four features and one label. The Iris training data can be found here . Here is an example of the data found in the file.
5.1,3.5,1.4,0.2,Iris-setosa
6.3,2.5,4.9,1.5,Iris-versicolor
6.0,3.0,4.8,1.8,Iris-virginica
The first four values are doubles which represent the features Sepal Length, Sepal Width, Petal Length, Petal Width. The final value is an enum that represents the label that we will predict which is the class of Iris.
We have the Iris class, so now we need a method to parse the training data file and generate a static List<Iris> collection. Here is the code:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NumlDemo
{
/// <summary>
/// Provides the services to parse the training data files
/// </summary>
public static class IrisDataParserService
{
//provides the training data to create the predictive model
public static List<Iris> TrainingIrisData { get; set; }
/// <summary>
/// Reads the trainingDataFile and populates the TrainingIrisData list
/// </summary>
/// <param name="trainingDataFile">File full of Iris data</param>
/// <returns></returns>
public static void LoadIrisTrainingData(string trainingDataFile)
{
//if we don't have a training data file
if (string.IsNullOrEmpty(trainingDataFile))
throw new ArgumentNullException("trainingDataFile");
//if the file doesn't exist on the file system
if (!File.Exists(trainingDataFile))
throw new FileNotFoundException();
if (TrainingIrisData == null)
//initialize the return training data set
TrainingIrisData = new List<Iris>();
//read the entire file contents into a string
using (var fileReader = new StreamReader(new FileStream(trainingDataFile, FileMode.Open)))
{
string fileLineContents;
while ((fileLineContents = fileReader.ReadLine()) != null)
{
//split the current line into an array of values
var irisValues = fileLineContents.Split(',');
double sepalLength = 0.0;
double sepalWidth = 0.0;
double petalLength = 0.0;
double petalWidth = 0.0;
if (irisValues.Length == 5)
{
Iris currentIris = new Iris();
double.TryParse(irisValues[0], out sepalLength);
currentIris.SepalLength = sepalLength;
double.TryParse(irisValues[1], out sepalWidth);
currentIris.SepalWidth = sepalWidth;
double.TryParse(irisValues[2], out petalLength);
currentIris.PetalLength = petalLength;
double.TryParse(irisValues[3], out petalWidth);
currentIris.PetalWidth = petalWidth;
if (irisValues[4] == "Iris-setosa")
currentIris.IrisClass = Iris.IrisTypes.IrisSetosa;
else if (irisValues[4] == "Iris-versicolor")
currentIris.IrisClass = Iris.IrisTypes.IrisVersicolour;
else
currentIris.IrisClass = Iris.IrisTypes.IrisVirginica;
IrisDataParserService.TrainingIrisData.Add(currentIris);
}
}
}
}
}
}
This code is pretty standard. We simply read each line in the file, split the values out into an array, and populate a List<Iris> collection of Iris objects based on the data found in the file.
Now the magic
Using the numl.net library, we need only use three classes to perform a prediction based on the Iris data set. We start with a Descriptor, which identifies the class in which we will learn and predict. Next, we will instantiate a DecisionTreeGenerator, passing the descriptor to the constructor. Finally, we will create our prediction model by calling the Generate method of the DecisionTreeGenerator, passing the training data (IEnumerable<Iris>) to the Generate method. The generate method will provide us with a model in which we can perform our prediction.
Here is the code:
using numl;
using numl.Model;
using numl.Supervised;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NumlDemo
{
class Program
{
public static void Main(string[] args)
{
//get the descriptor that describes the features and label from the Iris training objects
var irisDescriptor = Descriptor.Create<Iris>();
//create a decision tree generator and teach it about the Iris descriptor
var decisionTreeGenerator = new DecisionTreeGenerator(irisDescriptor);
//load the training data
IrisDataParserService.LoadIrisTrainingData(@"D:\Development\machinelearning\Iris Dataset\bezdekIris.data");
//create a model based on our training data using the decision tree generator
var decisionTreeModel = decisionTreeGenerator.Generate(IrisDataParserService.TrainingIrisData);
//create an iris that should be an Iris Setosa
var irisSetosa = new Iris
{
SepalLength = 5.1,
SepalWidth = 3.5,
PetalLength = 1.4,
PetalWidth = 0.2
};
//create an iris that should be an Iris Versicolor
var irisVersiColor = new Iris
{
SepalLength = 6.1,
SepalWidth = 2.8,
PetalLength = 4.0,
PetalWidth = 1.3
};
//create an iris that should be an Iris Virginica
var irisVirginica = new Iris
{
SepalLength = 7.7,
SepalWidth = 2.8,
PetalLength = 6.7,
PetalWidth = 2.0
};
var irisSetosaClass = decisionTreeModel.Predict<Iris>(irisSetosa);
var irisVersiColorClass = decisionTreeModel.Predict<Iris>(irisVersiColor);
var irisVirginicaClass = decisionTreeModel.Predict<Iris>(irisVirginica);
Console.WriteLine("The Iris Setosa was predicted as {0}",
irisSetosaClass.IrisClass.ToString());
Console.WriteLine("The Iris Versicolor was predicted as {0}",
irisVersiColorClass.IrisClass.ToString());
Console.WriteLine("The Iris Virginica was predicted as {0}",
irisVirginicaClass.IrisClass.ToString());
Console.ReadKey();
}
}
}
And that's all there is to it. As you can see, you can use the prediction model accurately and there's no math, only simple abstractions.
I hope this has peaked your interest in the numl.net library for machine learning in .NET.
Feel free to post any questions or opinions.
Thanks for reading!
Buddy James

Xamarin 2.0 : The prayers of mobile developers have been answered
Hello, and welcome to my latest article on refactorthis.net. This article is a product review of the latest release by Xamarin called Xamarin 2.0.
The state of mobile development
We are experiencing a revolution unlike any in the history of software development. Thanks to mobile devices, most of the world's population holds more computing power in their pocket than I could have dreamed about when I first started writing programs back in the days before the internet. I remember when we dialed into BBS or Bulletin Board Systems which were communities that ran on your neighbor's computer and allowed us to send email and play text based door games to pass the time. My how times have changed. And with this change brings a new paradigm for software developers to learn in order to keep up with the now hyper speed pace of devices and technology. We now live in a world where our TV's have IP addresses, and our children have cell phones. At the forefront of this new way of software development is Xamarin.
On 02/20/2013 Xamarin announced the release of Xamarin 2.0. The Xamarin 2.0 product release includes many ground breaking changes to Xamarin's mobile development tools for Android and iOS development with C#. The Xamarin 2.0 release includes:
A new IDE called Xamarin Studio which is an IDE aimed specifically at mobile development using C#.
A new component store with a catalog of free and paid libraries to help developers create better mobile applications faster.
A new pricing tier which includes a free starter edition for developers starting out with mobile development.
Visual Studio integration that makes developing iOS applications in Visual Studio possible.
I've been extremely excited about the release of Xamarin 2.0. This article is a product review of the new features of Xamarin 2.0 and my experience with the new features.
Xamarin.iOS for Visual Studio
I'm a .NET developer and for the past 10 years, Microsoft related technologies have put food on my table. C# is one of the most popular programming languages around today. Xamarin has lead the way for C# developers interested in developing mobile applications using C#. The release of Xamarin 2.0 has provided what many thought to be impossible. iOS development from within Visual Studio. Here is my experience with Xamarin.iOS and Visual Studio.
One thing to understand is that even though Xamarin.iOS allows you to develop iOS applications from within Microsoft Visual Studio, you still need a machine running Mac OS X, the iPhone SDK, and XCode to allow this integration to work.
Due to Apple's licensing, you can't build iOS applications on anything other than an Apple device. The Xamarin 2.0 release includes Xamarin.iOS which allows us to write our code in C# using Visual Studio, then build or deploy the application using a build server which is a system running Mac OS X and XCode.
Xamarin.iOS will search the network for a build server that meets the requirements to build iOS applications. Visual Studio will prompt the user with a list of all machines on the network that meet the build server requirements and allow you to choose which build server to use.
Since I don't own a Mac, I asked my brother-in-law if we could use his OS X machine to test the integration.
We ran into an issue at first in which the Xamarin.iOS host prompt helped me to diagnose. It turned out that we needed to change the firewall settings to open port 5000 to allow the two machines to communicate to build the application.
After my initial testing at my brother-in-law's place, I decided to continue my research from home.
I wanted to see if there were any other alternatives to buying a Mac in order to be able to develop iOS applications. I ran across a service called MacInCloud which allows you to rent a Mac development server in the cloud! They offer several options regarding payment plans. They even offer the ability to pay for use by the hour. Xamarin studio is found in the list of supported software on their features page.
This is a great option for developers like me who wish to develop iOS applications but aren't ready to run out and buy a Mac just yet.
My final thoughts on the Visual Studio Xamarin.iOS development integration are as follows.
Is the process 100% transparent? No. Though I don't believe it will ever be possible to make a completely transparent experience. That would require running Visual Studio on OS X, or Apple removing their restrictions regarding iOS development. EDIT It's been brought to my attention that since you will need to run a Mac system anyway, some people find it useful to run Visual Studio inside of a Virtual machine on the Mac. This will make the integration even better. You may also run the two machines side by side and use a program like VNC Server/Viewer to switch between the two environments. As I've stated earlier, you can also run the Mac build server in a virtual machine by using a service such as Macinthecloud. If you find a useful combination that isn't mentioned here, feel free to share in the comments!
Is this the best option that .NET developers have regarding developing iOS applications using Visual Studio on in Microsoft Windows? Yes. If you are a .NET developer and you are interested in developing applications for iOS, download Xamarin 2.0 and give it a try. Your mileage may vary.
Xamarin Studio — Its like MonoDevelop on steroids
One of the greatest parts of the Xamarin 2.0 release has got to be the addition of their new IDE, Xamarin Studio. Xamarin Studio is a multi-platform IDE that is aimed specifically at mobile development using .NET. The IDE is based on the older MonoDevelop IDE, however, there are new features that make this a completely different product.
MonoDevelop had a look and feel about it that suggested that it was aimed at Linux developers. The new Xamarin Studio has moved the focus away from Linux developers and is geared more toward the Mac OS X crowd. The motivation behind the new Xamarin Studio IDE was very much geared toward User Experience and productivity.
The IDE looks sleek and has a very minimalist design. The IDE exposes its features based on the context of the current developers actions. For instance, you don't see debugging buttons unless you are in debug mode. You don't have useless windows hanging around when they are aren't usable in the current context. IDE development has been geared toward developers so they've often tried to add more features at the price of sacrificing user experience. Xamarin understands that developers are users too and that providing a perfect blend of UX and functionality is the best approach to use when designing an IDE. I think that this was a brilliant move on Xamarin's part and I wouldn't be surprised to see some of the other well known IDEs following this design in future releases.
The IDE's search bar is another great addition to the Xamarin Studio IDE. The search bar can be found on the start screen as well as while developing an application. The search offers an auto complete type of functionality which provides results for everything from key shortcuts to code specific namespaces and classes.
The search bar provides context specific search results based on your current location within the IDE.
The IDE offers other great tools such as:
A regex builder
An XML designer
Integrated Source Control
Unit testing capabilities
When ran from an OS X machine, Xamarin studio offers iOS specific project templates with the ability to create, build, and deploy iOS applications.
Xamarin 2.0 also offers project templates for creating Android applications. One of the great tools offered by the Xamarin Studio is an Android user interface designer that allows the developer to drag and drop Android user interface widgets to allow the developer to visually create the UI for the Android application. The UI designer in Xamarin Studio is more intuitive and feature rich than the original designer included in the eclipse IDE! You also get the same Android UI designer from within Visual Studio when using MonoDroid for Android application development.
Xamarin Studio was built with the user in mind. The IDE is built to increase productivity by providing world class user experience. I'm very happy with the Xamarin Studio and I believe that I will probably use it more than Visual Studio when developing mobile applications.
Component Store
The component store is a wonderful resource for developers using Xamarin to develop Android and iOS applications using C#. The component store ties directly into the Xamarin Studio IDE and also has a web interface for obtaining components that will greatly increase your productivity in developing professional looking mobile applications. The Component store offers controls, frameworks, themes, web services, and other components that will make your life as an Android or iOS developer much easier. They offer free and paid components to assist in your mobile development efforts. You can even create your own libraries and submit them to the component store for review to be included in the list of components. I believe Xamarin's component store will be a great resource for anyone developing Android and iOS applications using Xamarin's development tools.
Starter Edition
In the past, Xamarin offered a free trial for developers to try out their product. The free trial simply limited the functionality of the product. One of the biggest limitations in my opinion was the inability to deploy to a physical device to test your applications. When I first began testing Xamarin for Android development, this limitation was a show stopper for me. I have had no luck with the Android emulator and this seems to be a problem with many Android developers. The emulator is slow and unstable. So when I heard that Xamarin had changed their licensing and now offers a free starter edition, I was thrilled. The starter edition is free and allows testing an Android application on the developer's Android device. You can even deploy the application to the Android App stores. There are limitations on Android applications that are created under the Starter edition. They can’t call to third party native libraries (i.e., P/Invoke) and they are capped in size at a max of 32k of IL code. However, we as developers at least have the option to deploy to our devices and test the applications so we can make an informed decision regarding upgrading to their new Independent developer license which at $299 is the cheapest license that Xamarin has offered to date! So if you are like me and you've put off trying Xamarin because of the restrictions that bound you to the horrible Android emulator, there should be nothing stopping you from giving the new Xamarin 2.0 release a try.
Conclusion
This concludes my review on Xamarin 2.0. I'd like to say that I'm very excited about the possibilities that these enhancements provide for .NET developers that wish to develop applications for iOS and Android using C# and .NET.
The free starter edition provides a solution to my biggest issue with the Xamarin tool set, and that's the ability to test your applications built with MonoDroid on your device instead of the horrible emulator.
The Xamarin.iOS integration with Microsoft Visual Studio is the best option to allow developers to develop iOS applications while using their favorite IDE to do it.
The Xamarin Studio IDE is a beautiful, feature rich product that will change the way that we look at what an IDE should be.
If you are a .NET developer and you are looking into mobile development, now is the time to check out Xamarin 2.0. I'm anxious to see what the next release will bring. Oh and don't forget about the Xamarin Evolve 2013 world wide developer conference in Austin, Texas from April 14-17 2013. I hope to see you there!
Thanks for reading!
Buddy James

Greetings friends and welcome to this article on Machine learning libraries for .NET developers. Machine learning is a hot topic right now and for good reason. Personally, I haven't been so excited about a technology since my computer used my 2800 baud modem to dial into a BBS over 17 years ago. The thought that my computer could communicate with another computer was so fascinating to me. That moment was the very moment that would forever change my life. I learned a lot about DOS by writing batch scripts and running other programs that allowed me to visit and then run a BBS system. It eventually lead me to QBasic. I wanted to learn to write BBS door games and QBasic was included as a part of a standard DOS installation back then.
Fast forward 17 years and I'm still in love with computers, programming, and the concept of communication between machines. The magic never disappeared. So when i first learned about the concept of Machine learning, I felt like that 13 year old kid again. The idea that a machine can learn to do things that it has not been programmed to do is now a passion of mine. The concepts of Machine learning have an extreme learning curve, however, I believe that we as humans can do anything that we put our mind to. So I began looking around for tutorials on machine learning. I found many great tutorials and books, however, most of them involved using python. I have nothing against python. As a matter of fact, I find it ironic that I started with BASIC and now in this moment of "rebirth" I'm beginning to use python which looks a lot like BASIC in many ways. The fact of the matter remains, I'm a .NET developer. I've spent the last 9 years in the .NET framework and I love the technology. C# is an awesome programming language and it's hard to imagine life without Visual Studio. What can I say, the IDE has spoiled me.
While I scoured the internet looking for tutorials related to Machine learning resources for .NET developers, I wished that there was a one resource that would assist me in my search for resources to help me achieve my goal.
Well that's what this article is all about. In this article, I will introduce you to some .NET libraries that will assist you in your quest to learn about Machine learning.
NND Neural Network Designer by Bragisoft
The Neural Network Designer project (NND) is a DBMS management system for neural networks that was created by Jan Bogaerts. The designer application is developed using WPF, and is a user interface which allows you to design your neural network, query the network, create and configure chat bots that are capable of asking questions and learning from your feed back. The chat bots can even scrape the internet for information to return in their output as well as to use for learning. The project includes a custom language syntax called NNL (neural network language) that you can use in configuring your machine learning project. The source code is designed so that the libraries can be used in your own custom applications so you don't have to start from scratch with such a complex set of technologies. The project is actually an open source project in which I am a part of. Some of the possibilities offered by this awesome project include predictions, image and pattern recognition, value inspection, memory profiling and much more. Stop by the Bragisoft NND website and download the application to give it a try.
Screen shots of the neural network designer by Bragisoft
A DBMS for neural networks
Mind map rand forrest
The chat bot designer and other tools
Accord.net
Here is a description from the Accord.NET project website
Accord.NET is a framework for scientific computing in .NET. The framework builds upon AForge.NET, an also popular framework for image processing, supplying new tools and libraries. Those libraries encompass a wide range of scientific computing applications, such as statistical data processing, machine learning, pattern recognition, including but not limited to, computer vision and computer audition. The framework offers a large number of probability distributions, hypothesis tests, kernel functions and support for most popular performance measurements techniques.
The most impressive parts of this library has got to be the documentation and sample applications that are distributed with the project. This makes the library easy to get started using. I also like the ability to perform operations like Audio processing (beat detection and more), Video processing (easy integration with your web cam, vision capabilities and object recognition). This is an excellent place to start with approaching Machine learning with the .NET framework. Here are a two videos that should whet your appetite.
Hand writing recognition with Accord.NET
Here is an example of head tracking with Accord.NET (super cool)
AIMLBot Program# AILM Chat bot library
AIMLBot (Program#) is a small, fast, standards-compliant yet easily customizable implementation of an AIML (Artificial Intelligence Markup Language) based chatter bot in C#. AIMLBot has been tested on both Microsoft's runtime environment and Mono. Put simply, it will allow you to chat (by entering text) with your computer using natural language. The project is located here.
Math.NET
Machine learning algorithms are extremely math heavy. Math.NET is a library that can assist with the math that is required to solve machine learning related problems.
Math.NET Numerics aims to provide methods and algorithms for numerical computations in science, engineering and every day use. Covered topics include special functions, linear algebra, probability models, random numbers, interpolation, integral transforms and more.
DotNumerics
DotNumerics is a website dedicated to numerical computing for .NET. DotNumerics includes a Numerical Library for .NET. The library is written in pure C# and has more than 100,000 lines of code with the most advanced algorithms for Linear Algebra, Differential Equations and Optimization problems. The Linear Algebra library includes CSLapack, CSBlas and CSEispack, these libraries are the translation from Fortran to C# of LAPACK, BLAS and EISPACK, respectively.
You can find the library here.
ALGLIB
ALGLIB is a cross-platform numerical analysis and data processing library. It supports several programming languages (C++, C#, Pascal, VBA) and several operating systems (Windows, Linux, Solaris). ALGLIB features include:
Accessing ‘R’ from C#–Lessons learned
Here are instructions to use the R statistical framework from within c#
ILNumerics
You can check out the library at http://www.ilnumerics.net
NuML.net http://numl.net
A nice site about the basics of machine learning in c# by Seth Juarez . NuML.NET is a machine learning library for .NET developers written by Seth Juarez. I've recently tried this library and I'm impressed! Seth has stated publicly that his intention behind the numl.net library is to abstract the scary math away from machine learning to provide tools that are more approachable by software developers and boy did he deliver! I've been working with this library for a little more than an hour and I've written a prediction app in c#. You can find his numl.net library source on github.
Encog Machine Learning Framework
Here is what the official Heaton Research website has to say about Encog:
Encog is an advanced machine learning framework that supports a variety of advanced algorithms, as well as support classes to normalize and process data. Machine learning algorithms such as Support Vector Machines, Artificial Neural Networks, Genetic Programming, Bayesian Networks, Hidden Markov Models and Genetic Algorithms are supported. Most Encog training algoritms are multi-threaded and scale well to multicore hardware. Encog can also make use of a GPU to further speed processing time. A GUI based workbench is also provided to help model and train machine learning algorithms. Encog has been in active development since 2008.
Encog is available for Java, .Net and C/C++.
Jeff Heaton knows a great deal about machine learning algorithms and he's created a wonderful library called Encog. I was able to write a neural network application that solved the classic XOR problem in 20 minutes after installing the library. What really amazes me is that he has an Encog Library for JavaScript which includes live samples on his website of Javascript + encog solving problems like the Traveling Salesman Problem and Conway's game of life, all in a browser! This library can even use your GPU for the heavy lifting if that's your choice. I would highly recommend that you at least check out his site and download the library to look at the examples. You can find the Encog library here.
Conclusion
This concludes my article on Machine learning resources for the .NET developer. If you have any suggestions regarding a project that you know of or you are working on related to Machine learning in .NET, please don't hesitate to leave a comment and I will update the article to mention the project. This article has shown that we as .NET developers have many resources available to us to use to implement Machine learning based solutions. I appreciate your time in reading this article and I hope you found it useful. Please subscribe to my RSS feed. Until next time..
Buddy James

About the author

My name is Buddy James. I'm a Microsoft Certified Solutions Developer from the Nashville, TN area. I'm a Software Engineer, an author, a blogger (http://www.refactorthis.net), a mentor, a thought leader, a technologist, a data scientist, and a husband. I enjoy working with design patterns, data mining, c#, WPF, Silverlight, WinRT, XAML, ASP.NET, python, CouchDB, RavenDB, Hadoop, Android(MonoDroid), iOS (MonoTouch), and Machine Learning. I love technology and I love to develop software, collect data, analyze the data, and learn from the data. When I'm not coding, I'm determined to make a difference in the world by using data and machine learning techniques. (follow me at @budbjames).