Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Challenge: Compliance Data Dashboard | Section
MLOps Compliance Automation and Monitoring
セクション 1.  11
single

single

bookChallenge: Compliance Data Dashboard

メニューを表示するにはスワイプしてください

As you approach the challenge of building a compliance data dashboard, recall how pandas enables you to efficiently analyze transaction data and how matplotlib helps you visualize patterns that may be relevant for compliance monitoring. These tools are essential for summarizing large datasets, identifying anomalies, and communicating findings to stakeholders in a compliance context.

123456789101112131415161718192021222324252627282930313233343536
import pandas as pd import matplotlib.pyplot as plt # Hardcoded transaction data data = { "id": [1, 2, 3, 4, 5, 6, 7, 8], "amount": [1200, 500, 3200, 1500, 700, 2200, 4000, 800], "account_id": ["A01", "A02", "A01", "A03", "A02", "A01", "A03", "A02"] } df = pd.DataFrame(data) # Calculate summary statistics total_amount = df["amount"].sum() average_amount = df["amount"].mean() max_amount = df["amount"].max() print("Total transaction amount:", total_amount) print("Average transaction amount:", average_amount) print("Maximum transaction amount:", max_amount) # Aggregate by account for bar chart account_totals = df.groupby("account_id")["amount"].sum() account_totals.plot(kind="bar", title="Total Transaction Amounts per Account") plt.xlabel("Account ID") plt.ylabel("Total Amount") plt.tight_layout() plt.show() # Identify anomalies: transactions > 2 std dev above mean mean_amount = df["amount"].mean() std_amount = df["amount"].std() anomaly_threshold = mean_amount + 2 * std_amount anomalies = df[df["amount"] > anomaly_threshold] print("Transactions above anomaly threshold (2 std dev):") print(anomalies)
copy

To structure your compliance dashboard, follow a clear sequence: start by loading and summarizing your transaction data, using pandas to calculate totals and averages. Next, use matplotlib to visualize aggregated results, such as total transactions per account, to spot trends or concentrations. Finally, apply statistical analysis to flag any transactions that are unusually large—those that are more than two standard deviations above the mean—helping you quickly detect potential compliance risks.

タスク

スワイプしてコーディングを開始

Build a Python script that acts as a compliance data dashboard. The script must:

  • Calculate the total, average, and maximum transaction amount from the DataFrame.
  • Aggregate transaction amounts by account and prepare the data for a bar chart visualization.
  • Identify all transactions where the amount is more than two standard deviations above the mean.
  • Store all results in variables as referenced in the starter code.

解答

Switch to desktop実践的な練習のためにデスクトップに切り替える下記のオプションのいずれかを利用して、現在の場所から続行する
すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  11
single

single

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

some-alt