Meu modelo de DecisionTree só retorna um fit 1.0 no desafio 'churn'.
Durante o desafio, o modelo dummy me trouxe o fit conforme as dicas do professor. Porém no modelo de DecisionTree não consigo chegar no fit correto.
@staticmethod
def split_test_data(data: pd.DataFrame, target: pd.DataFrame, **kwargs):
return train_test_split(data, target, **kwargs)
@staticmethod
def get_tree_fit(data: pd.DataFrame, target: pd.DataFrame, **kwargs):
tree = DecisionTreeClassifier(random_state=5, **kwargs)
return tree.fit(data, target)
@staticmethod
def get_tree_predict(tree: DecisionTreeClassifier, data: pd.DataFrame):
return tree.predict(data)
@staticmethod
def get_tree_score(tree: DecisionTreeClassifier, data: pd.DataFrame, target: pd.DataFrame):
return tree.score(data, target)
data_train, data_test, target_train, target_test = ml.split_test_data(data, target, stratify = target, random_state = 5)
tree = ml.get_tree_fit(data_train, target_train, max_depth=4)
score = ml.get_tree_score(tree, data_test, target_test)
print(f"The score of the tree model is {score}")
Print result: The score of the dummy model is 0.7964 The score of the tree model is 1.0