Anyspell
Utilities for hot, wet, dry, cold or persistent spells, as well as predictions
ExtremeExperiment
Bases: object
Obsolete i tihnk. Use the functions they're up to date
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
object
|
_type_
|
description |
required |
Source code in jetutils/anyspell.py
1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 | |
brier_score(y_true, y_proba=None, *, sample_weight=None, pos_label=None)
Compute the Brier score.
The higher the Brier score, the better. The Brier score measures the mean squared difference between the predicted probability and the actual outcome. The Brier score always takes on a value between zero and one, since this is the largest possible difference between a predicted probability (which must be between zero and one) and the actual outcome (which can take on values of only 0 and 1). It can be decomposed as the sum of refinement loss and calibration loss.
The Brier score is appropriate for binary and categorical outcomes that
can be structured as true or false, but is inappropriate for ordinal
variables which can take on three or more values (this is because the
Brier score assumes that all possible outcomes are equivalently
"distant" from one another). Which label is considered to be the positive
label is controlled via the parameter pos_label, which defaults to
the greater label unless y_true is all 0 or all -1, in which case
pos_label defaults to 1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_true
|
array-like of shape (n_samples,)
|
True targets. |
required |
y_proba
|
array-like of shape (n_samples,)
|
Probabilities of the positive class. |
None
|
sample_weight
|
array-like of shape (n_samples,)
|
Sample weights. |
None
|
pos_label
|
(int, float, bool or str)
|
Label of the positive class.
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
score |
float
|
Brier score loss. |
something else : float
|
another thing. |
References
.. [1] Wikipedia entry for the Brier score
<https://en.wikipedia.org/wiki/Brier_score>_.
Examples:
>>> import numpy as np
>>> from sklearn.metrics import brier_score_loss
>>> y_true = np.array([0, 1, 1, 0])
>>> y_true_categorical = np.array(["spam", "ham", "ham", "spam"])
>>> y_prob = np.array([0.1, 0.9, 0.8, 0.3])
>>> brier_score_loss(y_true, y_prob)
np.float64(0.037...)
>>> brier_score_loss(y_true, 1-y_prob, pos_label=0)
np.float64(0.037...)
>>> brier_score_loss(y_true_categorical, y_prob, pos_label="ham")
np.float64(0.037...)
>>> brier_score_loss(y_true, np.array(y_prob) > 0.5)
np.float64(0.0)
Source code in jetutils/anyspell.py
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 | |
mask_from_spells_pl(spells, to_mask, force_pl=False, time_before=datetime.timedelta(0), time_after=datetime.timedelta(0))
Huh i think this is borken
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spells
|
DataFrame
|
description |
required |
to_mask
|
DataArray | Dataset | DataFrame
|
description |
required |
force_pl
|
bool
|
description, by default False |
False
|
time_before
|
timedelta
|
description, by default datetime.timedelta(0) |
timedelta(0)
|
time_after
|
timedelta
|
description, by default datetime.timedelta(0) |
timedelta(0)
|
Returns:
| Type | Description |
|---|---|
_type_
|
description |
Source code in jetutils/anyspell.py
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 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 | |