statslibx 0.1.5__py3-none-any.whl → 0.1.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
statslibx/utils.py CHANGED
@@ -61,9 +61,9 @@ class UtilsStats:
61
61
  plt.rcParams['figure.figsize'] = [figsize[0], figsize[1]]
62
62
 
63
63
  def set_save_fig_options(self, save_fig: Optional[bool] = False,
64
- fig_format: str = 'png',
65
- fig_dpi: int = 300,
66
- figures_dir: str = 'figures'):
64
+ fig_format: str = 'png',
65
+ fig_dpi: int = 300,
66
+ figures_dir: str = 'figures'):
67
67
  """Configurar opciones para guardar figuras"""
68
68
  self._save_fig = save_fig
69
69
  self._fig_format = fig_format
@@ -163,7 +163,7 @@ class UtilsStats:
163
163
  raise Exception(f"Error al cargar el archivo {path}: {str(e)}")
164
164
 
165
165
  def _resolve_data(self, data: Union[pd.DataFrame, pd.Series, np.ndarray, list, str, Path],
166
- column: Optional[str] = None) -> Tuple[Union[pd.DataFrame, pd.Series, np.ndarray], str]:
166
+ column: Optional[str] = None) -> Tuple[Union[pd.DataFrame, pd.Series, np.ndarray], str]:
167
167
  """
168
168
  Resuelve el input de datos: si es una ruta, carga el archivo; si no, usa los datos directamente
169
169
 
@@ -219,9 +219,9 @@ class UtilsStats:
219
219
  return f"{num:.{decimals}f}"
220
220
 
221
221
  def check_normality(self,
222
- data: Union[pd.Series, np.ndarray, pd.DataFrame, str, Path],
223
- column: Optional[str] = None,
224
- alpha: float = 0.05) -> dict:
222
+ data: Union[pd.Series, np.ndarray, pd.DataFrame, str, Path],
223
+ column: Optional[str] = None,
224
+ alpha: float = 0.05) -> dict:
225
225
  """
226
226
  Verifica si los datos siguen distribución normal usando Shapiro-Wilk
227
227
 
@@ -265,10 +265,10 @@ class UtilsStats:
265
265
  }
266
266
 
267
267
  def calculate_confidence_intervals(self,
268
- data: Union[pd.Series, np.ndarray, pd.DataFrame, str, Path],
269
- column: Optional[str] = None,
270
- confidence_level: float = 0.95,
271
- method: str = 'parametric') -> dict:
268
+ data: Union[pd.Series, np.ndarray, pd.DataFrame, str, Path],
269
+ column: Optional[str] = None,
270
+ confidence_level: float = 0.95,
271
+ method: str = 'parametric') -> dict:
272
272
  """
273
273
  Calcula intervalos de confianza para la media
274
274
 
@@ -338,10 +338,10 @@ class UtilsStats:
338
338
  }
339
339
 
340
340
  def detect_outliers(self,
341
- data: Union[pd.Series, np.ndarray, pd.DataFrame, str, Path],
342
- column: Optional[str] = None,
343
- method: Literal['iqr', 'zscore', 'isolation_forest'] = 'iqr',
344
- **kwargs) -> np.ndarray:
341
+ data: Union[pd.Series, np.ndarray, pd.DataFrame, str, Path],
342
+ column: Optional[str] = None,
343
+ method: Literal['iqr', 'zscore', 'isolation_forest'] = 'iqr',
344
+ **kwargs) -> np.ndarray:
345
345
  """
346
346
  Detecta outliers usando diferentes métodos
347
347
 
@@ -399,7 +399,7 @@ class UtilsStats:
399
399
  return outliers
400
400
 
401
401
  def calculate_effect_size(self, group1: np.ndarray, group2: np.ndarray,
402
- method: Literal['cohen', 'hedges'] = 'cohen') -> dict:
402
+ method: Literal['cohen', 'hedges'] = 'cohen') -> dict:
403
403
  """
404
404
  Calcula el tamaño del efecto entre dos grupos
405
405
  """
@@ -530,15 +530,15 @@ class UtilsStats:
530
530
  return fig
531
531
 
532
532
  def plot_distribution(self,
533
- data: Union[pd.DataFrame, pd.Series, np.ndarray, str, Path],
534
- column: Optional[str] = None,
535
- plot_type: Literal['hist', 'kde', 'box', 'violin', 'all'] = 'hist',
536
- backend: Optional[Literal['matplotlib', 'seaborn', 'plotly']] = "seaborn",
537
- bins: int = 30,
538
- figsize: Optional[Tuple[int, int]] = None,
539
- save_fig: Optional[bool] = None,
540
- filename: Optional[str] = None,
541
- **kwargs):
533
+ data: Union[pd.DataFrame, pd.Series, np.ndarray, str, Path],
534
+ column: Optional[str] = None,
535
+ plot_type: Literal['hist', 'kde', 'box', 'violin', 'all'] = 'hist',
536
+ backend: Optional[Literal['matplotlib', 'seaborn', 'plotly']] = "seaborn",
537
+ bins: int = 30,
538
+ figsize: Optional[Tuple[int, int]] = None,
539
+ save_fig: Optional[bool] = None,
540
+ filename: Optional[str] = None,
541
+ **kwargs):
542
542
  """
543
543
  Graficar distribución de una variable
544
544
 
@@ -653,13 +653,13 @@ class UtilsStats:
653
653
  return fig
654
654
 
655
655
  def plot_correlation_matrix(self,
656
- data: Union[pd.DataFrame, str, Path],
657
- method: str = 'pearson',
658
- backend: Optional[Literal['seaborn', 'plotly']] = None,
659
- figsize: Optional[Tuple[int, int]] = None,
660
- save_fig: Optional[bool] = None,
661
- filename: Optional[str] = None,
662
- **kwargs):
656
+ data: Union[pd.DataFrame, str, Path],
657
+ method: str = 'pearson',
658
+ backend: Optional[Literal['seaborn', 'plotly']] = None,
659
+ figsize: Optional[Tuple[int, int]] = None,
660
+ save_fig: Optional[bool] = None,
661
+ filename: Optional[str] = None,
662
+ **kwargs):
663
663
  """
664
664
  Visualizar matriz de correlación
665
665
 
@@ -691,8 +691,8 @@ class UtilsStats:
691
691
  mask = np.triu(np.ones_like(corr_matrix, dtype=bool))
692
692
 
693
693
  sns.heatmap(corr_matrix, mask=mask, annot=True, fmt='.2f',
694
- cmap='coolwarm', center=0, ax=ax,
695
- square=True, linewidths=0.5, **kwargs)
694
+ cmap='coolwarm', center=0, ax=ax,
695
+ square=True, linewidths=0.5, **kwargs)
696
696
  ax.set_title(f'Matriz de Correlación ({method})', fontsize=14, pad=20)
697
697
  plt.tight_layout()
698
698
 
@@ -735,13 +735,13 @@ class UtilsStats:
735
735
  return fig
736
736
 
737
737
  def plot_scatter_matrix(self,
738
- data: Union[pd.DataFrame, str, Path],
739
- columns: Optional[List[str]] = None,
740
- backend: Optional[Literal['seaborn', 'plotly', 'pandas']] = None,
741
- figsize: Optional[Tuple[int, int]] = None,
742
- save_fig: Optional[bool] = None,
743
- filename: Optional[str] = None,
744
- **kwargs):
738
+ data: Union[pd.DataFrame, str, Path],
739
+ columns: Optional[List[str]] = None,
740
+ backend: Optional[Literal['seaborn', 'plotly', 'pandas']] = None,
741
+ figsize: Optional[Tuple[int, int]] = None,
742
+ save_fig: Optional[bool] = None,
743
+ filename: Optional[str] = None,
744
+ **kwargs):
745
745
  """
746
746
  Matriz de gráficos de dispersión (pairplot)
747
747
 
@@ -796,15 +796,15 @@ class UtilsStats:
796
796
  # ============= GRÁFICOS CON INTERVALOS DE CONFIANZA =============
797
797
 
798
798
  def plot_distribution_with_ci(self,
799
- data: Union[pd.DataFrame, pd.Series, np.ndarray, str, Path],
800
- column: Optional[str] = None,
801
- confidence_level: float = 0.95,
802
- ci_method: str = 'parametric',
803
- bins: int = 30,
804
- figsize: Optional[Tuple[int, int]] = None,
805
- save_fig: Optional[bool] = None,
806
- filename: Optional[str] = None,
807
- **kwargs) -> plt.Figure:
799
+ data: Union[pd.DataFrame, pd.Series, np.ndarray, str, Path],
800
+ column: Optional[str] = None,
801
+ confidence_level: float = 0.95,
802
+ ci_method: str = 'parametric',
803
+ bins: int = 30,
804
+ figsize: Optional[Tuple[int, int]] = None,
805
+ save_fig: Optional[bool] = None,
806
+ filename: Optional[str] = None,
807
+ **kwargs) -> plt.Figure:
808
808
  """
809
809
  Distribución con intervalos de confianza
810
810
 
@@ -911,12 +911,12 @@ class UtilsStats:
911
911
 
912
912
 
913
913
  def plot_multiple_distributions_with_ci(self,
914
- data_dict: dict,
915
- confidence_level: float = 0.95,
916
- figsize: Optional[Tuple[int, int]] = None,
917
- save_fig: Optional[bool] = None,
918
- filename: Optional[str] = None,
919
- **kwargs) -> plt.Figure:
914
+ data_dict: dict,
915
+ confidence_level: float = 0.95,
916
+ figsize: Optional[Tuple[int, int]] = None,
917
+ save_fig: Optional[bool] = None,
918
+ filename: Optional[str] = None,
919
+ **kwargs) -> plt.Figure:
920
920
  """
921
921
  Grafica múltiples distribuciones con sus intervalos de confianza
922
922
  """
@@ -960,7 +960,7 @@ class UtilsStats:
960
960
 
961
961
  ax2.axvline(ci_result['mean'], color='red', linestyle='-', linewidth=3)
962
962
  ax2.axvspan(ci_result['ci_lower'], ci_result['ci_upper'],
963
- alpha=0.3, color='orange')
963
+ alpha=0.3, color='orange')
964
964
  ax2.axvline(ci_result['ci_lower'], color='orange', linestyle='--', linewidth=2)
965
965
  ax2.axvline(ci_result['ci_upper'], color='orange', linestyle='--', linewidth=2)
966
966
 
@@ -980,8 +980,8 @@ class UtilsStats:
980
980
  # ============= MÉTODOS UTILITARIOS ADICIONALES =============
981
981
 
982
982
  def get_descriptive_stats(self,
983
- data: Union[pd.DataFrame, pd.Series, np.ndarray, str, Path],
984
- column: Optional[str] = None) -> dict:
983
+ data: Union[pd.DataFrame, pd.Series, np.ndarray, str, Path],
984
+ column: Optional[str] = None) -> dict:
985
985
  """
986
986
  Obtiene estadísticas descriptivas completas
987
987
 
@@ -1016,4 +1016,371 @@ class UtilsStats:
1016
1016
  'skewness': stats.skew(data_clean),
1017
1017
  'kurtosis': stats.kurtosis(data_clean),
1018
1018
  'range': np.max(data_clean) - np.min(data_clean)
1019
- }
1019
+ }
1020
+
1021
+ def help(self):
1022
+ """
1023
+ Muestra ayuda completa de la clase DescriptiveStats
1024
+ """
1025
+ help_text = """
1026
+ ╔════════════════════════════════════════════════════════════════════════════╗
1027
+ ║ 📊 CLASE UtilsStats - AYUDA COMPLETA ║
1028
+ ╚════════════════════════════════════════════════════════════════════════════╝
1029
+
1030
+ 📝 DESCRIPCIÓN:
1031
+ Clase para análisis estadístico descriptivo univariado y multivariado.
1032
+ Proporciona herramientas para análisis exploratorio de datos, medidas de
1033
+ tendencia central, dispersión, forma de distribución y regresión lineal.
1034
+
1035
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1036
+
1037
+ 📋 MÉTODOS PRINCIPALES:
1038
+
1039
+ ┌────────────────────────────────────────────────────────────────────────────┐
1040
+ │ 1. 📊 ANÁLISIS ESTADÍSTICO │
1041
+ └────────────────────────────────────────────────────────────────────────────┘
1042
+
1043
+ • .check_normality(data, alpha=0.05)
1044
+ Verifica normalidad usando test Shapiro-Wilk
1045
+ Retorna: dict con estadístico, p-value e interpretación
1046
+
1047
+ • .calculate_confidence_intervals(data, confidence_level=0.95,
1048
+ method='parametric')
1049
+ Calcula intervalos de confianza para la media
1050
+ Métodos: 'parametric' o 'bootstrap'
1051
+
1052
+ • .detect_outliers(data, method='iqr', **kwargs)
1053
+ Detecta valores atípicos
1054
+ Métodos: 'iqr', 'zscore', 'isolation_forest'
1055
+
1056
+ • .calculate_effect_size(group1, group2, method='cohen')
1057
+ Calcula tamaño del efecto entre grupos
1058
+ Métodos: 'cohen' (Cohen's d) o 'hedges' (Hedges' g)
1059
+
1060
+ • .get_descriptive_stats(data, column=None)
1061
+ Estadísticas descriptivas completas en un dict
1062
+
1063
+ ┌────────────────────────────────────────────────────────────────────────────┐
1064
+ │ 2. 🎨 VISUALIZACIÓN DE DISTRIBUCIONES │
1065
+ └────────────────────────────────────────────────────────────────────────────┘
1066
+
1067
+ • .plot_distribution(data, column=None, plot_type='hist',
1068
+ backend='seaborn', bins=30, figsize=None,
1069
+ save_fig=None, filename=None)
1070
+
1071
+ Grafica distribución de una variable
1072
+
1073
+ plot_type: 'hist', 'kde', 'box', 'violin', 'all'
1074
+ backend: 'matplotlib', 'seaborn', 'plotly'
1075
+
1076
+ • .plot_distribution_with_ci(data, column=None, confidence_level=0.95,
1077
+ ci_method='parametric', bins=30, figsize=None,
1078
+ save_fig=None, filename=None)
1079
+
1080
+ Distribución con intervalos de confianza visualizados
1081
+
1082
+ • .plot_multiple_distributions_with_ci(data_dict, confidence_level=0.95)
1083
+
1084
+ Compara múltiples distribuciones con sus IC
1085
+
1086
+ ┌────────────────────────────────────────────────────────────────────────────┐
1087
+ │ 3. 🎨 VISUALIZACIÓN MULTIVARIADA │
1088
+ └────────────────────────────────────────────────────────────────────────────┘
1089
+
1090
+ • .plot_correlation_matrix(data, method='pearson', backend='seaborn',
1091
+ figsize=None, save_fig=None)
1092
+
1093
+ Matriz de correlación con heatmap
1094
+ Métodos: 'pearson', 'spearman', 'kendall'
1095
+
1096
+ • .plot_scatter_matrix(data, columns=None, backend='seaborn',
1097
+ figsize=None, save_fig=None)
1098
+
1099
+ Matriz de gráficos de dispersión (pairplot)
1100
+ Backends: 'seaborn', 'plotly', 'pandas'
1101
+
1102
+ ┌────────────────────────────────────────────────────────────────────────────┐
1103
+ │ 4. ⚙️ CONFIGURACIÓN │
1104
+ └────────────────────────────────────────────────────────────────────────────┘
1105
+
1106
+ • .set_plot_backend(backend)
1107
+ Establece backend por defecto: 'matplotlib', 'seaborn', 'plotly'
1108
+
1109
+ • .set_default_figsize(figsize)
1110
+ Establece tamaño de figura por defecto: (ancho, alto)
1111
+
1112
+ • .set_save_fig_options(save_fig=False, fig_format='png',
1113
+ fig_dpi=300, figures_dir='figures')
1114
+
1115
+ Configura guardado automático de figuras
1116
+
1117
+ ┌────────────────────────────────────────────────────────────────────────────┐
1118
+ │ 5. 🛠️ UTILIDADES │
1119
+ └────────────────────────────────────────────────────────────────────────────┘
1120
+
1121
+ • .validate_dataframe(data)
1122
+ Valida y convierte datos a DataFrame
1123
+
1124
+ • .format_number(num, decimals=6, scientific=False)
1125
+ Formatea números con precisión específica
1126
+
1127
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1128
+
1129
+ 💡 EJEMPLOS DE USO:
1130
+
1131
+ ┌─ Ejemplo 1: Configuración Inicial ──────────────────────────────────────┐
1132
+ │ from utils import UtilsStats │
1133
+ │ import pandas as pd │
1134
+ │ import numpy as np │
1135
+ │ │
1136
+ │ # Inicializar │
1137
+ │ utils = UtilsStats() │
1138
+ │ │
1139
+ │ # Configurar visualización │
1140
+ │ utils.set_plot_backend('seaborn') │
1141
+ │ utils.set_default_figsize((12, 6)) │
1142
+ │ │
1143
+ │ # Configurar guardado automático │
1144
+ │ utils.set_save_fig_options( │
1145
+ │ save_fig=True, │
1146
+ │ fig_format='png', │
1147
+ │ fig_dpi=300, │
1148
+ │ figures_dir='mis_graficos' │
1149
+ │ ) │
1150
+ └──────────────────────────────────────────────────────────────────────────┘
1151
+
1152
+ ┌─ Ejemplo 2: Análisis de Normalidad ─────────────────────────────────────┐
1153
+ │ # Generar datos │
1154
+ │ datos_normales = np.random.normal(0, 1, 1000) │
1155
+ │ datos_no_normales = np.random.exponential(2, 1000) │
1156
+ │ │
1157
+ │ # Test de normalidad │
1158
+ │ resultado1 = utils.check_normality(datos_normales) │
1159
+ │ print(f"Normales: {resultado1['interpretation']}") │
1160
+ │ print(f"p-value: {resultado1['shapiro_pvalue']:.4f}") │
1161
+ │ │
1162
+ │ resultado2 = utils.check_normality(datos_no_normales) │
1163
+ │ print(f"No normales: {resultado2['interpretation']}") │
1164
+ └──────────────────────────────────────────────────────────────────────────┘
1165
+
1166
+ ┌─ Ejemplo 3: Intervalos de Confianza ────────────────────────────────────┐
1167
+ │ # Método paramétrico │
1168
+ │ ci_param = utils.calculate_confidence_intervals( │
1169
+ │ datos_normales, │
1170
+ │ confidence_level=0.95, │
1171
+ │ method='parametric' │
1172
+ │ ) │
1173
+ │ │
1174
+ │ print(f"Media: {ci_param['mean']:.3f}") │
1175
+ │ print(f"IC 95%: [{ci_param['ci_lower']:.3f}, " │
1176
+ │ f"{ci_param['ci_upper']:.3f}]") │
1177
+ │ │
1178
+ │ # Método bootstrap (para datos no normales) │
1179
+ │ ci_boot = utils.calculate_confidence_intervals( │
1180
+ │ datos_no_normales, │
1181
+ │ confidence_level=0.95, │
1182
+ │ method='bootstrap' │
1183
+ │ ) │
1184
+ └──────────────────────────────────────────────────────────────────────────┘
1185
+
1186
+ ┌─ Ejemplo 4: Detección de Outliers ──────────────────────────────────────┐
1187
+ │ # Método IQR (rango intercuartílico) │
1188
+ │ datos = np.random.normal(100, 15, 1000) │
1189
+ │ datos = np.append(datos, [200, 210, -50]) # Agregar outliers │
1190
+ │ │
1191
+ │ outliers_iqr = utils.detect_outliers(datos, method='iqr') │
1192
+ │ print(f"Outliers IQR: {outliers_iqr.sum()}") │
1193
+ │ │
1194
+ │ # Método Z-score │
1195
+ │ outliers_z = utils.detect_outliers( │
1196
+ │ datos, │
1197
+ │ method='zscore', │
1198
+ │ threshold=3 │
1199
+ │ ) │
1200
+ │ print(f"Outliers Z-score: {outliers_z.sum()}") │
1201
+ │ │
1202
+ │ # Isolation Forest (machine learning) │
1203
+ │ outliers_if = utils.detect_outliers( │
1204
+ │ datos, │
1205
+ │ method='isolation_forest', │
1206
+ │ contamination=0.05 │
1207
+ │ ) │
1208
+ └──────────────────────────────────────────────────────────────────────────┘
1209
+
1210
+ ┌─ Ejemplo 5: Tamaño del Efecto ──────────────────────────────────────────┐
1211
+ │ # Comparar dos grupos │
1212
+ │ grupo_control = np.random.normal(100, 15, 100) │
1213
+ │ grupo_tratamiento = np.random.normal(110, 15, 100) │
1214
+ │ │
1215
+ │ efecto = utils.calculate_effect_size( │
1216
+ │ grupo_control, │
1217
+ │ grupo_tratamiento, │
1218
+ │ method='cohen' │
1219
+ │ ) │
1220
+ │ │
1221
+ │ print(f"Cohen's d: {efecto['effect_size']:.3f}") │
1222
+ │ print(f"Interpretación: {efecto['interpretation']}") │
1223
+ │ print(f"Diferencia de medias: {efecto['mean_diff']:.2f}") │
1224
+ └──────────────────────────────────────────────────────────────────────────┘
1225
+
1226
+ ┌─ Ejemplo 6: Gráficos de Distribución ───────────────────────────────────┐
1227
+ │ df = pd.DataFrame({ │
1228
+ │ 'edad': np.random.normal(35, 10, 500), │
1229
+ │ 'salario': np.random.lognormal(10.5, 0.5, 500) │
1230
+ │ }) │
1231
+ │ │
1232
+ │ # Histograma simple │
1233
+ │ fig1 = utils.plot_distribution( │
1234
+ │ df, │
1235
+ │ column='edad', │
1236
+ │ plot_type='hist', │
1237
+ │ bins=30 │
1238
+ │ ) │
1239
+ │ │
1240
+ │ # Panel completo (histograma, box, violin, Q-Q) │
1241
+ │ fig2 = utils.plot_distribution( │
1242
+ │ df, │
1243
+ │ column='salario', │
1244
+ │ plot_type='all', │
1245
+ │ backend='seaborn' │
1246
+ │ ) │
1247
+ │ │
1248
+ │ # Con Plotly (interactivo) │
1249
+ │ fig3 = utils.plot_distribution( │
1250
+ │ df, │
1251
+ │ column='edad', │
1252
+ │ plot_type='violin', │
1253
+ │ backend='plotly' │
1254
+ │ ) │
1255
+ └──────────────────────────────────────────────────────────────────────────┘
1256
+
1257
+ ┌─ Ejemplo 7: Distribución con Intervalos de Confianza ───────────────────┐
1258
+ │ # Visualizar distribución con IC │
1259
+ │ fig = utils.plot_distribution_with_ci( │
1260
+ │ df, │
1261
+ │ column='edad', │
1262
+ │ confidence_level=0.95, │
1263
+ │ ci_method='parametric', │
1264
+ │ bins=30, │
1265
+ │ save_fig=True, │
1266
+ │ filename='edad_con_ic' │
1267
+ │ ) │
1268
+ │ │
1269
+ │ # Comparar múltiples distribuciones │
1270
+ │ data_dict = { │
1271
+ │ 'Grupo A': df['edad'][:200], │
1272
+ │ 'Grupo B': df['edad'][200:400], │
1273
+ │ 'Grupo C': df['edad'][400:] │
1274
+ │ } │
1275
+ │ │
1276
+ │ fig = utils.plot_multiple_distributions_with_ci( │
1277
+ │ data_dict, │
1278
+ │ confidence_level=0.95 │
1279
+ │ ) │
1280
+ └──────────────────────────────────────────────────────────────────────────┘
1281
+
1282
+ ┌─ Ejemplo 8: Matriz de Correlación ──────────────────────────────────────┐
1283
+ │ # Crear datos correlacionados │
1284
+ │ df = pd.DataFrame({ │
1285
+ │ 'A': np.random.normal(0, 1, 100), │
1286
+ │ 'B': np.random.normal(0, 1, 100), │
1287
+ │ 'C': np.random.normal(0, 1, 100) │
1288
+ │ }) │
1289
+ │ df['D'] = df['A'] * 0.8 + np.random.normal(0, 0.2, 100) │
1290
+ │ │
1291
+ │ # Matriz de correlación con seaborn │
1292
+ │ fig = utils.plot_correlation_matrix( │
1293
+ │ df, │
1294
+ │ method='pearson', │
1295
+ │ backend='seaborn', │
1296
+ │ figsize=(10, 8) │
1297
+ │ ) │
1298
+ │ │
1299
+ │ # Con Plotly (interactiva) │
1300
+ │ fig = utils.plot_correlation_matrix( │
1301
+ │ df, │
1302
+ │ method='spearman', │
1303
+ │ backend='plotly' │
1304
+ │ ) │
1305
+ └──────────────────────────────────────────────────────────────────────────┘
1306
+
1307
+ ┌─ Ejemplo 9: Matriz de Dispersión ───────────────────────────────────────┐
1308
+ │ # Pairplot completo │
1309
+ │ fig = utils.plot_scatter_matrix( │
1310
+ │ df, │
1311
+ │ columns=['A', 'B', 'C', 'D'], │
1312
+ │ backend='seaborn' │
1313
+ │ ) │
1314
+ │ │
1315
+ │ # Con Plotly │
1316
+ │ fig = utils.plot_scatter_matrix( │
1317
+ │ df, │
1318
+ │ backend='plotly' │
1319
+ │ ) │
1320
+ └──────────────────────────────────────────────────────────────────────────┘
1321
+
1322
+ ┌─ Ejemplo 10: Estadísticas Descriptivas Completas ───────────────────────┐
1323
+ │ # Obtener todas las estadísticas │
1324
+ │ stats = utils.get_descriptive_stats(df, column='edad') │
1325
+ │ │
1326
+ │ print(f"Media: {stats['mean']:.2f}") │
1327
+ │ print(f"Mediana: {stats['median']:.2f}") │
1328
+ │ print(f"Desv. Est.: {stats['std']:.2f}") │
1329
+ │ print(f"IQR: {stats['iqr']:.2f}") │
1330
+ │ print(f"Asimetría: {stats['skewness']:.3f}") │
1331
+ │ print(f"Curtosis: {stats['kurtosis']:.3f}") │
1332
+ └──────────────────────────────────────────────────────────────────────────┘
1333
+
1334
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1335
+
1336
+ 🎯 CARACTERÍSTICAS CLAVE:
1337
+
1338
+ ✓ Múltiples backends de visualización (matplotlib, seaborn, plotly)
1339
+ ✓ Guardado automático de figuras en alta resolución
1340
+ ✓ Análisis estadísticos robustos
1341
+ ✓ Detección de outliers con 3 métodos
1342
+ ✓ Intervalos de confianza paramétricos y bootstrap
1343
+ ✓ Visualizaciones profesionales listas para publicación
1344
+ ✓ Manejo automático de valores faltantes
1345
+ ✓ Integración perfecta con pandas y numpy
1346
+ ✓ Gráficos interactivos con Plotly
1347
+
1348
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1349
+
1350
+ 📊 BACKENDS DE VISUALIZACIÓN:
1351
+
1352
+ 🔹 Matplotlib:
1353
+ • Rápido y ligero
1354
+ • Ideal para gráficos simples
1355
+ • Mejor para exportar a archivos
1356
+
1357
+ 🔹 Seaborn:
1358
+ • Gráficos estadísticos elegantes
1359
+ • Temas predefinidos atractivos
1360
+ • Mejor para análisis exploratorio
1361
+
1362
+ 🔹 Plotly:
1363
+ • Gráficos interactivos
1364
+ • Zoom, pan, hover tooltips
1365
+ • Ideal para presentaciones y dashboards
1366
+
1367
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1368
+
1369
+ 💡 CONSEJOS Y MEJORES PRÁCTICAS:
1370
+
1371
+ 1. Siempre verificar normalidad antes de usar métodos paramétricos
1372
+ 2. Usar bootstrap para IC cuando los datos no son normales
1373
+ 3. Detectar outliers antes de calcular estadísticas
1374
+ 4. Guardar figuras en alta resolución (300 DPI) para publicaciones
1375
+ 5. Usar Plotly para presentaciones interactivas
1376
+ 6. Usar seaborn para análisis exploratorio rápido
1377
+
1378
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1379
+
1380
+ 📚 DOCUMENTACIÓN ADICIONAL:
1381
+ Para más información sobre métodos específicos, use:
1382
+ help(UtilsStats.nombre_metodo)
1383
+
1384
+ ╚════════════════════════════════════════════════════════════════════════════╝
1385
+ """
1386
+ print(help_text)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: statslibx
3
- Version: 0.1.5
3
+ Version: 0.1.6
4
4
  Summary: Librería de estadística descriptiva e inferencial para Python
5
5
  Home-page: https://github.com/Immanuel3008/StatsLibX
6
6
  Author: Emmanuel Ascendra Perez
@@ -1,14 +1,14 @@
1
- statslibx/__init__.py,sha256=KVRs6x_NAlnosyfyPpWHA-8ZpGqekwL7sbGcbvuP0rg,1173
2
- statslibx/descriptive.py,sha256=3bZswmyB2NxVjSPrj7l4P0cko77sKeN7zMT8gx5x5I4,38051
3
- statslibx/inferential.py,sha256=gpd9ek5cKo3kUCcKFTwq9tVHTmRYFoBvlcNf2EGRRCM,49310
4
- statslibx/utils.py,sha256=nmOLyRVlI35A-S0AcBgePtR_ezeYkFxG9--fqY920_A,40545
1
+ statslibx/__init__.py,sha256=gA9uNJ7Th8mJunugVps8UWgBNJtMeo_mHqU-QSkEXQE,1173
2
+ statslibx/descriptive.py,sha256=Hjti-Cs-7-SzrTb0k4s92c4nasLthVwhYU75GS56LAc,40124
3
+ statslibx/inferential.py,sha256=0lpVAp2SiKDgWkH3z3JoVFAjMaXW2VboxtA2vwPwq04,49947
4
+ statslibx/utils.py,sha256=qDqF_XgvEJbdQURA2v0gF0sw0nNQR4-MFXDvVTl_00s,68480
5
5
  statslibx/datasets/__init__.py,sha256=wQ4p8hXIhJqV-msWzTvvnbv-l7jyWz5Rn3JZyMSYJ44,452
6
6
  statslibx/datasets/course_completion.csv,sha256=jaqyxAh4YCsYuH5OFsjvGV7KUyM_7vQt6LgnqnNAFsI,22422135
7
7
  statslibx/datasets/iris.csv,sha256=xSdC5QMVqZ-Vajg_rt91dVUmdfZAnvD5pHB23QhHmTA,3858
8
8
  statslibx/datasets/penguins.csv,sha256=4HY2vYr3QmAJnqL4Z44uq7813vV5lAzHb2cGHuFsBsE,13478
9
9
  statslibx/datasets/sp500_companies.csv,sha256=WKS72YOGnAbyLR6kD95fOpIYZt5oXGjPryyFVqLRF_k,803820
10
10
  statslibx/datasets/titanic.csv,sha256=5seOS8ybyBMBCCWhgKZrsbu06m_OWyKtD9l0YXOImXU,29474
11
- statslibx-0.1.5.dist-info/METADATA,sha256=osEyU9pI4kjUMqjiCKUOkTpEGKiACgVaWp9b7mt3c6s,2943
12
- statslibx-0.1.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
- statslibx-0.1.5.dist-info/top_level.txt,sha256=eeYZXyFm0hIjuI0ba3wF6XW938Mv9tv7Nk9qgjYfCtU,10
14
- statslibx-0.1.5.dist-info/RECORD,,
11
+ statslibx-0.1.6.dist-info/METADATA,sha256=7djbcDCGKwPIIjMnF3hjrsjpgeJFUYxEO9zrVTayUj0,2943
12
+ statslibx-0.1.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
+ statslibx-0.1.6.dist-info/top_level.txt,sha256=eeYZXyFm0hIjuI0ba3wF6XW938Mv9tv7Nk9qgjYfCtU,10
14
+ statslibx-0.1.6.dist-info/RECORD,,