Однако, когда я приступил к изучению отдельного оценщика, я обнаружил трудности с интерпретацией функций двоичного ввода, таких как f60150. ниже. Реальное значение f60150 на самой нижней диаграмме легко интерпретировать — его критерий находится в ожидаемом диапазоне этой функции. Однако сравнение двоичных функций 0)[0]
n_keep = len(keep)
result = scipy.sparse.csr_matrix(
(np.ones(n_keep), (nnz_inds[0][keep], nnz_inds[1][keep])),
shape=mat.shape
)
return result
### Setup dataset
res = fetch_20newsgroups()
text = res.data
outcome = res.target
### Use default params from CountVectorizer to create initial count matrix
vec = CountVectorizer()
X = vec.fit_transform(text)
# Whether to "booleanize" the input matrix
booleanize = True
# Whether to, after "booleanizing", convert the data type to match what's returned by `vec.fit_transform(text)`
to_int = True
if booleanize and to_int:
X = booleanize_csr_matrix(X)
X = X.astype(np.int64)
# Make it a binary classification problem
y = np.where(outcome == 1, 1, 0)
# Random state ensures we will be able to compare trees and their features consistently
model = XGBClassifier(random_state=100)
model.fit(X, y)
plot_tree(model, rankdir='LR'); plt.show()
[/code]
Выполнение вышеописанного с параметрами booleanize и to_int, установленными в True, дает следующую диаграмму:
< img alt="введите описание изображения здесь" src="https://i.sstatic.net/Inycy.png" />
Выполнение описанного выше с помощью booleanize и to_int Для установлено значение False, получается следующая диаграмма:

Черт возьми, даже если я сделаю очень простой пример, я получу «правильные» результаты, независимо от того, X или y являются целочисленными или плавающими типами.
Код: Выделить всё
X = np.matrix(
[
[1,0],
[1,0],
[0,1],
[0,1],
[1,1],
[1,0],
[0,0],
[0,0],
[1,1],
[0,1]
]
)
y = np.array([1,0,0,0,1,1,1,0,1,1])
model = XGBClassifier(random_state=100)
model.fit(X, y)
plot_tree(model, rankdir='LR'); plt.show()

Подробнее здесь: https://stackoverflow.com/questions/523 ... rpretation