New! Use Simple ML for Sheets to apply machine learning to the data in your Google Sheets
Read More
Module: tfdf
Stay organized with collections
Save and categorize content based on your preferences.
User entry point for the TensorFlow Decision Forest API.
Basic usage:
# Imports
import tensorflow_decision_forests as tfdf
import pandas as pd
from wurlitzer import sys_pipes
# Load a dataset into a Pandas Dataframe.
dataset_df = pd.read_csv("/tmp/penguins.csv")
# Display the first 3 examples.
dataset_df.head(3)
# Convert the Pandas dataframe to a tf dataset
tf_dataset = tfdf.keras.pd_dataframe_to_tf_dataset(dataset_df,label="species")
model = tfdf.keras.RandomForestModel()
with sys_pipes():
model.fit(tf_dataset)
# Note: The `sys_pipes` part is to display logs during training.
# Evaluate model.
model.compile(metrics=["accuracy"])
model.evaluate(...test_dataset...)
# Save model.
model.save("/tmp/my_saved_model")
# ...
# Load a model: it loads as a generic keras model.
loaded_model = tf_keras.models.load_model("/tmp/my_saved_model")
Modules
builder
module: Model builder.
check_version
module: Check that version of TensorFlow is compatible with TF-DF.
inspector
module: Model inspector.
keras
module: Decision Forest in a Keras Model.
model_plotter
module: Plotting of decision forest models.
py_tree
module: Decision trees stored as python objects.
tuner
module: Specification of the parameters of a tuner.
Other Members |
version
|
'1.10.0'
|
compatible_tf_versions
|
['2.17.0']
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-08-23 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2024-08-23 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-08-23 UTC."],[],[]]