Samuel Mueller commited on
Commit
a07780a
1 Parent(s): fc8530b

updated interface

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -13,17 +13,17 @@ from sklearn.model_selection import cross_val_score
13
 
14
  def compute(file, y_attribute, cv_folds):
15
  if file is None:
16
- return 'Please upload a .arff file'
17
  if file.name.endswith('.arff'):
18
  dataset = openml.datasets.OpenMLDataset('t', 'test', data_file=file.name)
19
  X_, _, categorical_indicator_, attribute_names_ = dataset.get_data(
20
  dataset_format="array")
21
  if y_attribute not in attribute_names_:
22
- return f"**Select attribute from {', '.join(attribute_names_)}**"
23
  X, y, categorical_indicator_, attribute_names_ = dataset.get_data(
24
  dataset_format="array", target=y_attribute)
25
  else:
26
- return 'Please upload a .arff file'
27
 
28
  order = np.arange(y.shape[0])
29
  np.random.seed(13)
@@ -40,7 +40,7 @@ def compute(file, y_attribute, cv_folds):
40
  # print(file, type(file))
41
  return f"ROC AUC OVO Cross Val mean is {sum(scores) / len(scores)} from {scores}. " + (
42
  "The PFN is only trained for datasets with up to 1024 training examples and it had to extrapolate to greater datasets for this evaluation." if len(
43
- y) // cv_folds > 1024 else "")
44
 
45
 
46
  def upload_file(file):
@@ -58,7 +58,7 @@ def upload_file(file):
58
 
59
  with gr.Blocks() as demo:
60
  gr.Markdown("""This demo allows you to play with the **TabPFN**.
61
- Upload a .arff file, select an attribute to predict and the number of cross validation folds and get the ROC AUC OVO score.
62
  """)
63
  inp_file = gr.File(
64
  label='Drop a .arff file.')
@@ -67,7 +67,7 @@ with gr.Blocks() as demo:
67
 
68
  y_attribute = gr.Textbox(label='y attribute')
69
 
70
- examples = gr.Examples(examples=['iris.csv', 'balance-scale.arff'],
71
  inputs=[inp_file],
72
  outputs=[out_text, y_attribute],
73
  fn=upload_file,
@@ -76,6 +76,6 @@ with gr.Blocks() as demo:
76
  # out_table = gr.DataFrame()
77
  inp_file.change(fn=upload_file, inputs=inp_file, outputs=[out_text, y_attribute])
78
 
79
- btn.click(fn=compute, inputs=[inp_file, y_attribute, cv_folds], outputs=[out_text])
80
 
81
  demo.launch()
13
 
14
  def compute(file, y_attribute, cv_folds):
15
  if file is None:
16
+ return 'Please upload a .arff file', y_attribute
17
  if file.name.endswith('.arff'):
18
  dataset = openml.datasets.OpenMLDataset('t', 'test', data_file=file.name)
19
  X_, _, categorical_indicator_, attribute_names_ = dataset.get_data(
20
  dataset_format="array")
21
  if y_attribute not in attribute_names_:
22
+ return f"**Select attribute from {', '.join(attribute_names_)}**", y_attribute
23
  X, y, categorical_indicator_, attribute_names_ = dataset.get_data(
24
  dataset_format="array", target=y_attribute)
25
  else:
26
+ return 'Please upload a .arff file', y_attribute
27
 
28
  order = np.arange(y.shape[0])
29
  np.random.seed(13)
40
  # print(file, type(file))
41
  return f"ROC AUC OVO Cross Val mean is {sum(scores) / len(scores)} from {scores}. " + (
42
  "The PFN is only trained for datasets with up to 1024 training examples and it had to extrapolate to greater datasets for this evaluation." if len(
43
+ y) // cv_folds > 1024 else ""), y_attribute
44
 
45
 
46
  def upload_file(file):
58
 
59
  with gr.Blocks() as demo:
60
  gr.Markdown("""This demo allows you to play with the **TabPFN**.
61
+ Upload a .arff file, select an attribute to predict and the number of cross validation folds and get the ROC AUC OVO score for one seed.
62
  """)
63
  inp_file = gr.File(
64
  label='Drop a .arff file.')
67
 
68
  y_attribute = gr.Textbox(label='y attribute')
69
 
70
+ examples = gr.Examples(examples=['balance-scale.arff'],
71
  inputs=[inp_file],
72
  outputs=[out_text, y_attribute],
73
  fn=upload_file,
76
  # out_table = gr.DataFrame()
77
  inp_file.change(fn=upload_file, inputs=inp_file, outputs=[out_text, y_attribute])
78
 
79
+ btn.click(fn=compute, inputs=[inp_file, y_attribute, cv_folds], outputs=[out_text, y_attribute])
80
 
81
  demo.launch()