Add dataset loading capabilities #3062
Replies: 8 comments
-
Makes a lot of sense. We should think through what API we want to offer. Mathjs is a library that works in both browser and node.js, so ideally we offer an API that can be used in both environments and/or is as much environment agnostic as possible. We could create a function Note that there are some unit tests that use MatrixMarket, see |
Beta Was this translation helpful? Give feedback.
-
Great! I'd love to take a stab at this, though I won't be freeing-up for a couple of weeks, so I shouldn't commit just yet. Anyhow, I'm not fully understanding the use case of your |
Beta Was this translation helpful? Give feedback.
-
Thanks for your offer 👍 Before implementing anything I think it will be good to write out the various use cases we see. That way we can see what kind of API makes sense. What pops in my mind:
We should be careful not to reinvent the wheel here, and embrace API's and libraries that are already out there. The idea for a "simple" It would be nice if we can allow people to use their rest client of choice and embrace that instead of creating a full blown rest client ourselves. So usage can look like: // in the browser (user can add credentials, tokens, headers, whatever):
const dataString1 = await fetch(url).text() // <-- people use their loading mechanism of choice
const matrix1 = fromCSV(dataString1)
// in the browser, streaming for large amounts of data:
const dataStream2 = fetch(url).body // <-- people use their loading mechanism of choice
const matrix2 = fromCSV(dataStream2)
// in nodejs:
const dataStream3 = fs.createReadStream(file) // <-- people use their loading mechanism of choice
const matrix3 = fromCSV(dataStream3) |
Beta Was this translation helpful? Give feedback.
-
Good point, let's write down a handful of use cases. Here's what I would suggest
I think that would cover enough ground to accept most datasets you'd find online. With respect to not reinventing the wheel, I agree that it would be most convenient to let people use their loading mechanism of choice. So long as we give a couple of examples on the website on how to do that, then it would probably be enough :) Any other thoughts? |
Beta Was this translation helpful? Give feedback.
-
Agree, sounds good 👍 . A number of examples is a good idea. |
Beta Was this translation helpful? Give feedback.
-
How is this coming along. I could really use the ability to read matrix market files from R/python. So, I am willing to help. I have a little toy that takes when given an array of lines (the file) it can create a sparse matrix. It possibly can become a first iteration of fromMTX. However, I don't handle complex or double matrices. |
Beta Was this translation helpful? Give feedback.
-
@danielruss , I actually never got around it due to my year getting a little crazy. If you want to give it a stab, I'd say go ahead :) |
Beta Was this translation helpful? Give feedback.
-
Moving to Discussions. |
Beta Was this translation helpful? Give feedback.
-
From what I gather, there's no go-to utility to load a matrix / dataset from disk without resorting to the
fromJSON
function ofDenseMatrix
andSparseMatrix
. It would be great if we had a clean dataset loading interface supporting.csv
s, theMatrixMarket
format (very popular in R), and others alike.Thanks! I would be happy to discuss this further and/or lend y'all a hand
Beta Was this translation helpful? Give feedback.
All reactions