Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
exp-ml-2-hillengass-graf
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
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
igraf
exp-ml-2-hillengass-graf
Commits
2fcf1370
Commit
2fcf1370
authored
1 year ago
by
igraf
Browse files
Options
Downloads
Patches
Plain Diff
Update paths and file names
parent
68905859
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
project/src/README.md
+1
-1
1 addition, 1 deletion
project/src/README.md
project/src/classify_with_basic_classifiers.py
+2
-2
2 additions, 2 deletions
project/src/classify_with_basic_classifiers.py
with
3 additions
and
3 deletions
project/src/README.md
+
1
−
1
View file @
2fcf1370
...
...
@@ -7,7 +7,7 @@
This directory contains the scripts used for the project:
-
`classify_with_baseline.py`
- Classify images using a random and a majority classifier.
-
`classify_with_basic_classifiers.py`
- Classify images using a decision tree, random forest or a naive bayes classifier.
-
`find_optimal_parameters.py`
- Helper script to find the optimal parameters for a decision tree, random forest or a naive bayes classifier.
-
`find_optimal_parameters
_basic
.py`
- Helper script to find the optimal parameters for a decision tree, random forest or a naive bayes classifier.
-
`classify_with_CNN.py`
- Classify images using a convolutional neural network.
-
`evaluate_cnn.py`
Evaluate the trained models and create plots
...
...
This diff is collapsed.
Click to expand it.
project/src/classify_with_basic_classifiers.py
+
2
−
2
View file @
2fcf1370
...
...
@@ -26,7 +26,7 @@ from sklearn.metrics import accuracy_score, confusion_matrix, precision_recall_f
# Local imports for hyperparameter optimization
from
find_optimal_parameters
import
find_best_params_for_decision_tree
,
find_best_params_for_random_forest
,
find_best_params_for_naive_bayes
from
find_optimal_parameters
_basic
import
find_best_params_for_decision_tree
,
find_best_params_for_random_forest
,
find_best_params_for_naive_bayes
def
read_and_resize_image
(
image_path
:
str
,
resize
:
tuple
)
->
np
.
ndarray
:
...
...
@@ -324,7 +324,7 @@ def train_and_evaluate_classifier(classifier, dataset, feature_description, resi
logging
.
info
(
f
"
Confusion matrix saved to ../figures/
{
classifier_name
[
classifier
.
__name__
]
}
/
{
classifier
.
__name__
}
_
{
feature_description
}
_confusion_matrix_
{
params_as_string
}
.png
"
)
# Save the results to a simple text file
with
open
(
"
results.txt
"
,
"
a
"
)
as
f
:
with
open
(
"
results
_basic_classifiers
.txt
"
,
"
a
"
)
as
f
:
f
.
write
(
f
"
Results for
{
classifier
.
__name__
}
classifier on
{
feature_description
}
images:
\n
"
)
f
.
write
(
f
"
Optimal parameters:
{
params
}
\n
"
)
f
.
write
(
str
(
results
)
+
"
\n\n
"
)
...
...
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