Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Machine Learning
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
johannes bilk
Machine Learning
Commits
3862b889
Commit
3862b889
authored
1 year ago
by
johannes bilk
Browse files
Options
Downloads
Patches
Plain Diff
updated some decision tree code
parent
b65addb0
No related branches found
No related tags found
1 merge request
!17
Master
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
machineLearning/rf/decisionTree.py
+8
-3
8 additions, 3 deletions
machineLearning/rf/decisionTree.py
with
8 additions
and
3 deletions
machineLearning/rf/decisionTree.py
+
8
−
3
View file @
3862b889
...
@@ -10,6 +10,7 @@ from inspect import signature
...
@@ -10,6 +10,7 @@ from inspect import signature
from
..utility.progressbar
import
Progressbar
from
..utility.progressbar
import
Progressbar
from
collections
import
deque
from
collections
import
deque
from
concurrent.futures
import
ThreadPoolExecutor
from
concurrent.futures
import
ThreadPoolExecutor
import
warnings
def
saveObjectParameters
(
obj
,
saveDict
,
key
):
def
saveObjectParameters
(
obj
,
saveDict
,
key
):
...
@@ -225,8 +226,8 @@ class DecisionTree():
...
@@ -225,8 +226,8 @@ class DecisionTree():
"""
"""
training the tree
training the tree
"""
"""
if
not
self
.
_impurityMeasure
or
not
self
.
_leafFunction
or
not
self
.
_findSplit
:
if
not
self
.
_impurityMeasure
or
not
self
.
_findSplit
:
raise
AttributeError
(
'
some (impurity
, leaf func,
split algo) have not been set
'
)
raise
AttributeError
(
'
some (impurity
or
split algo) have not been set
'
)
# set the root node of the tree
# set the root node of the tree
id
=
str
(
self
.
id
+
1
).
zfill
(
len
(
str
(
self
.
treeID
+
1
)))
id
=
str
(
self
.
id
+
1
).
zfill
(
len
(
str
(
self
.
treeID
+
1
)))
...
@@ -245,7 +246,11 @@ class DecisionTree():
...
@@ -245,7 +246,11 @@ class DecisionTree():
make predictions from the trained tree
make predictions from the trained tree
"""
"""
if
self
.
_trained
is
False
:
if
self
.
_trained
is
False
:
raise
'
must train the tree before it can make predictions
'
raise
Exception
(
'
The tree must be trained before it can make predictions.
'
)
if
not
self
.
_leafFunction
:
warnings
.
warn
(
"
Since no leaf function was defined, the raw leaf values are returned.
"
)
return
self
.
raw
(
data
)
# getting the raw leaf values
# getting the raw leaf values
rawPredictions
=
self
.
raw
(
data
)
rawPredictions
=
self
.
raw
(
data
)
...
...
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