Spaces:
Sleeping
Sleeping
app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,13 @@
|
|
| 1 |
-
#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
|
| 2 |
-
|
| 3 |
import gradio as gr
|
| 4 |
import pandas as pd
|
| 5 |
-
|
| 6 |
import matplotlib.pyplot as plt
|
| 7 |
import seaborn as sns
|
| 8 |
import io
|
|
|
|
| 9 |
|
| 10 |
-
# OpenAI API Key (
|
| 11 |
-
|
| 12 |
|
| 13 |
def analyze_dataset(file):
|
| 14 |
# Load dataset
|
|
@@ -29,12 +28,12 @@ def analyze_dataset(file):
|
|
| 29 |
|
| 30 |
Provide a structured analysis, visualization suggestions, and cleaning strategies.
|
| 31 |
"""
|
| 32 |
-
response =
|
| 33 |
-
model="gpt-
|
| 34 |
messages=[{"role": "system", "content": "You are a data science expert."},
|
| 35 |
{"role": "user", "content": prompt}]
|
| 36 |
)
|
| 37 |
-
insights = response
|
| 38 |
|
| 39 |
# Generate visualizations
|
| 40 |
fig, ax = plt.subplots(figsize=(6, 4))
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import pandas as pd
|
| 3 |
+
from openai import OpenAI # For LLM integration
|
| 4 |
import matplotlib.pyplot as plt
|
| 5 |
import seaborn as sns
|
| 6 |
import io
|
| 7 |
+
import os
|
| 8 |
|
| 9 |
+
# OpenAI API Key (Hardcoded for now - ensure security in production)
|
| 10 |
+
client = OpenAI(api_key="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")
|
| 11 |
|
| 12 |
def analyze_dataset(file):
|
| 13 |
# Load dataset
|
|
|
|
| 28 |
|
| 29 |
Provide a structured analysis, visualization suggestions, and cleaning strategies.
|
| 30 |
"""
|
| 31 |
+
response = client.chat.completions.create(
|
| 32 |
+
model="gpt-4o-mini",
|
| 33 |
messages=[{"role": "system", "content": "You are a data science expert."},
|
| 34 |
{"role": "user", "content": prompt}]
|
| 35 |
)
|
| 36 |
+
insights = response.choices[0].message.content
|
| 37 |
|
| 38 |
# Generate visualizations
|
| 39 |
fig, ax = plt.subplots(figsize=(6, 4))
|