Machine Learning Demos in Mathematica®

Most of the graphics in the slides used in the lecture Theoretical Concepts of Machine Learning have been created by Ulrich Bodenhofer using Mathematica®. As the functionality implemented in these Mathematica® notebooks may be useful for students, other lecturers, and perhaps even for machine learning practitioners, they have been made available for the public.


The Mathematica® notebooks that are downloadable from this Web page are mainly for demonstrative purposes. They are not optimized for computation speed, memory usage, universality, or extensibility. The focus is mainly on creating illustrative pictures for courses in machine learning. While some of the implemented methods (e.g. k-nearest neighbor, support vector machines) work for higher dimensions, too, the visualizations are limited to problems with one or at most two input variables. Presently, the following features are supported:



  1. Unzip the two ZIP archives into directories of your choice
  2. Open the file General.nb with Mathematica® (version 6.0 or newer)
  3. Move to section "Load Data Sets" and change the path in the SetDirectory[] command to the path where you have unzipped the data files to


Any time you want to use one of the notebooks, load General.nb first and evaluate all cells therein before you evaluate any other notebook. That's it. You can easily use the notebooks with your own data. Explanations are provided inside the notebooks.

SVM Demos

The notebook SVM.nb loads Mathematica® notebooks that have been created by The SVM-Demo sub-folder of the data set archive contains eight data sets in libSVM input format and, grouped into sub-folders DataSetX, a large number of libSVM model files and their Mathematica® counterparts. If you want to visualize your own SVMs, convert the model file into a Mathematica® notebook by and follow the instructions provided in SVM.nb. The use of is simple: it expects input from the console and writes output to the console, so you have to use input-output redirection to make file-to-file conversions.


Click on any of these thumbnails to view full-size images:


This software is provided as is and comes without any warranty. Every user uses the software at his/her own risk. The developers of this software cannot be held responsible for any damages or losses caused by the use of this software.


This software can be used freely and modified for any purpose. However, the user is encouraged to refer to the original source.