Infragistics JQuery controls

Introducing RavenDB: Welcome to the world of NoSQL

Relational Databases If you are a software developer then you probably have some sort of experience with a traditional RDBMS (Relational Database Management System).  SQL or structured query language is the language that you use to retrieve data from a SQL based database system.  SQL based database systems are based on relational algebra.  You initiate queries to retrieve sets or intersections of data.  These databases are defined by their schema.  The schema defines tables, columns, relationships, constraints, and keys.  SQL databases have been around for a long time and they aren't going anywhere anytime soon.  There is a time and place to use this type of system.  Typical uses include Data warehousing, data reporting, and application data storage.   Complexities of SQL based database systems With SQL based database systems you often need a database administrator to facilitate maintenance on the server.  In a clustered database environment, concurrency can become an issue when you need to combine data from multiple database systems into one central database.  Issues of replication or redundancy and back up disaster recovery requires an administrator that fully understands the way that SQL schema's and programming work. SQL to objects and objects to SQL When programming in SQL based databases, there is a fundamental challenge of pulling data from a database using SQL and transforming the set based results into an object's properties.  The same difficulties must be resolved when saving object properties back to the SQL database.  For the past 10+ years it has been up to the developer to write custom code to handle these issues.  Recently, ORM systems have assisted developers with this issue.  The schema still requires the developer to map object properties to database columns.  If the schema changes, you have to change database stored procedures, functions, as well as application code that deals with selecting and inserting and updating data.  The functions that facilitate relational databases create difficulties that must be solved to use the systems effectively. Repository pattern The repository pattern exists to provide a way to retrieve data from a routine that provides a layer of abstraction between the call and the underlying database server.  This is usually implemented by some interfaces and specific repository classes.  This adds to the amount of infrastructure boiler plate code that must be used in each application to simply retrieve data from an SQL database. Ditching the schema Recently there has been a lot of talk about NoSQL based databases.  When I first heard about this concept, I was very skeptical on how this would work.  I had been working with SQL for the past 10 years and it's what I've been used to.  I decided I would take a look at RavenDB to see what all the fuss was about.  RavenDB has changed my views on the issue. There are times when you have no need to worry about the way that your data is stored.  There are some instances in which you have no need to generate reports on data or utilize relationships.  Some times you simply need the ability to store an object's state and retrieve it later for use in your application.  This illustrates a perfect time to utilize NoSQL and RavenDB. Saving data the SQL way To save data in a typical RDBMS, you must create a SQL INSERT or UPDATE statement and traverse the properties values of the object that you wish to save to the database.  If the schema ever changes, you must change all application code that saves or retrieves data from a database. Setting up RavenDB Embedded  You must start by adding RavenDB to your solution.  I did this by using the Nuget package manager.  There are 3 ways to run RavenDB.  You can run RavneDB as an HTTP service, a Windows service, or when using RavenDB in a .NET application, you can run the RavenDB embedded server which allows RavenDB to execute as an in process DLL service.  This requires no server to run.  You simply point to a folder on your file system to save the data. Please note that when you save data to RavenDB, the objects are serialized to JSON for storage.  Here is a screen shot of how to get to the Nuget package manager.  Keep in mind that you want to add RavenDB once you have your solution open in Visual Studio.   Once you launch the package manager Search for RavenDB and choose the embedded server. The nuget package manager will discover and download the other package dependencies like the RavenDB client and Database packages. When you run RavenDB in Embedded mode, the DataDirectory property of the DocumentStore should be the directory that you wish to store the data saved to the database. Once you have a valid document store, you need to create a session to preform the save and query operations. The session object provides a way of saving and accessing data in the document store.   Querying data in RavenDB You can use Linq to query data from a RavenDB database.  Linq provides a strongly typed way of querying a RavenDB database by specifying object properties in the query.   Here is a complete example of saving and querying a RavenDB database. The example is a console application.   The application is made up of a Customer class, a DataAccessLayer class, and the main program class. The program will create an instance of the Customer class and save that object to the RavenDB database.  Next, the program will query the database to retrieve a Customer object with the ID of the object that was just saved.  The program will print the two Id's for comparison and await for the user to press a key to end the program. Customer.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace RavenDBExample { public class Customer { public Guid Id; public string CustomerName; public string CustomerAddress; } } DataAccessLayer.cs using Raven.Client; using Raven.Client.Embedded; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace RavenDBExample { public static class DataAccessLayer { private static EmbeddableDocumentStore _documentStore; public static void SaveCustomer(Customer customer) { if (_documentStore == null) CreateDocumentStore(); using (IDocumentSession session = _documentStore.OpenSession()) { // Operations against session session.Store(customer); // Flush those changes session.SaveChanges(); } } private static void CreateDocumentStore() { _documentStore = new EmbeddableDocumentStore { DataDirectory = "Data" }; if (_documentStore == null) throw new NullReferenceException("Error creating document store"); _documentStore.Initialize(); } public static Customer LoadCustomer(Guid guid) { if (_documentStore == null) CreateDocumentStore(); using (IDocumentSession session = _documentStore.OpenSession()) { var customer = session.Query<Customer>().Where(cust => (cust.Id == guid)).FirstOrDefault(); return customer; } return null; } } } Program.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace RavenDBExample { public class Program { public static void Main(string[] args) { var customerToSave = new Customer { Id = Guid.NewGuid(), CustomerName = "John Doe", CustomerAddress = "1234 Mystery Street, Somewhere, California, 55555" }; DataAccessLayer.SaveCustomer(customerToSave); var existingCustomer = DataAccessLayer.LoadCustomer(customerToSave.Id); if (existingCustomer == null) throw new NullReferenceException("Unable to load the customer"); Console.WriteLine("The CustomerID that was saved = {0} . The CustomerID loaded = {1} .", customerToSave.Id, existingCustomer.Id); Console.ReadKey(); } } }   There are other features as well such as change tracking. Change tracking occurs when you retrieve an object from the database, all changes to that object are tracked. You can later call save changes on the session to save the changes to the object. This concludes a high level discussion of NoSQL vs SQL database systems and specifically how to use the RavenDB document database. As you can see, if you have no need to apply relational algebra or care about the schema of a database then NoSQL based databases like RavenDB can be extremely useful. Download the full application example below RavenDBExample.zip (2.42 mb)   kick it on DotNetKicks.com      


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).  

Related links

Month List

Category list

  • RSS feed for .NET.NET (37)
  • RSS feed for .NET 4.5.NET 4.5 (9)
  • RSS feed for AndroidAndroid (5)
  • RSS feed for Artificial IntelligenceArtificial Intelligence (6)
  • RSS feed for ASP.NET MVCASP.NET MVC (5)
  • RSS feed for ASP.NET WebFormsASP.NET WebForms (4)
  • RSS feed for AssemblerAssembler (3)
  • RSS feed for AssemblyAssembly (3)
  • RSS feed for Asynchronous ProgrammingAsynchronous Programming (3)
  • RSS feed for Big DataBig Data (7)
  • RSS feed for bit.lybit.ly (1)
  • RSS feed for BlogBlog (9)
  • RSS feed for BlogEngine.NETBlogEngine.NET (2)
  • RSS feed for BragisoftBragisoft (2)
  • RSS feed for c#c# (27)
  • RSS feed for C# 5.0C# 5.0 (1)
  • RSS feed for Code CompleteCode Complete (5)
  • RSS feed for Data AnalyticsData Analytics (3)
  • RSS feed for Data MiningData Mining (3)
  • RSS feed for Decision TreesDecision Trees (3)
  • RSS feed for Dependency InjectionDependency Injection (2)
  • RSS feed for Design PatternsDesign Patterns (10)
  • RSS feed for DevelopmentDevelopment (20)
  • RSS feed for dot42dot42 (2)
  • RSS feed for F#F# (1)
  • RSS feed for Functional ProgrammingFunctional Programming (1)
  • RSS feed for ILIL (1)
  • RSS feed for ILAsmILAsm (1)
  • RSS feed for INFRAGISTICSINFRAGISTICS (1)
  • RSS feed for IoCIoC (1)
  • RSS feed for iOSiOS (2)
  • RSS feed for iPadiPad (5)
  • RSS feed for iPhoneiPhone (5)
  • RSS feed for LinqLinq (1)
  • RSS feed for Machine learningMachine learning (8)
  • RSS feed for MathMath (3)
  • RSS feed for MicrosoftMicrosoft (5)
  • RSS feed for Microsoft ExcelMicrosoft Excel (1)
  • RSS feed for Microsoft OfficeMicrosoft Office (1)
  • RSS feed for Microsoft Patterns And PracticesMicrosoft Patterns And Practices (2)
  • RSS feed for Microsoft WordMicrosoft Word (1)
  • RSS feed for Mobile developmentMobile development (4)
  • RSS feed for Mobile sitesMobile sites (5)
  • RSS feed for monomono (8)
  • RSS feed for MonoDroidMonoDroid (5)
  • RSS feed for MonoTouchMonoTouch (2)
  • RSS feed for MSILMSIL (3)
  • RSS feed for MVVMMVVM (8)
  • RSS feed for NETADVANTAGENETADVANTAGE (1)
  • RSS feed for Neural NetworksNeural Networks (4)
  • RSS feed for NoSQLNoSQL (1)
  • RSS feed for numl.netnuml.net (1)
  • RSS feed for PDLPDL (1)
  • RSS feed for Prediction algorithmsPrediction algorithms (7)
  • RSS feed for PrismPrism (1)
  • RSS feed for Product ReviewProduct Review (9)
  • RSS feed for Pseudo CodePseudo Code (1)
  • RSS feed for Published booksPublished books (1)
  • RSS feed for RapidMinerRapidMiner (3)
  • RSS feed for RavenDBRavenDB (1)
  • RSS feed for ReviewsReviews (3)
  • RSS feed for RobotsRobots (1)
  • RSS feed for SecuritySecurity (1)
  • RSS feed for SilverlightSilverlight (3)
  • RSS feed for Simulated EvolutionSimulated Evolution (3)
  • RSS feed for Software DesignSoftware Design (12)
  • RSS feed for SQLSQL (1)
  • RSS feed for Structured learningStructured learning (3)
  • RSS feed for SyncfusionSyncfusion (3)
  • RSS feed for TDDTDD (1)
  • RSS feed for Tech NewsTech News (3)
  • RSS feed for TwitterTwitter (2)
  • RSS feed for UnityUnity (2)
  • RSS feed for ValidationValidation (1)
  • RSS feed for Visual Basic .NETVisual Basic .NET (2)
  • refactorthis.net | Neural Networks
    Infragistics WPF controls

    Assistant Professor receives $518,434 to apply Machine Learning to network analysis

    The University of Illinois at Urbana-Champaign - College of Engineering has awarded $518,434 to Assistant Professor Maxim Raginsky to use to apply Machine Learning techniques to network analysis to try and discover how to make networks more efficient. From the article http://csl.illinois.edu/news/raginsky-receives-career-award-apply-information-theory-machine-learning-problems “The overall design objective is to make sure that the network resources are allocated in a smart way, and each user receives only the data they need without significant waste of bandwidth or power,”  said Raginsky, a member of Illinois' electrical and computer engineering faculty. Raginsky uses ecological monitoring as an example. If someone is tracking a rare bird species in a specific habitat and wants to record how many of these birds fly in and out of the area, it would be a waste of resources to continuously stream video if what the person really wants is just the arrivals and departures of the birds. A big part of the problem is learning to detect events of interest and to reliably communicate only the data describing these events. “So I want to make sure that only the relevant information gets to those who need it, despite the fact that everyone is using the same network and the kinds of information that are relevant to one user are different than the kinds of information that are relevant to somebody else,” Raginsky said. These problems are messy and complex, and there is no hope to come up with an accurate model for all kinds of data being transmitted and received over networks because of the increasing size and complexity of both the networks and the data, Raginsky said. Machine learning offers a variety of tools for extracting predictively relevant information from observations, but to date most of the research on machine learning has not focused on the network aspect and all the resource constraints that it imposes. This project will systematically explore what is and is not possible in these types of large networks with multiple learning agents, specifically identifying the effect of bandwidth limitations, losses, delays and lack of central coordination on the performance of statistical learning algorithms, thus helping develop efficient and robust coding/decoding schemes. The NSF CAREER Award is awarded by the National Science Foundation specifically to “junior faculty members who demonstrate their roles through outstanding research and education,” according to NSF’s website. Raginsky said that because these awards are for 5-year projects, the proposals take a lot of time and effort. “You propose to research something you’re really passionate about, and presumably you want to work on this topic even if it did not get funded,” Raginsky said. “So, when I heard about my proposal being recommended for funding, of course it was a relief. I will have a good time working on this problem.” Raginsky is a member of the Decision and Control group at CSL. I think that this is a wonderful problem domain in which Machine learning can prove useful.  Machine learning is a powerful set of technologies, and we have yet to even scratch the surface of what it can do for human kind.  This goes to show you that there are other great uses besides targeted advertising systems, though that is where most of the jobs are at the moment.  Do you have ay ideas as to some practical applications of Machine learning that have yet to be tested? Please share by leaving a comment.  


    Machine learning: bitly can do a lot more for you than shrink your URLs..

    bitly's contributions to BigData and Machine learning Greetings to all of my fellow technologists.  I wanted to write an article to let you know about some very interesting resources that bitly has made available to developers and data lovers alike.  Just in case you've been living under a rock, bitly provides a URL shortening service.  What you may not know is they offer much more than that. Popular links can tell us a lot about the world If you have been working with machine learning and big data, I'm sure you know that access to data is extremely useful and that one of the best places to find useful data regarding what's happening on the Internet and in the world is the "Social web".  Everyone uses facebook, twitter, goggle+.  A lot of people use services like these to share with the world the subjects that they find important.  So that makes these networks extremely important regarding what people are looking at on the Internet and thus what people care about throughout the world.  Considering the fact that the same people that use these social networking tools to communicate with the world also use the bitly service to communicate the URLs of the pages that they find interesting or important, one would think that bitly's data could tell us a lot about what's going on in the world, and in real-time. Hilary Mason, remember the name A new hero of mine as an activist regarding machine learning and BigData is none other than Hilary Mason.  From her blog at http://www.hilarymason.com  Hilary Mason states "I'm the Chief Scientist at bitly, co-organizer of DataGotham, Co-Founder of HackNY, member of NYC Resistor".  Her blog post titled "Bitly Social Data APIs" describes some really interesting services that bitly offers to the public for obtaining useful information regarding links shared by bitly.  These services include how to see where in the world people are consuming a particular bitly link , how to see what is the world paying attention to right now (called "bursting phrases"), and my personal favorite, a real-time search engine which will bring back search results that are relevant based on what people are clicking on the day of the search. Hilary Mason and bitly have provided some great tools for developers that are interested in machine learning and data science.  I urge you to check out some of her talks on http://www.youtube.com . Links http://www.hilarymason.com is Hilary Mason's blog  http://www.hilarymason.com/blog/bitly-social-data-apis/ is the blog post on bitly's social data apis Youtube videos: Hilary Mason on machine learning  That about does it for this article.  Please leave a comment and tell us about someone that you admire in regards to machine learning and BigData. Thanks for reading. Buddy James    


    Machine learning resources for .NET developers

    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


    Machine Learning: 5 examples of what it is and why you should care

    Machine learning examples to make you think Hello folks, and welcome to another awe inspiring article from refactorthis.net .  This article is one that I'm very excited to present.  I'm sure you've guessed by now that the topic of this post is Machine learning.   If you don't know what machine learning is or don't care, I ask you to take a look at the fascinating examples that I've presented in this article.  You just may get inspired.   Background I'm a .NET developer and I have experience working in a myriad of different business domains.  My love affair with machine learning was brought about while I was working for an e-commerce website.  My boss had asked me to look into a new API that Google had released in beta at the time that would allow you to provide data about your customers and it would suggest products based on their shopping data.  That API is called Google prediction and you can read about the Google prediction API here.  It's been a couple of years since I was introduced to this technology and since that time I've contemplated how machine learning algorithms work and what possibilities they could unlock with the right amount of data and creativity. Since then I've done a lot of reading, and planning on ways that I can collect data to use in my journey to learn as much as I can about this new frontier that we as software developers are facing.  I was fortunate enough become the first accepted team member of the open source project called NND, or Neural Network Designer by Bragisoft.  Check back soon for an article dedicated to this wonderful open source project on machine learning and neural networks. Proceed with caution Let it be known, however, that machine learning algorithms are not for the faint of heart.  This is a very complex array of concepts and I don't plan to  try to explain them in this article.  What I will do is give a brief, simple introduction to a few of the prevalent topics that one would need to research in order to implement machine learning algorithms.  The main purpose of this article is to provide some wonderful youtube videos that provide insight into the possibilities of machine learning and it's practical applications.  Some of the videos just may blow your mind! So without further ado, let's bring forth the videos! A glimpse at the future to whet your appetite  This first video is full of commentary and stunning examples of robots that lack brains but are capable of learning by way of a design that mimics a central nervous system.  Although the video depicts the future as something to be worried about, it's still a great, non technical introduction to whet your appetite and make way for the other more specific videos that are focused on simulations and applications of machine learning. Watch a simulation of robots that learn to drive In this video, we see a software demonstration of animated robots that start with no knowledge of a driving course.  Watch what happens as the simulation is processed repeatedly, allowing the robots to learn the course with each generation.  Buckle up! Hey Darwin, what do you think of this? This next video is progressively more complex, however, the simulation clearly shows how a collection of bots act as they evolve.  The bots  can attack each other with the intent of killing and eating each other to sustain life.  They also reproduce to make baby bots.  Take a look at this awesome example of machine learning.. Virtual Darwinism take two This next video is another representation of virtual evolution by machine learning techniques.  Watch block like organisms learn to fight each other over a virtual cube that represents a block of food.   Machine learning for pattern matching and recognition This video shows an application that will render CAPTCHA verification methods obsolete.  I have a decent amount of experience working with OCR engines however, this is the most accurate recognition I've ever seen. Show and tell This concludes my article on machine learning examples.  I hope you enjoyed the article and that it has peaked your interest in machine learning.  Do you have a favorite video or application that demonstrates machine learning, neural networks, prediction algorithms, pattern matching or some other related technology?  If so, we'd love to hear about it so please leave a comment with a link. Thanks for reading, Buddy James kick it on DotNetKicks.com


    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).  

    Related links

    Month List

    None

    refactorthis.net | Machine learning resources for .NET developers
    Infragistics JQuery controls

    Machine learning resources for .NET developers

    Machine learning for .NET

    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

    A DBMS for neural networks

     

    Mind map rand forrest

    Machine learning

    The chat bot designer and other tools

    GUIs and debuggers

    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



    Comments (6) -

    Seth Juarez
    Seth Juarez
    3/4/2013 11:11:59 AM #

    Hey! I also made something: http://numl.net.

    Buddy James
    Buddy James
    3/9/2013 4:22:53 AM #

    Seth,

    Thank you for contributing.  I'm going to add your project to my list.

    The code looks great.  The site design is really awesome too!  Kudos!

    Buddy James

    terrell26
    terrell26
    3/21/2013 12:44:32 PM #

    You seem to know a great deal about this subject

    Buddy James
    Buddy James
    3/21/2013 5:33:28 PM #

    I appreciate the compliment.  I'm very passionate about machine learning and I'm constantly learning.

    Thanks again!

    Buddy James

    Don Syme
    Don Syme
    7/2/2013 4:46:37 AM #

    Great links!

    For F# developers (or C# developers adding an F# project to their solution) see also  

        http://fsharp.org/machine-learning

    Buddy James
    Buddy James
    7/4/2013 8:37:45 PM #

    Thanks for reading @Don.  I hear great things about F# and machine learning.  F# is on my list of languages to learn.  Thanks again!

    Buddy

    Pingbacks and trackbacks (1)+

    Add comment

      Country flag


    • Comment
    • Preview
    Loading

    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).  

    Related links

    Month List

    refactorthis.net | RapidMiner tips and tricks #1 How to use SQL Server named instances with RapidMiner Read/Write database operators
    Infragistics WPF controls

    RapidMiner tips and tricks #1 How to use SQL Server named instances with RapidMiner Read/Write database operators

     Tips and tricks. Tip #1 How to use SQL Server named instances with RapidMiner Read/Write to database operators

    Hello and welcome to my first of many tips and tricks for RapidMiner.  If you are unfamiliar with RapidMiner, it's a Open Source Java based data mining solution.  You can visit the official RapidMiner website by clicking here.  My plan is to write a short article to provide solutions to problems that I encounter as I learn more about this awesome application.  

    RapidMiner and database connectivity

    There are many operators in RapidMiner that take input data sets and generate models for prediction and analysis.  Often, you will want to write the result set of the model to a database.  To do this you use the "Write Database" operator.

    I was using RapidMiner for web mining by way of the Crawl Web operator.  The Example set output of the Crawl Web operator was connected to the input of the Write Database operator.  At the time I was using a SQL Server database that I pay for through my web hosting account.  Just like most everything in RapidMiner, the setup was easy and worked like a charm.  My database size quota was 200MB with my current hosting plan and it became apparent to me that I would quickly run out of space.  As such, I decided to use the local SQL Express 2012 named instanced on my machine.  This is where the problem was introduced.  I couldn't figure out how to successfully setup the database connection in RapidMiner.  

    RapidMiner, Named Instances, and Integrated Security

    The issues that I encountered when trying to setup my local SQL Server 2012 named instanced were as follows:

    1. If I used the named instance for the server name(localhost\SQLExpress), I was unable to connect.  I didn't encounter this problem with my hosting server's database because it was a direct hostname (xxx.sqlserverdb.com).  There was no instance name and so the configuration was easy.
    2. I wasn't sure how to specify integrated security as this is something that you usually specify in the connection string.  I didn't encounter this problem either using my hosting database server because I was given a user name and password to connect to the server.

    After some research and banging my head against my laptop, I finally figured out the resolution to my problems and I'm here to save someone else the headache.

    For the named instance issue, there is a trick that is not readily apparent to get this to work.  You set your database server name as per usual, in my case, localhost, however, when you specify the database name, you include a semicolon (;) followed by instance=<instance name>.  So for my local server instance (localhost\sqlexpress), I set the Host value to localhost and the Database scheme value to mydatabasename;instance=sqlexpress .  

    As far as the integrated security requirement, all you need to do is make sure that you have the latest JTDS SQL Server driver from here.  Once you download the zip file, you'll need to extract the file jtds-1.3.0-dist.zip\x86\SSO\ntlmauth.dll and place it in your windows\system32 directory.  This will insure that you have the driver with the capabilities of using the integrated security.  Once this file is in place, you simply leave the username and password values blank. Here is a screen shot of the Manage Database Connections window in RapidMiner for your reference.

     

    Well that about wraps it up.  Please leave a comment if you have any questions.

    Until next time,

    Buddy James



    Add comment

      Country flag


    • Comment
    • Preview
    Loading

    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).  

    Related links

    Month List

    refactorthis.net | How to keep your WPF UI responsive and report progress during a long running task. C# and asynchronous multithreading.
    Infragistics ASP.NET controls

    How to keep your WPF UI responsive and report progress during a long running task. C# and asynchronous multithreading.

    WPF Succinctly Download

     

     

    The problem

    Have you ever had to execute a bit of code that took an extremely long time to complete?  If so, I'm sure you've noticed that your user interface becomes unresponsive.  You can't use any controls on the form until the process completes.  This is extremely problematic and makes for a poor user experience.

    The cause

    This problem is because you have executed a synchronous block of code on the same thread as the user interface.  The user interface will not be able to respond to any user action until the synchronous method has completed.

    Let's look at an example that illustrates the execution of a synchronous method executing on the user interface thread.

    The example

     

    This example is very simple.  It's a WPF application with two buttons.  

    One of the buttons will start a long running for loop and the other button opens a MessageBox and

    displays a message to let you know that the UI is active.

    When you click the button to start the long running process, try to click the other button.  

    You will notice that you are unable to click the button to show the message box.

     

    Here's the MainWindow.xaml markup

    <Window x:Class="SynchronousExecution.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <Grid Width="111" Height="118">
            <Button Content="Start Process" Height="23" HorizontalAlignment="Left" Margin="10,10,0,0" Name="btnStartProcess" VerticalAlignment="Top" Width="89" Click="btnStartProcess_Click" />
            <Button Content="Try to click me" Height="23" HorizontalAlignment="Left" Margin="10,43,0,0" Name="btnTryMe" VerticalAlignment="Top" Width="89" Click="btnTryMe_Click" />
        </Grid>
    </Window>

     

    And here is the code behind MainWindow.xaml.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using System.Threading;
    
    namespace SynchronousExecution
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }
    
            private void btnStartProcess_Click(object sender, RoutedEventArgs e)
            {
                MessageBox.Show("Starting the long process.  Try to click the button below.");
                for (var loopCounter = 0; loopCounter < 500; loopCounter++)
                {
                    Thread.Sleep(100);
                }
                MessageBox.Show("The process has ended.");
            }
    
            private void btnTryMe_Click(object sender, RoutedEventArgs e)
            {
                MessageBox.Show("User interface is responding!");
            }
        }
    }

    Download  SynchronousExecution.zip (52.38 kb)

    The solution

    The solution to this problem is to spawn a new thread to execute the long running task.  By placing the execution on a seperate thread, this leaves the main UI thread free to interact with the user's input.

    Reporting progress 

    If you execute a long running task, you usually want to let your users know about the progress of the task.  A control to assist with this is the progressbar control.  

    The WPF progress bar control inherits from the RangeBase class.  The control contains the following properties to control how the progress is displayed to the user.

    Minimum The minimum value of the Value property.
    Maximum The maximum value of the Value property.
    SmallChange The value in which the Value property is incremented.
    Value The current value position between the Minimum and Maximum property.

    Multithreading concerns

    Multithreading is a complex topic and is beyond the scope of this article.  However, there are a few concerns that you must be aware of if you plan to access values on the UI thread from the worker thread.

    The System.Windows.Threading.Dispatcher object is used to execute code on the UI thread from the executing worker thread.  The Dispatcher object has the BeginInvoke method which will execute an asynchronous delegate on the thread in which the dispatcher object was created.  So by using the dispatcher object from the user interface code you are able to access the user interface controls from your worker thread.

    We'll take a look at another example that will bring all of these concepts together to illustrate executing a long running task on a seperate thread with a progress bar that updates the user interface via the Dispatcher object.

    The example

    The example is a WPF application.  The main window contains the following controls;

    lstRandomValues A ListBox control that will hold random values that are generated during the long running process. The pupose of this control is to illustrate the responsiveness of the user interface during the long running process.
    prgProgress A ProgressBar control that will illustrate the progress of the long running task. The ProgressBar is hidden by default. It's shown when the long running process begins and is hidden again when the process has ended or is canceled.
    txtProgress A TextBox control that displays the long running process percentage of completion.
    btnCancel A Button control that will cancel the long running process and in turn hide the progress bar and progress textbox.
    btnInteract A Button control that will launch a MessageBox to illustrate the responsiveness of the UI while the long running process is executing.
    btnBegin A Button control that will begin the long running process.

    And here is the code 

    Window1.xaml

    <Window x:Class="RandomNameSpace.ViewModels.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="400" Width="400">    
            <!-- Parent Grid -->
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <ListBox Grid.Row="0" Grid.Column="0" Name="lstRandomValues" Grid.ColumnSpan="2" />
            
                <Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2">
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    
                    <Border Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" x:Name="bdrProgress" Visibility="Hidden" Background="Azure" CornerRadius="10" BorderBrush="DarkGray" BorderThickness="1" HorizontalAlignment="Center" VerticalAlignment="Center">
                        <StackPanel>
                            <Grid Margin="5">
                                <ProgressBar x:Name="prgProgress" Width="200" Height="20" Minimum="0" Maximum="1" />
                                <TextBlock x:Name="txtProgress" HorizontalAlignment="Center" VerticalAlignment="Center" />
                            </Grid>
                            <Button x:Name="btnCancel" Content="Cancel" HorizontalAlignment="Right" Margin="3" Click="btnCancel_Click" />
                        </StackPanel>
                    </Border>
                    
                    <Button Grid.Row="1" Grid.Column="1" x:Name="btnInteract" HorizontalAlignment="Center"  Content="Interact with UI" Click="btnInteract_Click" Height="23.96" />
                    <Button Grid.Row="1" Grid.Column="0" x:Name="btnBegin" HorizontalAlignment="Left"  Content="Start Long Process" Click="btnBegin_Click"  Height="23.96" Margin="35,33.27,0,33.27" />
                </Grid>
            </Grid>
    </Window>

    Window1.xaml.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using System.Threading;
    using System.Windows.Threading;
    
    
    namespace RandomNameSpace.ViewModels
    {
    	/// <summary>
    	/// Interaction logic for Window1.xaml
    	/// </summary>
    	public partial class Window1 : Window 
    	{
            private bool IsCanceled = false;
    
            private RandomViewModel _viewModel;
    
            public RandomViewModel ViewModel
            {
                get { return _viewModel; }
                set { _viewModel = value; }
            }
    
    		public Window1()
    		{
    			InitializeComponent();
                PrepareViewModel();
    		}
    
            private void PrepareViewModel()
            {
                ViewModel = new RandomViewModel();
    
                this.lstRandomValues.DisplayMemberPath = "Value";
                this.lstRandomValues.DataContext = ViewModel;
                this.lstRandomValues.ItemsSource = ViewModel;
            }
    
    		private void btnBegin_Click(object sender, RoutedEventArgs e)
    		{
                BeginProcess();
    		}
    
    		private void btnInteract_Click(object sender, RoutedEventArgs e)
    		{
                MessageBox.Show("Interaction!");
    		}
    
    		private void btnCancel_Click(object sender, RoutedEventArgs e)
    		{
                CancelProcess();
    		}
    
            public void BeginProcess()
            {
                bdrProgress.Visibility = System.Windows.Visibility.Visible;
                DisableBeginButton();
                Action StartLoop;
                StartLoop = () => DoLongRunningProcess();
    
                Thread t;
    
                t = new Thread(StartLoop.Invoke);
                t.Start();
            }
    
            public void CancelProcess()
            {
                this.IsCanceled = true;
                Thread.Sleep(1500);
                ClearListBox();
                EnableBeginButton();
            }
    
            private void ClearListBox()
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Background, (SendOrPostCallback)delegate { this.ViewModel.Clear(); }, null);
            }
    
            private void DoLongRunningProcess()
            {
                for (var loopCounter = 0.0; loopCounter < 1.0; loopCounter = loopCounter + .1)
                {
                    if (!IsCanceled)
                    {
                        //add a random number to the viewmodel collection to be bound to the listview
                        Dispatcher.BeginInvoke(DispatcherPriority.Background, (SendOrPostCallback)delegate { this.ViewModel.AddValue(1564); }, null);
    
                        UpdateProgressBar(loopCounter);
                        Thread.Sleep(2000);
                    }
                    else
                    {
                        break;
                    }
                }
    
                IsCanceled = false;
    
                ClearListBox();
    
                MessageBox.Show("Completed");
    
                EnableBeginButton();
                HideProgressBar();
    
            }
    
            private void EnableBeginButton()
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Background, (SendOrPostCallback)delegate { this.btnBegin.SetValue(Button.IsEnabledProperty, true); }, null);
            }
    
            private void DisableBeginButton()
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Background, (SendOrPostCallback)delegate { this.btnBegin.SetValue(Button.IsEnabledProperty, false); }, null);
            }
    
            private void UpdateProgressBar(double value)
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Background, (SendOrPostCallback)delegate { this.prgProgress.SetValue(ProgressBar.ValueProperty, value); }, null);
                Dispatcher.BeginInvoke(DispatcherPriority.Background, (SendOrPostCallback)delegate { this.txtProgress.SetValue(TextBlock.TextProperty, (value * 100).ToString()); }, null);
            }
    
            private void HideProgressBar()
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Background, (SendOrPostCallback)delegate { this.bdrProgress.SetValue(Border.VisibilityProperty, Visibility.Collapsed); }, null);
            }
    	}
    }

     

    RandomValue.cs
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Linq;
    using System.Text;
    
    namespace RandomNameSpace.ViewModels
    {
        public class RandomValue : INotifyPropertyChanged
        {
            private int _value;
    
            public int Value
            {
                get
                {
                    return _value;
                }
                set
                {
                    if (_value != value)
                        _value = value;
    
                    OnPropertyChanged("Value");
                }
            }
    
    
            public event PropertyChangedEventHandler PropertyChanged;
    
            public void OnPropertyChanged(string propertyName)
            {
                var handler = PropertyChanged;
                if (handler != null)
                {
                    handler(this, new PropertyChangedEventArgs(propertyName));
                }
            }
        }
    }

    RandomViewModel.cs

    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Threading;
    
    namespace RandomNameSpace.ViewModels
    {
        public class RandomViewModel : ObservableCollection<RandomValue>
        {
            public RandomViewModel() : base() {}
    
            public void AddValue(int value)
            {
                Random rnd = new Random();
                var calculatedValue = (value * rnd.Next(3000));
    
                this.Add(new RandomValue { Value = (calculatedValue) });
            }
        }
    }

    Here is the entire solution for download. 

    WPFAsyncProgressBarMVVM.zip (77.39 kb)  

    This concludes the article.  Thank you for taking the time to read it!

    Until next time...

    ~/Buddy James

    kick it on DotNetKicks.com

     

     



    Pingbacks and trackbacks (1)+

    Add comment

      Country flag


    • Comment
    • Preview
    Loading

    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).  

    Related links

    Month List