cassiomo commited on
Commit
9c3c13a
·
verified ·
1 Parent(s): baed69e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +111 -0
app.py ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import numpy as np
4
+ import plotly.graph_objs as go
5
+ import plotly.figure_factory as ff
6
+
7
+ def main():
8
+ st.title("Bar Chart and 3D Graph Example")
9
+
10
+ # Generate some sample data for the bar chart
11
+ bar_data = pd.DataFrame({
12
+ 'Category': ['A', 'B', 'C', 'D'],
13
+ 'Values': [10, 20, 15, 25]
14
+ })
15
+
16
+ # Display the data for the bar chart
17
+ st.write("Sample Data for Bar Chart:")
18
+ st.write(bar_data)
19
+
20
+ # Create a bar chart
21
+ st.write("Bar Chart:")
22
+ fig_bar = go.Figure(data=[go.Bar(x=bar_data['Category'], y=bar_data['Values'])])
23
+ st.plotly_chart(fig_bar)
24
+
25
+ # Generate some sample data for the 3D surface plot
26
+ x = np.linspace(-5, 5, 100)
27
+ y = np.linspace(-5, 5, 100)
28
+ X, Y = np.meshgrid(x, y)
29
+ Z = np.sin(np.sqrt(X**2 + Y**2))
30
+
31
+ # Create a DataFrame for the 3D surface plot
32
+ surface_data = pd.DataFrame({'X': X.flatten(), 'Y': Y.flatten(), 'Z': Z.flatten()})
33
+
34
+ # Display the data for the 3D surface plot
35
+ st.write("Sample Data for 3D Surface Plot:")
36
+ st.write(surface_data.head())
37
+
38
+ # Create a 3D surface plot
39
+ st.write("3D Surface Plot:")
40
+ fig_surface = go.Figure(data=[go.Surface(z=surface_data['Z'].values.reshape(100, 100),
41
+ x=surface_data['X'].values.reshape(100, 100),
42
+ y=surface_data['Y'].values.reshape(100, 100))])
43
+ st.plotly_chart(fig_surface)
44
+
45
+ # Generate some sample data for the confusion matrix
46
+ confusion_matrix_data = np.array([[30, 10], [5, 55]])
47
+
48
+ # Create a DataFrame for the confusion matrix
49
+ cm_df = pd.DataFrame(confusion_matrix_data, columns=['Predicted Negative', 'Predicted Positive'], index=['Actual Negative', 'Actual Positive'])
50
+
51
+ # Display the data for the confusion matrix
52
+ st.write("Confusion Matrix Data:")
53
+ st.write(cm_df)
54
+
55
+ # Create a confusion matrix graph
56
+ st.write("Confusion Matrix:")
57
+ fig_cm = ff.create_annotated_heatmap(z=confusion_matrix_data, x=['Predicted Negative', 'Predicted Positive'], y=['Actual Negative', 'Actual Positive'], colorscale='Viridis')
58
+ fig_cm.update_layout(title="Confusion Matrix", xaxis_title="Predicted Label", yaxis_title="Actual Label")
59
+ st.plotly_chart(fig_cm)
60
+
61
+ # Generate some sample data for the heatmap
62
+ np.random.seed(0)
63
+ data = np.random.rand(10, 10)
64
+
65
+ # Create a DataFrame for the heatmap
66
+ heatmap_data = pd.DataFrame(data)
67
+
68
+ # Display the data for the heatmap
69
+ st.write("Sample Data for Heatmap:")
70
+ st.write(heatmap_data.head())
71
+
72
+ # Create a heatmap
73
+ st.write("Heatmap:")
74
+ fig_heatmap = go.Figure(data=go.Heatmap(z=data))
75
+ st.plotly_chart(fig_heatmap)
76
+
77
+ # Generate some sample data for the histogram
78
+ np.random.seed(0)
79
+ data = np.random.randn(1000)
80
+
81
+ # Create a DataFrame for the histogram
82
+ hist_data = pd.DataFrame({'Values': data})
83
+
84
+ # Display the data for the histogram
85
+ st.write("Sample Data for Histogram:")
86
+ st.write(hist_data.head())
87
+
88
+ # Create a histogram
89
+ st.write("Histogram:")
90
+ fig_hist = go.Figure(data=[go.Histogram(x=hist_data['Values'])])
91
+ st.plotly_chart(fig_hist)
92
+
93
+ # Generate some sample data for the scatter plot
94
+ np.random.seed(0)
95
+ x = np.random.randn(100)
96
+ y = np.random.randn(100)
97
+
98
+ # Create a DataFrame for the scatter plot
99
+ scatter_data = pd.DataFrame({'X': x, 'Y': y})
100
+
101
+ # Display the data for the scatter plot
102
+ st.write("Sample Data for Scatter Plot:")
103
+ st.write(scatter_data.head())
104
+
105
+ # Create a scatter plot
106
+ st.write("Scatter Plot:")
107
+ fig_scatter = go.Figure(data=[go.Scatter(x=scatter_data['X'], y=scatter_data['Y'], mode='markers')])
108
+ st.plotly_chart(fig_scatter)
109
+
110
+ if __name__ == "__main__":
111
+ main()