QSBench commited on
Commit
0090949
·
1 Parent(s): 16e3717
Files changed (2) hide show
  1. app.py +60 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ import numpy as np
4
+ from datasets import load_dataset
5
+ from sklearn.ensemble import RandomForestRegressor
6
+ from sklearn.metrics import r2_score
7
+ import matplotlib.pyplot as plt
8
+
9
+ # Загрузка датасета
10
+ ds = load_dataset("QSBench/QSBench-Core-v1.0.0-demo")
11
+
12
+ # Функция для отображения данных выбранного сплита
13
+ def show_data(split):
14
+ df = pd.DataFrame(ds[split])
15
+ return df.head(10)
16
+
17
+ # Функция для обучения модели
18
+ def train_and_plot():
19
+ feature_cols = ["total_gates", "gate_entropy", "meyer_wallach"]
20
+ target_col = "ideal_expval_Z_global"
21
+ X_train = pd.DataFrame(ds["train"])[feature_cols]
22
+ y_train = pd.DataFrame(ds["train"])[target_col]
23
+ X_test = pd.DataFrame(ds["test"])[feature_cols]
24
+ y_test = pd.DataFrame(ds["test"])[target_col]
25
+
26
+ model = RandomForestRegressor(n_estimators=100, random_state=42)
27
+ model.fit(X_train, y_train)
28
+ y_pred = model.predict(X_test)
29
+ r2 = r2_score(y_test, y_pred)
30
+
31
+ fig, ax = plt.subplots()
32
+ ax.scatter(y_test, y_pred, alpha=0.5)
33
+ ax.plot([y_test.min(), y_test.max()], [y_test.min(), y_test.max()], 'r--')
34
+ ax.set_xlabel("True value")
35
+ ax.set_ylabel("Predicted")
36
+ ax.set_title(f"Predictions vs. Truth (R² = {r2:.4f})")
37
+ return fig
38
+
39
+ with gr.Blocks(title="QSBench Demo Explorer") as demo:
40
+ gr.Markdown("""
41
+ # QSBench Core Demo Explorer
42
+ Interactive demo of the **QSBench Core Demo** dataset – 200 synthetic quantum circuits (6 qubits, depth 4).
43
+ This space shows how to load the data, inspect it, and train a simple model on the ideal expectation values.
44
+
45
+ 👉 **Full datasets (up to 200k samples, noisy versions, 10‑qubit transpilation packs) are available for purchase.**
46
+ [Visit the QSBench website](https://qsbench.github.io/)
47
+ """)
48
+ with gr.Tabs():
49
+ with gr.TabItem("Data Explorer"):
50
+ split_selector = gr.Dropdown(choices=["train", "validation", "test"], label="Choose a split", value="train")
51
+ data_table = gr.Dataframe()
52
+ split_selector.change(fn=show_data, inputs=split_selector, outputs=data_table)
53
+ with gr.TabItem("Model Demo"):
54
+ train_button = gr.Button("Train Random Forest")
55
+ plot_output = gr.Plot()
56
+ train_button.click(fn=train_and_plot, outputs=plot_output)
57
+ gr.Markdown("---")
58
+ gr.Markdown("### Get the full datasets\n- **QSBench Core** – 75k clean circuits (8 qubits)\n- **Depolarizing Noise Pack** – 150k circuits with depolarizing noise\n- **Amplitude Damping Pack** – 150k circuits with T1‑like relaxation\n- **Transpilation Hardware Pack** – 200k circuits (10 qubits) with hardware‑aware transpilation\n\n🔗 [Browse all datasets and purchase licenses](https://qsbench.github.io/)")
59
+
60
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ streamlit
2
+ datasets
3
+ pandas
4
+ scikit-learn
5
+ matplotlib