Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cs598mp-fall2021-proj
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
chsieh16
cs598mp-fall2021-proj
Commits
3bcef547
Commit
3bcef547
authored
3 years ago
by
chsieh16
Browse files
Options
Downloads
Patches
Plain Diff
Add negative as derived features
parent
361f4d92
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dtree_learner.py
+8
-2
8 additions, 2 deletions
dtree_learner.py
with
8 additions
and
2 deletions
dtree_learner.py
+
8
−
2
View file @
3bcef547
...
...
@@ -78,10 +78,16 @@ class DTreeLearner(LearnerBase):
@staticmethod
def
_generate_derived_features
(
base_vars
:
List
[
str
],
k
:
int
=
2
)
->
List
[
Tuple
[
str
,
Tuple
[
Any
,
str
]]]:
res
=
[]
for
var
in
base_vars
:
var_coeff_map
=
{
var
:
-
1
}
expr
=
f
"
(-1*
{
var
}
)
"
name
=
expr
res
.
append
((
name
,
(
var_coeff_map
,
expr
)))
if
len
(
base_vars
)
<
k
:
return
[]
return
res
res
=
[]
coeff_combinations
=
list
(
itertools
.
product
([
1
,
-
1
],
repeat
=
k
))
var_id_iter
=
range
(
len
(
base_vars
))
for
selected_var_ids
in
itertools
.
combinations
(
var_id_iter
,
k
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment