Cannot load numpy data into Kraskov O-Information Estimator

13 views
Skip to first unread message

Thomas Varley

unread,
Oct 27, 2023, 3:51:14 PM10/27/23
to Java Information Dynamics Toolkit (JIDT) discussion
Cross-posted from the Github issues page because I'm unsure if this is a bug or I'm just not understanding the documentation.

Here is the script I am using:

```
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 27 13:58:30 2023

@author: thosvarley
"""
import numpy as np
from jpype import isJVMStarted, startJVM, getDefaultJVMPath, JPackage, JArray, JDouble

def start_jvm(jar_location):
    """
    Getting the java virtual machine running so we can
    call JIDT functions.

    Parameters
    ----------
    jar_location : str
        The absolute path to wherever the JIDT .jar is.

    Returns
    -------
    None.

    """
    # Add JIDT jar library to the path
    # Start the JVM (add the "-Xmx" option with say 1024M if you get crashes due to not enough memory space)
    if isJVMStarted() == False: # It will choke if you try and start the JVM when it's already running.
        startJVM(getDefaultJVMPath(), "-ea", "-Djava.class.path=" + jar_location)

start_jvm("/home/thosvarley/.bin/jidt/infodynamics.jar")
#%%

data = np.random.randn(30,10_000)

oinfo_class = JPackage("infodynamics.measures.continuous.kraskov").OInfoCalculatorKraskov
oinfo_estimator = oinfo_class()

oinfo_estimator.initialise()
arr = JArray(JDouble, 2)(data.tolist())
oinfo_estimator.setObservations(arr)
```

And it returns the error:

```
java.lang.Exception: java.lang.Exception: Incorrect number of dimensions 10000 in supplied observations (expected 1)
```

I've gone looking through the tutorials, but all the Python tutorials are focused on information dynamics and there is nothing for total correlation, dual total correlation, O-information, etc.

Versions:

JPype: 1.2.1
JIDT: 1.61
Python: 3.8.18
OS: Linux Mint 20.1

Joseph Lizier

unread,
Oct 27, 2023, 9:56:16 PM10/27/23
to jidt-d...@googlegroups.com
Hi Thomas -- the error message is telling you that it's only expecting one column in the data, not 10000 -- you need to tell the estimator how many variables it's making the O-info estimation on. That will go in the initialise method call, i.e. oinfo_estimator.initialise(10000)  (one day, pending some time, all of these will go in setProperty calls, and the AutoAnalyser will do it for you; maybe Oinfo etc will be added there too)

(You'll never be able to estimate on 10000 variables though, maybe you meant to transpose data, though even 30 is beyond what can reasonably be handled in most cases)

--joe



--
JIDT homepage: https://github.com/jlizier/jidt
---
You received this message because you are subscribed to the Google Groups "Java Information Dynamics Toolkit (JIDT) discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jidt-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jidt-discuss/c8b748b0-f88c-45d6-9b93-ff9c862200cfn%40googlegroups.com.

Varley, Thomas

unread,
Oct 29, 2023, 6:41:00 PM10/29/23
to jidt-d...@googlegroups.com
Thanks Joe.

All the best
~Thomas

On 10/27/23 21:56, Joseph Lizier wrote:
This message was sent from a non-IU address. Please exercise caution when clicking links or opening attachments from external sources.

OpenPGP_0x4F5214B8966CC7B5.asc
OpenPGP_signature
Reply all
Reply to author
Forward
0 new messages