File size: 35,201 Bytes
de86128 46c15e8 de86128 78f7e42 1581d20 6c21ae3 69b8657 6c21ae3 8be36e0 6c21ae3 8be36e0 6c21ae3 8be36e0 6c21ae3 8be36e0 6c21ae3 8be36e0 1581d20 6c21ae3 8be36e0 1581d20 6c21ae3 3a31181 6c21ae3 1581d20 b7e795a 1581d20 b7e795a 1581d20 6c21ae3 78f7e42 6c21ae3 1581d20 8be36e0 1581d20 6c21ae3 8be36e0 6c21ae3 8be36e0 6c21ae3 78f7e42 1581d20 78f7e42 6c21ae3 1581d20 8be36e0 1581d20 6c21ae3 1581d20 613ab12 8be36e0 6c21ae3 8be36e0 78f7e42 613ab12 78f7e42 613ab12 1581d20 8be36e0 613ab12 8be36e0 78f7e42 8be36e0 1581d20 b7e795a 1581d20 8be36e0 78f7e42 1581d20 8be36e0 1581d20 78f7e42 8be36e0 78f7e42 1581d20 de86128 1581d20 8be36e0 1581d20 b7e795a 1581d20 8be36e0 78f7e42 8be36e0 1581d20 8be36e0 78f7e42 8be36e0 78f7e42 1581d20 8be36e0 1581d20 78f7e42 8be36e0 78f7e42 8be36e0 78f7e42 1581d20 78f7e42 1581d20 78f7e42 1581d20 78f7e42 1581d20 78f7e42 1581d20 78f7e42 1581d20 78f7e42 1581d20 46c15e8 1581d20 8be36e0 78f7e42 8be36e0 78f7e42 8be36e0 78f7e42 1581d20 78f7e42 1581d20 78f7e42 1581d20 78f7e42 8be36e0 78f7e42 1581d20 8be36e0 1581d20 8be36e0 1581d20 8be36e0 1581d20 78f7e42 1581d20 78f7e42 1581d20 b7e795a 56ea52e 1581d20 8be36e0 78f7e42 1581d20 8be36e0 1581d20 8be36e0 1581d20 8be36e0 1581d20 8be36e0 1581d20 78f7e42 1581d20 8be36e0 1581d20 8be36e0 1581d20 8be36e0 1581d20 78f7e42 56ea52e 1581d20 56ea52e b7e795a 1581d20 8be36e0 78f7e42 1581d20 8be36e0 1581d20 8be36e0 1581d20 8be36e0 1581d20 78f7e42 1581d20 8be36e0 1581d20 8be36e0 1581d20 8be36e0 1581d20 8be36e0 1581d20 8be36e0 1581d20 46c15e8 1581d20 8be36e0 1581d20 8be36e0 1581d20 8be36e0 1581d20 8be36e0 1581d20 8be36e0 1581d20 b7e795a 1581d20 8be36e0 78f7e42 1581d20 8be36e0 78f7e42 1581d20 78f7e42 1581d20 78f7e42 1581d20 78f7e42 1581d20 8be36e0 78f7e42 1581d20 78f7e42 1581d20 78f7e42 1581d20 8be36e0 78f7e42 1581d20 78f7e42 1581d20 78f7e42 1581d20 78f7e42 1581d20 b7e795a 1581d20 46c15e8 1581d20 46c15e8 b7e795a 1581d20 de86128 1581d20 de86128 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 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 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 443 444 445 446 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 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 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 |
import streamlit as st
import pandas as pd
from ast import literal_eval
import altair as alt
import matplotlib.pyplot as plt
from utils import process_dataset, eval_tags, change_and_delta
from language import process_for_lang, filter_multilinguality
from pipelines import filter_pipeline_data
def main():
# Pick revision at top
supported_revisions = ["13_03_23", "06_03_23", "27_02_23", "20_02_23", "13_02_23","06_02_23", "30_01_23", "24_01_23", "16_01_23", "10_01_23", "02_01_23", "19_12_22", "12_12_22", "05_12_22", "28_11_22", "22_11_22", "14_11_22", "07_11_22", "31_10_22", "24_10_22", "17_10_22", "10_10_22", "27_09_22"]
col1, col2, col3 = st.columns(3)
with col1:
new = st.selectbox(
'Last revision',
supported_revisions,
index=0)
with col2:
base = st.selectbox(
'Old revision',
supported_revisions,
index=1)
with col3:
base_old = st.selectbox(
'Very old revision',
supported_revisions,
index=2)
# Process dataset
old_old_data = process_dataset(base_old)
old_data = process_dataset(base)
data = process_dataset(new)
old_old_data["tags"] = old_old_data.apply(eval_tags, axis=1)
old_data["tags"] = old_data.apply(eval_tags, axis=1)
data["tags"] = data.apply(eval_tags, axis=1)
# High level count of models and rate of change
total_samples_old_old = old_old_data.shape[0]
total_samples_old = old_data.shape[0]
total_samples = data.shape[0]
curr_change, delta = change_and_delta(total_samples_old_old, total_samples_old, total_samples)
col1, col2 = st.columns(2)
with col1:
st.metric(label="Total public models", value=total_samples, delta=total_samples-total_samples_old)
with col2:
st.metric(label="Rate of change", value=curr_change, delta=delta)
# Tabs don't work in Spaces st version
tab1, tab2, tab3, tab4, tab5, tab6, tab7, tab8 = st.tabs(["Language", "License", "Pipeline", "Social Features", "Libraries", "Model Cards", "Super users", "Raw Data"])
with tab1:
st.header("Languages info")
filtered_data = data.copy()
old_filtered_data = old_data.copy()
old_old_filtered_data = old_old_data.copy()
modality = st.selectbox(
'Modalities',
["All", "NLP", "Audio", "Multimodal"])
filtered_data, no_lang_count, total_langs, langs = process_for_lang(filtered_data, modality)
old_filtered_data, no_lang_count_old, total_langs_old, langs_old = process_for_lang(old_filtered_data, modality)
old_old_filtered_data, no_lang_count_old_old, total_langs_old_old, _ = process_for_lang(old_old_filtered_data, modality)
v = filtered_data.shape[0]-no_lang_count
v_old = old_filtered_data.shape[0]-no_lang_count_old
v_old_old = old_old_filtered_data.shape[0]-no_lang_count_old_old
col1, col2 = st.columns(2)
with col1:
st.metric(label="Language Specified", value=v, delta=int(v-v_old))
with col2:
curr_change, delta = change_and_delta(v_old_old, v_old, v)
st.metric(label="Language Specified Rate of Change", value=curr_change, delta=delta)
col1, col2 = st.columns(2)
with col1:
st.metric(label="No Language Specified", value=no_lang_count, delta=int(no_lang_count-no_lang_count_old))
with col2:
curr_change, delta = change_and_delta(no_lang_count_old_old, no_lang_count_old, no_lang_count)
st.metric(label="No Language Specified Rate of Change", value=curr_change, delta=delta)
col1, col2 = st.columns(2)
with col1:
st.metric(label="Total Unique Languages", value=total_langs, delta=int(total_langs-total_langs_old))
with col2:
curr_change, delta = change_and_delta(total_langs_old_old, total_langs_old, total_langs)
st.metric(label="Total Unique Languages Rate of Change", value=curr_change, delta=delta)
st.text(f"New languages {set(langs)-set(langs_old)}")
st.text(f"Lost languages {set(langs_old)-set(langs)}")
st.subheader("Count of languages per model repo")
st.text("Some repos are for multiple languages, so the count is greater than 1")
linguality = st.selectbox(
'All or just Multilingual',
["All", "Just Multilingual", "Three or more languages"])
models_with_langs = filter_multilinguality(filtered_data, linguality)
models_with_langs_old = filter_multilinguality(old_filtered_data, linguality)
df1 = models_with_langs['language_count'].value_counts()
df1_old = models_with_langs_old['language_count'].value_counts()
st.bar_chart(df1)
st.subheader("Most frequent languages")
linguality_2 = st.selectbox(
'All or filtered',
["All", "No English", "Remove top 10"])
models_with_langs = filtered_data[filtered_data["language_count"] > 0]
langs = models_with_langs["languages"].explode()
langs = langs[langs != {}]
orig_d = langs.value_counts().rename_axis("language").to_frame('counts').reset_index()
d = orig_d
models_with_langs_old = old_filtered_data[old_filtered_data["language_count"] > 0]
langs = models_with_langs_old["languages"].explode()
langs = langs[langs != {}]
orig_d_old = langs.value_counts().rename_axis("language").to_frame('counts').reset_index()
if linguality_2 == "No English":
d = orig_d.iloc[1:]
elif linguality_2 == "Remove top 10":
d = orig_d.iloc[10:]
# Just keep top 25 to avoid vertical scroll
d = d.iloc[:25]
st.write(alt.Chart(d).mark_bar().encode(
x='counts',
y=alt.X('language', sort=None)
))
st.subheader("Raw Data")
l = df1.rename_axis("lang_count").reset_index().rename(columns={"language_count": "r_c"})
l_old = df1_old.rename_axis("lang_count").reset_index().rename(columns={"language_count": "old_r_c"})
final_data = pd.merge(
l, l_old, how="outer", on="lang_count"
)
final_data["diff"] = final_data["r_c"] - final_data["old_r_c"]
st.dataframe(final_data)
d = orig_d.astype(str)
orig_d_old = orig_d_old.astype(str).rename(columns={"counts": "old_c"})
final_data = pd.merge(
d, orig_d_old, how="outer", on="language"
)
final_data['counts'] = final_data['counts'].fillna(0).astype(int)
final_data['old_c'] = final_data['old_c'].fillna(0).astype(int)
final_data["diff"] = final_data["counts"] - final_data["old_c"]
final_data['language'] = final_data['language'].astype(str)
st.dataframe(final_data)
with tab2:
st.header("License info")
no_license_count = data["license"].isna().sum()
no_license_count_old = old_data["license"].isna().sum()
no_license_count_old_old = old_old_data["license"].isna().sum()
col1, col2 = st.columns(2)
with col1:
v = total_samples-no_license_count
v_old = total_samples_old-no_license_count_old
st.metric(label="License Specified", value=v, delta=int(v-v_old))
with col2:
v = total_samples-no_license_count
v_old = total_samples_old-no_license_count_old
v_old_old = total_samples_old-no_license_count_old_old
curr_change, delta = change_and_delta(v_old_old, v_old, v)
st.metric(label="License Specified Rate of Change", value=curr_change, delta=delta)
col1, col2 = st.columns(2)
with col1:
st.metric(label="No License Specified", value=no_license_count, delta=int(no_license_count-no_license_count_old))
with col2:
curr_change, delta = change_and_delta(no_license_count_old_old, no_license_count_old, no_license_count)
st.metric(label="No License Specified Rate of Change", value=curr_change, delta=delta)
col1, col2 = st.columns(2)
unique_licenses = len(data["license"].unique())
unique_licenses_old = len(old_data["license"].unique())
unique_licenses_old_old = len(old_old_data["license"].unique())
with col1:
st.metric(label="Total Unique Licenses", value=unique_licenses, delta=int(unique_licenses-unique_licenses_old))
with col2:
curr_change, delta = change_and_delta(unique_licenses_old_old, unique_licenses_old, unique_licenses)
st.metric(label="Total Unique Licenses Rate of Change", value=curr_change, delta=delta)
st.text(f"New licenses {set(data['license'].unique())-set(old_data['license'].unique())}")
st.text(f"Old licenses {set(old_data['license'].unique())-set(data['license'].unique())}")
st.subheader("Distribution of licenses per model repo")
license_filter = st.selectbox(
'All or filtered',
["All", "No Apache 2.0", "Remove top 10"])
filter = 0
if license_filter == "All":
filter = 0
elif license_filter == "No Apache 2.0":
filter = 1
else:
filter = 2
d = data["license"].value_counts().rename_axis("license").to_frame('counts').reset_index()
if filter == 1:
d = d.iloc[1:]
elif filter == 2:
d = d.iloc[10:]
# Just keep top 25 to avoid vertical scroll
d = d.iloc[:25]
st.write(alt.Chart(d).mark_bar().encode(
x='counts',
y=alt.X('license', sort=None)
))
st.text("There are some edge cases, as old repos using lists of licenses.")
st.subheader("Raw Data")
d = data["license"].value_counts().rename_axis("license").to_frame('counts').reset_index()
d_old = old_data["license"].value_counts().rename_axis("license").to_frame('counts').reset_index().rename(columns={"counts": "old_c"})
final_data = pd.merge(
d, d_old, how="outer", on="license"
)
final_data["diff"] = final_data["counts"] - final_data["old_c"]
st.dataframe(final_data)
with tab3:
st.header("Pipeline info")
tags = data["tags"].explode()
tags = tags[tags.notna()].value_counts().rename_axis("tag").to_frame('counts').reset_index()
s = tags["tag"]
s = s[s.apply(type) == str]
unique_tags = len(s.unique())
tags_old = old_data["tags"].explode()
tags_old = tags_old[tags_old.notna()].value_counts().rename_axis("tag").to_frame('counts').reset_index()
s_o = tags_old["tag"]
s_o = s_o[s_o.apply(type) == str]
unique_tags_old = len(s_o.unique())
tags_old_old = old_old_data["tags"].explode()
tags_old_old = tags_old_old[tags_old_old.notna()].value_counts().rename_axis("tag").to_frame('counts').reset_index()
s_old_old = tags_old_old["tag"]
s_old_old = s_old_old[s_old_old.apply(type) == str]
unique_tags_old_old = len(s_old_old.unique())
no_pipeline_count = data["pipeline"].isna().sum()
no_pipeline_count_old = old_data["pipeline"].isna().sum()
no_pipeline_count_old_old = old_old_data["pipeline"].isna().sum()
col1, col2 = st.columns(2)
v = total_samples-no_pipeline_count
v_old = total_samples_old-no_pipeline_count_old
v_old_old = total_samples_old_old-no_pipeline_count_old_old
with col1:
st.metric(label="# models that have any pipeline", value=v, delta=int(v-v_old))
with col2:
curr_change, delta = change_and_delta(v_old_old, v_old, v)
st.metric(label="# models rate of change", value=curr_change, delta=delta)
col1, col2 = st.columns(2)
with col1:
st.metric(label="No pipeline Specified", value=no_pipeline_count, delta=int(no_pipeline_count-no_pipeline_count_old))
with col2:
curr_change, delta = change_and_delta(no_pipeline_count_old_old, no_pipeline_count_old, no_pipeline_count)
st.metric(label="No pipeline Specified rate of change", value=curr_change, delta=delta)
col1, col2 = st.columns(2)
with col1:
st.metric(label="Total Unique Tags", value=unique_tags, delta=int(unique_tags-unique_tags_old))
with col2:
curr_change, delta = change_and_delta(unique_tags_old_old, unique_tags_old, unique_tags)
st.metric(label="Total Unique Tags", value=curr_change, delta=delta)
modality_filter = st.selectbox(
'Modalities',
["All", "NLP", "CV", "Audio", "RL", "Multimodal", "Tabular"])
st.subheader("High-level metrics")
col1, col2, col3 = st.columns(3)
with col1:
p = st.selectbox(
'What pipeline do you want to see?',
["all", *data["pipeline"].unique()]
)
with col2:
l = st.selectbox(
'What library do you want to see?',
["all", "not transformers", *data["library"].unique()]
)
with col3:
f = st.selectbox(
'What trf framework support?',
["all", "pytorch", "tensorflow", "jax"]
)
col1, col2 = st.columns(2)
with col1:
filt = st.multiselect(
label="Tags (All by default)",
options=s.unique(),
default=None)
with col2:
o = st.selectbox(
label="Operation (for tags)",
options=["Any", "All", "None"]
)
filtered_data, tags = filter_pipeline_data(data, modality_filter, p, l, f, filt, o)
filtered_data_old, old_tags = filter_pipeline_data(old_data, modality_filter, p, l, f, filt, o)
filtered_data_old_old, old_old_tags = filter_pipeline_data(old_old_data, modality_filter, p, l, f, filt, o)
st.subheader("Pipeline breakdown")
d = filtered_data["pipeline"].value_counts().rename_axis("pipeline").to_frame('counts').reset_index()
columns_of_interest = ["downloads_30d", "likes", "pytorch", "tensorflow", "jax"]
grouped_data = filtered_data.groupby("pipeline").sum()[columns_of_interest]
final_data = pd.merge(
d, grouped_data, how="outer", on="pipeline"
)
d_old = filtered_data_old["pipeline"].value_counts().rename_axis("pipeline").to_frame('counts').reset_index()
grouped_data_old = filtered_data_old.groupby("pipeline").sum()[columns_of_interest]
final_data_old = pd.merge(
d_old, grouped_data_old, how="outer", on="pipeline"
)
d_old = filtered_data_old_old["pipeline"].value_counts().rename_axis("pipeline").to_frame('counts').reset_index()
grouped_data_old_old = filtered_data_old_old.groupby("pipeline").sum()[columns_of_interest]
sums = grouped_data.sum()
sums_old = grouped_data_old.sum()
sums_old_old = grouped_data_old_old.sum()
col1, col2, col3, col4 = st.columns(4)
v = filtered_data.shape[0]
v_old = filtered_data_old.shape[0]
v_old_old = filtered_data_old_old.shape[0]
with col1:
st.metric(label="Total models", value=v, delta=int(v - v_old))
with col2:
curr_change, delta = change_and_delta(v_old_old, v_old, v)
st.metric(label="Total models rate of change", value=curr_change, delta=delta)
with col3:
st.metric(label="Cumulative Downloads (30d)", value=sums["downloads_30d"], delta=int(sums["downloads_30d"] - sums_old["downloads_30d"]))
with col4:
print(sums_old_old["downloads_30d"], sums_old["downloads_30d"], sums["downloads_30d"])
curr_change, delta = change_and_delta(sums_old_old["downloads_30d"], sums_old["downloads_30d"], sums["downloads_30d"])
st.metric(label="Cumulative Downloads (30d) rate of change", value=curr_change, delta=delta)
col1, col2, col3 = st.columns(3)
with col1:
st.metric(label="Total unique pipelines", value=len(filtered_data["pipeline"].unique()))
with col2:
st.metric(label="Cumulative likes", value=sums["likes"], delta=int(sums["likes"] - sums_old["likes"]))
with col3:
curr_change, delta = change_and_delta(sums_old_old["likes"], sums_old["likes"], sums["likes"])
st.metric(label="Cumulative Likes rate of change", value=curr_change, delta=delta)
col1, col2, col3 = st.columns(3)
with col1:
st.metric(label="Total in PT", value=sums["pytorch"], delta=int(sums["pytorch"] - sums_old["pytorch"]))
with col2:
st.metric(label="Total in TF", value=sums["tensorflow"], delta=int(sums["tensorflow"] - sums_old["tensorflow"]))
with col3:
st.metric(label="Total in JAX", value=sums["jax"], delta=int(sums["jax"] - sums_old["jax"]))
col1, col2 = st.columns(2)
with col1:
st.metric(label="Total unique libraries", value=len(filtered_data["library"].unique()))
with col2:
st.metric(label="Total unique modality", value=len(filtered_data["modality"].unique()))
col1, col2 = st.columns(2)
with col1:
st.metric(label="Total transformers models", value=len(filtered_data[filtered_data["library"] == "transformers"]))
with col2:
st.metric(label="Total non transformers models", value=len(filtered_data[filtered_data["library"] != "transformers"]))
st.metric(label="Unique Tags", value=len(tags), delta=int(len(tags) - len(old_tags)))
st.text(f"New tags {set(tags)-set(old_tags)}")
st.text(f"Lost tags {set(old_tags)-set(tags)}")
st.subheader("Pipeline breakdown by modality")
col1, col2 = st.columns(2)
with col1:
st.metric(label="Total CV models", value=len(filtered_data[filtered_data["modality"] == "cv"]))
with col2:
st.metric(label="Total NLP models", value=len(filtered_data[filtered_data["modality"] == "nlp"]))
col1, col2 = st.columns(2)
with col1:
st.metric(label="Total Audio models", value=len(filtered_data[filtered_data["modality"] == "audio"]))
with col2:
st.metric(label="Total RL models", value=len(filtered_data[filtered_data["modality"] == "rl"]))
col1, col2 = st.columns(2)
with col1:
st.metric(label="Total Tabular models", value=len(filtered_data[filtered_data["modality"] == "tabular"]))
with col2:
st.metric(label="Total Multimodal models", value=len(filtered_data[filtered_data["modality"] == "multimodal"]))
st.subheader("Count of models per pipeline")
st.write(alt.Chart(d).mark_bar().encode(
x='counts',
y=alt.X('pipeline', sort=None)
))
st.subheader("Aggregated data")
st.dataframe(final_data)
st.subheader("Most common model types (specific to transformers)")
d = filtered_data["model_type"].value_counts().rename_axis("model_type").to_frame('counts').reset_index()
d = d.iloc[:15]
st.write(alt.Chart(d).mark_bar().encode(
x='counts',
y=alt.X('model_type', sort=None)
))
st.subheader("Most common library types (Learn more in library tab)")
d = filtered_data["library"].value_counts().rename_axis("library").to_frame('counts').reset_index().head(15)
st.write(alt.Chart(d).mark_bar().encode(
x='counts',
y=alt.X('library', sort=None)
))
st.subheader("Tags by count")
tags = filtered_data["tags"].explode()
tags = tags[tags.notna()].value_counts().rename_axis("tag").to_frame('counts').reset_index()
st.write(alt.Chart(tags.head(30)).mark_bar().encode(
x='counts',
y=alt.X('tag', sort=None)
))
st.subheader("Raw Data")
columns_of_interest = [
"repo_id", "author", "model_type", "files_per_repo", "library",
"downloads_30d", "likes", "pytorch", "tensorflow", "jax"]
raw_data = filtered_data[columns_of_interest]
st.dataframe(raw_data)
# todo : add activity metric
with tab4:
st.header("Social Features")
columns_of_interest = ["prs_count", "prs_open", "prs_merged", "prs_closed", "discussions_count", "discussions_open", "discussions_closed"]
sums = data[columns_of_interest].sum()
sums_old = old_data[columns_of_interest].sum()
sums_old_old = old_old_data[columns_of_interest].sum()
col1, col2, col3, col4 = st.columns(4)
with col1:
st.metric(label="Total PRs", value=sums["prs_count"],delta=int(sums["prs_count"] - sums_old["prs_count"]))
with col2:
st.metric(label="PRs opened", value=sums["prs_open"], delta=int(sums["prs_open"] - sums_old["prs_open"]))
with col3:
st.metric(label="PRs merged", value=sums["prs_merged"], delta=int(sums["prs_merged"] - sums_old["prs_merged"]))
with col4:
st.metric(label="PRs closed", value=sums["prs_closed"], delta=int(sums["prs_closed"] - sums_old["prs_closed"]))
col1, col2, col3, col4 = st.columns(4)
with col1:
curr_change, delta = change_and_delta(sums_old_old["prs_count"], sums_old["prs_count"], sums["prs_count"])
st.metric(label="Total PRs change", value=curr_change,delta=delta)
with col2:
curr_change, delta = change_and_delta(sums_old_old["prs_open"], sums_old["prs_open"], sums["prs_open"])
st.metric(label="PRs opened change", value=curr_change,delta=delta)
with col3:
curr_change, delta = change_and_delta(sums_old_old["prs_merged"], sums_old["prs_merged"], sums["prs_merged"])
st.metric(label="PRs merged change", value=curr_change,delta=delta)
with col4:
curr_change, delta = change_and_delta(sums_old_old["prs_closed"], sums_old["prs_closed"], sums["prs_closed"])
st.metric(label="PRs closed change", value=curr_change,delta=delta)
col1, col2, col3 = st.columns(3)
with col1:
st.metric(label="Total discussions", value=sums["discussions_count"], delta=int(sums["discussions_count"] - sums_old["discussions_count"]))
with col2:
st.metric(label="Discussions open", value=sums["discussions_open"], delta=int(sums["discussions_open"] - sums_old["discussions_open"]))
with col3:
st.metric(label="Discussions closed", value=sums["discussions_closed"], delta=int(sums["discussions_closed"] - sums_old["discussions_closed"]))
col1, col2, col3 = st.columns(3)
with col1:
curr_change, delta = change_and_delta(sums_old_old["discussions_count"], sums_old["discussions_count"], sums["discussions_count"])
st.metric(label="Total discussions change", value=curr_change,delta=delta)
with col2:
curr_change, delta = change_and_delta(sums_old_old["discussions_open"], sums_old["discussions_open"], sums["discussions_open"])
st.metric(label="Discussions open change", value=curr_change,delta=delta)
with col3:
curr_change, delta = change_and_delta(sums_old_old["discussions_closed"], sums_old["discussions_closed"], sums["discussions_closed"])
st.metric(label="Discussions closed change", value=curr_change,delta=delta)
likes = []
for r in supported_revisions:
likes.append(process_dataset(r)["likes"].sum())
source = pd.DataFrame({
'revision': supported_revisions[::-1],
'likes': likes[::-1],
})
st.subheader("Total likes")
st.write(alt.Chart(source).mark_bar().encode(
x=alt.X('revision', sort=alt.EncodingSortField(field="revision", op="count", order='ascending')),
y='likes'
))
st.subheader("Likes Rate of Change")
diffs = source["likes"].pct_change()
source = pd.DataFrame({
'revision': supported_revisions[::-1][1:],
'likes_change': diffs[1:],
})
print(source[["revision", "likes_change"]])
st.write(alt.Chart(source).mark_bar().encode(
x=alt.X('revision', sort=alt.EncodingSortField(field="revision", op="count", order='ascending')),
y='likes_change'
))
st.subheader("Raw Data")
filtered_data = data[["repo_id", "prs_count", "prs_open", "prs_merged", "prs_closed", "discussions_count", "discussions_open", "discussions_closed"]].sort_values("prs_count", ascending=False).reset_index(drop=True)
st.dataframe(filtered_data)
with tab5:
st.header("Library info")
no_library_count = data["library"].isna().sum()
no_library_count_old = old_data["library"].isna().sum()
no_library_count_old_old = old_old_data["library"].isna().sum()
col1, col2, col3 = st.columns(3)
with col1:
v = total_samples-no_library_count
v_old = total_samples_old-no_library_count_old
st.metric(label="# models that have any library", value=v, delta=int(v-v_old))
with col2:
st.metric(label="No library Specified", value=no_library_count, delta=int(no_library_count-no_library_count_old))
with col3:
v = len(data["library"].unique())
v_old = len(old_data["library"].unique())
st.metric(label="Total Unique library", value=v, delta=int(v-v_old))
col1, col2, col3 = st.columns(3)
with col1:
v = total_samples-no_library_count
v_old = total_samples_old-no_library_count_old
v_old_old = total_samples_old_old-no_library_count_old_old
curr_change, delta = change_and_delta(v_old_old, v_old, v)
st.metric(label="# models that have any library change", value=curr_change, delta=delta)
with col2:
curr_change, delta = change_and_delta(no_library_count_old_old, no_library_count_old, no_library_count)
st.metric(label="No library Specified Change", value=curr_change, delta=delta)
with col3:
v = len(data["library"].unique())
v_old = len(old_data["library"].unique())
v_old_old = len(old_old_data["library"].unique())
curr_change, delta = change_and_delta(v_old_old, v_old, v)
st.metric(label="Total Unique library", value=curr_change, delta=delta)
st.subheader("High-level metrics")
filtered_data = data[data['library'].notna()]
filtered_data_old = old_data[old_data['library'].notna()]
col1, col2 = st.columns(2)
with col1:
lib = st.selectbox(
'What library do you want to see? ',
["all", "not transformers", *filtered_data["library"].unique()]
)
with col2:
pip = st.selectbox(
'What pipeline do you want to see? ',
["all", *filtered_data["pipeline"].unique()]
)
if pip != "all" :
filtered_data = filtered_data[filtered_data["pipeline"] == pip]
filtered_data_old = filtered_data_old[filtered_data_old["pipeline"] == pip]
if lib != "all" and lib != "not transformers":
filtered_data = filtered_data[filtered_data["library"] == lib]
filtered_data_old = filtered_data_old[filtered_data_old["library"] == lib]
if lib == "not transformers":
filtered_data = filtered_data[filtered_data["library"] != "transformers"]
filtered_data_old = filtered_data_old[filtered_data_old["library"] != "transformers"]
d = filtered_data["library"].value_counts().rename_axis("library").to_frame('counts').reset_index()
grouped_data = filtered_data.groupby("library").sum()[["downloads_30d", "likes"]]
final_data = pd.merge(
d, grouped_data, how="outer", on="library"
)
sums = grouped_data.sum()
d_old = filtered_data_old["library"].value_counts().rename_axis("library").to_frame('counts').reset_index()
grouped_data_old = filtered_data_old.groupby("library").sum()[["downloads_30d", "likes"]]
final_data_old = pd.merge(
d_old, grouped_data_old, how="outer", on="library"
).add_suffix('_old')
final_data_old = final_data_old.rename(index=str, columns={"library_old": "library"})
sums_old = grouped_data_old.sum()
col1, col2, col3 = st.columns(3)
with col1:
v = filtered_data.shape[0]
v_old = filtered_data_old.shape[0]
st.metric(label="Total models", value=v, delta=int(v-v_old))
with col2:
st.metric(label="Cumulative Downloads (30d)", value=sums["downloads_30d"], delta=int(sums["downloads_30d"]-sums_old["downloads_30d"]))
with col3:
st.metric(label="Cumulative likes", value=sums["likes"], delta=int(sums["likes"]-sums_old["likes"]))
st.subheader("Most common library types (Learn more in library tab)")
d = filtered_data["library"].value_counts().rename_axis("library").to_frame('counts').reset_index().head(15)
st.write(alt.Chart(d).mark_bar().encode(
x='counts',
y=alt.X('library', sort=None)
))
st.subheader("Aggregated Data")
final_data = pd.merge(
final_data, final_data_old, how="outer", on="library"
)
final_data["counts_diff"] = final_data["counts"] - final_data["counts_old"]
final_data["downloads_diff"] = final_data["downloads_30d"] - final_data["downloads_30d_old"]
final_data["likes_diff"] = final_data["likes"] - final_data["likes_old"]
st.dataframe(final_data)
st.subheader("Raw Data")
columns_of_interest = ["repo_id", "author", "files_per_repo", "library", "downloads_30d", "likes"]
filtered_data = filtered_data[columns_of_interest]
st.dataframe(filtered_data)
with tab6:
st.header("Model cards")
columns_of_interest = ["has_model_index", "has_metadata", "has_text", "text_length"]
rows = data.shape[0]
rows_old = old_data.shape[0]
rows_old_old = old_old_data.shape[0]
cond = data["has_model_index"] | data["has_text"]
with_model_card = data[cond]
c_model_card = with_model_card.shape[0]
cond = old_data["has_model_index"] | old_data["has_text"]
with_model_card_old = old_data[cond]
c_model_card_old = with_model_card_old.shape[0]
cond = old_old_data["has_model_index"] | old_old_data["has_text"]
with_model_card_old_old = old_old_data[cond]
c_model_card_old_old = with_model_card_old_old.shape[0]
st.subheader("High-level metrics")
col1, col2, col3, col4 = st.columns(4)
with col1:
st.metric(label="# with model card file", value=c_model_card, delta=int(c_model_card-c_model_card_old))
with col2:
curr_change, delta = change_and_delta(c_model_card_old_old, c_model_card_old, c_model_card)
st.metric(label="# with model card file change", value=curr_change, delta=delta)
with col3:
st.metric(label="# without model card file", value=rows-c_model_card, delta=int((rows-c_model_card)-(rows_old-c_model_card_old)))
with col4:
curr_change, delta = change_and_delta(rows_old_old-c_model_card_old_old, rows_old-c_model_card_old, rows-c_model_card)
st.metric(label="# without model card file change", value=curr_change, delta=delta)
with_index = data["has_model_index"].sum()
with_index_old = old_data["has_model_index"].sum()
with_index_old_old = old_old_data["has_model_index"].sum()
with col1:
st.metric(label="# with model index", value=with_index, delta=int(with_index-with_index_old))
with col2:
curr_change, delta = change_and_delta(with_index_old_old, with_index_old, with_index)
st.metric(label="# with model index change", value=curr_change, delta=delta)
with col3:
st.metric(label="# without model index", value=rows-with_index, delta=int((rows-with_index)-(rows_old-with_index_old)))
with col4:
curr_change, delta = change_and_delta(rows_old_old-with_index_old_old, rows_old-with_index_old, rows-with_index)
st.metric(label="# without model index change", value=curr_change, delta=delta)
with_text = data["has_text"]
with_text_old = old_data["has_text"]
with_text_old_old = old_old_data["has_text"]
with_text_sum = with_text.sum()
with_text_old_sum = with_text_old.sum()
with_text_old_old_sum = with_text_old_old.sum()
with col1:
st.metric(label="# with model card text", value=with_text_sum, delta=int(with_text_sum-with_text_old_sum))
with col2:
curr_change, delta = change_and_delta(with_text_old_old_sum, with_text_old_sum, with_text_sum)
st.metric(label="# with model card text change", value=curr_change, delta=delta)
with col3:
st.metric(label="# without card text", value=rows-with_text_sum, delta=int((rows-with_text_sum)-(with_text_old_sum)))
with col4:
curr_change, delta = change_and_delta(rows_old_old-with_text_old_old_sum, rows_old-with_text_old_sum, rows-with_text_sum)
st.metric(label="# without card text change", value=curr_change, delta=delta)
st.subheader("Length (chars) of model card content")
fig, _ = plt.subplots()
_ = data["length_bins"].value_counts().plot.bar()
st.metric(label="# average length of model card (chars)", value=data[with_text]["text_length"].mean())
st.pyplot(fig)
st.subheader("Tags (Read more in Pipeline tab)")
tags = data["tags"].explode()
tags = tags[tags.notna()].value_counts().rename_axis("tag").to_frame('counts').reset_index()
st.write(alt.Chart(tags.head(30)).mark_bar().encode(
x='counts',
y=alt.X('tag', sort=None)
))
with tab7:
st.header("Authors")
st.text("This info corresponds to the repos owned by the authors")
authors = data.groupby("author").sum().drop(["text_length", "Unnamed: 0"], axis=1).sort_values("downloads_30d", ascending=False)
d = data["author"].value_counts().rename_axis("author").to_frame('counts').reset_index()
final_data = pd.merge(
d, authors, how="outer", on="author"
)
st.dataframe(final_data)
with tab8:
st.header("Raw Data")
d = data.astype(str)
st.dataframe(d)
if __name__ == '__main__':
main()
|