Tom commited on
Commit
c8d673b
·
1 Parent(s): 4ee4ca0
Files changed (1) hide show
  1. app.py +16 -17
app.py CHANGED
@@ -9,6 +9,7 @@ import dash
9
  import dash_core_components as dcc
10
  import dash_html_components as html
11
  import dash_table
 
12
  from sklearn.model_selection import train_test_split
13
  from sklearn.ensemble import RandomForestClassifier
14
  from sklearn.linear_model import LogisticRegression
@@ -132,7 +133,7 @@ def create_dashboard(df, correlation_data, clustering_data, prediction_results):
132
 
133
  html.Div([
134
  html.H2('Clustering Analysis'),
135
- html.P(f'Best Clustering Algorithm: {clustering_data["best_model"]}'),
136
  dcc.Graph(
137
  id='clustering_scatter',
138
  figure={
@@ -167,23 +168,21 @@ def create_dashboard(df, correlation_data, clustering_data, prediction_results):
167
 
168
  app.run_server(debug=True)
169
 
170
- # Main execution
171
- if __name__ == "__main__":
172
- # Load dataset
173
- df = pd.read_csv('student_data.csv') # Replace with your CSV file
174
-
175
- # Preprocess the data
176
  df = enhanced_preprocessing(df)
 
177
 
178
- # Perform correlation analysis
179
- correlation_data = calculate_correlations(df)
180
-
181
- # Perform clustering analysis
182
- df, best_model = perform_clustering(df)
183
- clustering_data = {'best_model': best_model}
 
184
 
185
- # Perform prediction analysis
186
- prediction_results = pd.DataFrame(perform_predictions(df))
187
 
188
- # Create and launch the dashboard
189
- create_dashboard(df, correlation_data, clustering_data, prediction_results)
 
 
9
  import dash_core_components as dcc
10
  import dash_html_components as html
11
  import dash_table
12
+ import gradio as gr
13
  from sklearn.model_selection import train_test_split
14
  from sklearn.ensemble import RandomForestClassifier
15
  from sklearn.linear_model import LogisticRegression
 
133
 
134
  html.Div([
135
  html.H2('Clustering Analysis'),
136
+ html.P(f"Best Clustering Algorithm: {clustering_data['best_model']}"),
137
  dcc.Graph(
138
  id='clustering_scatter',
139
  figure={
 
168
 
169
  app.run_server(debug=True)
170
 
171
+ def load_csv(file):
172
+ df = pd.read_csv(file.name)
 
 
 
 
173
  df = enhanced_preprocessing(df)
174
+ return df
175
 
176
+ # Main execution
177
+ iface = gr.Interface(
178
+ fn=load_csv,
179
+ inputs=gr.inputs.File(label="Upload CSV File"),
180
+ outputs="dataframe",
181
+ description="Upload a CSV file to perform comprehensive student data analysis."
182
+ )
183
 
184
+ iface.launch()
 
185
 
186
+ # Note: The data loading is done through Gradio, no need for an additional file parameter.
187
+ if __name__ == "__main__":
188
+ pass