Spaces:
Build error
Build error
Gabriel
commited on
Commit
·
1341b77
1
Parent(s):
e5fece0
feat: model, app, requirements
Browse files- app.py +57 -0
- fakejobposts.pth +3 -0
- requirements.txt +1 -0
app.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
+
from torch import tensor
|
| 4 |
+
from torch.nn import functional as F
|
| 5 |
+
from sklearn.preprocessing import LabelEncoder
|
| 6 |
+
import pandas as pd
|
| 7 |
+
|
| 8 |
+
label_encoder = LabelEncoder()
|
| 9 |
+
|
| 10 |
+
coeffs = torch.load('fakejobposts.pth')
|
| 11 |
+
|
| 12 |
+
indep_cols = ['job_title', 'company_name', 'company_desc', 'job_desc',
|
| 13 |
+
'job_requirement', 'salary', 'location', 'employment_type',
|
| 14 |
+
'department']
|
| 15 |
+
|
| 16 |
+
def calc_preds(coeffs, indeps):
|
| 17 |
+
layers, consts = coeffs
|
| 18 |
+
n = len(layers)
|
| 19 |
+
res = indeps
|
| 20 |
+
for i, l in enumerate(layers):
|
| 21 |
+
res = res @ l + consts[i]
|
| 22 |
+
if i != n-1:
|
| 23 |
+
res = F.relu(res)
|
| 24 |
+
if torch.sigmoid(res) > 0.5:
|
| 25 |
+
return 'Real Job Post'
|
| 26 |
+
else:
|
| 27 |
+
return 'Fake Job Post'
|
| 28 |
+
|
| 29 |
+
def main(job_title, company_name, company_desc, job_desc,
|
| 30 |
+
job_requirement, salary, location, employment_type,
|
| 31 |
+
department):
|
| 32 |
+
df = pd.DataFrame(columns=indep_cols)
|
| 33 |
+
df.loc[0] = [job_title, company_name, company_desc, job_desc,
|
| 34 |
+
job_requirement, salary, location, employment_type,
|
| 35 |
+
department]
|
| 36 |
+
|
| 37 |
+
for column in df.columns:
|
| 38 |
+
df[column] = label_encoder.fit_transform(df[column])
|
| 39 |
+
|
| 40 |
+
t_indep = tensor(df[indep_cols].values, dtype=torch.float)
|
| 41 |
+
vals,indices = t_indep.max(dim=0)
|
| 42 |
+
t_indep = t_indep / vals
|
| 43 |
+
return calc_preds(coeffs, t_indep)
|
| 44 |
+
|
| 45 |
+
iface = gr.Interface(
|
| 46 |
+
fn=main,
|
| 47 |
+
inputs=[gr.Textbox(label="Job title"), gr.Textbox(label="Company name"),
|
| 48 |
+
gr.Textbox(label="Company description"), gr.Textbox(label="Job description"),
|
| 49 |
+
gr.Textbox(label="Job Requirements"), gr.Textbox(label="Salary"),
|
| 50 |
+
gr.Textbox(label="Location"), gr.Textbox(label="Employment Type"),
|
| 51 |
+
gr.Textbox(label="Department")],
|
| 52 |
+
outputs="text",
|
| 53 |
+
title="Job posting identifier",
|
| 54 |
+
description="Identifies job posts as real or fake"
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
iface.launch()
|
fakejobposts.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ef267d4b182c048a7a82f4ebe7c4c1496780a7a0d5da802411d9046eba0e65aa
|
| 3 |
+
size 2687
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
fastai
|