Spaces:
Running
Running
sghorbal commited on
Commit ·
60abdf9
1
Parent(s): bac07b6
store the ground truth about frauds
Browse files
migrations/version_2.sql
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-- Alter table TRANSACTION. Add 'is_real_fraud' nullable column
|
| 2 |
+
ALTER TABLE TRANSACTIONS
|
| 3 |
+
ADD COLUMN is_real_fraud BOOLEAN DEFAULT NULL;
|
src/entity/api/transaction_api.py
CHANGED
|
@@ -16,6 +16,7 @@ class TransactionApi(BaseModel):
|
|
| 16 |
transaction_timestamp: int = Field(..., title="Timestamp", description="The timestamp of the transaction.")
|
| 17 |
transaction_amount: float = Field(..., ge=0, title="Amount", description="The transaction amount.")
|
| 18 |
transaction_category: Optional[str] = Field(None, title="Product category", description="The category of product of the transaction.")
|
|
|
|
| 19 |
merchant_name: str = Field(..., title="Name", description="The name of the merchant.")
|
| 20 |
merchant_latitude: float = Field(..., title="Latitude", description="The latitude of the merchant.")
|
| 21 |
merchant_longitude: float = Field(..., title="Longitude", description="The longitude of the merchant.")
|
|
@@ -94,7 +95,8 @@ class TransactionApi(BaseModel):
|
|
| 94 |
customer_address_zip=self.customer_postal_code,
|
| 95 |
customer_address_latitude=self.customer_latitude,
|
| 96 |
customer_address_longitude=self.customer_longitude,
|
| 97 |
-
customer_address_city_population=self.customer_city_population
|
|
|
|
| 98 |
)
|
| 99 |
|
| 100 |
class Config:
|
|
@@ -119,6 +121,6 @@ class TransactionApi(BaseModel):
|
|
| 119 |
"customer_postal_code": 94105,
|
| 120 |
"customer_latitude": 37.7749,
|
| 121 |
"customer_longitude": -122.4194,
|
| 122 |
-
"customer_city_population": 870000
|
| 123 |
}
|
| 124 |
}
|
|
|
|
| 16 |
transaction_timestamp: int = Field(..., title="Timestamp", description="The timestamp of the transaction.")
|
| 17 |
transaction_amount: float = Field(..., ge=0, title="Amount", description="The transaction amount.")
|
| 18 |
transaction_category: Optional[str] = Field(None, title="Product category", description="The category of product of the transaction.")
|
| 19 |
+
transaction_is_real_fraud: Optional[bool] = Field(..., title="Ground truth", description="True if the transaction really is a fraud (ground truth).")
|
| 20 |
merchant_name: str = Field(..., title="Name", description="The name of the merchant.")
|
| 21 |
merchant_latitude: float = Field(..., title="Latitude", description="The latitude of the merchant.")
|
| 22 |
merchant_longitude: float = Field(..., title="Longitude", description="The longitude of the merchant.")
|
|
|
|
| 95 |
customer_address_zip=self.customer_postal_code,
|
| 96 |
customer_address_latitude=self.customer_latitude,
|
| 97 |
customer_address_longitude=self.customer_longitude,
|
| 98 |
+
customer_address_city_population=self.customer_city_population,
|
| 99 |
+
is_real_fraud=self.transaction_is_real_fraud,
|
| 100 |
)
|
| 101 |
|
| 102 |
class Config:
|
|
|
|
| 121 |
"customer_postal_code": 94105,
|
| 122 |
"customer_latitude": 37.7749,
|
| 123 |
"customer_longitude": -122.4194,
|
| 124 |
+
"customer_city_population": 870000,
|
| 125 |
}
|
| 126 |
}
|
src/entity/transaction.py
CHANGED
|
@@ -34,6 +34,7 @@ class Transaction(Base):
|
|
| 34 |
merchant_address_latitude: Mapped[float] = mapped_column(Float, nullable=True)
|
| 35 |
merchant_address_longitude: Mapped[float] = mapped_column(Float, nullable=True)
|
| 36 |
is_fraud: Mapped[bool] = mapped_column(Boolean, nullable=True)
|
|
|
|
| 37 |
|
| 38 |
# Dependent table
|
| 39 |
fraud_details: Mapped[FraudDetails] = relationship("FraudDetails", back_populates="transaction", cascade="all, delete-orphan", uselist=False)
|
|
|
|
| 34 |
merchant_address_latitude: Mapped[float] = mapped_column(Float, nullable=True)
|
| 35 |
merchant_address_longitude: Mapped[float] = mapped_column(Float, nullable=True)
|
| 36 |
is_fraud: Mapped[bool] = mapped_column(Boolean, nullable=True)
|
| 37 |
+
is_real_fraud: Mapped[bool] = mapped_column(Boolean, nullable=True)
|
| 38 |
|
| 39 |
# Dependent table
|
| 40 |
fraud_details: Mapped[FraudDetails] = relationship("FraudDetails", back_populates="transaction", cascade="all, delete-orphan", uselist=False)
|