/
dataset_use_spec.qmd
61 lines (36 loc) · 1.58 KB
/
dataset_use_spec.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
execute:
freeze: true
---
[R/feature_spec.R](https://github.com/rstudio/tfdatasets//blob/main/R/feature_spec.R#L1057)
# dataset_use_spec
## Transform the dataset using the provided spec.
## Description
Prepares the dataset to be used directly in a model.The transformed dataset is prepared to return tuples (x,y) that can be used directly in Keras.
## Usage
```r
dataset_use_spec(dataset, spec)
```
## Arguments
|Arguments|Description|
|---|---|
| dataset | A TensorFlow dataset. |
| spec | A feature specification created with `feature_spec()`. |
## Value
A TensorFlow dataset.
## Examples
```{r, eval=ecodown::examples_not_run()}
library(tfdatasets)
data(hearts)
hearts <- tensor_slices_dataset(hearts) %>% dataset_batch(32)
# use the formula interface
spec <- feature_spec(hearts, target ~ age) %>%
step_numeric_column(age)
spec_fit <- fit(spec)
final_dataset <- hearts %>% dataset_use_spec(spec_fit)
```
## See Also
- `feature_spec()` to initialize the feature specification.
- `fit.FeatureSpec()` to create a tensorflow dataset prepared to modeling.
- steps to a list of all implemented steps.
Other Feature Spec Functions: `feature_spec()`, `fit.FeatureSpec()`, `step_bucketized_column()`, `step_categorical_column_with_hash_bucket()`, `step_categorical_column_with_identity()`, `step_categorical_column_with_vocabulary_file()`, `step_categorical_column_with_vocabulary_list()`, `step_crossed_column()`, `step_embedding_column()`, `step_indicator_column()`, `step_numeric_column()`, `step_remove_column()`, `step_shared_embeddings_column()`, `steps`