lessPython 0.1.0__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.
- lessPy/ANOVA.py +680 -0
- lessPy/Chart.py +1055 -0
- lessPy/Correlation.py +236 -0
- lessPy/Flows.py +116 -0
- lessPy/Logit.py +615 -0
- lessPy/Prop_test.py +267 -0
- lessPy/Regression.py +1491 -0
- lessPy/VariableLabels.py +119 -0
- lessPy/X.py +426 -0
- lessPy/XY.py +2007 -0
- lessPy/__init__.py +60 -0
- lessPy/anova_rmd.py +227 -0
- lessPy/bc_plotly.py +575 -0
- lessPy/bubble_plotly.py +470 -0
- lessPy/corCFA.py +316 -0
- lessPy/corEFA.py +220 -0
- lessPy/corPrint.py +45 -0
- lessPy/corProp.py +73 -0
- lessPy/corRead.py +48 -0
- lessPy/corReflect.py +72 -0
- lessPy/corReorder.py +161 -0
- lessPy/corScree.py +87 -0
- lessPy/data/Anova_1way.csv +25 -0
- lessPy/data/Anova_2way.csv +49 -0
- lessPy/data/Anova_rb.csv +8 -0
- lessPy/data/Anova_rbf.csv +49 -0
- lessPy/data/Anova_sp.csv +57 -0
- lessPy/data/BodyMeas.csv +341 -0
- lessPy/data/Cars93.csv +94 -0
- lessPy/data/Employee.csv +38 -0
- lessPy/data/Employee_lbl.csv +9 -0
- lessPy/data/FreqTable99.csv +5 -0
- lessPy/data/Jackets.csv +1026 -0
- lessPy/data/Learn.csv +35 -0
- lessPy/data/Mach4.csv +352 -0
- lessPy/data/Mach4_lbl.csv +21 -0
- lessPy/data/Reading.csv +101 -0
- lessPy/data/StockPrice.csv +1489 -0
- lessPy/data/WeightLoss.csv +11 -0
- lessPy/datasets.py +46 -0
- lessPy/date_infer.py +112 -0
- lessPy/details.py +314 -0
- lessPy/dn_plotly.py +495 -0
- lessPy/dot_plotly.py +385 -0
- lessPy/freq_poly_plotly.py +324 -0
- lessPy/getColors.py +399 -0
- lessPy/hier_plotly.py +352 -0
- lessPy/hs_plotly.py +395 -0
- lessPy/logit_rmd.py +410 -0
- lessPy/order_by.py +94 -0
- lessPy/pie_plotly.py +292 -0
- lessPy/pivot.py +158 -0
- lessPy/plotly_utils.py +787 -0
- lessPy/plt_add.py +129 -0
- lessPy/plt_contour.py +192 -0
- lessPy/plt_contour_facet.py +194 -0
- lessPy/plt_forecast.py +677 -0
- lessPy/plt_mat_plotly.py +201 -0
- lessPy/plt_plotly.py +216 -0
- lessPy/plt_smooth.py +170 -0
- lessPy/plt_time.py +143 -0
- lessPy/prob_norm.py +111 -0
- lessPy/prob_tcut.py +131 -0
- lessPy/prob_znorm.py +110 -0
- lessPy/radar_plotly.py +201 -0
- lessPy/reg_rmd.py +754 -0
- lessPy/rename.py +33 -0
- lessPy/reshape.py +95 -0
- lessPy/showColors.py +130 -0
- lessPy/simCImean.py +165 -0
- lessPy/simCLT.py +265 -0
- lessPy/simFlips.py +104 -0
- lessPy/simMeans.py +146 -0
- lessPy/stats_out.py +189 -0
- lessPy/ttest.py +641 -0
- lessPy/utils.py +235 -0
- lessPy/vbs_plotly.py +545 -0
- lesspython-0.1.0.dist-info/METADATA +93 -0
- lesspython-0.1.0.dist-info/RECORD +82 -0
- lesspython-0.1.0.dist-info/WHEEL +5 -0
- lesspython-0.1.0.dist-info/licenses/LICENSE +338 -0
- lesspython-0.1.0.dist-info/top_level.txt +1 -0
lessPy/corRead.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# corRead.py — analog of corRead.R.
|
|
2
|
+
#
|
|
3
|
+
# corRead(): read a correlation matrix from a text file that
|
|
4
|
+
# holds only the coefficients — no header row, no row labels,
|
|
5
|
+
# whitespace- (or sep-) delimited. Validates that the values are
|
|
6
|
+
# numeric and the matrix is square, then labels the rows/columns
|
|
7
|
+
# from var_names, or X1..Xn by default. Returns the matrix as a
|
|
8
|
+
# DataFrame, ready for corEFA / corCFA / corScree, etc.
|
|
9
|
+
|
|
10
|
+
import numpy as np
|
|
11
|
+
import pandas as pd
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def corRead(file=None, var_names=None, sep=None):
|
|
15
|
+
"""Read a square correlation matrix of coefficients (no
|
|
16
|
+
header, no row labels) from a text file, whitespace-delimited
|
|
17
|
+
unless sep= is given. Names the variables from var_names, or
|
|
18
|
+
X1..Xn. Returns the matrix as a DataFrame. R analog: corRead()
|
|
19
|
+
(its `from` argument is this `file`; there is no interactive
|
|
20
|
+
file chooser)."""
|
|
21
|
+
if file is None:
|
|
22
|
+
raise ValueError(
|
|
23
|
+
"file= is required: the path to a text file of "
|
|
24
|
+
"correlation coefficients (Python has no interactive "
|
|
25
|
+
"file chooser)")
|
|
26
|
+
df = pd.read_csv(file, sep=r"\s+" if sep is None else sep,
|
|
27
|
+
header=None, engine="python")
|
|
28
|
+
if not all(pd.api.types.is_numeric_dtype(df[c])
|
|
29
|
+
for c in df.columns):
|
|
30
|
+
raise ValueError(
|
|
31
|
+
"the correlation matrix must be numeric; the file "
|
|
32
|
+
"has non-numeric values. Check that it contains only "
|
|
33
|
+
"coefficients, with no variable names or row labels.")
|
|
34
|
+
myc = df.to_numpy(dtype=float)
|
|
35
|
+
if myc.shape[0] != myc.shape[1]:
|
|
36
|
+
raise ValueError(
|
|
37
|
+
"the correlation matrix must be square; the read "
|
|
38
|
+
f"matrix is {myc.shape[0]} x {myc.shape[1]}.")
|
|
39
|
+
n = myc.shape[1]
|
|
40
|
+
if var_names is not None:
|
|
41
|
+
if len(var_names) != n:
|
|
42
|
+
raise ValueError(
|
|
43
|
+
f"var_names length ({len(var_names)}) must equal "
|
|
44
|
+
f"the number of variables ({n}).")
|
|
45
|
+
names = [str(v) for v in var_names]
|
|
46
|
+
else:
|
|
47
|
+
names = [f"X{i}" for i in range(1, n + 1)]
|
|
48
|
+
return pd.DataFrame(myc, index=names, columns=names)
|
lessPy/corReflect.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# corReflect.py — analog of corReflect.R.
|
|
2
|
+
#
|
|
3
|
+
# corReflect(): reverse the sign of the correlations of the named
|
|
4
|
+
# variables, to flip reverse-scored items so they correlate
|
|
5
|
+
# positively with the rest of a scale. Reflecting a variable
|
|
6
|
+
# negates all its off-diagonal correlations; reflecting two of
|
|
7
|
+
# them leaves their mutual correlation unchanged (it flips twice).
|
|
8
|
+
# Returns the reflected correlation matrix; the heat map is on the
|
|
9
|
+
# returned frame's .attrs["plots"].
|
|
10
|
+
|
|
11
|
+
import numpy as np
|
|
12
|
+
import pandas as pd
|
|
13
|
+
|
|
14
|
+
from .utils import get_option
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def corReflect(R, vars, main=None, heat_map=True):
|
|
18
|
+
"""Reflect (negate) the correlations of the variables named
|
|
19
|
+
in vars within the correlation matrix R (a DataFrame or
|
|
20
|
+
array; raw data is correlated first). Returns the reflected
|
|
21
|
+
correlation-matrix DataFrame; its .attrs["plots"] holds the
|
|
22
|
+
heat map. R analog: corReflect()"""
|
|
23
|
+
Rm = pd.DataFrame(R)
|
|
24
|
+
vals = Rm.to_numpy(dtype=float)
|
|
25
|
+
if (Rm.shape[0] != Rm.shape[1]
|
|
26
|
+
or not np.allclose(vals, vals.T, atol=1e-8)):
|
|
27
|
+
Rm = Rm.select_dtypes("number").corr()
|
|
28
|
+
Rm.index = Rm.columns = [str(c) for c in Rm.columns]
|
|
29
|
+
names = list(Rm.columns)
|
|
30
|
+
vars = [vars] if isinstance(vars, str) else list(vars)
|
|
31
|
+
bad = [str(v) for v in vars if str(v) not in names]
|
|
32
|
+
if bad:
|
|
33
|
+
raise ValueError(
|
|
34
|
+
f"variables not in the matrix: {', '.join(bad)}")
|
|
35
|
+
|
|
36
|
+
# sign vector: -1 for a reflected variable. The outer product
|
|
37
|
+
# negates each reflected variable's off-diagonal row/col and
|
|
38
|
+
# leaves the diagonal (sign^2 = 1) and any pair of reflected
|
|
39
|
+
# variables (two flips) unchanged. ~ corReflect.R loop
|
|
40
|
+
s = np.ones(len(names))
|
|
41
|
+
for v in vars:
|
|
42
|
+
s[names.index(str(v))] = -1.0
|
|
43
|
+
out = pd.DataFrame(np.outer(s, s) * Rm.to_numpy(dtype=float),
|
|
44
|
+
index=Rm.index, columns=Rm.columns)
|
|
45
|
+
|
|
46
|
+
plots = {}
|
|
47
|
+
if heat_map:
|
|
48
|
+
plots["heatmap"] = _heatmap(out, main)
|
|
49
|
+
out.attrs["plots"] = plots
|
|
50
|
+
return out
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _heatmap(df, main):
|
|
54
|
+
import plotly.graph_objects as go
|
|
55
|
+
|
|
56
|
+
from .plotly_utils import plotly_style, to_hex
|
|
57
|
+
labels = list(df.columns)
|
|
58
|
+
Z = df.to_numpy(dtype=float).copy()
|
|
59
|
+
np.fill_diagonal(Z, np.nan)
|
|
60
|
+
style = plotly_style()
|
|
61
|
+
fig = go.Figure(go.Heatmap(
|
|
62
|
+
z=Z, x=labels, y=labels, zmin=-1, zmax=1,
|
|
63
|
+
colorscale="RdBu", reversescale=True,
|
|
64
|
+
colorbar=dict(title="r")))
|
|
65
|
+
fig.update_yaxes(autorange="reversed")
|
|
66
|
+
fig.update_layout(
|
|
67
|
+
template=None, paper_bgcolor=to_hex(style["window_fill"]),
|
|
68
|
+
title=dict(text=main or "With Reflected Item Coefficients",
|
|
69
|
+
x=0.5, xanchor="center",
|
|
70
|
+
font=dict(size=round(
|
|
71
|
+
16 * get_option("main_size", 1)))))
|
|
72
|
+
return fig
|
lessPy/corReorder.py
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# corReorder.py — analog of corReorder.R.
|
|
2
|
+
#
|
|
3
|
+
# corReorder(): reorder the variables of a correlation matrix so
|
|
4
|
+
# that related variables are adjacent, by hierarchical clustering
|
|
5
|
+
# (the default), the Hunter (1973) chaining algorithm, a manual
|
|
6
|
+
# order, or as-is. Returns the reordered correlation matrix (a
|
|
7
|
+
# DataFrame); the heat map and, for hclust, the dendrogram are on
|
|
8
|
+
# the returned frame's .attrs["plots"]. Useful before corCFA or a
|
|
9
|
+
# heat map, to reveal the cluster structure.
|
|
10
|
+
|
|
11
|
+
import numpy as np
|
|
12
|
+
import pandas as pd
|
|
13
|
+
|
|
14
|
+
from .utils import get_option
|
|
15
|
+
|
|
16
|
+
# R hclust method -> scipy linkage method. scipy 'ward' is R's
|
|
17
|
+
# ward.D2 (squared updates); ward.D has no scipy equivalent, so
|
|
18
|
+
# it maps to ward with a note. 'weighted' is R's mcquitty.
|
|
19
|
+
_LINKAGE = {"complete": "complete", "single": "single",
|
|
20
|
+
"average": "average", "mcquitty": "weighted",
|
|
21
|
+
"centroid": "centroid", "median": "median",
|
|
22
|
+
"ward.D2": "ward", "ward.D": "ward"}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def corReorder(R, order="hclust", hclust_type="complete",
|
|
26
|
+
dist_type="R", n_clusters=None, vars=None,
|
|
27
|
+
chain_first=0, heat_map=True, dendrogram=True,
|
|
28
|
+
diagonal_new=True, main=None):
|
|
29
|
+
"""Reorder the variables of a correlation matrix R (a
|
|
30
|
+
DataFrame or array; raw data is correlated first).
|
|
31
|
+
order="hclust" (default), "chain", "manual" (vars=[...]), or
|
|
32
|
+
"as_is". Returns the reordered correlation-matrix DataFrame;
|
|
33
|
+
its .attrs["plots"] holds the heat map (and dendrogram).
|
|
34
|
+
R analog: corReorder()"""
|
|
35
|
+
if order not in ("hclust", "chain", "manual", "as_is"):
|
|
36
|
+
raise ValueError('order: "hclust", "chain", "manual", '
|
|
37
|
+
'"as_is"')
|
|
38
|
+
Rm = pd.DataFrame(R)
|
|
39
|
+
vals = Rm.to_numpy(dtype=float)
|
|
40
|
+
if (Rm.shape[0] != Rm.shape[1]
|
|
41
|
+
or not np.allclose(vals, vals.T, atol=1e-8)):
|
|
42
|
+
Rm = Rm.select_dtypes("number").corr()
|
|
43
|
+
Rm.index = Rm.columns = [str(c) for c in Rm.columns]
|
|
44
|
+
S = Rm.to_numpy(dtype=float)
|
|
45
|
+
names = list(Rm.columns)
|
|
46
|
+
nv = len(names)
|
|
47
|
+
if vars is not None:
|
|
48
|
+
order = "manual"
|
|
49
|
+
|
|
50
|
+
Z = None
|
|
51
|
+
if order == "manual":
|
|
52
|
+
label = [names.index(str(v)) for v in vars]
|
|
53
|
+
elif order == "as_is":
|
|
54
|
+
diagonal_new = False
|
|
55
|
+
label = list(range(nv))
|
|
56
|
+
elif order == "chain":
|
|
57
|
+
label = _chain(S, nv, int(chain_first))
|
|
58
|
+
else: # hclust
|
|
59
|
+
label, Z = _hclust(S, hclust_type, dist_type, n_clusters,
|
|
60
|
+
names)
|
|
61
|
+
|
|
62
|
+
out = Rm.iloc[label, label]
|
|
63
|
+
plots = {}
|
|
64
|
+
if heat_map:
|
|
65
|
+
plots["heatmap"] = _heatmap(out, diagonal_new, main)
|
|
66
|
+
if order == "hclust" and dendrogram and Z is not None:
|
|
67
|
+
try:
|
|
68
|
+
plots["dendrogram"] = _dendrogram(Z, names, label)
|
|
69
|
+
except Exception: # optional; skip if it fails
|
|
70
|
+
pass
|
|
71
|
+
out.attrs["plots"] = plots
|
|
72
|
+
out.attrs["order"] = label
|
|
73
|
+
return out
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _chain(S, nv, first):
|
|
77
|
+
"""Hunter (1973) chaining: start with the variable of largest
|
|
78
|
+
summed squared correlation (or the user's chain_first), then
|
|
79
|
+
repeatedly append the unselected variable most correlated (in
|
|
80
|
+
absolute value) with the last one. ~ corReorder.R chain."""
|
|
81
|
+
if first == 0:
|
|
82
|
+
first = int(np.argmax((S ** 2).sum(axis=1)))
|
|
83
|
+
else:
|
|
84
|
+
first = first - 1 # 1-based -> 0-based
|
|
85
|
+
label = [first]
|
|
86
|
+
remaining = set(range(nv)) - {first}
|
|
87
|
+
while remaining:
|
|
88
|
+
k = label[-1]
|
|
89
|
+
nxt = max(remaining, key=lambda j: abs(S[k, j]))
|
|
90
|
+
label.append(nxt)
|
|
91
|
+
remaining.discard(nxt)
|
|
92
|
+
return label
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _hclust(S, method, dist_type, n_clusters, names):
|
|
96
|
+
from scipy.cluster.hierarchy import (
|
|
97
|
+
fcluster, leaves_list, linkage)
|
|
98
|
+
from scipy.spatial.distance import squareform
|
|
99
|
+
if method not in _LINKAGE:
|
|
100
|
+
raise ValueError(f"hclust_type: {', '.join(_LINKAGE)}")
|
|
101
|
+
D = S if dist_type == "dist" else 1 - S
|
|
102
|
+
cond = squareform(D, checks=False)
|
|
103
|
+
Z = linkage(cond, method=_LINKAGE[method])
|
|
104
|
+
label = leaves_list(Z).tolist()
|
|
105
|
+
if n_clusters is not None:
|
|
106
|
+
cl = fcluster(Z, t=n_clusters, criterion="maxclust")
|
|
107
|
+
# renumber clusters by first appearance in the original
|
|
108
|
+
# variable order, as R's cutree
|
|
109
|
+
seen = {}
|
|
110
|
+
cl = [seen.setdefault(c, len(seen) + 1) for c in cl]
|
|
111
|
+
ttl = f"{n_clusters} Cluster Solution"
|
|
112
|
+
print(f"\n{ttl}\n" + "-" * len(ttl))
|
|
113
|
+
for nm, c in sorted(zip(names, cl), key=lambda p: p[1]):
|
|
114
|
+
print(f"{nm}: {c}")
|
|
115
|
+
return label, Z
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def _apply_diag(M):
|
|
119
|
+
"""Replace the diagonal with the average of its adjacent
|
|
120
|
+
off-diagonal values, for a cleaner heat map. ~ diagonal_new."""
|
|
121
|
+
nv = M.shape[0]
|
|
122
|
+
D = M.copy()
|
|
123
|
+
if nv >= 2:
|
|
124
|
+
D[0, 0] = M[0, 1]
|
|
125
|
+
for i in range(1, nv - 1):
|
|
126
|
+
D[i, i] = round((M[i, i - 1] + M[i, i + 1]) / 2, 2)
|
|
127
|
+
D[nv - 1, nv - 1] = M[nv - 1, nv - 2]
|
|
128
|
+
return D
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def _heatmap(df, diagonal_new, main):
|
|
132
|
+
import plotly.graph_objects as go
|
|
133
|
+
from .plotly_utils import plotly_style, to_hex
|
|
134
|
+
Z = df.to_numpy(dtype=float).copy()
|
|
135
|
+
if diagonal_new:
|
|
136
|
+
Z = _apply_diag(Z)
|
|
137
|
+
labels = list(df.columns)
|
|
138
|
+
style = plotly_style()
|
|
139
|
+
fig = go.Figure(go.Heatmap(
|
|
140
|
+
z=Z, x=labels, y=labels, zmin=-1, zmax=1,
|
|
141
|
+
colorscale="RdBu", reversescale=True,
|
|
142
|
+
colorbar=dict(title="r")))
|
|
143
|
+
fig.update_yaxes(autorange="reversed")
|
|
144
|
+
fig.update_layout(
|
|
145
|
+
template=None, paper_bgcolor=to_hex(style["window_fill"]),
|
|
146
|
+
title=dict(text=main or "Reordered Correlations", x=0.5,
|
|
147
|
+
xanchor="center",
|
|
148
|
+
font=dict(size=round(
|
|
149
|
+
16 * get_option("main_size", 1)))))
|
|
150
|
+
return fig
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _dendrogram(Z, names, label):
|
|
154
|
+
from plotly.figure_factory import create_dendrogram
|
|
155
|
+
fig = create_dendrogram(
|
|
156
|
+
np.zeros((len(names), 1)), labels=names,
|
|
157
|
+
linkagefun=lambda _x: Z)
|
|
158
|
+
fig.update_layout(
|
|
159
|
+
title=dict(text="Cluster Dendrogram", x=0.5,
|
|
160
|
+
xanchor="center"))
|
|
161
|
+
return fig
|
lessPy/corScree.py
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# corScree.py — analog of corScree.R.
|
|
2
|
+
#
|
|
3
|
+
# corScree(): the scree plots for deciding the number of factors
|
|
4
|
+
# — the eigenvalues of a correlation matrix against their index,
|
|
5
|
+
# and the differences of successive eigenvalues. Prints both
|
|
6
|
+
# sequences and returns them with the two plotly figures.
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
import pandas as pd
|
|
10
|
+
|
|
11
|
+
from .plotly_utils import (
|
|
12
|
+
axis_format, axis_num, plot_border, plotly_style, to_hex,
|
|
13
|
+
x_grid)
|
|
14
|
+
from .utils import fmt, get_option, pretty
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class corScreeResults:
|
|
18
|
+
"""Results of corScree(): the eigenvalues, the differences of
|
|
19
|
+
successive eigenvalues, and the two plotly figures in
|
|
20
|
+
.plots."""
|
|
21
|
+
|
|
22
|
+
def __init__(self, **kw):
|
|
23
|
+
self.__dict__.update(kw)
|
|
24
|
+
|
|
25
|
+
def __repr__(self):
|
|
26
|
+
return f"<lessPy corScree: {len(self.eigenvalues)} vars>"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def corScree(R, main=None):
|
|
30
|
+
"""Scree analysis of a correlation matrix R (a DataFrame or
|
|
31
|
+
array; raw data is correlated first): its eigenvalues and
|
|
32
|
+
their successive differences, each printed and plotted.
|
|
33
|
+
Returns a corScreeResults with the figures in .plots.
|
|
34
|
+
R analog: corScree()"""
|
|
35
|
+
Rm = pd.DataFrame(R)
|
|
36
|
+
vals = Rm.to_numpy(dtype=float)
|
|
37
|
+
if (Rm.shape[0] != Rm.shape[1]
|
|
38
|
+
or not np.allclose(vals, vals.T, atol=1e-8)):
|
|
39
|
+
Rm = Rm.select_dtypes("number").corr()
|
|
40
|
+
S = Rm.to_numpy(dtype=float)
|
|
41
|
+
|
|
42
|
+
ev = np.linalg.eigvalsh(S)[::-1] # descending
|
|
43
|
+
ev_diff = ev[:-1] - ev[1:] # -diff(ev)
|
|
44
|
+
|
|
45
|
+
def line(seq):
|
|
46
|
+
return " ".join(fmt(v, 3) for v in seq)
|
|
47
|
+
|
|
48
|
+
print("\nEigenvalues\n" + "-" * 11 + "\n" + line(ev)
|
|
49
|
+
+ "\n\nDifferences of Successive Eigenvalues\n"
|
|
50
|
+
+ "-" * 37 + "\n" + line(ev_diff) + "\n")
|
|
51
|
+
|
|
52
|
+
plots = {
|
|
53
|
+
"scree": _scree_plot(ev, "Eigenvalues", main),
|
|
54
|
+
"differences": _scree_plot(
|
|
55
|
+
ev_diff, "Differences of Successive Eigenvalues",
|
|
56
|
+
main)}
|
|
57
|
+
return corScreeResults(eigenvalues=ev, differences=ev_diff,
|
|
58
|
+
plots=plots)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _scree_plot(y, y_lab, main):
|
|
62
|
+
"""A line-with-markers plot of y against its 1-based index.
|
|
63
|
+
~ .plt.main segments plot in corScree.R"""
|
|
64
|
+
import plotly.graph_objects as go
|
|
65
|
+
style = plotly_style()
|
|
66
|
+
x = np.arange(1, len(y) + 1)
|
|
67
|
+
col = to_hex(get_option("fit_color", "#5C4032"))
|
|
68
|
+
fig = go.Figure(go.Scatter(
|
|
69
|
+
x=x, y=y, mode="lines+markers",
|
|
70
|
+
line=dict(color=col, width=1.5),
|
|
71
|
+
marker=dict(size=7, color=col), hoverinfo="x+y",
|
|
72
|
+
showlegend=False))
|
|
73
|
+
axT2 = pretty(float(min(y.min(), 0)), float(y.max()))
|
|
74
|
+
ax_x = axis_num("Index", list(x), [str(i) for i in x])
|
|
75
|
+
ax_y = axis_num(y_lab, axT2, axis_format(axT2, 2))
|
|
76
|
+
ax_y.update(showgrid=True,
|
|
77
|
+
gridcolor=to_hex(style["grid_col"]),
|
|
78
|
+
gridwidth=1, griddash="dot")
|
|
79
|
+
fig.update_layout(
|
|
80
|
+
xaxis=ax_x, yaxis=ax_y,
|
|
81
|
+
shapes=x_grid(list(x)) + plot_border(), template=None,
|
|
82
|
+
plot_bgcolor=to_hex(style["panel_fill"]),
|
|
83
|
+
paper_bgcolor=to_hex(style["window_fill"]),
|
|
84
|
+
title=dict(text=main or "", x=0.5, xanchor="center",
|
|
85
|
+
font=dict(size=round(
|
|
86
|
+
16 * get_option("main_size", 1)))))
|
|
87
|
+
return fig
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"Dosage","Time"
|
|
2
|
+
"00mg",25.6
|
|
3
|
+
"00mg",25.8
|
|
4
|
+
"00mg",25.5
|
|
5
|
+
"00mg",23.3
|
|
6
|
+
"00mg",26.5
|
|
7
|
+
"00mg",26
|
|
8
|
+
"00mg",18.4
|
|
9
|
+
"00mg",23
|
|
10
|
+
"05mg",23.4
|
|
11
|
+
"05mg",21.9
|
|
12
|
+
"05mg",24.8
|
|
13
|
+
"05mg",24
|
|
14
|
+
"05mg",28.2
|
|
15
|
+
"05mg",25.2
|
|
16
|
+
"05mg",19
|
|
17
|
+
"05mg",20.8
|
|
18
|
+
"10mg",24.2
|
|
19
|
+
"10mg",19
|
|
20
|
+
"10mg",16.4
|
|
21
|
+
"10mg",19.4
|
|
22
|
+
"10mg",18.5
|
|
23
|
+
"10mg",20.1
|
|
24
|
+
"10mg",13.1
|
|
25
|
+
"10mg",11.9
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"Difficulty","Dosage","Time"
|
|
2
|
+
"Easy","00mg",25.6
|
|
3
|
+
"Easy","00mg",25.8
|
|
4
|
+
"Easy","00mg",25.5
|
|
5
|
+
"Easy","00mg",23.3
|
|
6
|
+
"Easy","00mg",26.5
|
|
7
|
+
"Easy","00mg",26
|
|
8
|
+
"Easy","00mg",18.4
|
|
9
|
+
"Easy","00mg",23
|
|
10
|
+
"Easy","05mg",23.4
|
|
11
|
+
"Easy","05mg",21.9
|
|
12
|
+
"Easy","05mg",24.8
|
|
13
|
+
"Easy","05mg",24
|
|
14
|
+
"Easy","05mg",28.2
|
|
15
|
+
"Easy","05mg",25.2
|
|
16
|
+
"Easy","05mg",19
|
|
17
|
+
"Easy","05mg",20.8
|
|
18
|
+
"Easy","10mg",24.2
|
|
19
|
+
"Easy","10mg",19
|
|
20
|
+
"Easy","10mg",16.4
|
|
21
|
+
"Easy","10mg",19.4
|
|
22
|
+
"Easy","10mg",18.5
|
|
23
|
+
"Easy","10mg",20.1
|
|
24
|
+
"Easy","10mg",13.1
|
|
25
|
+
"Easy","10mg",11.9
|
|
26
|
+
"Hard","00mg",40.5
|
|
27
|
+
"Hard","00mg",36
|
|
28
|
+
"Hard","00mg",26.7
|
|
29
|
+
"Hard","00mg",41.3
|
|
30
|
+
"Hard","00mg",36.2
|
|
31
|
+
"Hard","00mg",32.8
|
|
32
|
+
"Hard","00mg",34.2
|
|
33
|
+
"Hard","00mg",30.1
|
|
34
|
+
"Hard","05mg",40.3
|
|
35
|
+
"Hard","05mg",36
|
|
36
|
+
"Hard","05mg",31.8
|
|
37
|
+
"Hard","05mg",32.2
|
|
38
|
+
"Hard","05mg",28.4
|
|
39
|
+
"Hard","05mg",32.2
|
|
40
|
+
"Hard","05mg",25.4
|
|
41
|
+
"Hard","05mg",27.4
|
|
42
|
+
"Hard","10mg",46.7
|
|
43
|
+
"Hard","10mg",38.5
|
|
44
|
+
"Hard","10mg",32.8
|
|
45
|
+
"Hard","10mg",39
|
|
46
|
+
"Hard","10mg",40.8
|
|
47
|
+
"Hard","10mg",34.7
|
|
48
|
+
"Hard","10mg",39.3
|
|
49
|
+
"Hard","10mg",43
|
lessPy/data/Anova_rb.csv
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"Difficulty","Dosage","Block","Time"
|
|
2
|
+
"Easy","mg00","Blck1",25.6
|
|
3
|
+
"Easy","mg05","Blck1",23.4
|
|
4
|
+
"Easy","mg10","Blck1",24.2
|
|
5
|
+
"Hard","mg00","Blck1",40.5
|
|
6
|
+
"Hard","mg05","Blck1",40.3
|
|
7
|
+
"Hard","mg10","Blck1",46.7
|
|
8
|
+
"Easy","mg00","Blck2",25.8
|
|
9
|
+
"Easy","mg05","Blck2",21.9
|
|
10
|
+
"Easy","mg10","Blck2",19
|
|
11
|
+
"Hard","mg00","Blck2",36
|
|
12
|
+
"Hard","mg05","Blck2",36
|
|
13
|
+
"Hard","mg10","Blck2",38.5
|
|
14
|
+
"Easy","mg00","Blck3",25.5
|
|
15
|
+
"Easy","mg05","Blck3",24.8
|
|
16
|
+
"Easy","mg10","Blck3",16.4
|
|
17
|
+
"Hard","mg00","Blck3",26.7
|
|
18
|
+
"Hard","mg05","Blck3",31.8
|
|
19
|
+
"Hard","mg10","Blck3",32.8
|
|
20
|
+
"Easy","mg00","Blck4",23.3
|
|
21
|
+
"Easy","mg05","Blck4",24
|
|
22
|
+
"Easy","mg10","Blck4",19.4
|
|
23
|
+
"Hard","mg00","Blck4",41.3
|
|
24
|
+
"Hard","mg05","Blck4",32.2
|
|
25
|
+
"Hard","mg10","Blck4",39
|
|
26
|
+
"Easy","mg00","Blck5",26.5
|
|
27
|
+
"Easy","mg05","Blck5",28.2
|
|
28
|
+
"Easy","mg10","Blck5",18.5
|
|
29
|
+
"Hard","mg00","Blck5",36.2
|
|
30
|
+
"Hard","mg05","Blck5",28.4
|
|
31
|
+
"Hard","mg10","Blck5",40.8
|
|
32
|
+
"Easy","mg00","Blck6",26
|
|
33
|
+
"Easy","mg05","Blck6",25.2
|
|
34
|
+
"Easy","mg10","Blck6",20.1
|
|
35
|
+
"Hard","mg00","Blck6",32.8
|
|
36
|
+
"Hard","mg05","Blck6",32.2
|
|
37
|
+
"Hard","mg10","Blck6",34.7
|
|
38
|
+
"Easy","mg00","Blck7",18.4
|
|
39
|
+
"Easy","mg05","Blck7",19
|
|
40
|
+
"Easy","mg10","Blck7",13.1
|
|
41
|
+
"Hard","mg00","Blck7",34.2
|
|
42
|
+
"Hard","mg05","Blck7",25.4
|
|
43
|
+
"Hard","mg10","Blck7",39.3
|
|
44
|
+
"Easy","mg00","Blck8",23
|
|
45
|
+
"Easy","mg05","Blck8",20.8
|
|
46
|
+
"Easy","mg10","Blck8",11.9
|
|
47
|
+
"Hard","mg00","Blck8",30.1
|
|
48
|
+
"Hard","mg05","Blck8",27.4
|
|
49
|
+
"Hard","mg10","Blck8",43
|
lessPy/data/Anova_sp.csv
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"Person","Food","Supplement","Reps"
|
|
2
|
+
"p1","Hi","sup1",2
|
|
3
|
+
"p1","Hi","sup2",4
|
|
4
|
+
"p1","Hi","sup3",4
|
|
5
|
+
"p1","Hi","sup4",3
|
|
6
|
+
"p2","Hi","sup1",2
|
|
7
|
+
"p2","Hi","sup2",5
|
|
8
|
+
"p2","Hi","sup3",4
|
|
9
|
+
"p2","Hi","sup4",6
|
|
10
|
+
"p3","Hi","sup1",8
|
|
11
|
+
"p3","Hi","sup2",6
|
|
12
|
+
"p3","Hi","sup3",7
|
|
13
|
+
"p3","Hi","sup4",9
|
|
14
|
+
"p4","Hi","sup1",4
|
|
15
|
+
"p4","Hi","sup2",3
|
|
16
|
+
"p4","Hi","sup3",5
|
|
17
|
+
"p4","Hi","sup4",7
|
|
18
|
+
"p5","Hi","sup1",2
|
|
19
|
+
"p5","Hi","sup2",1
|
|
20
|
+
"p5","Hi","sup3",2
|
|
21
|
+
"p5","Hi","sup4",3
|
|
22
|
+
"p6","Hi","sup2",5
|
|
23
|
+
"p6","Hi","sup1",5
|
|
24
|
+
"p6","Hi","sup3",6
|
|
25
|
+
"p6","Hi","sup4",8
|
|
26
|
+
"p7","Hi","sup1",2
|
|
27
|
+
"p7","Hi","sup2",3
|
|
28
|
+
"p7","Hi","sup3",2
|
|
29
|
+
"p7","Hi","sup4",4
|
|
30
|
+
"p1","Low","sup1",2
|
|
31
|
+
"p1","Low","sup2",2
|
|
32
|
+
"p1","Low","sup3",3
|
|
33
|
+
"p1","Low","sup4",3
|
|
34
|
+
"p2","Low","sup1",1
|
|
35
|
+
"p2","Low","sup2",4
|
|
36
|
+
"p2","Low","sup3",3
|
|
37
|
+
"p2","Low","sup4",4
|
|
38
|
+
"p3","Low","sup1",6
|
|
39
|
+
"p3","Low","sup2",3
|
|
40
|
+
"p3","Low","sup3",7
|
|
41
|
+
"p3","Low","sup4",8
|
|
42
|
+
"p4","Low","sup1",2
|
|
43
|
+
"p4","Low","sup2",3
|
|
44
|
+
"p4","Low","sup3",4
|
|
45
|
+
"p4","Low","sup4",5
|
|
46
|
+
"p5","Low","sup1",1
|
|
47
|
+
"p5","Low","sup2",1
|
|
48
|
+
"p5","Low","sup3",2
|
|
49
|
+
"p5","Low","sup4",3
|
|
50
|
+
"p6","Low","sup2",5
|
|
51
|
+
"p6","Low","sup1",5
|
|
52
|
+
"p6","Low","sup3",7
|
|
53
|
+
"p6","Low","sup4",8
|
|
54
|
+
"p7","Low","sup1",3
|
|
55
|
+
"p7","Low","sup2",2
|
|
56
|
+
"p7","Low","sup3",2
|
|
57
|
+
"p7","Low","sup4",4
|