How to Train Decision Forests with TensorFlow.
Desision Forests are are a group of AI calculations with quality and speed cutthroat with (and frequently good for) neural organizations, particularly when you're working with even information. They're worked from numerous choice trees, which makes them simple to utilize and comprehend - and you can exploit a plenty of interpretability apparatuses and procedures that as of now exist today.
So in this Tutorial , we will show how easy it is to train a model with TensorFlow Decision Forests.
Reference:
https://github.com/tensorflow/decision-forests
Step:1
import tensorflow_decision_forests as tfdf
import pandas as pd
why we have to import pandas here is
pandas is a ultimate tool for proprocessing text files and csv files and xlsx files.
we need to install .
pip3 install tensorflow_decision_forests --upgradeBecause Tensorflow update are newly came ,so we need to install above package for Decision Forest training.
Step:2
# Load the dataset in a Pandas dataframe.
train_df = pd.read_csv("project/train.csv") test_df = pd.read_csv("project/test.csv")
we have to use to pandas for reading csv files. Now load these data with tf_df which was newly install or new update in tensorflow decision foresttrain_ds = tfdf.keras.pd_dataframe_to_tf_dataset(train_df, label="my_label") test_ds = tfdf.keras.pd_dataframe_to_tf_dataset(test_df, label="my_label")
# Train the model
model = tfdf.keras.RandomForestModel()
model.fit(train_ds)We can also view summary of model,by means what you have done before with that model.
# Look at the model.
model.summary()
# Evaluate the model.
model.evaluate(test_ds)
# Export to a TensorFlow SavedModel.
# Note: the model is compatible with Yggdrasil Decision Forests.
model.save("project/model")