SPMF’s architecture (3) The Preference Manager

This is the third of a series of blog posts about the architecture of the SPMF data mining library. Today, I will explain the role of another an internal module in SPMF, called the Preference Manager. This module is used to store the preferences of the user so that every time that a user utilizes SPMF his preferences will be saved for the next time.

The Architecture of SPMF

Before going into details, let’s have a look at the overall architecture of SPMF, depicted in the picture below.

SPMF is basically a Java program that provides a graphical user interface as well as a command line user interface for the user. These two interfaces are used to call algorithms offered by SPMF, which are of three types: (1) data preprocessing algorithms and tools, (2) data mining algorithms, and (3) visualizations. There is also a module called the Algorithm Manager, which takes care of managing all algorithms offered in SPMF, and another module called the Command Processor which is called by the graphical or command line interface to run the algorithms. These modules have been discussed in the previous posts about the architecture of SPMF (links above).

Today, I will talk about the Preference Manager. It is a module that is designed to save information about the user preferences.

What kind of user preferences are saved by SPMF?

Here is a list of some user preferences that are saved by SPMF:

  • The last directory that has been used for reading an input file.
  • The last directory that has been used to save an output file.
  • The last directory that has been used to save results from an experiment.
  • The user prefers to run algorithms using a separated process from the graphical user interface or not
  • The user prefers to open output files using the SPMF text editor or using the system’s text editor.
  • The font size and other preferences set by the user for the SPMF text editor.
  • etc.

Where are all these preferences saved?

The Preference Manager save the user preferences on the local computer through the Java.util.prefs package. If you are using Windows, it means that the preferences from SPMF will be saved in the Windows Registry.

How is the Preference Manager working?

The Preference manager has several methods. The main method is called getInstance(). It is a static method that allows to access the instance of the Preference Manager to then be able to call its other methods.

The Preference Manager has several methods for reading and saving various user preferences. These methods have names that start with set and get, respectively. For example, to read and write the user preference for the input file directory, there are two methods in the Preference Manager called setInputFilePath() and getInputFilePath(). There are other similar methods for the other preferences.

Here is thus a visual representation of the class Preference Manager with its methods:

If the method getInputFilePath() is called on a Windows computer, the Preference Manager will read the values in the Windows Registry for a key “ca.pfv.spmf.gui.input”. If this key does not exist, the value null will be returned.

For example, if I check in the Registry Editor of Windows (regedit) on my computer, I can see that all preferences of SPMF are stored here in the registry:

The exact location in the Registry may vary on different computers.

If you look at the code of the Preference Manager, you will see the definitions for all these registry keys.

And if you want to see the code of the methods to read and write the user preferences about the input file in the Preference Manager, here it is:

As you can see, the Preference Manager class is very simple! It is simply designed to read and write various user preferences to different locations. But nevertheless, the Preference Manager plays an important role in the software. This is why I wanted to talk about that today.

Conclusion

Today, I have explained the role of the Preference Manager, a simple but important module in SPMF. Hope that this has been interesting. Next time, I will explain more about the architecture of SPMF.

==
Philippe Fournier-Viger is a distinguished professor  and the founder of the open-source data mining software SPMF, offering more than 250 data mining algorithms. 

This entry was posted in Data Mining, Data science, Java, open-source, Pattern Mining, spmf and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *