Consider the following data:
import pandas as pd
y_train = pd.DataFrame({0: {14194: 'Fake', 13891: 'Fake', 13247: 'Fake', 11236: 'Fake', 2716: 'Real', 2705: 'Real', 16133: 'Fake', 7652: 'Real', 7725: 'Real', 16183: 'Fake'}})
X_train = pd.DataFrame({'one': {14194: 'e',
13891: 'b',
13247: 'v',
11236: 't',
2716: 'e',
2705: 'e',
16133: 'h',
7652: 's',
7725: 's',
16183: 's'},
'two': {14194: 'a',
13891: 'a',
13247: 'e',
11236: 'n',
2716: 'c',
2705: 'a',
16133: 'n',
7652: 'e',
7725: 'h',
16183: 'e'},
'three': {14194: 's',
13891: 'l',
13247: 'n',
11236: 'c',
2716: 'h',
2705: 'r',
16133: 'i',
7652: 'r',
7725: 'e',
16183: 's'},
'four': {14194: 'd',
13891: 'e',
13247: 'r',
11236: 'g',
2716: 'o',
2705: 'r',
16133: 'p',
7652: 'v',
7725: 'r',
16183: 'i'},
'five': {14194: 'f',
13891: 'b',
13247: 'o',
11236: 'b',
2716: 'i',
2705: 'i',
16133: 'i',
7652: 'i',
7725: 'b',
16183: 'i'},
'six': {14194: 'p',
13891: 's',
13247: 'l',
11236: 'l',
2716: 'n',
2705: 'n',
16133: 'n',
7652: 'l',
7725: 'e',
16183: 'u'},
'seven': {14194: 's',
13891: 's',
13247: 's',
11236: 'e',
2716: 'g',
2705: 'g',
16133: 's',
7652: 'e',
7725: 't',
16183: 'r'}})
and the following code:
from catboost import CatBoostClassifier
from catboost import Pool
cat_features = list(X_train.columns)
pool = Pool(X_train, y_train, cat_features=list(range(7)), feature_names=cat_features)
model = CatBoostClassifier(verbose=0).fit(pool)
model.plot_tree(
tree_idx=1,
pool=pool # "pool" is required parameter for trees with one hot features
)
I get the following:
But I don't understand what {five} pr_num0 tb0 type0, value>8 means. I was hoping it would look like the titanic example from the manual which is:
import catboost
from catboost import CatBoostClassifier, Pool
from catboost.datasets import titanic
titanic_df = titanic()
X = titanic_df[0].drop('Survived',axis=1)
y = titanic_df[0].Survived
is_cat = (X.dtypes != float)
for feature, feat_is_cat in is_cat.to_dict().items():
if feat_is_cat:
X[feature].fillna("NAN", inplace=True)
cat_features_index = np.where(is_cat)[0]
pool = Pool(X, y, cat_features=cat_features_index, feature_names=list(X.columns))
model = CatBoostClassifier(
max_depth=2, verbose=False, max_ctr_complexity=1, iterations=2).fit(pool)
model.plot_tree(
tree_idx=0,
pool=pool
)
This gives:
How can I get the equivalent of Sex, value = Female
for my example? That would be for example, One, value = b
.