# Customer Flags Prediction Challenge — Data

来源：https://www.kaggle.com/competitions/customer-flags-prediction-challenge/data

本地 Meta Kaggle 快照；不是本次实时页面。

# Dataset Description

In the **Customer Flags Prediction Challenge**, participants are provided with three main datasets to build their predictive models. Each dataset contains crucial information that will help you understand customer behaviors and attributes. Below is a detailed description of each dataset, including file contents and how they relate to the competition objectives.

---

## **Dataset Overview**

1. **Customer Features Data**
   - **Filename**: `customer_features.zip`
   - **Extracted File**: `customer_features.csv`
   - **Description**: Contains detailed customer information, including demographic data, account creation details, activity timestamps, and target flags.

2. **Balance Features Data**
   - **Filename**: `customer_account_balances.zip`
   - **Extracted File**: `balance_features.csv`
   - **Description**: Provides information about customers' account balances across various currencies at specific timestamps.

3. **Test Data**
   - **Filename**: `test.zip`
   - **Extracted File**: `test.csv`
   - **Description**: Contains the test set for which you need to predict the target flags. It includes the same features as the training data but excludes the target variables.

---

## **1. Customer Features Data**

### **File Information**

- **Compressed File**: `customer_features.zip`
- **Uncompressed File**: `customer_features.csv`
- **File Format**: CSV (Comma-Separated Values)

### **Description**

This dataset includes comprehensive information about each customer and serves as the primary source for feature extraction. It contains both input features and the target variables (except in the test set).

### **Data Fields**

1. **customer_id** *(string)*

   - **Description**: Unique identifier for each customer.
   - **Notes**: This field is the primary key and is used to link with other datasets.

2. **sign_up_date** *(datetime)*

   - **Description**: The date and time when the customer signed up on the platform.
   - **Format**: YYYY-MM-DD HH:MM:SS

3. **created_at** *(datetime)*

   - **Description**: Timestamp indicating when the customer account was created.
   - **Notes**: May be similar to `sign_up_date` but can differ in some cases.

4. **first_trade_time** *(datetime)*

   - **Description**: Timestamp of the customer's first trade activity.
   - **Notes**: This field is sparse; many customers may not have initiated a trade.

5. **first_offramp_time** *(datetime)*

   - **Description**: Timestamp of the customer's first offramp activity (withdrawing funds from the platform).
   - **Notes**: Sparse data; useful for understanding customer engagement.

6. **first_onramp_time** *(datetime)*

   - **Description**: Timestamp of the customer's first onramp activity (depositing funds into the platform).
   - **Notes**: Sparse data; indicates initial engagement.

7. **gender** *(string)*

   - **Description**: Gender of the customer.
   - **Possible Values**: 'Male', 'Female', 'Other', or may be missing.
   - **Notes**: May contain missing or unspecified values.

8. **dob** *(date)*

   - **Description**: Date of birth of the customer.
   - **Format**: YYYY-MM-DD
   - **Notes**: May contain missing values.

9. **banker_score** *(float)*

   - **Description**: A score representing the customer's activity level or engagement on the platform.
   - **Range**: [Insert range if known]
   - **Notes**: The exact calculation method may be proprietary.

10. **virtual_flag** *(int)*

    - **Description**: **Target variable** indicating whether the customer account is virtual.
    - **Values**: 1 (Virtual account), 0 (Real account)

11. **system_flag** *(int)*

    - **Description**: **Target variable** indicating whether the account is system-generated.
    - **Values**: 1 (System-generated account), 0 (Not system-generated)

12. **cloned_flag** *(int)*

    - **Description**: **Target variable** indicating whether the account is cloned.
    - **Values**: 1 (Cloned account), 0 (Not cloned)

13. **seeder** *(int)*

    - **Description**: **Target variable** indicating whether the customer is a seeder.
    - **Values**: 1 (Seeder), 0 (Not a seeder)

### **Usage Notes**

- **Target Variables**: The four flags (`virtual_flag`, `system_flag`, `cloned_flag`, `seeder`) are the target variables you need to predict.
- **Missing Data**: Some fields, such as `gender` and `dob`, may have missing values. Appropriate handling (e.g., imputation or modeling missingness) is necessary.
- **Time-Based Features**: The timestamps can be used to create features like account age, time since last activity, etc.

---

## **2. Balance Features Data**

### **File Information**

- **Compressed File**: `customer_account_balances.zip`
- **Uncompressed File**: `balance_features.csv`
- **File Format**: CSV

### **Description**

This dataset provides snapshots of customer account balances across different currencies. It can help in understanding customers' financial behaviors and engagement levels.

### **Data Fields**

1. **customer_id** *(string)*

   - **Description**: Unique identifier linking to the `customer_features.csv`.
   - **Notes**: Use this field to merge with customer features.

2. **currency_code** *(int)*

   - **Description**: Numeric code representing the type of currency (e.g., USD, EUR, cryptocurrency codes).
   - **Notes**: A mapping of `currency_code` to actual currency names may be provided or inferred.

3. **balance** *(float)*

   - **Description**: The available balance for the customer in the specified currency.
   - **Notes**: Represents funds that are available for transactions.

4. **frozen_balance** *(float)*

   - **Description**: The portion of the customer's balance that is frozen or on hold.
   - **Notes**: Funds may be frozen due to holds, disputes, or regulatory reasons.

5. **snapshot_timestamp** *(datetime)*

   - **Description**: The date and time when the balance snapshot was taken.
   - **Format**: YYYY-MM-DD HH:MM:SS
   - **Notes**: If multiple snapshots are available, you can analyze balance trends over time.

### **Usage Notes**

- **Multiple Records per Customer**: Customers may have multiple records if they hold balances in different currencies or if multiple snapshots are provided.
- **Data Aggregation**: You may need to aggregate balances per customer (e.g., total balance, number of currencies held).
- **Currency Handling**: Consider normalizing balances across different currencies if necessary (e.g., converting to a base currency).

---

## **3. Test Data**

### **File Information**

- **Compressed File**: `test.zip`
- **Uncompressed File**: `test.csv`
- **File Format**: CSV

### **Description**

The test dataset contains customer features for which you need to predict the target flags. This dataset has the same structure as `customer_features.csv` but excludes the target variables (`virtual_flag`, `system_flag`, `cloned_flag`, `seeder`).

### **Data Fields**

- All fields from the **Customer Features Data**, except the target variables.

### **Usage Notes**

- **Predictions Required**: For each `customer_id` in the test set, you need to predict all four target flags.
- **Feature Consistency**: Ensure that any feature engineering or preprocessing steps applied to the training data are consistently applied to the test data.

---

## **Data Relationships**

- **Linking Datasets**: Use `customer_id` to link records between `customer_features.csv`, `balance_features.csv`, and `test.csv`.
- **Primary and Foreign Keys**: `customer_id` acts as the primary key in `customer_features.csv` and as a foreign key in `balance_features.csv`.

---

## **Data Access and Extraction**

### **Downloading the Data**

- All datasets are available for download from the competition's **"Data"** tab.
- **Note**: You may need to agree to the competition rules or data usage terms before downloading.

### **Extracting the Data**

- The files are compressed in ZIP format.
- Use standard tools to extract the CSV files:
  - **Windows**: Right-click the ZIP file and select "Extract All..."
  - **macOS**: Double-click the ZIP file to extract.
  - **Linux**: Use the `unzip` command in the terminal.
  - **Python**: Use the `zipfile` module to extract programmatically.

### **Example in Python**

```python
import zipfile

# Extract customer_features.zip
with zipfile.ZipFile('customer_features.zip', 'r') as zip_ref:
    zip_ref.extractall()

# Extract customer_account_balances.zip
with zipfile.ZipFile('customer_account_balances.zip', 'r') as zip_ref:
    zip_ref.extractall()

# Extract test.zip
with zipfile.ZipFile('test.zip', 'r') as zip_ref:
    zip_ref.extractall()
```

---

## **Data Quality and Preprocessing**

- **Missing Values**: Identify and handle missing values in features like `gender`, `dob`, and activity timestamps.
- **Data Types**: Ensure that date and timestamp fields are correctly parsed as datetime objects.
- **Anomalies**: Check for inconsistent or outlier values that may need to be addressed.
- **Normalization**: Consider normalizing numerical features like `banker_score`, `balance`, and `frozen_balance`.

---

## **Feature Engineering Suggestions**

- **Temporal Features**:
  - Account age: Difference between `snapshot_timestamp` and `created_at`.
  - Time since last activity: Calculate durations since `first_trade_time`, `first_onramp_time`, etc.
- **Financial Features**:
  - Total balance: Sum of balances across all currencies per customer.
  - Balance ratios: Ratio of `frozen_balance` to `balance`.
  - Currency diversity: Number of different currencies held by the customer.
- **Activity Indicators**:
  - Binary flags indicating whether a customer has engaged in trading, on-ramping, or off-ramping.
- **Demographic Features**:
  - Age: Calculate from `dob`.
  - Gender encoding: Convert categorical `gender` into numerical values.

---

## **Important Notes**

- **Privacy and Anonymization**: All data has been anonymized to protect customer privacy. Do not attempt to de-anonymize or infer personal identities.
- **Data Usage**: The data provided is for the sole purpose of this competition. Do not distribute or use the data for other purposes.
- **External Data**: The use of external data is prohibited. All features must be derived from the provided datasets.

---

## **Data Dictionary Summary**

| Field Name           | Data Type | Description                                                  |
|----------------------|-----------|--------------------------------------------------------------|
| **customer_id**      | string    | Unique customer identifier                                   |
| **sign_up_date**     | datetime  | Customer sign-up date and time                               |
| **created_at**       | datetime  | Account creation timestamp                                   |
| **first_trade_time** | datetime  | Timestamp of first trade activity                            |
| **first_offramp_time** | datetime | Timestamp of first offramp activity                          |
| **first_onramp_time** | datetime  | Timestamp of first onramp activity                           |
| **gender**           | string    | Customer's gender                                            |
| **dob**              | date      | Customer's date of birth                                     |
| **banker_score**     | float     | Customer activity score                                      |
| **virtual_flag**     | int       | Target: Virtual account flag (1 or 0)                        |
| **system_flag**      | int       | Target: System-generated account flag (1 or 0)               |
| **cloned_flag**      | int       | Target: Cloned account flag (1 or 0)                         |
| **seeder**           | int       | Target: Seeder flag (1 or 0)                                 |
| **currency_code**    | int       | Code representing currency type                              |
| **balance**          | float     | Available balance in specified currency                      |
| **frozen_balance**   | float     | Frozen balance in specified currency                         |
| **snapshot_timestamp** | datetime | Timestamp when balance snapshot was taken                   |

---

## **Next Steps**

- **Data Exploration**: Begin by exploring the datasets to understand distributions, correlations, and potential data quality issues.
- **Feature Engineering**: Create meaningful features that could improve model performance.
- **Model Development**: Develop and train models using the training data, and generate predictions for the test set.
- **Submission**: Prepare your submission file as per the guidelines and submit it for evaluation.

---

## **Assistance and Resources**

- **Discussion Forums**: Engage with the community to ask questions and share insights.
- **Starter Notebook**: Utilize the provided starter notebook to kickstart your analysis.
- **FAQs**: Check the FAQs for answers to common questions about the data.

---

By thoroughly understanding the datasets and their nuances, you'll be better equipped to build effective models for the **Customer Flags Prediction Challenge**. Good luck, and we look forward to seeing your innovative approaches!

---

*Note: If you have specific questions about the datasets or encounter any issues, please reach out through the competition's **Discussion Forum** or contact the organizers directly.*