System save at 27/11/2025 11:34 by user_client2024

This commit is contained in:
user_client2024 2025-11-27 06:04:35 +00:00
parent b152e9fbc9
commit b341970f51
3 changed files with 38 additions and 26 deletions

View File

@ -2,7 +2,7 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 42,
"id": "e706cfb0-2234-4c4c-95d8-d1968f656aa0", "id": "e706cfb0-2234-4c4c-95d8-d1968f656aa0",
"metadata": { "metadata": {
"tags": [] "tags": []
@ -14,7 +14,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 43,
"id": "2f9a4ca7-c066-4d93-9957-0d9145f9265d", "id": "2f9a4ca7-c066-4d93-9957-0d9145f9265d",
"metadata": { "metadata": {
"tags": [] "tags": []
@ -57,7 +57,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 44,
"id": "134d0b3d-5481-4975-af07-c80ab09d6dd2", "id": "134d0b3d-5481-4975-af07-c80ab09d6dd2",
"metadata": { "metadata": {
"tags": [] "tags": []
@ -157,7 +157,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 34, "execution_count": 45,
"id": "d220561a-34c9-48d2-8e2f-5d174a87540b", "id": "d220561a-34c9-48d2-8e2f-5d174a87540b",
"metadata": { "metadata": {
"tags": [] "tags": []
@ -180,7 +180,11 @@
" \"Debit_transaction_amount\", \"Total_no_of_debit_transactions\",\n", " \"Debit_transaction_amount\", \"Total_no_of_debit_transactions\",\n",
" \"Wash_Ratio\", \"Segment\", \"Risk\", \"SAR_FLAG\"]\n", " \"Wash_Ratio\", \"Segment\", \"Risk\", \"SAR_FLAG\"]\n",
" df = pd.DataFrame(row_list, columns = cols)\n", " df = pd.DataFrame(row_list, columns = cols)\n",
" \n", " df[[\"Credit_transaction_amount\",\n",
" \"Debit_transaction_amount\",\n",
" \"Wash_Ratio\"]] = df[[\"Credit_transaction_amount\",\n",
" \"Debit_transaction_amount\",\n",
" \"Wash_Ratio\"]].astype('int')\n",
" # Step 1: Compute 90th percentiles per Segment for all 3 fields\n", " # Step 1: Compute 90th percentiles per Segment for all 3 fields\n",
" percentiles = (\n", " percentiles = (\n",
" df.groupby(\"Segment\")[[\"Credit_transaction_amount\",\n", " df.groupby(\"Segment\")[[\"Credit_transaction_amount\",\n",
@ -219,7 +223,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 40, "execution_count": 51,
"id": "2e5a0ea9-64cd-4a8d-9a5d-e5e7b36a401a", "id": "2e5a0ea9-64cd-4a8d-9a5d-e5e7b36a401a",
"metadata": { "metadata": {
"tags": [] "tags": []
@ -232,7 +236,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 39, "execution_count": 50,
"id": "830c7ec3-9707-46db-9b27-ac4f9d46a03a", "id": "830c7ec3-9707-46db-9b27-ac4f9d46a03a",
"metadata": { "metadata": {
"tags": [] "tags": []
@ -244,14 +248,14 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 38, "execution_count": 49,
"id": "150bb5ce-6be1-44fc-a606-6d375354626d", "id": "150bb5ce-6be1-44fc-a606-6d375354626d",
"metadata": { "metadata": {
"tags": [] "tags": []
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"# a[a[\"SAR_FLAG\"] == \"Y\"]" "# a[a[\"SAR_FLAG\"] == \"Y\"]\n"
] ]
} }
], ],

View File

@ -2,7 +2,7 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 42,
"id": "e706cfb0-2234-4c4c-95d8-d1968f656aa0", "id": "e706cfb0-2234-4c4c-95d8-d1968f656aa0",
"metadata": { "metadata": {
"tags": [] "tags": []
@ -14,7 +14,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 43,
"id": "2f9a4ca7-c066-4d93-9957-0d9145f9265d", "id": "2f9a4ca7-c066-4d93-9957-0d9145f9265d",
"metadata": { "metadata": {
"tags": [] "tags": []
@ -57,7 +57,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 44,
"id": "134d0b3d-5481-4975-af07-c80ab09d6dd2", "id": "134d0b3d-5481-4975-af07-c80ab09d6dd2",
"metadata": { "metadata": {
"tags": [] "tags": []
@ -157,7 +157,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 34, "execution_count": 45,
"id": "d220561a-34c9-48d2-8e2f-5d174a87540b", "id": "d220561a-34c9-48d2-8e2f-5d174a87540b",
"metadata": { "metadata": {
"tags": [] "tags": []
@ -180,7 +180,11 @@
" \"Debit_transaction_amount\", \"Total_no_of_debit_transactions\",\n", " \"Debit_transaction_amount\", \"Total_no_of_debit_transactions\",\n",
" \"Wash_Ratio\", \"Segment\", \"Risk\", \"SAR_FLAG\"]\n", " \"Wash_Ratio\", \"Segment\", \"Risk\", \"SAR_FLAG\"]\n",
" df = pd.DataFrame(row_list, columns = cols)\n", " df = pd.DataFrame(row_list, columns = cols)\n",
" \n", " df[[\"Credit_transaction_amount\",\n",
" \"Debit_transaction_amount\",\n",
" \"Wash_Ratio\"]] = df[[\"Credit_transaction_amount\",\n",
" \"Debit_transaction_amount\",\n",
" \"Wash_Ratio\"]].astype('int')\n",
" # Step 1: Compute 90th percentiles per Segment for all 3 fields\n", " # Step 1: Compute 90th percentiles per Segment for all 3 fields\n",
" percentiles = (\n", " percentiles = (\n",
" df.groupby(\"Segment\")[[\"Credit_transaction_amount\",\n", " df.groupby(\"Segment\")[[\"Credit_transaction_amount\",\n",
@ -219,7 +223,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 40, "execution_count": 51,
"id": "2e5a0ea9-64cd-4a8d-9a5d-e5e7b36a401a", "id": "2e5a0ea9-64cd-4a8d-9a5d-e5e7b36a401a",
"metadata": { "metadata": {
"tags": [] "tags": []
@ -232,7 +236,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 39, "execution_count": 50,
"id": "830c7ec3-9707-46db-9b27-ac4f9d46a03a", "id": "830c7ec3-9707-46db-9b27-ac4f9d46a03a",
"metadata": { "metadata": {
"tags": [] "tags": []
@ -244,14 +248,14 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 38, "execution_count": 49,
"id": "150bb5ce-6be1-44fc-a606-6d375354626d", "id": "150bb5ce-6be1-44fc-a606-6d375354626d",
"metadata": { "metadata": {
"tags": [] "tags": []
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"# a[a[\"SAR_FLAG\"] == \"Y\"]" "# a[a[\"SAR_FLAG\"] == \"Y\"]\n"
] ]
} }
], ],

20
main.py
View File

@ -1,13 +1,13 @@
#!/usr/bin/env python #!/usr/bin/env python
# coding: utf-8 # coding: utf-8
# In[4]: # In[42]:
import pandas as pd import pandas as pd
# In[5]: # In[43]:
from tms_data_interface import SQLQueryInterface from tms_data_interface import SQLQueryInterface
@ -20,7 +20,7 @@ seq = SQLQueryInterface(schema="transactionschema")
seq.execute_raw("show tables") seq.execute_raw("show tables")
# In[6]: # In[44]:
query = """ query = """
@ -114,7 +114,7 @@ query = """
""" """
# In[34]: # In[45]:
from tms_data_interface import SQLQueryInterface from tms_data_interface import SQLQueryInterface
@ -133,7 +133,11 @@ class Scenario:
"Debit_transaction_amount", "Total_no_of_debit_transactions", "Debit_transaction_amount", "Total_no_of_debit_transactions",
"Wash_Ratio", "Segment", "Risk", "SAR_FLAG"] "Wash_Ratio", "Segment", "Risk", "SAR_FLAG"]
df = pd.DataFrame(row_list, columns = cols) df = pd.DataFrame(row_list, columns = cols)
df[["Credit_transaction_amount",
"Debit_transaction_amount",
"Wash_Ratio"]] = df[["Credit_transaction_amount",
"Debit_transaction_amount",
"Wash_Ratio"]].astype('int')
# Step 1: Compute 90th percentiles per Segment for all 3 fields # Step 1: Compute 90th percentiles per Segment for all 3 fields
percentiles = ( percentiles = (
df.groupby("Segment")[["Credit_transaction_amount", df.groupby("Segment")[["Credit_transaction_amount",
@ -170,20 +174,20 @@ class Scenario:
return df return df
# In[40]: # In[51]:
# sen = Scenario() # sen = Scenario()
# a = sen.logic() # a = sen.logic()
# In[39]: # In[50]:
# a # a
# In[38]: # In[49]:
# a[a["SAR_FLAG"] == "Y"] # a[a["SAR_FLAG"] == "Y"]