Compare
Functions to measure the structural similarity between devices.
dice_coefficient(device_a, device_b)
Calculates the Dice coefficient between two binary devices. A value closer to 1 indicates more similarity. The Dice coefficient is calculated as twice the number of pixels in common divided by the total number of pixels in the two devices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
device_a
|
Device
|
The first device (binarized). |
required |
device_b
|
Device
|
The second device (binarized). |
required |
Returns:
Type | Description |
---|---|
float
|
The Dice coefficient between two devices. |
Warnings
UserWarning If one or both devices are not binarized.
Source code in prefab/compare.py
hamming_distance(device_a, device_b)
Calculates the Hamming distance between two binary devices. A lower value indicates more similarity. The Hamming distance is calculated as the number of positions at which the corresponding pixels are different.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
device_a
|
Device
|
The first device (binarized). |
required |
device_b
|
Device
|
The second device (binarized). |
required |
Returns:
Type | Description |
---|---|
int
|
The Hamming distance between two devices. |
Warnings
UserWarning If one or both devices are not binarized.
Source code in prefab/compare.py
intersection_over_union(device_a, device_b)
Calculates the Intersection over Union (IoU) between two binary devices. A value closer to 1 indicates more similarity (more overlap).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
device_a
|
Device
|
The first device (binarized). |
required |
device_b
|
Device
|
The second device (binarized). |
required |
Returns:
Type | Description |
---|---|
float
|
The Intersection over Union between two devices. |
Warnings
UserWarning If one or both devices are not binarized.
Source code in prefab/compare.py
mean_squared_error(device_a, device_b)
Calculate the mean squared error (MSE) between two non-binarized devices. A lower value indicates more similarity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
device_a
|
Device
|
The first device (non-binarized). |
required |
device_b
|
Device
|
The second device (non-binarized). |
required |
Returns:
Type | Description |
---|---|
float
|
The mean squared error between two devices. |