Reputation: 371
I'm new to tensorflow. I want to train a recommendation model on my dataset using the TensorFlow Recommenders library and the simple code provided at:
https://github.com/tensorflow/recommenders
I want to know how can I use (load and feed to the model) my custom .csv file in the following format instead of loading the built-in Movielens dataset?
user_id | item_id | rating |
---|---|---|
2 | 8 | 3 |
5 | 12 | 4 |
6 | 4 | 2 |
... | ... | ... |
My Tensorflow versions:
tensorflow==2.4.0
tensorflow-datasets==4.2.0
tensorflow-recommenders==0.4.0
Upvotes: 5
Views: 960
Reputation: 1183
import pandas as pd
DATA_URL = "D:/ratings.csv"
df = pd.read_csv(DATA_URL)
ratings = tf.data.Dataset.from_tensor_slices(dict(df)).map(lambda x: {
"user_id": str(x["user_id"]),
"item_id": str(x["item_id"]),
"rating": float(x["rating"])
})
Upvotes: 5