loubnabnl HF staff commited on
Commit
f698f3c
·
1 Parent(s): 3328375

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -7
app.py CHANGED
@@ -6,11 +6,21 @@ st.set_page_config(page_title="Kaggle Notebooks inspection", layout="wide")
6
 
7
  st.markdown("<h1 style='text-align: center; color: #00BFFF;'>Kaggle Notebooks inspection 🔍</h1>", unsafe_allow_html=True)
8
 
9
- st.markdown("Here you can inspect Kaggle notebooks that were converted to python scripts and deduplicated.")
 
 
 
 
 
 
 
 
10
  @st.cache()
11
- def load_data(upvote=0, size=0):
12
- ds = load_dataset("loubnabnl/subset_kaggle_scripts_2", split="train")
13
- ds = ds.filter(lambda x: x["upvotes"] >= upvote and x["seq_len"] >= size)
 
 
14
  return ds
15
 
16
  def show_extra_info(e):
@@ -30,11 +40,24 @@ def show_extra_info(e):
30
  text = f"The title of the notebook is: **{kv['Title']}** and it has **{kv['TotalVotes']} ⬆️ upvotes**.{data_text}"
31
  return text
32
 
33
-
34
  vote = st.sidebar.slider("Minimum notebook ⬆️ upvotes", min_value=0, max_value=100, step=1, value=0)
35
  size = st.sidebar.slider("Length of the notebook in number of tokens", min_value=0, max_value=15_000, step=1000, value=0)
36
- samples = load_data(vote, size)
 
 
 
 
 
 
37
  index_example = st.sidebar.number_input(f"Choose a sample from the existing {len(samples)} notebooks:", min_value=0, max_value=max(0, len(samples)-1), value=0, step=1)
38
 
39
- st.markdown(show_extra_info(samples[index_example]), unsafe_allow_html=True)
 
 
 
 
 
 
 
40
  st.code(samples[index_example]["script"])
 
6
 
7
  st.markdown("<h1 style='text-align: center; color: #00BFFF;'>Kaggle Notebooks inspection 🔍</h1>", unsafe_allow_html=True)
8
 
9
+ st.markdown("""
10
+ Here you can inspect Kaggle notebooks that were converted to python scripts and deduplicated.
11
+
12
+ In the sidebar, you can choose to display:
13
+ - **dataset description and title** when it exists; this information was already available in Kaggle dataset
14
+ - only files for which we **retrieved extra information on the datasets being loaded** in the notebook using Kaggle API (e.g., column names, types, summary...), which makes up about 8% of the dataset.
15
+ There might be multiple CSV files loaded in the same notebook; we use delimiters `<start_description>` and `<end_description>` to separate them.
16
+ """)
17
+
18
  @st.cache()
19
+ def load_data(upvote=0, size=0, has_data_info=False):
20
+ ds = load_dataset("loubnabnl/kaggle_scripts_final_wdata", split="train")
21
+ if has_data_info:
22
+ ds = ds.filter(lambda x: x["has_data_info"])
23
+ ds = ds.filter(lambda x: x["upvotes"] >= upvote and x["script_nb_tokens"] >= size)
24
  return ds
25
 
26
  def show_extra_info(e):
 
40
  text = f"The title of the notebook is: **{kv['Title']}** and it has **{kv['TotalVotes']} ⬆️ upvotes**.{data_text}"
41
  return text
42
 
43
+ st.sidebar.header('Notebook Filters')
44
  vote = st.sidebar.slider("Minimum notebook ⬆️ upvotes", min_value=0, max_value=100, step=1, value=0)
45
  size = st.sidebar.slider("Length of the notebook in number of tokens", min_value=0, max_value=15_000, step=1000, value=0)
46
+
47
+ st.sidebar.header('Display Settings')
48
+ show_data_metadata = st.sidebar.checkbox("Show associated (not necessarily retrieved) data Title and Description", value=True)
49
+ show_only_files_with_data = st.sidebar.checkbox("Show only files for which we retrieved dataset information", value=False)
50
+
51
+ samples = load_data(vote, size, show_only_files_with_data)
52
+ st.sidebar.header('Sample Selection')
53
  index_example = st.sidebar.number_input(f"Choose a sample from the existing {len(samples)} notebooks:", min_value=0, max_value=max(0, len(samples)-1), value=0, step=1)
54
 
55
+ if show_data_metadata:
56
+ st.markdown(f'<h2 style="color:blue;">Kaggle dataset description:</h2>', unsafe_allow_html=True)
57
+ st.markdown(show_extra_info(samples[index_example]), unsafe_allow_html=True)
58
+
59
+ if samples[index_example]["has_data_info"]:
60
+ st.markdown(f'<h2 style="color:blue;">Retrieved data information:</h2>', unsafe_allow_html=True)
61
+ st.code(samples[index_example]["retreived_data_description"])
62
+ st.markdown(f'<h2 style="color:blue;">Notebook {index_example} converted to script:</h2>', unsafe_allow_html=True)
63
  st.code(samples[index_example]["script"])