-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/accuracy #73
Feature/accuracy #73
Conversation
Codecov Report
@@ Coverage Diff @@
## master #73 +/- ##
==========================================
+ Coverage 92.6% 92.85% +0.25%
==========================================
Files 7 7
Lines 500 532 +32
==========================================
+ Hits 463 494 +31
- Misses 37 38 +1
Continue to review full report at Codecov.
|
@@ -111,13 +113,14 @@ def from_pandas_df(df, i_variables, d_variable, alpha_merge=0.05, max_depth=2, | |||
the type of dependent variable. Supported variable types are 'categorical' or | |||
'continuous' | |||
""" | |||
ind_df = df[list(i_variables.keys())] | |||
df_ordered_keys = [x for x in df.columns if x in i_variables.keys()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kinda gross. Will need to discuss this with you @xulaus, it's logic that seems to be the best in a given situation, but isn't foolproof. Actually, I don't think this can every go into prod.
ind_values = ind_df.values | ||
dep_values = df[d_variable].values | ||
weights = df[weight] if weight is not None else None | ||
return Tree(ind_values, dep_values, alpha_merge, max_depth, min_parent_node_size, | ||
min_child_node_size, list(ind_df.columns.values), split_threshold, weights, | ||
list(i_variables.values()), dep_variable_type) | ||
[i_variables[key] for key in df_ordered_keys], dep_variable_type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here ☝️
else: | ||
tree_predictions = tree_predictions.append(pd.DataFrame([[node.node_id, node.predict]] * len(index), index=index)) | ||
tree_predictions.columns = ['node_id', 'prediction'] | ||
# need to retroactively fill missing values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dataset may not contain all the other i variables at that node, and thus they will be missed off of the node
This adds an accuracy method to Tree.
fixes #72