cupid_streamlit_utils
module¶
Utility code for the Streamlit app in cupid_streamlit.py
.
download_parameters_results(file_name, do_estimates, pars_res)
¶
formats the summary of the simulation (parameters and results) and offers to download the summary as a text file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_name |
str
|
the summary will be downloaded in file_name |
required |
do_estimates |
bool
|
if True, the two estimators were run and we also give the estimation results |
required |
pars_res |
Any
|
a tuple with what we need to format the summary |
required |
Returns:
Type | Description |
---|---|
None
|
nothing |
Source code in cupid_matching/cupid_streamlit_utils.py
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 |
|
make_margins(n, ncat, scenario='Constant')
¶
generates the numbers by type on one side of the market
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n |
int
|
the total number of individuals on that side of the market |
required |
ncat |
int
|
the number of types on that side of the market |
required |
scenario |
str
|
"Constant", "Increasing", or "Decreasing" numbers as a function of type |
'Constant'
|
Returns:
Type | Description |
---|---|
np.ndarray
|
the numbers by type on this side |
Source code in cupid_matching/cupid_streamlit_utils.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
plot_heatmap(mat, str_format, str_tit=None)
¶
Plots a heatmap of the matrix
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mat |
np.ndarray
|
the matrix to plot |
required |
str_tit |
str | None
|
a title, if any |
None
|
Returns:
Type | Description |
---|---|
alt.Chart
|
the heatmap |
Source code in cupid_matching/cupid_streamlit_utils.py
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 |
|
plot_matching(mus)
¶
generates the complete plot of matching patterns
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mus |
Matching
|
the matching patterns |
required |
Returns:
Type | Description |
---|---|
alt.Chart
|
the plot |
Source code in cupid_matching/cupid_streamlit_utils.py
171 172 173 174 175 176 177 178 179 180 181 182 183 |
|
table_estimates(coeff_names, true_coeffs, estimates, stderrs)
¶
returns a table of the estimates
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coeff_names |
list[str]
|
the names of the coefficients |
required |
true_coeffs |
np.ndarray
|
the true values of the coefficients |
required |
estimates |
np.ndarray
|
the estimated values of the coefficients |
required |
stderrs |
np.ndarray
|
the standard errors of the estimates |
required |
Returns:
Type | Description |
---|---|
pd.DataFrame
|
the table |
Source code in cupid_matching/cupid_streamlit_utils.py
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 |
|