Orange Forum • View topic - Load data from a matrix in memory?

Load data from a matrix in memory?

A place to ask questions about methods in Orange and how they are used and other general support.

Load data from a matrix in memory?

Postby HaohanWang » Fri Dec 20, 2013 6:31

Is that possible for me to Load Data from a matrix in memory?
Currently, every time I need to load data from a matrix in memory, I have to write this into a csv file and use Orange.Data.Table to load it in csv file.
There should be a better solution, right?

Thanks!!!

Re: Load data from a matrix in memory?

Postby Ales » Fri Dec 27, 2013 17:00

HaohanWang wrote:There should be a better solution, right?
Yes. You create a new domain and pass the data (a list if lists) to the Table constructor
Code: Select all
domain = Orange.data.Domain(
    [Orange.feature.Continuous("X1"),
     Orange.feature.Continuous("X2")],
    Orange.feature.Discrete("Class", values=["A", "B"])
)

data = Orange.data.Table(domain, [[1.0, 2.0, "A"], [2.0, 3.0, "B"]])

See the documentation for more examples.


Return to Questions & Support



cron