3

Is it possible to train a tensorflow.js model using the path to a csv file on my computer? thank you!

Karkadan
  • 131
  • 1
  • 3
  • 1
    The question doesn't appear to include any attempt at all to solve the problem. StackOverflow expects you to [try to solve your own problem first](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users), as your attempts help us to better understand what you want. Please edit the question to show what you've tried, and show a specific roadblock you're running into with [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). For more information, please see [How to Ask](https://stackoverflow.com/help/how-to-ask). – Andreas Nov 29 '18 at 05:40

3 Answers3

8

From the version 0.14.1, You can read csv file using tf.data.csv. However the data should be sent by a server.

One can serve a local file using a server like http-server.

http-server -c1 --cors .

Or using python3 http-server

python3 -m http.server .

Then you can read your csv file

const csvUrl = 'localhost:port/file'; 

async function run() {

   const csvDataset = tf.data.csv(
     csvUrl, {
       columnConfigs: {
         medv: {
           isLabel: true
         }
       }
     });

// then you can use your dataset

}
edkeveked
  • 17,989
  • 10
  • 55
  • 93
  • 2
    Our `tf.data.csv()` convenience method does indeed assume a URL source; it just does `return new CSVDataset(new URLDataSource(source), csvConfig);`. Using the slightly lower-level API, you can use `FileDataSource` there instead, passing it files from a browser upload (see https://stackoverflow.com/questions/53639919/load-tensorflow-js-model-from-local-file-system-in-javascript). – David Soergel Dec 20 '18 at 20:30
0

You can start here: https://js.tensorflow.org/api/0.14.1/#data.csv . Not sure if you can pull the csv from the local file storage though. But what have you tried?

Come back when you have some work done!!

talvasconcelos
  • 75
  • 1
  • 1
  • 12
0

You can also convert the data into a JSON file with an online converter. It may be the easiest way.

Julius
  • 21
  • 7