タクシーで不正防止システムをゼロから作成する

こんにちは。私の名前はニキータ・バシュンです。ラッキーグループのデータアナリストとして働いています。私の話は、3人のチームで、旅行予約サービスの不正防止システムをゼロから作成した方法についてです。



画像



前書き



かつて欺く方法を知っていた彼は何度も欺くでしょう。

Lope de Vega

私たちの場合の詐欺は、運転手が会社をだましている状況です。お金を稼ぐための詐欺。



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





— MVP, .

, :



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

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


画像



:



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




  • False Positive, False Negative . :

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




画像



SQL- DWH, . . , , «»:



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


, .



. « » . , ? -. , .



画像



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 :



  • ;
  • .


:



画像



( , ).



, :



画像



— .



: , , .



.



, . , , — . «» .



画像



FP- , .



— , , . .



« ». , , :



  • ;
  • ;
  • ;
  • — .


.



, . , , , , . - :



画像



, , — .



Google Spreadsheets. . , :



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




. , — :



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

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


, , . , «».



— , . — , . !




, ?



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


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



画像



:



  • 15 ;
  • 6800 ;
  • 500 .


しかし、最も重要な成功は、多くの都市で疑惑のケースが徐々に減少することです。結局のところ、理想的には、これ以上キャッチしたくない何もキャッチしたくない



結論



不正防止システムの主な機能と原則、および遭遇した問題について説明しようとしました。計画には、MLを使用した検索の最適化、制裁監視システムの作成(現在は初期段階)、マネージャーの作業のインターフェイスの改善、動的レポートの作成、新しいパターンの開発などが含まれます。



結局のところ、私たちは旅の始まりに過ぎません。




All Articles