Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-074
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2022-074
2022-074
Commits
ade817f3
Commit
ade817f3
authored
Nov 13, 2022
by
Anuththara18
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fastapi codes added
parent
242e6086
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
135 additions
and
12 deletions
+135
-12
HerokuDeployment/app.py
HerokuDeployment/app.py
+112
-12
HerokuDeployment/famodel.py
HerokuDeployment/famodel.py
+7
-0
HerokuDeployment/seamodel.py
HerokuDeployment/seamodel.py
+8
-0
HerokuDeployment/suamodel.py
HerokuDeployment/suamodel.py
+8
-0
No files found.
HerokuDeployment/app.py
View file @
ade817f3
...
@@ -2,10 +2,20 @@ from fastapi import FastAPI
...
@@ -2,10 +2,20 @@ from fastapi import FastAPI
import
uvicorn
import
uvicorn
import
pickle
import
pickle
from
models
import
Performance
from
models
import
Performance
from
famodel
import
FAPerformance
from
seamodel
import
SEAPerformance
from
suamodel
import
SUAPerformance
app
=
FastAPI
()
app
=
FastAPI
()
modelaa1
=
pickle
.
load
(
open
(
"modelaa1.sav"
,
"rb"
))
modelaa2
=
pickle
.
load
(
open
(
"modelaa2.sav"
,
"rb"
))
modelsea
=
pickle
.
load
(
open
(
"modelsea.sav"
,
"rb"
))
modelsua
=
pickle
.
load
(
open
(
"modelsua.sav"
,
"rb"
))
modelda
=
pickle
.
load
(
open
(
"modelda.sav"
,
"rb"
))
modelfa1
=
pickle
.
load
(
open
(
"modelfa1.sav"
,
"rb"
))
modelfa2
=
pickle
.
load
(
open
(
"modelfa2.sav"
,
"rb"
))
model
=
pickle
.
load
(
open
(
"selectivemodel.sav"
,
"rb"
))
@
app
.
get
(
"/{name}"
)
@
app
.
get
(
"/{name}"
)
async
def
hello
(
name
):
async
def
hello
(
name
):
...
@@ -14,8 +24,38 @@ async def hello(name):
...
@@ -14,8 +24,38 @@ async def hello(name):
@
app
.
get
(
"/"
)
@
app
.
get
(
"/"
)
async
def
greet
():
async
def
greet
():
return
{
"Hello World!"
}
return
{
"Hello World!"
}
@
app
.
post
(
"/aa1predict"
)
async
def
predict
(
req
:
Performance
):
age
=
req
.
age
mrt
=
req
.
mrt
pcr
=
req
.
pcr
oer
=
req
.
oer
cer
=
req
.
cer
features
=
list
([
age
,
mrt
,
pcr
,
oer
,
cer
])
predict
=
modelaa1
.
predict
([
features
])
if
(
predict
==
0
):
return
{
"{}"
.
format
(
predict
)}
else
:
return
{
"{}"
.
format
(
predict
)}
@
app
.
post
(
"/aa2predict"
)
async
def
predict
(
req
:
Performance
):
age
=
req
.
age
mrt
=
req
.
mrt
pcr
=
req
.
pcr
oer
=
req
.
oer
cer
=
req
.
cer
features
=
list
([
age
,
mrt
,
pcr
,
oer
,
cer
])
predict
=
modelaa2
.
predict
([
features
])
if
(
predict
==
0
):
return
{
"{}"
.
format
(
predict
)}
elif
(
predict
==
1
):
return
{
"{}"
.
format
(
predict
)}
else
:
return
{
"{}"
.
format
(
predict
)}
@
app
.
post
(
"/predict"
)
@
app
.
post
(
"/
da
predict"
)
async
def
predict
(
req
:
Performance
):
async
def
predict
(
req
:
Performance
):
age
=
req
.
age
age
=
req
.
age
mrt
=
req
.
mrt
mrt
=
req
.
mrt
...
@@ -23,15 +63,75 @@ async def predict(req:Performance):
...
@@ -23,15 +63,75 @@ async def predict(req:Performance):
oer
=
req
.
oer
oer
=
req
.
oer
cer
=
req
.
cer
cer
=
req
.
cer
features
=
list
([
age
,
mrt
,
pcr
,
oer
,
cer
])
features
=
list
([
age
,
mrt
,
pcr
,
oer
,
cer
])
predict
=
model
.
predict
([
features
])
predict
=
modelda
.
predict
([
features
])
if
(
predict
==
1
):
if
(
predict
==
0
):
return
{
"Ans 1 {}"
.
format
(
predict
)}
return
{
"{}"
.
format
(
predict
)}
elif
(
predict
==
2
):
else
:
return
{
"Ans 2 {}"
.
format
(
predict
)}
return
{
"{}"
.
format
(
predict
)}
elif
(
predict
==
3
):
return
{
"Ans 3 {}"
.
format
(
predict
)}
@
app
.
post
(
"/faonepredict"
)
async
def
predict
(
req
:
FAPerformance
):
age
=
req
.
age
mrt
=
req
.
mrt
pcr
=
req
.
pcr
oer
=
req
.
oer
features
=
list
([
age
,
mrt
,
pcr
,
oer
])
predict
=
modelfa1
.
predict
([
features
])
if
(
predict
==
0
):
return
{
"{}"
.
format
(
predict
)}
else
:
return
{
"{}"
.
format
(
predict
)}
@
app
.
post
(
"/fatwopredict"
)
async
def
predict
(
req
:
FAPerformance
):
age
=
req
.
age
mrt
=
req
.
mrt
pcr
=
req
.
pcr
oer
=
req
.
oer
features
=
list
([
age
,
mrt
,
pcr
,
oer
])
predict
=
modelfa2
.
predict
([
features
])
if
(
predict
==
0
):
return
{
"{}"
.
format
(
predict
)}
else
:
else
:
return
{
"
Ans 4
{}"
.
format
(
predict
)}
return
{
"{}"
.
format
(
predict
)}
@
app
.
post
(
"/seapredict"
)
async
def
predict
(
req
:
SEAPerformance
):
age
=
req
.
age
td
=
req
.
td
pcr
=
req
.
pcr
oer
=
req
.
oer
cer
=
req
.
cer
features
=
list
([
age
,
td
,
pcr
,
oer
,
cer
])
predict
=
modelsea
.
predict
([
features
])
if
(
predict
==
0
):
return
{
"{}"
.
format
(
predict
)}
elif
(
predict
==
1
):
return
{
"{}"
.
format
(
predict
)}
elif
(
predict
==
2
):
return
{
"{}"
.
format
(
predict
)}
else
:
return
{
"{}"
.
format
(
predict
)}
@
app
.
post
(
"/suapredict"
)
async
def
predict
(
req
:
SUAPerformance
):
age
=
req
.
age
mrt
=
req
.
mrt
pcr
=
req
.
pcr
oer
=
req
.
oer
td
=
req
.
td
features
=
list
([
age
,
mrt
,
pcr
,
oer
,
td
])
predict
=
modelsua
.
predict
([
features
])
if
(
predict
==
0
):
return
{
"{}"
.
format
(
predict
)}
elif
(
predict
==
1
):
return
{
"{}"
.
format
(
predict
)}
else
:
return
{
"{}"
.
format
(
predict
)}
"""
if __name__=="__main__":
if __name__=="__main__":
uvicorn
.
run
(
app
,
host
=
"127.0.0.1"
,
port
=
5049
)
uvicorn.run(app, host="127.0.0.1", port=5049)
\ No newline at end of file
"""
\ No newline at end of file
HerokuDeployment/famodel.py
0 → 100644
View file @
ade817f3
from
pydantic
import
BaseModel
class
FAPerformance
(
BaseModel
):
age
:
int
mrt
:
float
pcr
:
float
oer
:
float
HerokuDeployment/seamodel.py
0 → 100644
View file @
ade817f3
from
pydantic
import
BaseModel
class
SEAPerformance
(
BaseModel
):
age
:
int
td
:
float
pcr
:
float
oer
:
float
cer
:
float
HerokuDeployment/suamodel.py
0 → 100644
View file @
ade817f3
from
pydantic
import
BaseModel
class
SUAPerformance
(
BaseModel
):
age
:
int
mrt
:
float
pcr
:
float
oer
:
float
td
:
float
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment