text_plain_output_1.png
import numpy as np

import pandas as pd

import tensorflow_decision_forests as tfdf

df = pd.read_csv('/kaggle/input/playground-series-s3e10/train.csv')

label = 'Class'
classes = df[label].unique().tolist()
df[label] = df[label].map(classes.index)

df = df.iloc[:, 1:]

def split_dataset(dataset, test_ratio=0.15):
    test_indices = np.random.rand(len(dataset)) < test_ratio
    return (dataset[~test_indices], dataset[test_indices])
train_ds_pd, test_ds_pd = split_dataset(df)
train_ds = tfdf.keras.pd_dataframe_to_tf_dataset(train_ds_pd, label=label)
test_ds = tfdf.keras.pd_dataframe_to_tf_dataset(test_ds_pd, label=label)

model = tfdf.keras.GradientBoostedTreesModel()
model.fit(train_ds)

model.compile(metrics=['accuracy', 'AUC', 'Precision', 'Recall', 'binary_crossentropy'])
evaluation = model.evaluate(test_ds, return_dict=True)

model.make_inspector().variable_importances()

model.make_inspector().evaluation()

model.make_inspector().training_logs()[295:]