Schaffung eines Betrugsbekämpfungssystems in einem Taxi von Grund auf neu

Guten Tag. Mein Name ist Nikita Bashun, ich arbeite als Datenanalyst in der Lucky Group of Companies. In meiner Geschichte geht es darum, wie wir mit einem Team von drei Personen ein Betrugsbekämpfungssystem für den Reisebuchungsservice von Grund auf neu erstellt haben.



Bild



Einführung



Wer weiß, wie man täuscht, wird oft täuschen.

Lope de Vega

Betrug ist in unserem Fall eine Situation, in der ein Fahrer ein Unternehmen täuscht. Betrug, um Geld zu bekommen.



, , 25, Delphi. . , . , . …





— MVP, .

, :



  • . ( «-» ), , . ;
  • . — , ( , ). -, 200 .
  • , — « »:

    • , (, 0% );
    • , -.


Bild



:



  • — , , , ;
  • - ( ) — , , ;
  • — , , , .








Bild



SQL- DWH, . . , , «»:



WHERE susp = 1 --   
  AND finished_orders >= 3 --        
  AND cancelled >= 3 --    ,        
  AND dist_fin_drivers <= 2 --      
  AND ok <= 2 --   2-     


, .



. « » . , ? -. , .



Bild



python. pandas, postgres, Google ( ). , , Apache Airflow.



API .

:



credentials = ServiceAccountCredentials.from_json_keyfile_dict(
    config.crd,
    ['https://www.googleapis.com/auth/spreadsheets',
     'https://www.googleapis.com/auth/drive'])

httpAuth = credentials.authorize(httplib2.Http())
service = googleapiclient.discovery.build('sheets', 'v4', http=httpAuth)
sheet = service.spreadsheets()


:



base_range = f'{city_name}!A{ss_row + 1}:Z{ss_row + reserved_rows}'
sheet.values().append(spreadsheetId=spreadsheetid,
                                 range=base_range,
                                 body={"values": df_pos.values.tolist()},
                                 valueInputOption='RAW').execute()


:



range_from_ss = f'{city_name}!A{ss_row}:S{ss_row + reserved_rows}'

data_from_ss = service.spreadsheets().values().get(
            spreadsheetId=spreadsheetid,
            range=range_from_ss).execute().get('values', [])

data_from_ss = pd.DataFrame(data_from_ss)
data_from_ss_cols = ['id', '', '']
data_from_ss = data_from_ss.loc[1:, data_from_ss_cols]


PG:



vls_ss = ','.join([f"""({', '.join([f(d[c]) for c in data_from_ss_cols])}
                    )""" for d in data_from_ss.to_dict('rows')])

sql_update = f"""
    WITH updated as (
        UPDATE fraud_billing
        SET resolution = tb.resolution,
            comment=tb.comment,
            dt = NOW()
        FROM (VALUES {vls_ss}) AS tb(fraud_billing_id, resolution, comment)
        WHERE fraud_billing.fraud_billing_id = CAST(tb.fraud_billing_id AS INTEGER)
            AND ((fraud_billing.resolution IS NULL AND tb.resolution IS NOT NULL)
                OR (fraud_billing.comment IS NULL AND tb.comment IS NOT NULL)
                OR (fraud_billing.comment IS NOT NULL AND tb.comment IS NOT NULL
                   AND fraud_billing.comment <> tb.comment)
                OR (fraud_billing.resolution IS NOT NULL AND tb.resolution IS NOT NULL
                    AND fraud_billing.resolution <> tb.resolution)
               )
        RETURNING {alias_cols_text_with_id}
        )
    INSERT INTO fraud_billing_history ({cols_text_with_id})
    SELECT {cols_text_with_id}
    FROM updated;
"""

crs_postgres.execute(sql_update)
con_postgres.commit()


postgres :



  • ;
  • .


:



Bild



( , ).



, :



Bild



— .



: , , .



.



, . , , — . «» .



Bild



FP- , .



— , , . .



« ». , , :



  • ;
  • ;
  • ;
  • — .


.



, . , , , , . - :



Bild



, , — .



Google Spreadsheets. . , :



  • , «» ;
  • API — ;
  • ;
  • , .




. , — :



  • . - , - , - . , . ;
  • . , , :

    • - , ;
    • - ;
    • - , ;
    • - .


, , . , «».



— , . — , . !




, ?



  • . . , «» , . ;
  • . , . , .


( ) 35%. — 25%. , — — , . : , , , . .



Bild



:



  • 15 ;
  • 6800 ;
  • 500 .


Der wichtigste Erfolg ist jedoch die schrittweise Reduzierung der Verdachtsfälle in vielen Städten. Schließlich wollen wir im Idealfall nicht mehr fangen , wir wollen nichts fangen .



Fazit



Ich habe versucht, die Hauptfunktionen und -prinzipien des Betrugsbekämpfungssystems sowie die Schwierigkeiten zu beschreiben, auf die wir gestoßen sind. Die Pläne umfassen: Verwendung von ML zur Optimierung der Suche, Schaffung eines Sanktionsüberwachungssystems (jetzt in der Anfangsphase), Verbesserung der Benutzeroberfläche für Manager, Erstellung dynamischer Berichte, Entwicklung neuer Muster und vieles mehr.



Immerhin stehen wir erst am Anfang der Reise.




All Articles