Claims Module
The Claims module provides tools for managing and analyzing claims data in reinsurance contexts. It includes classes for representing individual claims, collections of claims, and claims development triangles.
Core Classes
Claims Data Structure
The module provides a hierarchical structure for representing claims:
ClaimYearType: An enumeration defining different claim year bases (Accident Year, Underwriting Year, etc.)ClaimDevelopmentHistory: Tracks the development of a claim over time, including paid and incurred amountsClaimsMetaData: Contains metadata about a claim (ID, dates, limits, etc.)Claim: Combines metadata and development history for a single claimClaims: A collection of Claim objects with methods to access and manipulate them
Claims Triangles
The triangles module provides tools for creating and analyzing claims development triangles:
Triangle: Represents a claims development triangle with methods for:- Converting between cumulative and incremental triangles
- Calculating age-to-age factors
- Fitting curves to development patterns
IBNERPatternExtractor: Extracts IBNER (Incurred But Not Enough Reported) patterns from triangles
Examples
Creating and Working with Claims
from pyre.claims.claims import Claim, Claims, ClaimsMetaData, ClaimDevelopmentHistory, ClaimYearType
from datetime import date
# Create claim metadata
metadata = ClaimsMetaData(
claim_id="CL001",
currency="USD",
contract_limit=1000000,
contract_deductible=10000,
claim_year_basis=ClaimYearType.ACCIDENT_YEAR,
loss_date=date(2022, 3, 15),
report_date=date(2022, 4, 1),
line_of_business="Property"
)
# Create claim development history
development = ClaimDevelopmentHistory(
development_months=[0, 3, 6, 9, 12],
cumulative_dev_paid=[0, 15000, 30000, 45000, 50000],
cumulative_dev_incurred=[80000, 70000, 60000, 55000, 50000]
)
# Create a claim
claim = Claim(metadata, development)
# Access claim properties
print(f"Claim ID: {claim.claims_meta_data.claim_id}")
print(f"Latest paid amount: {claim.uncapped_claim_development_history.latest_paid()}")
print(f"Latest incurred amount: {claim.uncapped_claim_development_history.latest_incurred()}")
print(f"Latest reserved amount: {claim.uncapped_claim_development_history.latest_reserved_amount()}")
# Create a collection of claims
claims_collection = Claims([claim])
# Add another claim
second_claim = Claim(
ClaimsMetaData("CL002", "EUR", loss_date=date(2022, 5, 10)),
ClaimDevelopmentHistory(
[0, 3, 6],
[0, 5000, 10000],
[20000, 15000, 12000]
)
)
claims_collection.append(second_claim)
# Access claims in the collection
for claim in claims_collection:
print(f"Claim {claim.claims_meta_data.claim_id} - "
f"Loss date: {claim.claims_meta_data.loss_date}")
# Get unique modelling years
print(f"Modelling years: {claims_collection.modelling_years()}")
Working with Claims Triangles
from pyre.claims.triangles import Triangle, CurveType
from pyre.claims.claims import Claims
# Assuming we have a Claims collection called 'claims_data'
# Create a triangle from claims data
incurred_triangle = Triangle.from_claims(claims_data, value_type="incurred")
paid_triangle = Triangle.from_claims(claims_data, value_type="paid")
# Display the triangle
print(incurred_triangle)
# Convert to incremental triangle
incremental_triangle = incurred_triangle.to_incremental()
# Calculate age-to-age factors
factors = incurred_triangle.calculate_age_to_age_factors()
print("Age-to-age factors:")
for origin_year, factors_dict in factors.items():
print(f" Year {origin_year}: {factors_dict}")
# Get average age-to-age factors
avg_factors = incurred_triangle.get_average_age_to_age_factors(method="volume")
print(f"Volume-weighted average factors: {avg_factors}")
# Fit a curve to the development pattern
curve_params = incurred_triangle.fit_curve(CurveType.EXPONENTIAL)
print(f"Curve parameters: {curve_params}")
# Extract IBNER pattern
ibner_extractor = IBNERPatternExtractor(incurred_triangle)
ibner_pattern = ibner_extractor.get_IBNER_pattern()
print(f"IBNER pattern: {ibner_pattern}")
API Reference
Claim
Represents an insurance claim with associated metadata and development history.
This class provides access to the claim's metadata, uncapped and capped development histories, and a string representation for easy inspection. The uncapped and capped development histories are calculated based on the contract deductible and limit specified in the claim's metadata.
Attributes:
| Name | Type | Description |
|---|---|---|
_claims_meta_data |
ClaimsMetaData
|
Metadata associated with the claim, such as claim ID, deductible, and limit. |
_claim_development_history |
ClaimDevelopmentHistory
|
The development history of the claim, including paid and incurred amounts over time. |
_uncapped_claim_development_history |
ClaimDevelopmentHistory
|
Cached uncapped development history. |
_capped_claim_development_history |
ClaimDevelopmentHistory
|
Cached capped development history. |
Properties
claims_meta_data: Returns the claim's metadata. uncapped_claim_development_history: Returns the claim's development history after applying the deductible, but before applying the contract limit. capped_claim_development_history: Returns the claim's development history after applying both the deductible and the contract limit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
claims_meta_data
|
ClaimsMetaData
|
Metadata for the claim. |
required |
claims_development_history
|
ClaimDevelopmentHistory
|
Development history for the claim. |
required |
Example
claim = Claim(meta_data, dev_history) print(claim.capped_claim_development_history)
Source code in src\pyre\claims\claims.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |
ClaimDevelopmentHistory
Represents the development history of an insurance claim, tracking cumulative and incremental paid and incurred amounts over development months.
Attributes:
| Name | Type | Description |
|---|---|---|
development_months |
List[int]
|
List of development months corresponding to each data point. |
cumulative_dev_paid |
List[float]
|
Cumulative paid amounts at each development month. |
cumulative_dev_incurred |
List[float]
|
Cumulative incurred amounts at each development month. |
Properties
cumulative_reserved_amount (List[float]): List of reserved amounts (incurred minus paid) at each development month. latest_paid (float): Most recent cumulative paid amount, or 0.0 if no data. latest_incurred (float): Most recent cumulative incurred amount, or 0.0 if no data. latest_reserved_amount (float): Most recent reserved amount (incurred minus paid), or 0.0 if no data. latest_development_month (int): Most recent development month, or 0 if no data. incremental_dev_incurred (List[float]): List of incremental incurred amounts at each development month. incremental_dev_paid (List[float]): List of incremental paid amounts at each development month. mean_payment_duration (Optional[float]): Weighted average development month of payments, or None if no payments.
Methods:
| Name | Description |
|---|---|
incremental_dev |
Sequence[float]) -> List[float]: Converts a sequence of cumulative values into incremental values. |
Source code in src\pyre\claims\claims.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
cumulative_reserved_amount
property
Returns a list of reserved amounts (incurred minus paid) at each development month.
ClaimYearType
Bases: Enum
Enumeration of claim year types used in insurance data analysis.
Attributes:
| Name | Type | Description |
|---|---|---|
ACCIDENT_YEAR |
Represents the year in which the insured event (accident) occurred. |
|
UNDERWRITING_YEAR |
Represents the year in which the insurance policy was underwritten or issued. |
|
REPORTED_YEAR |
Represents the year in which the claim was reported to the insurer. |
Source code in src\pyre\claims\claims.py
8 9 10 11 12 13 14 15 16 17 18 | |
Claims
A container class for managing a collection of Claim objects.
This class provides convenient accessors and methods for working with a list of claims, including retrieving modelling years, development periods, and currencies represented in the claims. It also supports list-like behaviors such as indexing, slicing, appending, and iteration.
Attributes:
| Name | Type | Description |
|---|---|---|
claims |
list[Claim]
|
The list of Claim objects managed by this container. |
Properties
modelling_years (List): Sorted list of unique modelling years across all claims. development_periods (List): Sorted list of unique development periods (in months) across all claims. currencies (Set): Set of unique currencies represented in the claims.
Methods:
| Name | Description |
|---|---|
append |
Claim): Appends a Claim object to the collection. |
__getitem__ |
Supports indexing and slicing to access claims. |
__iter__ |
Returns an iterator over the claims. |
__len__ |
Returns the number of claims in the collection. |
Source code in src\pyre\claims\claims.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
currencies
property
Returns a list of currencies for all claims.
development_periods
property
Returns a sorted list of unique development period sequences across all claims.
Each element in the returned list is a list of development months from a claim.
modelling_years
property
Returns a list of modelling years for all claims.
ClaimsMetaData
Metadata for an insurance claim, including key dates, financial limits, and classification details.
Attributes:
| Name | Type | Description |
|---|---|---|
claim_id |
str
|
Unique identifier for the claim. |
currency |
str
|
Currency code for the claim amounts. |
contract_limit |
float
|
Maximum limit of the insurance contract. Defaults to 0.0. |
contract_deductible |
float
|
Deductible amount for the contract. Defaults to 0.0. |
claim_in_xs_of_deductible |
bool
|
Indicates if the claim is in excess of the deductible. Defaults to False. |
claim_year_basis |
ClaimYearType
|
Basis for determining the claim year (e.g., accident, underwriting, reported). Defaults to ClaimYearType.ACCIDENT_YEAR. |
loss_date |
date
|
Date of loss occurrence. Defaults to 1900-01-01. |
policy_inception_date |
date
|
Policy inception date. Defaults to 1900-01-01. |
report_date |
date
|
Date the claim was reported. Defaults to 1900-01-01. |
line_of_business |
Optional[str]
|
Line of business associated with the claim. Defaults to None. |
status |
Optional[str]
|
Status of the claim (e.g., "Open", "Closed"). Defaults to "Open". |
Properties
modelling_year (ClaimsException | int): Returns the modelling year based on the claim_year_basis, or raises ClaimsException if required date is missing.
Source code in src\pyre\claims\claims.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
modelling_year
property
Returns the modelling year based on the claim_year_basis.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The year to use for modelling purposes. |
Raises:
| Type | Description |
|---|---|
ClaimsException
|
If the required date for the specified claim_year_basis is missing. |
CurveType
Bases: Enum
Enum representing different types of curves that can be fitted to triangle data.
Source code in src\pyre\claims\triangles.py
11 12 13 14 15 16 17 18 19 | |
IBNERPatternExtractor
Extracts IBNER patterns from either a Claims object or a Triangle object.
Source code in src\pyre\claims\triangles.py
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | |
get_D_triangle()
Returns the D triangle (IBNER development).
Source code in src\pyre\claims\triangles.py
491 492 493 494 495 | |
get_IBNER_pattern()
Returns the average D (IBNER) pattern per development year.
Source code in src\pyre\claims\triangles.py
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | |
get_N_triangle()
Returns the N triangle (new claims).
Source code in src\pyre\claims\triangles.py
485 486 487 488 489 | |
Triangle
Represents a triangle of claim values (e.g., paid or incurred) by origin (modelling) year and development period.
The triangle is stored as a nested dictionary where: - The outer key is the origin year (int) - The inner key is the development period (int) - The value is the claim amount (float)
Example structure: { 2020: {1: 100.0, 2: 150.0, 3: 175.0}, 2021: {1: 110.0, 2: 165.0}, 2022: {1: 120.0} }
Source code in src\pyre\claims\triangles.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | |
__getitem__(key)
Get a value from the triangle using tuple indexing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Tuple[int, int]
|
Tuple of (origin_year, development_period) |
required |
Returns:
| Type | Description |
|---|---|
Optional[float]
|
The value at the specified position or None if not found |
Example
value = triangle[2020, 2] # Gets the value for origin year 2020, development period 2
Source code in src\pyre\claims\triangles.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
__init__(triangle=None, origin_years=None, dev_periods=None)
Initialize a Triangle directly or as an empty structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
triangle
|
Optional[Dict[int, Dict[int, float]]]
|
Dictionary mapping origin years to dictionaries mapping development periods to values |
None
|
origin_years
|
Optional[List[int]]
|
List of origin years in the triangle |
None
|
dev_periods
|
Optional[List[int]]
|
List of development periods in the triangle |
None
|
Source code in src\pyre\claims\triangles.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
__repr__()
Return a string representation of the Triangle object.
Source code in src\pyre\claims\triangles.py
91 92 93 | |
__setitem__(key, value)
Set a value in the triangle using tuple indexing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Tuple[int, int]
|
Tuple of (origin_year, development_period) |
required |
value
|
Optional[float]
|
The value to set |
required |
Example
triangle[2020, 2] = 150.0 # Sets the value for origin year 2020, development period 2
Source code in src\pyre\claims\triangles.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
__str__()
Return a formatted string representation of the triangle.
Source code in src\pyre\claims\triangles.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
calculate_age_to_age_factors()
Calculate age-to-age factors for the triangle.
Age-to-age factors are calculated as the ratio of the value at development period j+1 to the value at development period j for each origin year.
Returns:
| Type | Description |
|---|---|
Dict[int, Dict[int, float]]
|
Dict[int, Dict[int, float]]: A dictionary mapping origin years to dictionaries mapping development periods to age-to-age factors. |
Source code in src\pyre\claims\triangles.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | |
fit_curve(curve_type, c_values=None)
Fit a curve to the average age-to-age factors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
curve_type
|
CurveType
|
Type of curve to fit. Options are: - CurveType.EXPONENTIAL: Exponential curve - CurveType.POWER: Power curve - CurveType.WEIBULL: Weibull curve - CurveType.INVERSE_POWER: Inverse power curve (Sherman) |
required |
c_values
|
List[float]
|
List of candidate c values for inverse power fit. Defaults to [0.5, 1.0, 1.5, 2.0, 2.5, 3.0]. |
None
|
Returns:
| Type | Description |
|---|---|
Tuple[Dict[str, float], Dict[str, float]]
|
Tuple[Dict[str, float], Dict[str, float]]: A tuple containing: - Parameters of the fitted curve - Metrics assessing the quality of the fit |
Source code in src\pyre\claims\triangles.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | |
from_claims(claims, value_type='incurred')
classmethod
Construct a Triangle from a Claims object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
claims
|
Claims
|
Claims object containing claim data |
required |
value_type
|
str
|
Type of values to extract, either "incurred" or "paid" |
'incurred'
|
Returns:
| Type | Description |
|---|---|
Triangle
|
A new Triangle object with aggregated claim values |
Raises:
| Type | Description |
|---|---|
ValueError
|
If value_type is not "incurred" or "paid" |
Source code in src\pyre\claims\triangles.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
get_average_age_to_age_factors(method='simple')
Calculate average age-to-age factors across all origin years.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
str
|
Method to use for averaging. Options are: - "simple": Simple arithmetic mean - "volume": Volume-weighted average |
'simple'
|
Returns:
| Type | Description |
|---|---|
Dict[int, float]
|
Dict[int, float]: A dictionary mapping development periods to average age-to-age factors. |
Source code in src\pyre\claims\triangles.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | |
get_latest_diagonal()
Get the latest diagonal of the triangle.
Returns:
| Type | Description |
|---|---|
Dict[int, float]
|
Dictionary mapping origin years to their latest available values |
Source code in src\pyre\claims\triangles.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
get_value(origin_year, dev_period)
Get a value from the triangle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
origin_year
|
int
|
The origin year |
required |
dev_period
|
int
|
The development period |
required |
Returns:
| Type | Description |
|---|---|
Optional[float]
|
The value at the specified position or None if not found |
Source code in src\pyre\claims\triangles.py
158 159 160 161 162 163 164 165 166 167 168 169 | |
set_value(origin_year, dev_period, value)
Set a value in the triangle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
origin_year
|
int
|
The origin year |
required |
dev_period
|
int
|
The development period |
required |
value
|
Optional[float]
|
The value to set |
required |
Source code in src\pyre\claims\triangles.py
171 172 173 174 175 176 177 178 179 180 | |
to_cumulative()
Convert an incremental triangle to a cumulative triangle.
Returns:
| Type | Description |
|---|---|
Triangle
|
A new Triangle with cumulative values |
Source code in src\pyre\claims\triangles.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
to_incremental()
Convert a cumulative triangle to an incremental triangle.
Returns:
| Type | Description |
|---|---|
Triangle
|
A new Triangle with incremental values |
Source code in src\pyre\claims\triangles.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |