In last December's Science David N. Reshef, et al. proposed an interesting method to detect associations in data (Detecting Novel Associations in Large Data Sets, Science 334, 1518, 2011). Contrary to classical correlation methods, this method is able to detect non-linear relationships.

Mathematica graphics (table from the cited article)

On their website, the authors provide a Java application, MINE, and an interface to the language R. Having no Java experience I never took up JLink but it is my guess that it should be reasonable straightforward to interface MINE with Mathematica. Could someone show me how?

Native implementations of the method in Mathematica are more than welcome too. I'm planning to do that in the near future, but still haven't found time to read the technical report yet.


2 Answers 2


You don't need JLink for this, because MINE program (Java version) seems to not be able to transmit the results by any data transfer protocol. Rather, you launch it from the command line, as a Java executable (jar file). It takes the name of the input data file as one of the command line parameters, and it writes its output into another file.

I will illustrate the steps needed to run it from Mathematica on Win7, but they should be similar on other systems.

1.Download MINE.jar and an example file (say Spellman.csv), and save them in some directory. I saved them in a directory C:\Temp\MINE

2.Find out the location of the Java runtime coming with Mathematica. One way to do this is to run



LinkObject["C:\Program Files\Wolfram Research\Mathematica\8.0\SystemFiles\Java\
Windows-x86-  64\bin\javaw" -classpath ..."]


3.Define these directories:

$MINEDir = "C:\\Temp\\MINE";
$JavaDir = "C:\\Program Files\\Wolfram Research\\Mathematica\\8.0\\SystemFiles

4.Set the current directory to be the one with Java installation:


5.Run this command (for example - this corresponds to an example they show):

stringify[s__String] := StringJoin["\"", s, "\""]

  "javaw -jar ",
  stringify@FileNameJoin[{$MINEDir, "MINE.jar"}],
  " ",
  stringify@FileNameJoin[{$MINEDir, "Spellman.csv"}],
  " 0 cv=0.7"

In practice, the string with parameters you will build dynamically, from the parameter values, of course. Since I don't have a good grasp on possible parameters and their values, I refrained from implementing this, but this is straightforward to do. Note that stringify is only needed for Windows (probably), to prevent the Windows shell from mis-interpreting spaces. It should return 0 if executed correctly, and you should also see a command-line window popping up and floating for a second or two, that it takes to compute.

6.This shows the data files:

In[8]:= (dataFiles = FileNames["*.csv",{$MINEDir}])//InputForm

The first one is the original data set. The last one contains the results. It should be possible to automate the identification of which is which.

7.Import the results:

In[9]:= Import["C:\\Temp\\MINE\\Spellman.csv,mv=0,cv=0.7,B=n^0.6,Results.csv"]//Short[#,3]&

Out[9]//Short= {{X var,Y var,MIC (strength),MIC-p^2 (nonlinearity),MAS (non-monotonicity),
MEV (functionality),MCN (complexity),Linear regression (p)},<<4380>>,{time,<<6>>,0.00775905}}

It should be possible to automate all that, this is just to show the basic steps. I must add that the program does not contain an awful lot of documentation, so figuring out the parameters etc may be not completely trivial.

  • $\begingroup$ Thanks Leonid! Did you examine the R interface? I'm not familiar with R but from my superficial examination it looked like it was able to internalize MINE completely. I supposed MMA could do the same with JLink. $\endgroup$ Jan 23, 2012 at 21:01
  • $\begingroup$ @Sjoerd No, I did not. It may be that R interface is able to integrate it more tightly. $\endgroup$ Jan 23, 2012 at 21:03
  • $\begingroup$ @Sjoerd The problem is that this jar file is an executable, but contains no JavaDocs, so there was no way to know which methods are there to input or store data, perform computations, etc. And the Java sources aren't attached either - just bytecode-compiled .class files. If docs and / or sources were present, then things would be different / simpler. $\endgroup$ Jan 23, 2012 at 21:13
  • 1
    $\begingroup$ I think it should be possible to write something that directly feeds and uses the classes in the jar by inspecting the R-code or the python-code which at least to me would be somewhat simpler to understand. But as Leonid said: without docs or sources that will be a lot of difficult but unpleasant work that probably no one will be willing to do just for reputation :-). If I had need for it I'd ask the authors for details, probably offering to make the result publicly available as a motivation for them to cooperate. $\endgroup$ Jan 23, 2012 at 21:45
  • $\begingroup$ @Albert It is fairly easy to use JLink to inspect methods and fields in classes, plus one could probably dig out a Java class decompiler - but as you said, this is still quite a bit of work. $\endgroup$ Jan 23, 2012 at 21:49

If anyone has an hour or two to spend on this, here is a starting point. Actually having had a look at the python script MINE.py I think it probably wouldn't be too much work (but still more than I'm willing to invest now)...



analyzeClass = LoadJavaClass["main.Analyze"]

analysisClass = LoadJavaClass["analysis.Analysis"]

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.