Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -64,7 +64,6 @@ def capabilities() -> Dict[str, Any]:
|
|
| 64 |
return {
|
| 65 |
"capabilities": [
|
| 66 |
"advanced_visualizations",
|
| 67 |
-
"plotly_html",
|
| 68 |
"matplotlib_seaborn_png",
|
| 69 |
]
|
| 70 |
}
|
|
@@ -89,6 +88,7 @@ def sanitize_script(script: str) -> str:
|
|
| 89 |
- Remove deprecated plt.style.use
|
| 90 |
- Ensure seaborn theme is set
|
| 91 |
- Avoid unsafe casts of string columns to float
|
|
|
|
| 92 |
"""
|
| 93 |
try:
|
| 94 |
# Force read_csv('data.csv')
|
|
@@ -120,6 +120,13 @@ def sanitize_script(script: str) -> str:
|
|
| 120 |
script,
|
| 121 |
count=1,
|
| 122 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
return script
|
| 124 |
except Exception:
|
| 125 |
return script
|
|
@@ -155,14 +162,13 @@ POVINNÉ POKROČILÉ VIZUALIZACE:
|
|
| 155 |
3. INTERAKTIVNÍ A 3D VIZUALIZACE:
|
| 156 |
- 3D scatter plots s color mapping
|
| 157 |
- Surface plots a contour plots
|
| 158 |
-
-
|
| 159 |
- Animated plots s matplotlib.animation
|
| 160 |
- Subplot grids s komplexními layouty
|
| 161 |
|
| 162 |
4. POKROČILÉ KNIHOVNY (POVINNÉ):
|
| 163 |
- PyTorch pro deep learning vizualizace
|
| 164 |
- scikit-learn pro ML algoritmy
|
| 165 |
-
- plotly pro interaktivní grafy
|
| 166 |
- seaborn pro statistické grafy
|
| 167 |
- matplotlib pro custom vizualizace
|
| 168 |
- numpy pro numerické operace
|
|
@@ -177,10 +183,8 @@ TECHNICKÉ POŽADAVKY:
|
|
| 177 |
- Uložte každý graf jako 'graph1.{output_format}', 'graph2.{output_format}', atd.
|
| 178 |
- Hlavní graf uložte jako 'main.{output_format}'
|
| 179 |
|
| 180 |
-
|
| 181 |
-
-
|
| 182 |
-
- Pokud 'output_format' je 'png' nebo 'svg', použijte 'fig.write_image(...)' (Kaleido)
|
| 183 |
-
- Pokud 'output_format' je 'html', použijte 'fig.write_html(...)'
|
| 184 |
|
| 185 |
KRITICKÉ SYNTAX POŽADAVKY:
|
| 186 |
- NIKDY nepoužívejte plt.style.use() - je to ZASTARALÉ a způsobuje chyby!
|
|
@@ -192,30 +196,7 @@ KRITICKÉ SYNTAX POŽADAVKY:
|
|
| 192 |
- PRO ML a numerické operace používejte pouze numerické sloupce: numeric_df = df.select_dtypes(include=['number'])
|
| 193 |
- Nikdy neprovádějte df.astype(float) na celém DataFrame; místo toho použijte pd.to_numeric(..., errors='coerce') na jednotlivé sloupce nebo pracujte s numeric_df
|
| 194 |
|
| 195 |
-
|
| 196 |
-
```python
|
| 197 |
-
# Clustering analysis
|
| 198 |
-
from sklearn.cluster import KMeans, DBSCAN
|
| 199 |
-
from sklearn.decomposition import PCA
|
| 200 |
-
from sklearn.manifold import TSNE
|
| 201 |
-
import plotly.express as px
|
| 202 |
-
import plotly.graph_objects as go
|
| 203 |
-
|
| 204 |
-
# PCA analysis
|
| 205 |
-
pca = PCA(n_components=2)
|
| 206 |
-
pca_result = pca.fit_transform(numeric_data)
|
| 207 |
-
|
| 208 |
-
# Clustering
|
| 209 |
-
kmeans = KMeans(n_clusters=3)
|
| 210 |
-
clusters = kmeans.fit_predict(numeric_data)
|
| 211 |
-
|
| 212 |
-
# 3D interactive plot
|
| 213 |
-
fig = px.scatter_3d(df, x='PC1', y='PC2', z='PC3', color='cluster',
|
| 214 |
-
title='3D PCA with Clustering')
|
| 215 |
-
fig.write_html('interactive_3d.html')
|
| 216 |
-
```
|
| 217 |
-
|
| 218 |
-
Vytvořte podobně pokročilý skript s více vizualizacemi!
|
| 219 |
"""
|
| 220 |
resp = client.messages.create(
|
| 221 |
model="claude-3-5-sonnet-20241022", # Funkční model
|
|
|
|
| 64 |
return {
|
| 65 |
"capabilities": [
|
| 66 |
"advanced_visualizations",
|
|
|
|
| 67 |
"matplotlib_seaborn_png",
|
| 68 |
]
|
| 69 |
}
|
|
|
|
| 88 |
- Remove deprecated plt.style.use
|
| 89 |
- Ensure seaborn theme is set
|
| 90 |
- Avoid unsafe casts of string columns to float
|
| 91 |
+
- Remove any Plotly imports/usages (Plotly disabled)
|
| 92 |
"""
|
| 93 |
try:
|
| 94 |
# Force read_csv('data.csv')
|
|
|
|
| 120 |
script,
|
| 121 |
count=1,
|
| 122 |
)
|
| 123 |
+
# Strip Plotly imports and common usages
|
| 124 |
+
script = re.sub(r"^\s*import\s+plotly[\s\S]*?$", "", script, flags=re.MULTILINE)
|
| 125 |
+
script = re.sub(r"^\s*from\s+plotly[\s\S]*?$", "", script, flags=re.MULTILINE)
|
| 126 |
+
script = re.sub(r"px\.", "# px.", script)
|
| 127 |
+
script = re.sub(r"go\.", "# go.", script)
|
| 128 |
+
script = re.sub(r"\.write_html\(", "# .write_html(", script)
|
| 129 |
+
script = re.sub(r"\.write_image\(", "# .write_image(", script)
|
| 130 |
return script
|
| 131 |
except Exception:
|
| 132 |
return script
|
|
|
|
| 162 |
3. INTERAKTIVNÍ A 3D VIZUALIZACE:
|
| 163 |
- 3D scatter plots s color mapping
|
| 164 |
- Surface plots a contour plots
|
| 165 |
+
- Interaktivní prvky pouze pokud je to možné s matplotlib; preferujte statické PNG
|
| 166 |
- Animated plots s matplotlib.animation
|
| 167 |
- Subplot grids s komplexními layouty
|
| 168 |
|
| 169 |
4. POKROČILÉ KNIHOVNY (POVINNÉ):
|
| 170 |
- PyTorch pro deep learning vizualizace
|
| 171 |
- scikit-learn pro ML algoritmy
|
|
|
|
| 172 |
- seaborn pro statistické grafy
|
| 173 |
- matplotlib pro custom vizualizace
|
| 174 |
- numpy pro numerické operace
|
|
|
|
| 183 |
- Uložte každý graf jako 'graph1.{output_format}', 'graph2.{output_format}', atd.
|
| 184 |
- Hlavní graf uložte jako 'main.{output_format}'
|
| 185 |
|
| 186 |
+
OMEZENÍ:
|
| 187 |
+
- Plotly je zakázáno; nepoužívejte importy ani funkce Plotly
|
|
|
|
|
|
|
| 188 |
|
| 189 |
KRITICKÉ SYNTAX POŽADAVKY:
|
| 190 |
- NIKDY nepoužívejte plt.style.use() - je to ZASTARALÉ a způsobuje chyby!
|
|
|
|
| 196 |
- PRO ML a numerické operace používejte pouze numerické sloupce: numeric_df = df.select_dtypes(include=['number'])
|
| 197 |
- Nikdy neprovádějte df.astype(float) na celém DataFrame; místo toho použijte pd.to_numeric(..., errors='coerce') na jednotlivé sloupce nebo pracujte s numeric_df
|
| 198 |
|
| 199 |
+
Vytvořte pokročilý skript s více vizualizacemi výhradně pomocí matplotlib a seaborn.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
"""
|
| 201 |
resp = client.messages.create(
|
| 202 |
model="claude-3-5-sonnet-20241022", # Funkční model
|