Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,15 @@
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
-
from huggingface_hub.hf_api import create_repo, upload_file
|
4 |
from huggingface_hub.repository import Repository
|
5 |
import subprocess
|
6 |
import os
|
7 |
import tempfile
|
8 |
import sweetviz as sv
|
9 |
|
10 |
-
def analyze_datasets(dataset, dataset_name,
|
11 |
df = pd.read_csv(dataset.name)
|
|
|
12 |
if column is not None:
|
13 |
analyze_report = sv.analyze(df, target_feat=column, pairwise_analysis=pairwise)
|
14 |
else:
|
@@ -24,9 +25,10 @@ def analyze_datasets(dataset, dataset_name, username, token, column=None, pairwi
|
|
24 |
|
25 |
return f"Your dataset report will be ready at {repo_url}"
|
26 |
|
27 |
-
def compare_column_values(dataset, dataset_name,
|
28 |
|
29 |
df = pd.read_csv(dataset.name)
|
|
|
30 |
arr = df[column].unique()
|
31 |
arr = list(arr[arr != column])
|
32 |
compare_report = sv.compare_intra(df, df[column] == category, arr[0])
|
@@ -42,10 +44,11 @@ def compare_column_values(dataset, dataset_name, username, token, column, catego
|
|
42 |
|
43 |
return f"Your dataset report will be ready at {repo_url}"
|
44 |
|
45 |
-
def compare_dataset_splits(dataset, dataset_name,
|
46 |
df = pd.read_csv(dataset.name)
|
47 |
train = df.sample(frac=splits)
|
48 |
test = df.loc[df.index.difference(train.index)]
|
|
|
49 |
|
50 |
compare_report = sv.compare([train, "Training Data"], [test, "Test Data"])
|
51 |
compare_report.show_html('index.html', open_browser=False)
|
@@ -75,15 +78,14 @@ with gr.Blocks() as demo:
|
|
75 |
column = gr.Text(label = "Compare dataset against a target variable (Optional)")
|
76 |
pairwise = gr.Radio(["off", "on"], label = "Enable pairwise analysis")
|
77 |
token = gr.Textbox(label = "Your Hugging Face Token")
|
78 |
-
username = gr.Textbox(label = "Your Hugging Face User Name")
|
79 |
dataset_name = gr.Textbox(label = "Dataset Name")
|
80 |
-
pushing_desc = gr.Markdown("This app needs your Hugging Face Hub
|
81 |
inference_run = gr.Button("Infer")
|
82 |
inference_progress = gr.StatusTracker(cover_container=True)
|
83 |
outcome = gr.outputs.Textbox()
|
84 |
inference_run.click(
|
85 |
analyze_datasets,
|
86 |
-
inputs=[dataset, dataset_name,
|
87 |
outputs=outcome,
|
88 |
status_tracker=inference_progress,
|
89 |
)
|
@@ -94,9 +96,8 @@ with gr.Blocks() as demo:
|
|
94 |
description = gr.Markdown("Split a dataset and compare splits. You need to give a fraction, e.g. 0.8.")
|
95 |
dataset = gr.File(label = "Dataset")
|
96 |
split_ratio = gr.Number(label = "Split Ratios")
|
97 |
-
pushing_desc = gr.Markdown("This app needs your Hugging Face Hub
|
98 |
token = gr.Textbox(label = "Your Hugging Face Token")
|
99 |
-
username = gr.Textbox(label = "Your Hugging Face User Name")
|
100 |
dataset_name = gr.Textbox(label = "Dataset Name")
|
101 |
inference_run = gr.Button("Infer")
|
102 |
inference_progress = gr.StatusTracker(cover_container=True)
|
@@ -104,7 +105,7 @@ with gr.Blocks() as demo:
|
|
104 |
outcome = gr.outputs.Textbox()
|
105 |
inference_run.click(
|
106 |
compare_dataset_splits,
|
107 |
-
inputs=[dataset, dataset_name,
|
108 |
outputs=outcome,
|
109 |
status_tracker=inference_progress,
|
110 |
)
|
@@ -117,9 +118,8 @@ with gr.Blocks() as demo:
|
|
117 |
dataset = gr.File(label = "Dataset")
|
118 |
column = gr.Text(label = "Enter column:")
|
119 |
category = gr.Text(label = "Enter category:")
|
120 |
-
pushing_desc = gr.Markdown("This app needs your Hugging Face Hub
|
121 |
token = gr.Textbox(label = "Your Hugging Face Token")
|
122 |
-
username = gr.Textbox(label = "Your Hugging Face User Name")
|
123 |
dataset_name = gr.Textbox(label = "Dataset Name")
|
124 |
inference_run = gr.Button("Run Analysis")
|
125 |
inference_progress = gr.StatusTracker(cover_container=True)
|
@@ -127,7 +127,7 @@ with gr.Blocks() as demo:
|
|
127 |
outcome = gr.outputs.Textbox()
|
128 |
inference_run.click(
|
129 |
compare_column_values,
|
130 |
-
inputs=[dataset, dataset_name,
|
131 |
outputs=outcome,
|
132 |
status_tracker=inference_progress,
|
133 |
)
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
+
from huggingface_hub.hf_api import create_repo, upload_file, HfApi
|
4 |
from huggingface_hub.repository import Repository
|
5 |
import subprocess
|
6 |
import os
|
7 |
import tempfile
|
8 |
import sweetviz as sv
|
9 |
|
10 |
+
def analyze_datasets(dataset, dataset_name, token, column=None, pairwise="off"):
|
11 |
df = pd.read_csv(dataset.name)
|
12 |
+
username = HfApi().whoami(token=token)["name"]
|
13 |
if column is not None:
|
14 |
analyze_report = sv.analyze(df, target_feat=column, pairwise_analysis=pairwise)
|
15 |
else:
|
|
|
25 |
|
26 |
return f"Your dataset report will be ready at {repo_url}"
|
27 |
|
28 |
+
def compare_column_values(dataset, dataset_name, token, column, category):
|
29 |
|
30 |
df = pd.read_csv(dataset.name)
|
31 |
+
username = HfApi().whoami(token=token)["name"]
|
32 |
arr = df[column].unique()
|
33 |
arr = list(arr[arr != column])
|
34 |
compare_report = sv.compare_intra(df, df[column] == category, arr[0])
|
|
|
44 |
|
45 |
return f"Your dataset report will be ready at {repo_url}"
|
46 |
|
47 |
+
def compare_dataset_splits(dataset, dataset_name, token, splits):
|
48 |
df = pd.read_csv(dataset.name)
|
49 |
train = df.sample(frac=splits)
|
50 |
test = df.loc[df.index.difference(train.index)]
|
51 |
+
username = HfApi().whoami(token=token)["name"]
|
52 |
|
53 |
compare_report = sv.compare([train, "Training Data"], [test, "Test Data"])
|
54 |
compare_report.show_html('index.html', open_browser=False)
|
|
|
78 |
column = gr.Text(label = "Compare dataset against a target variable (Optional)")
|
79 |
pairwise = gr.Radio(["off", "on"], label = "Enable pairwise analysis")
|
80 |
token = gr.Textbox(label = "Your Hugging Face Token")
|
|
|
81 |
dataset_name = gr.Textbox(label = "Dataset Name")
|
82 |
+
pushing_desc = gr.Markdown("This app needs your Hugging Face Hub token and a unique name for your dataset report.")
|
83 |
inference_run = gr.Button("Infer")
|
84 |
inference_progress = gr.StatusTracker(cover_container=True)
|
85 |
outcome = gr.outputs.Textbox()
|
86 |
inference_run.click(
|
87 |
analyze_datasets,
|
88 |
+
inputs=[dataset, dataset_name, token, column, pairwise],
|
89 |
outputs=outcome,
|
90 |
status_tracker=inference_progress,
|
91 |
)
|
|
|
96 |
description = gr.Markdown("Split a dataset and compare splits. You need to give a fraction, e.g. 0.8.")
|
97 |
dataset = gr.File(label = "Dataset")
|
98 |
split_ratio = gr.Number(label = "Split Ratios")
|
99 |
+
pushing_desc = gr.Markdown("This app needs your Hugging Face Hub token and a unique name for your dataset report.")
|
100 |
token = gr.Textbox(label = "Your Hugging Face Token")
|
|
|
101 |
dataset_name = gr.Textbox(label = "Dataset Name")
|
102 |
inference_run = gr.Button("Infer")
|
103 |
inference_progress = gr.StatusTracker(cover_container=True)
|
|
|
105 |
outcome = gr.outputs.Textbox()
|
106 |
inference_run.click(
|
107 |
compare_dataset_splits,
|
108 |
+
inputs=[dataset, dataset_name, token, split_ratio],
|
109 |
outputs=outcome,
|
110 |
status_tracker=inference_progress,
|
111 |
)
|
|
|
118 |
dataset = gr.File(label = "Dataset")
|
119 |
column = gr.Text(label = "Enter column:")
|
120 |
category = gr.Text(label = "Enter category:")
|
121 |
+
pushing_desc = gr.Markdown("This app needs your Hugging Face Hub token and a unique name for your dataset report.")
|
122 |
token = gr.Textbox(label = "Your Hugging Face Token")
|
|
|
123 |
dataset_name = gr.Textbox(label = "Dataset Name")
|
124 |
inference_run = gr.Button("Run Analysis")
|
125 |
inference_progress = gr.StatusTracker(cover_container=True)
|
|
|
127 |
outcome = gr.outputs.Textbox()
|
128 |
inference_run.click(
|
129 |
compare_column_values,
|
130 |
+
inputs=[dataset, dataset_name, token, column, category ],
|
131 |
outputs=outcome,
|
132 |
status_tracker=inference_progress,
|
133 |
)
|