I have two sets of data from two experiments. All data can be divided in three classes, e.g.:

$$\begin{array}{cccc}\rm{Parameter}1&\rm{Parameter}2 ...&\rm{Parameter}N&\rm{Class}\\\hline a_1&b_1&c_1&A\\a_2&b_2&c_2&B\\a_3&b_3&c_3&C\\...\end{array}$$

The values of the parameters define a class. I want to develop criteria based on one data set (with preassigned classes) so that I could assign classes to the second data set. As all the parameters have a certain meaning, I would not like to have a 'black box' method like neural networks, but I would like to have something like, "If Parameter1 is less than X and Parameter2 is within the interval [Y,Z] then it is class A."

What is the best way to do it? Is there an implementation of such a way in Python?


3 Answers 3


You are looking for a decision tree. It will produce exactly this "if this then that" type of rules that you are looking for. Other methods, such as SVM, will produce a result that may work better, but that will be hard to explain.

You really should read a book, or Wikipedia: https://en.wikipedia.org/wiki/Statistical_classification

  • 3
    $\begingroup$ And for a non-subject-matter-driven decision tree the sample size required to yield reliable structure will be extremely high unless the signal:noise ratio is very high. $\endgroup$ Commented Apr 2, 2014 at 12:26
  • 2
    $\begingroup$ The free ebook Elements of Statistical Learning covers various classification methods and their use with R. $\endgroup$
    – nico
    Commented Apr 2, 2014 at 14:59

If you want to do this in Python, scikit-learn has a nice Decision Tree implementation. Learn more here:



As I understand it, what you are after is semi-supervised learning: you learn a few, previously labelled samples, and then label the remaining unlabelled samples with the help of the trained classifier.

There are a number of approaches to this problem. A very popular one are Transductive Support Vector Machines, first introduced in this paper by T. Joachim. It is implemented in SVMlight (which happens to be developed by the author of the previous paper).

Another option are manifold learning algorithms like isomap or tSNE, to name just two of them.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.