Using CSV data as input to recommender
@maciejkula is already working on this.
Since Jun 17, 2021.
Assessment
This issue has not been assessed yet.
Description
I'm trying to replicate the quick start recommender with some csv data, and using the pandas read_csv operation.
Reading the csv data works and I can inspect it, e.g.
my_file_train = pd.read_csv("my_file.csv",header=0)
and I can view the .head() the data appears as expected. The type of the my_file_train is
<class 'pandas.core.frame.DataFrame'>
Following the approach taken in https://stackoverflow.com/questions/58362316/how-do-i-go-from-pandas-dataframe-to-tensorflow-batchdataset-for-nlp I can get a DataSet from the Panda DataFrame
training_dataset = (
tf.data.Dataset.from_tensor_slices(
(
tf.cast(my_file_train['feature1'].values, tf.string),
tf.cast(my_file_train['user_id'].values, tf.int64)
)
)
)
The type of training_datasetis:
<class 'tensorflow.python.data.ops.dataset_ops.TensorSliceDataset'>
but so then I try to build vocabularies as in the example, where we see code like this:
user_ids_vocabulary = tf.keras.layers.experimental.preprocessing.StringLookup(mask_token=None)
user_ids_vocabulary.adapt(ratings.map(lambda x: x["user_id"]))
and I had thought that I could do something similar like this:
user_ids_vocabulary = tf.keras.layers.experimental.preprocessing.StringLookup(mask_token=None)
user_ids_vocabulary.adapt(training_dataset.map(lambda x: x[1]))
since the DataSet I have is tuples rather than a dictionary, but I get the following error:
TypeError: () takes 1 positional argument but 2 were given
which probably just exposes that I'm taking completely the wrong approach somewhere, but I'd be very grateful if anyone could set me on track.
Would it be simpler to create my own tfds dataset a la https://www.tensorflow.org/datasets/add_dataset rather than converting it on the fly? or is there some thing simple that I'm missing in terms of the manipulation that I'm trying to do?
- Dominant language
- Python
- Stars
- 2k
- Forks
- 300
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from tensorflow/recommenders
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
tensorflow/recommenders#759 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 38/100
tensorflow/recommenders#758 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
tensorflow/recommenders#757 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
tensorflow/recommenders#756 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
tensorflow/recommenders#755 · 1 comment ·
All issues in tensorflow/recommenders
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100