Ashar086 commited on
Commit
168a3a3
·
verified ·
1 Parent(s): 0c2542c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +134 -1
app.py CHANGED
@@ -12,6 +12,137 @@ from sentiment_analysis import SentimentAnalyzer
12
  from data_storytelling import DataStoryteller
13
  import pandas as pd
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  class DataAutomationApp:
16
  def __init__(self):
17
  self.data = None
@@ -108,4 +239,6 @@ class DataAutomationApp:
108
 
109
  if __name__ == "__main__":
110
  app = DataAutomationApp()
111
- app.run()
 
 
 
12
  from data_storytelling import DataStoryteller
13
  import pandas as pd
14
 
15
+ class DataAutomationApp:
16
+ def __init__(self):
17
+ self.data = None
18
+ self.cleaner = DataCleaner()
19
+ self.visualizer = VisualizationSelector()
20
+ self.analyzer = DataAnalyzer()
21
+ self.report_generator = ReportGenerator()
22
+ self.api_connector = APIConnector()
23
+ self.nl_query_engine = NLQueryEngine()
24
+ self.predictive_analytics = PredictiveAnalytics()
25
+ self.anomaly_detector = AnomalyDetector()
26
+ self.time_series_forecaster = TimeSeriesForecaster()
27
+ self.sentiment_analyzer = SentimentAnalyzer()
28
+ self.data_storyteller = DataStoryteller()
29
+
30
+ def load_data(self, file):
31
+ if file.name.endswith('.csv'):
32
+ self.data = pd.read_csv(file)
33
+ elif file.name.endswith(('.xls', '.xlsx')):
34
+ self.data = pd.read_excel(file)
35
+ else:
36
+ st.error("Unsupported file format. Please upload a CSV or Excel file.")
37
+
38
+ def run(self):
39
+ st.title("Data Automation and Visualization App")
40
+
41
+ # File upload
42
+ uploaded_file = st.file_uploader("Choose a CSV or Excel file", type=["csv", "xlsx"])
43
+ if uploaded_file is not None:
44
+ self.load_data(uploaded_file)
45
+ if self.data is not None:
46
+ st.success("Data loaded successfully!")
47
+
48
+ # Sidebar for feature selection
49
+ st.sidebar.title("Select a Feature")
50
+ feature = st.sidebar.radio(
51
+ "Choose what you'd like to do:",
52
+ ("Clean Data", "Generate Visualizations", "Analyze Data",
53
+ "Natural Language Query", "Run Predictive Analytics",
54
+ "Detect Anomalies", "Forecast Time Series",
55
+ "Analyze Sentiment", "Generate Data Story",
56
+ "Generate Report")
57
+ )
58
+
59
+ # Based on the selected feature, execute corresponding functionality
60
+ if feature == "Clean Data":
61
+ st.subheader("Clean Data")
62
+ if st.button("Clean Data"):
63
+ self.data = self.cleaner.clean(self.data)
64
+ st.write(self.data.head())
65
+
66
+ elif feature == "Generate Visualizations":
67
+ st.subheader("Generate Visualizations")
68
+ if st.button("Generate Visualizations"):
69
+ visualizations = self.visualizer.select_visualizations(self.data)
70
+ for viz in visualizations:
71
+ st.pyplot(viz)
72
+
73
+ elif feature == "Analyze Data":
74
+ st.subheader("Analyze Data")
75
+ if st.button("Analyze Data"):
76
+ insights = self.analyzer.analyze(self.data)
77
+ st.write(insights)
78
+
79
+ elif feature == "Natural Language Query":
80
+ st.subheader("Ask a Question About Your Data")
81
+ query = st.text_input("Ask a question about your data:")
82
+ if query:
83
+ result = self.nl_query_engine.process_query(query, self.data)
84
+ st.write(result)
85
+
86
+ elif feature == "Run Predictive Analytics":
87
+ st.subheader("Run Predictive Analytics")
88
+ if st.button("Run Predictive Analytics"):
89
+ prediction = self.predictive_analytics.predict(self.data)
90
+ st.write(prediction)
91
+
92
+ elif feature == "Detect Anomalies":
93
+ st.subheader("Detect Anomalies")
94
+ if st.button("Detect Anomalies"):
95
+ anomalies = self.anomaly_detector.detect(self.data)
96
+ st.write(anomalies)
97
+
98
+ elif feature == "Forecast Time Series":
99
+ st.subheader("Forecast Time Series")
100
+ if st.button("Forecast Time Series"):
101
+ forecast = self.time_series_forecaster.forecast(self.data)
102
+ st.write(forecast)
103
+
104
+ elif feature == "Analyze Sentiment":
105
+ st.subheader("Analyze Sentiment")
106
+ if st.button("Analyze Sentiment"):
107
+ sentiment = self.sentiment_analyzer.analyze(self.data)
108
+ st.write(sentiment)
109
+
110
+ elif feature == "Generate Data Story":
111
+ st.subheader("Generate Data Story")
112
+ if st.button("Generate Data Story"):
113
+ story = self.data_storyteller.generate_story(self.data)
114
+ st.write(story)
115
+
116
+ elif feature == "Generate Report":
117
+ st.subheader("Generate Report")
118
+ if st.button("Generate Report"):
119
+ report = self.report_generator.generate(self.data)
120
+ st.download_button(
121
+ label="Download Report",
122
+ data=report,
123
+ file_name="data_report.txt",
124
+ mime="text/plain"
125
+ )
126
+
127
+ if __name__ == "__main__":
128
+ app = DataAutomationApp()
129
+ app.run()
130
+
131
+ '''
132
+ import streamlit as st
133
+ from data_cleaning import DataCleaner
134
+ from visualization import VisualizationSelector
135
+ from data_analysis import DataAnalyzer
136
+ from report_generator import ReportGenerator
137
+ from api_integration import APIConnector
138
+ from natural_language_query import NLQueryEngine
139
+ from predictive_analytics import PredictiveAnalytics
140
+ from anomaly_detection import AnomalyDetector
141
+ from time_series_forecasting import TimeSeriesForecaster
142
+ from sentiment_analysis import SentimentAnalyzer
143
+ from data_storytelling import DataStoryteller
144
+ import pandas as pd
145
+
146
  class DataAutomationApp:
147
  def __init__(self):
148
  self.data = None
 
239
 
240
  if __name__ == "__main__":
241
  app = DataAutomationApp()
242
+ app.run()
243
+
244
+ '''