AutoStatLib 0.2.5__py3-none-any.whl → 0.2.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.

Potentially problematic release.


This version of AutoStatLib might be problematic. Click here for more details.

@@ -16,7 +16,7 @@ class StatisticalAnalysis(StatisticalTests, NormalityTests, TextFormatting, Help
16
16
  paired=False,
17
17
  tails=2,
18
18
  popmean=None,
19
- posthoc=False,
19
+ posthoc=True,
20
20
  verbose=True):
21
21
  self.results = None
22
22
  self.error = False
@@ -92,6 +92,7 @@ class StatisticalAnalysis(StatisticalTests, NormalityTests, TextFormatting, Help
92
92
  self.p_value = None
93
93
  self.posthoc_matrix_df = None
94
94
  self.posthoc_matrix = []
95
+ self.posthoc_name = None
95
96
 
96
97
  self.log('\n' + '-'*67)
97
98
  self.log('Statistical analysis __init__iated for data in {} groups\n'.format(
@@ -174,7 +175,6 @@ class StatisticalAnalysis(StatisticalTests, NormalityTests, TextFormatting, Help
174
175
  else:
175
176
  self.run_test_auto()
176
177
 
177
-
178
178
  # print the results
179
179
  self.results = self.create_results_dict()
180
180
  self.print_results()
@@ -186,9 +186,8 @@ class StatisticalAnalysis(StatisticalTests, NormalityTests, TextFormatting, Help
186
186
  if self.verbose == True:
187
187
  print(self.summary)
188
188
 
189
-
190
-
191
189
  # public methods:
190
+
192
191
  def RunAuto(self):
193
192
  self.run_test(test='auto')
194
193
 
AutoStatLib/_version.py CHANGED
@@ -1,2 +1,2 @@
1
1
  # AutoStatLib package version:
2
- __version__ = "0.2.5"
2
+ __version__ = "0.2.6"
AutoStatLib/helpers.py CHANGED
@@ -1,6 +1,7 @@
1
1
  import numpy as np
2
2
  import pandas as pd
3
3
 
4
+
4
5
  class Helpers():
5
6
 
6
7
  def matrix_to_dataframe(self, matrix):
@@ -61,9 +62,11 @@ class Helpers():
61
62
  'Groups_SE': [np.std(self.data[i]).item() / np.sqrt(len(self.data)).item() for i in range(len(self.data))],
62
63
  # actually returns list of lists of numpy dtypes of float64, next make it return regular floats:
63
64
  'Samples': self.data,
64
- 'Posthoc_Matrix': self.posthoc_matrix if self.posthoc_matrix else 'N/A',
65
- 'Posthoc_Matrix_printed': [[self.make_p_value_printed(element) for element in row] for row in self.posthoc_matrix] if self.posthoc_matrix else 'N/A',
66
- 'Posthoc_Matrix_stars': [[self.make_stars_printed(self.make_stars(element)) for element in row] for row in self.posthoc_matrix] if self.posthoc_matrix else 'N/A',
65
+ 'Posthoc_Tests_Name': self.posthoc_name if self.posthoc_name is not None else '',
66
+ 'Posthoc_Matrix': self.posthoc_matrix if self.posthoc_matrix else [],
67
+ 'Posthoc_Matrix_bool': [[bool(element) for element in row] for row in self.posthoc_matrix] if self.posthoc_matrix else [],
68
+ 'Posthoc_Matrix_printed': [[self.make_p_value_printed(element) for element in row] for row in self.posthoc_matrix] if self.posthoc_matrix else [],
69
+ 'Posthoc_Matrix_stars': [[self.make_stars_printed(self.make_stars(element)) for element in row] for row in self.posthoc_matrix] if self.posthoc_matrix else [],
67
70
  }
68
71
 
69
72
  def log(self, *args, **kwargs):
@@ -74,4 +77,4 @@ class Helpers():
74
77
  def AddWarning(self, warning_id):
75
78
  message = self.warning_ids_all[warning_id]
76
79
  self.log(message)
77
- self.warnings.append(message)
80
+ self.warnings.append(message)
@@ -20,7 +20,7 @@ class NormalityTests():
20
20
 
21
21
  # Shapiro-Wilk test
22
22
  sw_stat, sw_p_value = shapiro(data)
23
- if sw_p_value > 0.05:
23
+ if sw_p_value and sw_p_value > 0.05:
24
24
  sw = True
25
25
  else:
26
26
  sw = False
@@ -28,7 +28,7 @@ class NormalityTests():
28
28
  # Lilliefors test
29
29
  lf_stat, lf_p_value = lilliefors(
30
30
  data, dist='norm')
31
- if lf_p_value > 0.05:
31
+ if lf_p_value and lf_p_value > 0.05:
32
32
  lf = True
33
33
  else:
34
34
  lf = False
@@ -37,7 +37,7 @@ class NormalityTests():
37
37
  if n >= 20:
38
38
  ad_stat, ad_p_value = self.anderson_get_p(
39
39
  data, dist='norm')
40
- if ad_p_value > 0.05:
40
+ if ad_p_value and ad_p_value > 0.05:
41
41
  ad = True
42
42
  else:
43
43
  ad = False
@@ -46,13 +46,11 @@ class NormalityTests():
46
46
  # test result is skewed if n<20
47
47
  if n >= 20:
48
48
  ap_stat, ap_p_value = normaltest(data)
49
- if ap_p_value > 0.05:
49
+ if ap_p_value and ap_p_value > 0.05:
50
50
  ap = True
51
51
  else:
52
52
  ap = False
53
53
 
54
- # print(ap_p_value, ad_p_value, sw_p_value, lf_p_value)
55
-
56
54
  return (sw, lf, ad, ap)
57
55
 
58
56
  def anderson_get_p(self, data, dist='norm'):
@@ -82,4 +80,4 @@ class NormalityTests():
82
80
  else:
83
81
  p = None
84
82
 
85
- return ad, p
83
+ return ad, p
@@ -1,10 +1,10 @@
1
1
  import numpy as np
2
2
  import scikit_posthocs as sp
3
3
  from statsmodels.stats.anova import AnovaRM
4
+ from statsmodels.stats.multicomp import pairwise_tukeyhsd
4
5
  from scipy.stats import ttest_rel, ttest_ind, ttest_1samp, wilcoxon, mannwhitneyu, f_oneway, kruskal, friedmanchisquare
5
6
 
6
7
 
7
-
8
8
  class StatisticalTests():
9
9
  '''
10
10
  Statistical tests mixin
@@ -50,7 +50,7 @@ class StatisticalTests():
50
50
  test_names_dict = {
51
51
  'anova_1w_ordinary': 'Ordinary One-Way ANOVA',
52
52
  'anova_1w_rm': 'Repeated Measures One-Way ANOVA',
53
- 'friedman': 'Friedman test',
53
+ 'friedman': 'Friedman test',
54
54
  'kruskal_wallis': 'Kruskal-Wallis test',
55
55
  'mann_whitney': 'Mann-Whitney U test',
56
56
  't_test_independent': 't-test for independent samples',
@@ -89,6 +89,15 @@ class StatisticalTests():
89
89
  # p_value /= 2
90
90
  # if self.tails == 1:
91
91
  # p_value /= 2
92
+
93
+ # if p_value < 0.05 and self.posthoc:
94
+ # data_flat = np.concatenate(self.data)
95
+ # self.posthoc_name = 'Tukey`s multiple comparisons'
96
+ # group_labels = np.concatenate(
97
+ # [[f"Group_{i+1}"] * len(group) for i, group in enumerate(self.data)])
98
+ # # Tukey's multiple comparisons
99
+ # tukey_result = pairwise_tukeyhsd(data_flat, group_labels)
100
+ # print(tukey_result)
92
101
  return stat, p_value
93
102
 
94
103
  def anova_1w_rm(self):
@@ -117,7 +126,9 @@ class StatisticalTests():
117
126
 
118
127
  # Perform Dunn's multiple comparisons if Kruskal-Wallis is significant
119
128
  if p_value < 0.05 and self.posthoc:
120
- self.posthoc_matrix = sp.posthoc_dunn(self.data, p_adjust='bonferroni').values.tolist()
129
+ self.posthoc_matrix = sp.posthoc_dunn(
130
+ self.data, p_adjust='bonferroni').values.tolist()
131
+ self.posthoc_name = 'Dunn`s multiple comparisons'
121
132
  return stat, p_value
122
133
 
123
134
  def mann_whitney(self):
@@ -161,7 +172,7 @@ class StatisticalTests():
161
172
  if self.tails == 1:
162
173
  p_value /= 2
163
174
  return stat, p_value
164
-
175
+
165
176
  def wilcoxon_single_sample(self):
166
177
  if self.popmean == None:
167
178
  self.popmean = 0
@@ -170,4 +181,4 @@ class StatisticalTests():
170
181
  stat, p_value = wilcoxon(data)
171
182
  if self.tails == 1:
172
183
  p_value /= 2
173
- return stat, p_value
184
+ return stat, p_value
@@ -51,22 +51,26 @@ class TextFormatting():
51
51
  break
52
52
  self.log(self.autospace(row_values, space))
53
53
 
54
- def make_stars(self, p) -> int:
55
- if p is not None:
56
- if p < 0.0001:
57
- return 4
58
- if p < 0.001:
59
- return 3
60
- elif p < 0.01:
61
- return 2
62
- elif p < 0.05:
63
- return 1
54
+ def print_results(self):
55
+ self.log('\n\nResults: \n')
56
+ for i in self.results:
57
+ shift = 27 - len(i)
58
+ if i == 'Warnings':
59
+ self.log(i, ':', ' ' * shift, len(self.results[i]))
60
+ elif i == 'Posthoc_Tests_Name':
61
+ self.log(i, ':', ' ' * shift,
62
+ self.results[i]) if self.results[i] != '' else 'N/A'
63
+ elif i == 'Posthoc_Matrix':
64
+ self.log(i, ':', ' ' * shift, '{0}x{0} matrix'.format(
65
+ len(self.results[i])) if self.results[i] else 'N/A')
66
+ elif (i == 'Samples'
67
+ or i == 'Posthoc_Matrix_bool'
68
+ or i == 'Posthoc_Matrix_printed'
69
+ or i == 'Posthoc_Matrix_stars'
70
+ ):
71
+ pass
64
72
  else:
65
- return 0
66
- return 0
67
-
68
- def make_stars_printed(self, n) -> str:
69
- return '*' * n if n else 'ns'
73
+ self.log(i, ':', ' ' * shift, self.results[i])
70
74
 
71
75
  def make_p_value_printed(self, p) -> str:
72
76
  if p is not None:
@@ -84,15 +88,19 @@ class TextFormatting():
84
88
  return 'N/A'
85
89
  return 'N/A'
86
90
 
87
- def print_results(self):
88
- self.log('\n\nResults: \n')
89
- for i in self.results:
90
- shift = 27 - len(i)
91
- if i == 'Warnings':
92
- self.log(i, ':', ' ' * shift, len(self.results[i]))
93
- if i == 'Posthoc_Matrix':
94
- self.log(i, ':', ' ' * shift, '{0}x{0} matrix'.format(len(self.results[i])))
95
- elif i == 'Samples' or i == 'Posthoc_Matrix_printed' or i == 'Posthoc_Matrix_stars':
96
- pass
91
+ def make_stars(self, p) -> int:
92
+ if p is not None:
93
+ if p < 0.0001:
94
+ return 4
95
+ if p < 0.001:
96
+ return 3
97
+ elif p < 0.01:
98
+ return 2
99
+ elif p < 0.05:
100
+ return 1
97
101
  else:
98
- self.log(i, ':', ' ' * shift, self.results[i])
102
+ return 0
103
+ return 0
104
+
105
+ def make_stars_printed(self, n) -> str:
106
+ return '*' * n if n else 'ns'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: AutoStatLib
3
- Version: 0.2.5
3
+ Version: 0.2.6
4
4
  Summary: AutoStatLib - a simple statistical analysis tool
5
5
  Author: Stemonitis, SciWare LLC
6
6
  Author-email: konung-yaropolk <yaropolk1995@gmail.com>
@@ -509,15 +509,16 @@ License: GNU LESSER GENERAL PUBLIC LICENSE
509
509
 
510
510
  That's all there is to it!
511
511
 
512
- Project-URL: Homepage, https://github.com/konung-yaropolk/NPL
513
- Project-URL: Issues, https://github.com/konung-yaropolk/NPL/issues
512
+ Project-URL: Homepage, https://github.com/konung-yaropolk/AutoStatLib
513
+ Project-URL: Repository, https://github.com/konung-yaropolk/AutoStatLib.git
514
+ Project-URL: Issues, https://github.com/konung-yaropolk/AutoStatLib/issues
514
515
  Keywords: Science,Statistics
515
516
  Classifier: Programming Language :: Python
516
517
  Classifier: Programming Language :: Python :: 3
517
518
  Classifier: Programming Language :: Python :: 3.12
518
519
  Classifier: License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)
519
520
  Classifier: Operating System :: OS Independent
520
- Classifier: Development Status :: 2 - Pre-Alpha
521
+ Classifier: Development Status :: 4 - Beta
521
522
  Classifier: Intended Audience :: Developers
522
523
  Classifier: Intended Audience :: Science/Research
523
524
  Classifier: Natural Language :: English
@@ -620,26 +621,30 @@ results = analysis.GetResult()
620
621
  The results dictionary keys with representing value types:
621
622
  ```
622
623
  {
623
- 'p-value': String
624
- 'Significance(p<0.05)': Boolean
625
- 'Stars_Printed': String
626
- 'Test_Name': String
627
- 'Groups_Compared': Integer
628
- 'Population_Mean': Float (taken from the input)
629
- 'Data_Normaly_Distributed': Boolean
630
- 'Parametric_Test_Applied': Boolean
631
- 'Paired_Test_Applied': Boolean
632
- 'Tails': Integer (taken from the input)
633
- 'p-value_exact': Float
634
- 'Stars': Integer
635
- 'Warnings': String
636
- 'Groups_N': List of integers
637
- 'Groups_Median': List of floats
638
- 'Groups_Mean': List of floats
639
- 'Groups_SD': List of floats
640
- 'Groups_SE': List of floats
641
- 'Samples': List of input values by groups
624
+ 'p-value' : String
625
+ 'Significance(p<0.05)' : Boolean
626
+ 'Stars_Printed' : String
627
+ 'Test_Name' : String
628
+ 'Groups_Compared' : Integer
629
+ 'Population_Mean' : Float (taken from the input)
630
+ 'Data_Normaly_Distributed' : Boolean
631
+ 'Parametric_Test_Applied' : Boolean
632
+ 'Paired_Test_Applied' : Boolean
633
+ 'Tails' : Integer (taken from the input)
634
+ 'p-value_exact' : Float
635
+ 'Stars' : Integer
636
+ 'Warnings' : String
637
+ 'Groups_N' : List of integers
638
+ 'Groups_Median' : List of floats
639
+ 'Groups_Mean' : List of floats
640
+ 'Groups_SD' : List of floats
641
+ 'Groups_SE' : List of floats
642
+ 'Samples' : List of input values by groups
642
643
  (taken from the input)
644
+ 'Posthoc_Matrix' : 2D List of floats
645
+ 'Posthoc_Matrix_bool' : 2D List of Boolean
646
+ 'Posthoc_Matrix_printed': 2D List of String
647
+ 'Posthoc_Matrix_stars': 2D List of String
643
648
  }
644
649
  ```
645
650
  If errors occured, *GetResult()* returns an empty dictionary
@@ -0,0 +1,13 @@
1
+ AutoStatLib/AutoStatLib.py,sha256=KJM2x-fChnxVinnCFsAKpoacKeoIJcJw_r8FYqPCljk,9677
2
+ AutoStatLib/__init__.py,sha256=0wHYnglzKRPqSHtZlfbMEA2Bj5rDR4LLaXbOrJi-sqM,101
3
+ AutoStatLib/__main__.py,sha256=ROKWensrxDh3Gl-yhexJ-BYFohDSh9y-CuMkaLpmnnQ,247
4
+ AutoStatLib/_version.py,sha256=dXJmKxrIARBAzN_ILPim1iDgRdZ6HKMR3FqtamGwNUk,53
5
+ AutoStatLib/helpers.py,sha256=d8P6_q706rjuc6N4WBbdOqNQFuAIjCHfmrhgJABFxqE,3646
6
+ AutoStatLib/normality_tests.py,sha256=TYeKpfpJRzOHvDZucObuZhPktjiZpSZwh381eJ8ENC4,2381
7
+ AutoStatLib/statistical_tests.py,sha256=xfHdTtN5Es_qoVMUwX8VFsl-FLpF3zd56S9ya7dPXVo,6566
8
+ AutoStatLib/text_formatting.py,sha256=rWDsrlZdquook7lUg8t2mb3az8nR12BDprxfy_NwE2o,3576
9
+ autostatlib-0.2.6.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
10
+ autostatlib-0.2.6.dist-info/METADATA,sha256=BDNKvdfcHaPlSF2q3YuDpOPFK_K7_hKcDH2NgjdCYtQ,36872
11
+ autostatlib-0.2.6.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
12
+ autostatlib-0.2.6.dist-info/top_level.txt,sha256=BuHzVyE2andc7RwD_UPmDjLl9CUAyBH6WHZGjaIReUI,12
13
+ autostatlib-0.2.6.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (76.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,13 +0,0 @@
1
- AutoStatLib/AutoStatLib.py,sha256=yPNnwCvHSSlEKQvtnoaLFDq6znPlXCz-CrzGInG-1Ys,9647
2
- AutoStatLib/__init__.py,sha256=0wHYnglzKRPqSHtZlfbMEA2Bj5rDR4LLaXbOrJi-sqM,101
3
- AutoStatLib/__main__.py,sha256=ROKWensrxDh3Gl-yhexJ-BYFohDSh9y-CuMkaLpmnnQ,247
4
- AutoStatLib/_version.py,sha256=-QrGYOb9bx4vC_twSInOBJoijtj78lvUzV19y4-tH38,53
5
- AutoStatLib/helpers.py,sha256=9Fj9pHlXSM3tGHF5L0-i6DilA9VZk6Re93ob_IRxsYg,3424
6
- AutoStatLib/normality_tests.py,sha256=wvOmo6F7drnhhikoGltyQJC4OBk3PLCszY6ItJk1e0M,2385
7
- AutoStatLib/statistical_tests.py,sha256=LDcBRkq56hepR23RZtbBnZOs9k9frVjmiB2EKiEkCYs,5990
8
- AutoStatLib/text_formatting.py,sha256=ShE4BRO69lsC1VT3SsYrmPkuvW7QnyfHVPZEbjNQ_hI,3250
9
- AutoStatLib-0.2.5.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
10
- AutoStatLib-0.2.5.dist-info/METADATA,sha256=qJxSrqHlL0wsqaH-ah6MAJa15ikH4NCco1dyVxuNlWs,36572
11
- AutoStatLib-0.2.5.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
12
- AutoStatLib-0.2.5.dist-info/top_level.txt,sha256=BuHzVyE2andc7RwD_UPmDjLl9CUAyBH6WHZGjaIReUI,12
13
- AutoStatLib-0.2.5.dist-info/RECORD,,