TabPFN commited on
Commit
dda1ebd
·
1 Parent(s): 3383b5d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -9
app.py CHANGED
@@ -14,7 +14,9 @@ import os
14
  import matplotlib.pyplot as plt
15
  from matplotlib.colors import ListedColormap
16
 
17
- def compute(table: np.array):
 
 
18
  vfunc = np.vectorize(lambda s: len(str(s)))
19
  non_empty_row_mask = (vfunc(table).sum(1) != 0)
20
  table = table[non_empty_row_mask]
@@ -82,7 +84,6 @@ def compute(table: np.array):
82
 
83
 
84
  def upload_file(file, remove_entries=10):
85
- global headers
86
  if file.name.endswith('.arff'):
87
  dataset = openml.datasets.OpenMLDataset('t', 'test', data_file=file.name)
88
  X_, _, categorical_indicator_, attribute_names_ = dataset.get_data(
@@ -101,8 +102,6 @@ def upload_file(file, remove_entries=10):
101
 
102
 
103
  def update_table(table):
104
- global headers
105
- table = pd.DataFrame(table)
106
  vfunc = np.vectorize(lambda s: len(str(s)))
107
  non_empty_row_mask = (vfunc(table).sum(1) != 0)
108
  table = table[non_empty_row_mask]
@@ -115,12 +114,9 @@ def update_table(table):
115
  eval_lines = empty_inds[0]
116
 
117
  table.iloc[eval_lines, y_column] = ''
118
- table.columns = headers
119
 
120
  return table
121
 
122
- headers = []
123
-
124
  gr.Markdown("""This demo allows you to experiment with the **TabPFN** model for tabular data.
125
 
126
  If you remove values in the target column, TabPFN will make predictions on them after clicking on the Button. The first 10 target values were already removed for this example dataset, so TabPFN will predict the first 10 classes.
@@ -130,8 +126,8 @@ gr.Markdown("""This demo allows you to experiment with the **TabPFN** model for
130
  with gr.Blocks() as demo:
131
  with gr.Row():
132
  with gr.Column():
133
- inp_table = gr.DataFrame(type='numpy', value=upload_file(Path('iris.csv'), remove_entries=10)
134
- , headers=[''] * 3)
135
 
136
  inp_file = gr.File(
137
  label='Drop either a .csv (without header, only numeric values for all but the labels) or a .arff file.')
 
14
  import matplotlib.pyplot as plt
15
  from matplotlib.colors import ListedColormap
16
 
17
+ def compute(df_table):
18
+ headers = df_table.columns
19
+ table = df_table.to_numpy()
20
  vfunc = np.vectorize(lambda s: len(str(s)))
21
  non_empty_row_mask = (vfunc(table).sum(1) != 0)
22
  table = table[non_empty_row_mask]
 
84
 
85
 
86
  def upload_file(file, remove_entries=10):
 
87
  if file.name.endswith('.arff'):
88
  dataset = openml.datasets.OpenMLDataset('t', 'test', data_file=file.name)
89
  X_, _, categorical_indicator_, attribute_names_ = dataset.get_data(
 
102
 
103
 
104
  def update_table(table):
 
 
105
  vfunc = np.vectorize(lambda s: len(str(s)))
106
  non_empty_row_mask = (vfunc(table).sum(1) != 0)
107
  table = table[non_empty_row_mask]
 
114
  eval_lines = empty_inds[0]
115
 
116
  table.iloc[eval_lines, y_column] = ''
 
117
 
118
  return table
119
 
 
 
120
  gr.Markdown("""This demo allows you to experiment with the **TabPFN** model for tabular data.
121
 
122
  If you remove values in the target column, TabPFN will make predictions on them after clicking on the Button. The first 10 target values were already removed for this example dataset, so TabPFN will predict the first 10 classes.
 
126
  with gr.Blocks() as demo:
127
  with gr.Row():
128
  with gr.Column():
129
+ inp_table = gr.DataFrame(type='pandas', value=upload_file(Path('iris.csv'), remove_entries=10)
130
+ , headers=[''] * 5)
131
 
132
  inp_file = gr.File(
133
  label='Drop either a .csv (without header, only numeric values for all but the labels) or a .arff file.')