jcmachicao commited on
Commit
1ab9f2b
·
verified ·
1 Parent(s): 2bd05f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -14
app.py CHANGED
@@ -31,13 +31,13 @@ if uploaded_file is not None:
31
  if len(u_col) < 25:
32
  col_selec.append(col)
33
 
34
- st.write('Esta es la lista de variables que será usada para la clusterización.')
35
- st.write(col_selec)
36
 
37
  df_100 = df_050[col_selec]
38
  df_110 = pd.get_dummies(df_100)
39
 
40
- st.write('Esta es la matriz de correlación de todas las categorías')
41
 
42
  corr_matrix = df_110.corr()
43
  plt.figure(figsize=(21, 21)) # Adjust the figure size as needed
@@ -45,7 +45,7 @@ if uploaded_file is not None:
45
  plt.title('Mapa de Calor de la Correlation de Variables')
46
  st.pyplot(plt)
47
 
48
- st.write('A continuación se va a hacer el clustering usando PCA.')
49
 
50
  X_sc = scaler.fit_transform(df_110)
51
  st.write('La forma de la data es: ', X_sc.shape)
@@ -57,19 +57,12 @@ if uploaded_file is not None:
57
  data_200['pca_1'] = X_pca[:, 0]
58
  data_200['pca_2'] = X_pca[:, 1]
59
 
60
- plt.figure(figsize=(8, 8))
61
- plt.scatter(data_200.pca_1, data_200.pca_2)
62
- plt.title('Diagrama de Dispersión PCA')
63
- plt.xlabel('Principal Component 1')
64
- plt.ylabel('Principal Component 2')
65
-
66
- st.pyplot(plt)
67
  st.write(data_200.columns)
68
 
69
  #st.write(data_200['COD_DEPARTAMENTO'].unique())
70
  #st.write(data_200['ESTADO_ESTUDIANTE'].unique())
71
-
72
  #VIRTU = st.selectbox('Virtual: ', ['UVIR', 'PCGT'])
 
73
  INGRE = st.selectbox('Estado: ', ['Abandono', 'Activo'])
74
 
75
  data_210 = data_200[data_200['ESTADO_INGRESANTE']==INGRE]
@@ -77,6 +70,8 @@ if uploaded_file is not None:
77
  fig2 = px.scatter(data_210, x='pca_1', y='pca_2', title='Distribución PCA', width=800, height=800)
78
  st.plotly_chart(fig2)
79
 
 
 
80
  GRIDSIZEX = st.slider('Seleccione la densidad de la grilla de hexágonos: ', 0, 100, 10)
81
 
82
  plt.figure(figsize=(10, 8))
@@ -86,12 +81,15 @@ if uploaded_file is not None:
86
  plt.xlabel('Principal Component 1')
87
  plt.ylabel('Principal Component 2')
88
  st.pyplot(plt)
89
-
 
 
90
  plt.figure(figsize=(7, 4))
91
  densidades = pd.DataFrame(plt_extracto.get_array())
92
  densidades.hist(bins=50, log=True)
93
  plt.xlabel('Cantidad de Ocurrencias')
94
  plt.ylabel('Frecuencia')
 
95
  plt.title('Histograma de Densidades')
96
  st.pyplot(plt)
97
 
@@ -102,6 +100,9 @@ if uploaded_file is not None:
102
  offsets_df.columns = ['col1', 'col2', 'densidad']
103
  offset_selec = offsets_df.sort_values(by='densidad', ascending=False)
104
  patrones_df = pd.DataFrame(index = [0,1,2,3,4,5,6,7,8,9], data=offset_selec.values[0:10], columns=offset_selec.columns)
 
 
 
105
  st.write(patrones_df)
106
 
107
  NUM_CASOS = st.slider("¿Cuántos casos elige explorar?", 1, 10, 3)
@@ -120,11 +121,18 @@ if uploaded_file is not None:
120
  ]
121
 
122
  st.write(enfoqueX.shape)
 
 
 
123
  LISTA_SELEC = st.multiselect('Escoja la variable de color: ', list(enfoqueX.columns))
124
  st.write(LISTA_SELEC)
125
-
126
  fig2 = px.parallel_categories(data_frame=enfoqueX[list(LISTA_SELEC)])
127
  st.plotly_chart(fig2)
 
 
 
 
128
 
129
 
130
 
 
31
  if len(u_col) < 25:
32
  col_selec.append(col)
33
 
34
+ st.header('Lista de variables que será usada para la clusterización')
35
+ st.write(' '.join(col_selec))
36
 
37
  df_100 = df_050[col_selec]
38
  df_110 = pd.get_dummies(df_100)
39
 
40
+ st.header('Matriz de correlación de todas las categorías')
41
 
42
  corr_matrix = df_110.corr()
43
  plt.figure(figsize=(21, 21)) # Adjust the figure size as needed
 
45
  plt.title('Mapa de Calor de la Correlation de Variables')
46
  st.pyplot(plt)
47
 
48
+ st.header('Clustering usando PCA')
49
 
50
  X_sc = scaler.fit_transform(df_110)
51
  st.write('La forma de la data es: ', X_sc.shape)
 
57
  data_200['pca_1'] = X_pca[:, 0]
58
  data_200['pca_2'] = X_pca[:, 1]
59
 
 
 
 
 
 
 
 
60
  st.write(data_200.columns)
61
 
62
  #st.write(data_200['COD_DEPARTAMENTO'].unique())
63
  #st.write(data_200['ESTADO_ESTUDIANTE'].unique())
 
64
  #VIRTU = st.selectbox('Virtual: ', ['UVIR', 'PCGT'])
65
+
66
  INGRE = st.selectbox('Estado: ', ['Abandono', 'Activo'])
67
 
68
  data_210 = data_200[data_200['ESTADO_INGRESANTE']==INGRE]
 
70
  fig2 = px.scatter(data_210, x='pca_1', y='pca_2', title='Distribución PCA', width=800, height=800)
71
  st.plotly_chart(fig2)
72
 
73
+ st.header('Diagrama de densidades')
74
+
75
  GRIDSIZEX = st.slider('Seleccione la densidad de la grilla de hexágonos: ', 0, 100, 10)
76
 
77
  plt.figure(figsize=(10, 8))
 
81
  plt.xlabel('Principal Component 1')
82
  plt.ylabel('Principal Component 2')
83
  st.pyplot(plt)
84
+
85
+ st.header('Histograma de Densidades')
86
+
87
  plt.figure(figsize=(7, 4))
88
  densidades = pd.DataFrame(plt_extracto.get_array())
89
  densidades.hist(bins=50, log=True)
90
  plt.xlabel('Cantidad de Ocurrencias')
91
  plt.ylabel('Frecuencia')
92
+
93
  plt.title('Histograma de Densidades')
94
  st.pyplot(plt)
95
 
 
100
  offsets_df.columns = ['col1', 'col2', 'densidad']
101
  offset_selec = offsets_df.sort_values(by='densidad', ascending=False)
102
  patrones_df = pd.DataFrame(index = [0,1,2,3,4,5,6,7,8,9], data=offset_selec.values[0:10], columns=offset_selec.columns)
103
+
104
+ st.header('Tabla de Densidades')
105
+
106
  st.write(patrones_df)
107
 
108
  NUM_CASOS = st.slider("¿Cuántos casos elige explorar?", 1, 10, 3)
 
121
  ]
122
 
123
  st.write(enfoqueX.shape)
124
+
125
+ st.header('Diagrama de Coordenadas Paralelas')
126
+
127
  LISTA_SELEC = st.multiselect('Escoja la variable de color: ', list(enfoqueX.columns))
128
  st.write(LISTA_SELEC)
129
+
130
  fig2 = px.parallel_categories(data_frame=enfoqueX[list(LISTA_SELEC)])
131
  st.plotly_chart(fig2)
132
+
133
+ st.header('Descarga de Items de Hexagonos Densos Elegidos')
134
+
135
+
136
 
137
 
138