Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TP-IA-Syntax-Error
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VIGEOLAS-CHOURY Paul
TP-IA-Syntax-Error
Commits
480c60fa
Commit
480c60fa
authored
4 months ago
by
VIGEOLAS-CHOURY Paul
Browse files
Options
Downloads
Plain Diff
Merge branch 'main' into 'gris'
# Conflicts: # TP.py
parents
398e7538
005a2d06
No related branches found
No related tags found
1 merge request
!1
Gris
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.idea/.gitignore
+8
-0
8 additions, 0 deletions
.idea/.gitignore
.idea/vcs.xml
+6
-0
6 additions, 0 deletions
.idea/vcs.xml
TP.py
+36
-3
36 additions, 3 deletions
TP.py
with
50 additions
and
3 deletions
.idea/.gitignore
0 → 100644
+
8
−
0
View file @
480c60fa
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
This diff is collapsed.
Click to expand it.
.idea/vcs.xml
0 → 100644
+
6
−
0
View file @
480c60fa
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"VcsDirectoryMappings"
>
<mapping
directory=
""
vcs=
"Git"
/>
</component>
</project>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
TP.py
+
36
−
3
View file @
480c60fa
...
...
@@ -163,21 +163,54 @@ def predictFromHisto(S, model, list_dict=True):
def
computeError
(
S
):
"""
Compute the empirical error of the model on the given sample.
:param S: the sample to test
:param S: the sample to test
.
:return: the empirical error of the model on the given sample.
"""
error_count
=
0
for
image
in
S
:
if
image
[
"
y_true_class
"
]
!=
image
[
"
y_predicted_class
"
]:
error_count
+=
1
return
error_count
return
round
(
error_count
/
len
(
S
),
2
)
def
computeScore
(
S
):
"""
Compute the score of the model on the given sample.
:param S: the sample to test.
:return: the score in percentages of the model on the given sample.
"""
y_true_classes
=
[]
y_predicted_classes
=
[]
for
image
in
S
:
y_true_classes
.
append
(
image
[
"
y_true_class
"
])
y_predicted_classes
.
append
(
image
[
"
y_predicted_class
"
])
return
accuracy_score
(
y_true_classes
,
y_predicted_classes
)
return
round
(
accuracy_score
(
y_true_classes
,
y_predicted_classes
),
2
)
*
100
def
computePredictionFile
(
classifier
):
"""
Compute a file with the predictions of the model.
:param classifier: the classifier to use.
:return: A file .txt with the name of the team, the classifier used, the description methods of images,
the prediction on each image, the empirical error, the real error and the score.
"""
file
=
open
(
"
syntax_error.txt
"
,
"
w+
"
)
file
.
write
(
"
# T. Bertochio, N. Efremon, P. Vigeolas-Choury (Equipe Syntax Error)
\n
"
)
file
.
write
(
"
# Nom de l’algorithme d’apprentissage utilisé
\n
"
)
file
.
write
(
"
# Valeurs des hyper-paramètres principaux de l’algorithme
\n
"
)
file
.
write
(
"
# Concaténation: histogramme de couleurs, niveaux de gris
\n
"
)
S
=
buildSampleFromPath
(
"
./Init/Mer
"
,
"
./Init/Ailleurs
"
)
classifier
,
S_test
,
y_test
,
S_train
,
y_train
=
fitFromHisto
(
S
,
classifier
)
predictFromHisto
(
S
,
classifier
)
for
image
in
S
:
image_name
=
os
.
path
.
split
(
image
[
"
name_path
"
])[
1
]
if
image
[
"
y_predicted_class
"
]
==
1
:
image_predicted_class
=
"
+1
"
else
:
image_predicted_class
=
"
-1
"
file
.
write
(
image_name
+
"
"
+
image_predicted_class
+
"
\n
"
)
file
.
write
(
"
# EE =
"
+
str
(
computeError
(
S_train
))
+
"
\n
"
)
file
.
write
(
"
# ER =
"
+
str
(
computeError
(
S_test
))
+
"
\n
"
)
file
.
close
()
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