-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
685 additions
and
637 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,3 +164,4 @@ cython_debug/ | |
# Project | ||
healthcare-dataset-stroke-data.csv | ||
catboost_info/ | ||
cvepred_model.pkl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,37 @@ | ||
from fastapi import FastAPI | ||
from fastapi.responses import RedirectResponse | ||
from cvepred.dataset import create_dataset, split_datasets, RANDOM_STATE | ||
from cvepred.api_models import CveModels | ||
from pycaret.classification import setup | ||
|
||
app = FastAPI() | ||
|
||
samples = create_dataset() | ||
(df_train, df_test) = split_datasets(samples) | ||
|
||
s = setup( | ||
data=df_train, | ||
test_data=df_test, | ||
target="hasExploit", | ||
session_id=RANDOM_STATE, | ||
preprocess=False, | ||
) | ||
model = s.load_model("cvepred_model") | ||
|
||
|
||
@app.get("/") | ||
def read_root(): | ||
return {"Hello": "World"} | ||
def redirect_to_docs(): | ||
return RedirectResponse(url="/docs") | ||
|
||
|
||
@app.get("/sample") | ||
def sample() -> CveModels: | ||
data = samples.sample(n=20).drop(columns=["hasExploit"]).to_dict("records") | ||
|
||
return CveModels.model_validate({"data": data}) | ||
|
||
|
||
@app.post("/predict") | ||
def predict(inputs: CveModels): | ||
# s.predict_model(model, ) | ||
raise Exception("Not implemented yet") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from pydantic import BaseModel | ||
import typing as ty | ||
|
||
# attackVector category | ||
# attackComplexity category | ||
# privilegesRequired category | ||
# userInteraction category | ||
# scope category | ||
# confidentialityImpact category | ||
# integrityImpact category | ||
# availabilityImpact category | ||
# hasExploit bool | ||
|
||
|
||
class CveModel(BaseModel): | ||
attackVector: str | ||
attackComplexity: str | ||
privilegesRequired: str | ||
userInteraction: str | ||
scope: str | ||
confidentialityImpact: str | ||
integrityImpact: str | ||
availabilityImpact: str | ||
# hasExploit: bool | ||
|
||
|
||
class CveModels(BaseModel): | ||
data: ty.List[CveModel] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters