Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mnist-code-evaluator
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
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AIcrowd
mnist-code-evaluator
Commits
416c43d5
Commit
416c43d5
authored
3 years ago
by
Jyotish P
Browse files
Options
Downloads
Patches
Plain Diff
Override participant entrypoint
parent
78fe054c
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
aicrowd.yaml
+3
-0
3 additions, 0 deletions
aicrowd.yaml
data/predict.py
+49
-0
49 additions, 0 deletions
data/predict.py
data/run.sh
+5
-0
5 additions, 0 deletions
data/run.sh
evaluator.py
+4
-6
4 additions, 6 deletions
evaluator.py
requirements.txt
+2
-0
2 additions, 0 deletions
requirements.txt
with
63 additions
and
6 deletions
aicrowd.yaml
+
3
−
0
View file @
416c43d5
...
@@ -20,6 +20,9 @@ docker:
...
@@ -20,6 +20,9 @@ docker:
evaluation
:
evaluation
:
global
:
global
:
files
:
predict.py
:
predict.py
run.sh
:
run.sh
resources
:
resources
:
cpu
:
1
cpu
:
1
memory
:
2Gi
memory
:
2Gi
...
...
This diff is collapsed.
Click to expand it.
data/predict.py
0 → 100644
+
49
−
0
View file @
416c43d5
import
timeout_decorator
import
os
import
pandas
as
pd
from
config
import
SubmissionConfig
class
Timeouts
:
model_initialization
=
10
predict_batch
=
10
class
Constants
:
SHARED_DISK
=
os
.
getenv
(
"
AICROWD_SHARED_DISK
"
,
"
/shared
"
)
PREDICTIONS_OUTPUT_PATH
=
os
.
path
.
join
(
SHARED_DISK
,
"
predictions.csv
"
)
DATASET_DIR
=
os
.
getenv
(
"
AICROWD_DATASET_PATH
"
,
"
/dataset
"
)
TEST_DATA_PATH
=
os
.
path
.
join
(
DATASET_DIR
,
"
test.csv
"
)
DEBUG_RUN
=
os
.
getenv
(
"
AICROWD_DEBUG_RUN
"
,
"
false
"
)
==
"
true
"
@timeout_decorator.timeout
(
Timeouts
.
model_initialization
)
def
initialize_predictor
():
return
SubmissionConfig
.
predictor
()
@timeout_decorator.timeout
(
Timeouts
.
predict_batch
)
def
predict_batch
(
predictor
,
batch_input
):
return
predictor
.
predict_batch
(
batch_input
)
def
append_results
(
results
):
if
Constants
.
DEBUG_RUN
:
return
with
open
(
Constants
.
PREDICTIONS_OUTPUT_PATH
,
"
a
"
)
as
fp
:
for
result
in
results
:
fp
.
write
(
f
"
{
result
}
\n
"
)
def
main
():
predictor
=
initialize_predictor
()
test_data
=
pd
.
read_csv
(
Constants
.
TEST_DATA_PATH
)
for
_
,
row
in
test_data
.
iterrows
():
result
=
predict_batch
(
predictor
,
[
row
])
append_results
(
result
)
if
__name__
==
"
__main__
"
:
main
()
This diff is collapsed.
Click to expand it.
data/run.sh
0 → 100644
+
5
−
0
View file @
416c43d5
#!/bin/bash
python predict.py
This diff is collapsed.
Click to expand it.
evaluator.py
+
4
−
6
View file @
416c43d5
import
os
import
os
import
time
import
time
import
pandas
as
pd
import
pandas
as
pd
import
numpy
as
np
from
sklearn.metrics
import
f1_score
,
log_loss
from
sklearn.metrics
import
f1_score
,
log_loss
class
Constants
:
class
Constants
:
SHARED_DISK
=
os
.
getenv
(
"
AICROWD_SHARED_DI
SK
"
,
"
test/shared
"
)
SHARED_DISK
=
os
.
getenv
(
"
AICROWD_SHARED_DI
R
"
,
"
test/shared
"
)
PREDICTIONS_DIR
=
os
.
getenv
(
"
AICROWD_PREDICTIONS_DIR
"
,
"
test/predictions
"
)
PREDICTIONS_DIR
=
os
.
getenv
(
"
AICROWD_PREDICTIONS_DIR
"
,
"
test/predictions
"
)
GROUND_TRUTH_DIR
=
os
.
getenv
(
"
AICROWD_GROUND_TRUTH_
PATH
"
,
"
test
"
)
GROUND_TRUTH_DIR
=
os
.
getenv
(
"
AICROWD_GROUND_TRUTH_
DIR
"
,
"
test
"
)
PREDICTIONS_FILE_PATH
=
os
.
path
.
join
(
SHARED_DISK
,
"
predictions.csv
"
)
PREDICTIONS_FILE_PATH
=
os
.
path
.
join
(
SHARED_DISK
,
"
predictions.csv
"
)
GROUND_TRUTH_PATH
=
os
.
path
.
join
(
GROUND_TRUTH_DIR
,
"
test_ground_truth.csv
"
)
GROUND_TRUTH_PATH
=
os
.
path
.
join
(
GROUND_TRUTH_DIR
,
"
test_ground_truth.csv
"
)
...
@@ -18,9 +19,6 @@ class AIcrowdEvaluator:
...
@@ -18,9 +19,6 @@ class AIcrowdEvaluator:
pass
pass
def
evaluate
(
self
):
def
evaluate
(
self
):
while
not
os
.
path
.
exists
(
"
/tmp/let-go
"
):
time
.
sleep
(
10
)
predictions
=
pd
.
read_csv
(
Constants
.
PREDICTIONS_FILE_PATH
,
header
=
None
)
predictions
=
pd
.
read_csv
(
Constants
.
PREDICTIONS_FILE_PATH
,
header
=
None
)
ground_truth
=
pd
.
read_csv
(
Constants
.
GROUND_TRUTH_PATH
,
header
=
None
)
ground_truth
=
pd
.
read_csv
(
Constants
.
GROUND_TRUTH_PATH
,
header
=
None
)
...
@@ -33,7 +31,7 @@ class AIcrowdEvaluator:
...
@@ -33,7 +31,7 @@ class AIcrowdEvaluator:
y_pred
[
index
][
val
]
=
1
y_pred
[
index
][
val
]
=
1
f1
=
f1_score
(
ground_truth
,
submiss
ion
,
average
=
"
micro
"
)
f1
=
f1_score
(
ground_truth
,
predict
ion
s
,
average
=
"
micro
"
)
log_loss_score
=
log_loss
(
ground_truth
,
y_pred
,
labels
=
labels
)
log_loss_score
=
log_loss
(
ground_truth
,
y_pred
,
labels
=
labels
)
return
{
return
{
...
...
This diff is collapsed.
Click to expand it.
requirements.txt
+
2
−
0
View file @
416c43d5
...
@@ -2,3 +2,5 @@ numpy
...
@@ -2,3 +2,5 @@ numpy
pandas
pandas
minio
minio
loguru
loguru
sklearn
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