Skip to content

Commit

Permalink
Merge pull request #46 from serengil/feat-task-2612-issue-30
Browse files Browse the repository at this point in the history
no subdataset for else condition
  • Loading branch information
serengil committed Dec 26, 2023
2 parents b54df75 + 9bf190d commit 9d5697a
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions chefboost/training/Training.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,11 +556,8 @@ def buildDecisionTree(

# ---------------------------
# add else condition in the decision tree

if df.Decision.dtypes == "object": # classification
pivot = pd.DataFrame(subdataset.Decision.value_counts()).sort_values(
by=["count"], ascending=False
)
pivot = pd.DataFrame(df.Decision.value_counts()).sort_values(by=["count"], ascending=False)
else_decision = f"return '{str(pivot.iloc[0].name)}'"

if enableParallelism != True:
Expand Down Expand Up @@ -588,7 +585,7 @@ def buildDecisionTree(
decision_rules.append(sample_rule)

else: # regression
else_decision = f"return {subdataset.Decision.mean()}"
else_decision = f"return {df.Decision.mean()}"

if enableParallelism != True:
functions.storeRule(file, (functions.formatRule(root), "else:"))
Expand Down

0 comments on commit 9d5697a

Please sign in to comment.