Spaces:
Runtime error
Runtime error
Final Updates
Browse files- main.py +12 -3
- pipeline.pkl +2 -2
- rfc_model.pkl +2 -2
- transformers.py +4 -0
main.py
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
from fastapi import FastAPI,HTTPException
|
|
|
|
| 2 |
from typing import Literal,List
|
| 3 |
import uvicorn
|
| 4 |
from pydantic import BaseModel
|
| 5 |
import pandas as pd
|
| 6 |
import os
|
| 7 |
import pickle
|
|
|
|
| 8 |
|
| 9 |
# setup
|
| 10 |
SRC = os.path.abspath('.')
|
|
@@ -25,6 +27,14 @@ app = FastAPI(
|
|
| 25 |
version= '1.0.0'
|
| 26 |
)
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
class IncomePredictionInput(BaseModel):
|
| 29 |
age: int
|
| 30 |
gender: str
|
|
@@ -49,7 +59,7 @@ class IncomePredictionInput(BaseModel):
|
|
| 49 |
losses: int
|
| 50 |
stocks_status: int
|
| 51 |
citizenship: str
|
| 52 |
-
|
| 53 |
|
| 54 |
|
| 55 |
class IncomePredictionOutput(BaseModel):
|
|
@@ -89,6 +99,5 @@ def income_classification(income: IncomePredictionInput):
|
|
| 89 |
raise HTTPException(status_code=500, detail=f"Error during classification: {error_detail}")
|
| 90 |
|
| 91 |
|
| 92 |
-
|
| 93 |
-
uvicorn.run('main:app', reload=True)
|
| 94 |
|
|
|
|
| 1 |
from fastapi import FastAPI,HTTPException
|
| 2 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
from typing import Literal,List
|
| 4 |
import uvicorn
|
| 5 |
from pydantic import BaseModel
|
| 6 |
import pandas as pd
|
| 7 |
import os
|
| 8 |
import pickle
|
| 9 |
+
from transformers import log_transform
|
| 10 |
|
| 11 |
# setup
|
| 12 |
SRC = os.path.abspath('.')
|
|
|
|
| 27 |
version= '1.0.0'
|
| 28 |
)
|
| 29 |
|
| 30 |
+
app.add_middleware(
|
| 31 |
+
CORSMiddleware,
|
| 32 |
+
allow_origins=["*"],
|
| 33 |
+
allow_credentials=True,
|
| 34 |
+
allow_methods=["*"],
|
| 35 |
+
allow_headers=["*"],
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
class IncomePredictionInput(BaseModel):
|
| 39 |
age: int
|
| 40 |
gender: str
|
|
|
|
| 59 |
losses: int
|
| 60 |
stocks_status: int
|
| 61 |
citizenship: str
|
| 62 |
+
|
| 63 |
|
| 64 |
|
| 65 |
class IncomePredictionOutput(BaseModel):
|
|
|
|
| 99 |
raise HTTPException(status_code=500, detail=f"Error during classification: {error_detail}")
|
| 100 |
|
| 101 |
|
| 102 |
+
|
|
|
|
| 103 |
|
pipeline.pkl
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5798dfdbe5793f5277903f528f13beb821822483d09768f514183eab7a6c7335
|
| 3 |
+
size 5296
|
rfc_model.pkl
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:28b7b8c02725a3b1914fc171cdf0a03ac31360a2bc55515832273809804203ef
|
| 3 |
+
size 353869321
|
transformers.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
|
| 3 |
+
def log_transform(x):
|
| 4 |
+
return np.log(x + 1)
|