| import streamlit as st |
| from data_cleaning import DataCleaner |
| from visualization import VisualizationSelector |
| from data_analysis import DataAnalyzer |
| from report_generator import ReportGenerator |
| from api_integration import APIConnector |
| from natural_language_query import NLQueryEngine |
| from predictive_analytics import PredictiveAnalytics |
| from anomaly_detection import AnomalyDetector |
| from time_series_forecasting import TimeSeriesForecaster |
| from sentiment_analysis import SentimentAnalyzer |
| from data_storytelling import DataStoryteller |
| import pandas as pd |
|
|
| class DataAutomationApp: |
| def __init__(self): |
| self.data = None |
| self.cleaner = DataCleaner() |
| self.visualizer = VisualizationSelector() |
| self.analyzer = DataAnalyzer() |
| self.report_generator = ReportGenerator() |
| self.api_connector = APIConnector() |
| self.nl_query_engine = NLQueryEngine() |
| self.predictive_analytics = PredictiveAnalytics() |
| self.anomaly_detector = AnomalyDetector() |
| self.time_series_forecaster = TimeSeriesForecaster() |
| self.sentiment_analyzer = SentimentAnalyzer() |
| self.data_storyteller = DataStoryteller() |
|
|
| def load_data(self, file): |
| if file.name.endswith('.csv'): |
| self.data = pd.read_csv(file) |
| elif file.name.endswith(('.xls', '.xlsx')): |
| self.data = pd.read_excel(file) |
| else: |
| st.error("Unsupported file format. Please upload a CSV or Excel file.") |
|
|
| def run(self): |
| st.title("Data Automation and Visualization App") |
|
|
| |
| uploaded_file = st.file_uploader("Choose a CSV or Excel file", type=["csv", "xlsx"]) |
| if uploaded_file is not None: |
| self.load_data(uploaded_file) |
| if self.data is not None: |
| st.success("Data loaded successfully!") |
|
|
| |
| st.sidebar.title("Select a Feature") |
| feature = st.sidebar.radio( |
| "Choose what you'd like to do:", |
| ("Clean Data", "Generate Visualizations", "Analyze Data", |
| "Natural Language Query", "Run Predictive Analytics", |
| "Detect Anomalies", "Forecast Time Series", |
| "Analyze Sentiment", "Generate Data Story", |
| "Generate Report") |
| ) |
|
|
| |
| if feature == "Clean Data": |
| st.subheader("Clean Data") |
| if st.button("Clean Data"): |
| self.data = self.cleaner.clean(self.data) |
| st.write(self.data.head()) |
|
|
| elif feature == "Generate Visualizations": |
| st.subheader("Generate Visualizations") |
| if st.button("Generate Visualizations"): |
| visualizations = self.visualizer.select_visualizations(self.data) |
| for viz in visualizations: |
| st.pyplot(viz) |
|
|
| elif feature == "Analyze Data": |
| st.subheader("Analyze Data") |
| if st.button("Analyze Data"): |
| insights = self.analyzer.analyze(self.data) |
| st.write(insights) |
|
|
| elif feature == "Natural Language Query": |
| st.subheader("Ask a Question About Your Data") |
| query = st.text_input("Ask a question about your data:") |
| if query: |
| result = self.nl_query_engine.process_query(query, self.data) |
| st.write(result) |
|
|
| elif feature == "Run Predictive Analytics": |
| st.subheader("Run Predictive Analytics") |
| if st.button("Run Predictive Analytics"): |
| prediction = self.predictive_analytics.predict(self.data) |
| st.write(prediction) |
|
|
| elif feature == "Detect Anomalies": |
| st.subheader("Detect Anomalies") |
| if st.button("Detect Anomalies"): |
| anomalies = self.anomaly_detector.detect(self.data) |
| st.write(anomalies) |
|
|
| elif feature == "Forecast Time Series": |
| st.subheader("Forecast Time Series") |
| if st.button("Forecast Time Series"): |
| forecast = self.time_series_forecaster.forecast(self.data) |
| st.write(forecast) |
|
|
| elif feature == "Analyze Sentiment": |
| st.subheader("Analyze Sentiment") |
| if st.button("Analyze Sentiment"): |
| sentiment = self.sentiment_analyzer.analyze(self.data) |
| st.write(sentiment) |
|
|
| elif feature == "Generate Data Story": |
| st.subheader("Generate Data Story") |
| if st.button("Generate Data Story"): |
| story = self.data_storyteller.generate_story(self.data) |
| st.write(story) |
|
|
| elif feature == "Generate Report": |
| st.subheader("Generate Report") |
| if st.button("Generate Report"): |
| report = self.report_generator.generate(self.data) |
| st.download_button( |
| label="Download Report", |
| data=report, |
| file_name="data_report.txt", |
| mime="text/plain" |
| ) |
|
|
| if __name__ == "__main__": |
| app = DataAutomationApp() |
| app.run() |
|
|
|
|