Karkadan
Karkadan

Reputation: 131

How to train a tensorflow.js model using a csv file?

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

Upvotes: 3

Views: 3427

Answers (3)

Julius
Julius

Reputation: 31

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

Upvotes: 0

edkeveked
edkeveked

Reputation: 18381

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

}

Upvotes: 8

talvasconcelos
talvasconcelos

Reputation: 75

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!!

Upvotes: 0

Related Questions