Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
AIR
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christian Fischer Pedersen
AIR
Commits
3315ccd8
Commit
3315ccd8
authored
3 years ago
by
Christian Marius Lillelund
Browse files
Options
Downloads
Patches
Plain Diff
added arguments to api response
parent
e082ec9a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#77117
passed
3 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ml/src/api/main.py
+11
-0
11 additions, 0 deletions
ml/src/api/main.py
with
11 additions
and
0 deletions
ml/src/api/main.py
+
11
−
0
View file @
3315ccd8
...
...
@@ -94,6 +94,7 @@ class OutputData(pydantic.BaseModel):
FallShapValues
:
dict
ClusterId
:
int
ClusterValues
:
List
Arguments
:
List
@app.get
(
'
/
'
)
def
index
():
...
...
@@ -173,6 +174,7 @@ def predict(incoming_data: InputData):
raise
HTTPException
(
status_code
=
400
,
detail
=
"
Ats not found, check ats list
"
)
df
=
prepare_data
(
data
)
arguments
=
generate_arguments
(
df
)
complete_model
=
read_joblib
(
f
'
complete_xgboost.joblib
'
)
compliance_model
=
read_joblib
(
f
'
compliance_xgboost.joblib
'
)
...
...
@@ -205,6 +207,7 @@ def predict(incoming_data: InputData):
'
FallShapValues
'
:
fall_shap_values
,
'
ClusterId
'
:
int
(
df
.
iloc
[
0
][
'
Cluster
'
]),
'
ClusterValues
'
:
cluster_values
,
'
Arguments
'
:
arguments
}
def
add_embeddings
(
df
:
pd
.
DataFrame
,
case
:
str
)
->
pd
.
DataFrame
:
...
...
@@ -215,6 +218,14 @@ def add_embeddings(df: pd.DataFrame, case: str) -> pd.DataFrame:
df
[
column
]
=
pd
.
to_numeric
(
df
[
column
])
return
df
def
generate_arguments
(
df
:
pd
.
DataFrame
):
gender
=
'
kvinde
'
if
df
.
iloc
[
0
].
Gender_Male
==
0
else
'
mand
'
arguments
=
list
({
f
'
Personen er en
{
gender
}
'
,
f
'
Personen er
{
int
(
121
-
df
.
iloc
[
0
].
BirthYear
)
}
år gammel
'
,
f
'
Personen har i gennemsnit lånt hjælpemidler i
{
int
(
df
.
iloc
[
0
].
LoanPeriod
)
}
dage
'
,
f
'
Personen har
{
int
(
df
.
iloc
[
0
].
NumberAts
)
}
hjælpemidler i hjemmet
'
})
return
arguments
def
prepare_data
(
data
:
dict
)
->
pd
.
DataFrame
:
new_data
=
{
k
:
[
v
]
for
k
,
v
in
data
.
items
()}
new_data_df
=
pd
.
DataFrame
.
from_dict
(
new_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