File size: 1,771 Bytes
9943c93
e77919f
9943c93
 
 
 
 
0003b2f
9943c93
0003b2f
9943c93
 
 
 
 
0003b2f
9943c93
 
 
 
 
 
0003b2f
9943c93
 
 
 
 
 
9fc7d2b
 
9943c93
4df47de
e77919f
9943c93
 
 
 
 
 
 
 
 
 
882aca1
 
930b6f5
9943c93
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import gradio as gr
import torch
from gears import load_tensor, calc_preds

coeffs = load_tensor()

examples = [
    """-0.260648; -0.469648; 2.496266; -0.083724; 0.129681;0.732898; 0.519014; -0.130006; 0.727159; 0.637735; -0.987020; 0.293438; -0.941386; 0.549020; 1.804879; 0.215598; 0.512307; 0.333644; 0.124270; 0.091202; -0.110552; 0.217606; -0.134794; 0.165959; 0.126280; -0.434824; -0.081230; -0.151045; 17982.1""",

    """ 0.985100; -0.356045; 0.558056; -0.429654; 0.277140; 0.428605; 0.406466; -0.133118; 0.347452; 0.529808; 0.140107; 1.564246; 0.574074; 0.627719; 0.706121; 0.789188; 0.403810; 0.201799; -0.340687; -0.233984; -0.194936; -0.605761; 0.079469; -0.577395; 0.190090; 0.296503; -0.248052; -0.064512; 6531.370000""",

    """
    -0.478427; 0.142165; -0.046838; 0.683350; 0.067820; -0.404898; -0.206496; 0.184366; -0.762935; -0.228392; 0.660903;
    -0.387520; -0.533249; -0.502266; 0.405143; -0.060691; -0.207237; 0.305603; 0.134876; -0.033921; 0.098977; -0.075191;
    -0.481489; 0.678900; -0.011520; 0.409021; 0.075859; -0.447139;
    1534.530000
    """,

    """
    -0.617111; -1.733888; 1.150655; 0.207829; 0.903533; -0.171524; 0.551679; -0.167744; 0.338861; 0.291418; -0.884790;
    0.344854; 0.763902; 0.068704; 2.560478; 0.955467; 0.663089; 1.897704; 0.024869; 1.841243; 0.153856; 0.369734; 1.471004;
    -0.497633; 0.377656; -0.328051; -0.512415; -0.013653;
    10554.680000
    """
]

ans_examples = [0,0,1,1]

# 0, 1, 541, 623



def predict(indeps):
    indeps = torch.tensor(list(map(float,indeps.split(';'))))

    fraud = calc_preds(coeffs, indeps)

    if fraud >= 0.5:
        return "Fraud"

    return "Not fraud"

gr.Interface(
    fn=predict,
    inputs="text",
    outputs="text",
    examples=examples
).launch(share=False)