aplr 10.13.0__cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl → 10.14.0__cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.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 aplr might be problematic. Click here for more details.
- aplr/aplr.py +33 -26
- {aplr-10.13.0.dist-info → aplr-10.14.0.dist-info}/METADATA +2 -3
- aplr-10.14.0.dist-info/RECORD +8 -0
- aplr_cpp.cpython-311-i386-linux-gnu.so +0 -0
- aplr-10.13.0.dist-info/RECORD +0 -8
- {aplr-10.13.0.dist-info → aplr-10.14.0.dist-info}/WHEEL +0 -0
- {aplr-10.13.0.dist-info → aplr-10.14.0.dist-info}/licenses/LICENSE +0 -0
- {aplr-10.13.0.dist-info → aplr-10.14.0.dist-info}/top_level.txt +0 -0
aplr/aplr.py
CHANGED
|
@@ -334,12 +334,9 @@ class APLRRegressor:
|
|
|
334
334
|
:param path: The file path to save the plot. If empty and save is True, a default path will be used.
|
|
335
335
|
"""
|
|
336
336
|
try:
|
|
337
|
-
import pandas as pd
|
|
338
337
|
import matplotlib.pyplot as plt
|
|
339
338
|
except ImportError:
|
|
340
|
-
raise ImportError(
|
|
341
|
-
"pandas and matplotlib are required for plotting. Please install them."
|
|
342
|
-
)
|
|
339
|
+
raise ImportError("matplotlib is required for plotting. Please install it.")
|
|
343
340
|
|
|
344
341
|
all_affiliations = self.get_unique_term_affiliations()
|
|
345
342
|
if affiliation not in all_affiliations:
|
|
@@ -362,43 +359,55 @@ class APLRRegressor:
|
|
|
362
359
|
|
|
363
360
|
predictor_names = affiliation.split(" & ")
|
|
364
361
|
|
|
365
|
-
shape_df = pd.DataFrame(shape, columns=predictor_names + ["contribution"])
|
|
366
|
-
|
|
367
362
|
is_main_effect: bool = len(predictor_indexes_used) == 1
|
|
368
363
|
is_two_way_interaction: bool = len(predictor_indexes_used) == 2
|
|
369
364
|
|
|
370
365
|
if is_main_effect:
|
|
371
366
|
fig = plt.figure()
|
|
372
|
-
|
|
373
|
-
|
|
367
|
+
# Sort by predictor value for a clean line plot
|
|
368
|
+
sorted_indices = np.argsort(shape[:, 0])
|
|
369
|
+
plt.plot(shape[sorted_indices, 0], shape[sorted_indices, 1])
|
|
370
|
+
plt.xlabel(predictor_names[0])
|
|
374
371
|
plt.ylabel("Contribution to linear predictor")
|
|
375
|
-
plt.title(f"Main effect of {
|
|
372
|
+
plt.title(f"Main effect of {predictor_names[0]}")
|
|
376
373
|
plt.grid(True)
|
|
377
374
|
elif is_two_way_interaction:
|
|
378
375
|
fig = plt.figure(figsize=(8, 6))
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
376
|
+
|
|
377
|
+
# Get unique coordinates and their inverse mapping
|
|
378
|
+
y_unique, y_inv = np.unique(shape[:, 0], return_inverse=True)
|
|
379
|
+
x_unique, x_inv = np.unique(shape[:, 1], return_inverse=True)
|
|
380
|
+
|
|
381
|
+
# Create grid for sums and counts
|
|
382
|
+
grid_sums = np.zeros((len(y_unique), len(x_unique)))
|
|
383
|
+
grid_counts = np.zeros((len(y_unique), len(x_unique)))
|
|
384
|
+
|
|
385
|
+
# Populate sums and counts to later calculate the mean
|
|
386
|
+
np.add.at(grid_sums, (y_inv, x_inv), shape[:, 2])
|
|
387
|
+
np.add.at(grid_counts, (y_inv, x_inv), 1)
|
|
388
|
+
|
|
389
|
+
# Calculate mean, avoiding division by zero
|
|
390
|
+
with np.errstate(divide="ignore", invalid="ignore"):
|
|
391
|
+
pivot_table_values = np.true_divide(grid_sums, grid_counts)
|
|
392
|
+
# Where there's no data, pivot_table_values will be nan, which is fine for imshow.
|
|
393
|
+
|
|
385
394
|
plt.imshow(
|
|
386
|
-
|
|
395
|
+
pivot_table_values,
|
|
387
396
|
aspect="auto",
|
|
388
397
|
origin="lower",
|
|
389
398
|
extent=[
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
399
|
+
x_unique.min(),
|
|
400
|
+
x_unique.max(),
|
|
401
|
+
y_unique.min(),
|
|
402
|
+
y_unique.max(),
|
|
394
403
|
],
|
|
395
404
|
cmap="Blues_r",
|
|
396
405
|
)
|
|
397
406
|
plt.colorbar(label="Contribution to the linear predictor")
|
|
398
|
-
plt.xlabel(
|
|
399
|
-
plt.ylabel(
|
|
407
|
+
plt.xlabel(predictor_names[1])
|
|
408
|
+
plt.ylabel(predictor_names[0])
|
|
400
409
|
plt.title(
|
|
401
|
-
f"Interaction between {
|
|
410
|
+
f"Interaction between {predictor_names[0]} and {predictor_names[1]}"
|
|
402
411
|
)
|
|
403
412
|
else:
|
|
404
413
|
print(
|
|
@@ -407,9 +416,7 @@ class APLRRegressor:
|
|
|
407
416
|
return
|
|
408
417
|
|
|
409
418
|
if save:
|
|
410
|
-
save_path = (
|
|
411
|
-
path if path else f"shape_of_{affiliation.replace(' & ', '_')}.png"
|
|
412
|
-
)
|
|
419
|
+
save_path = path or f"shape_of_{affiliation.replace(' & ', '_')}.png"
|
|
413
420
|
plt.savefig(save_path)
|
|
414
421
|
|
|
415
422
|
if plot:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aplr
|
|
3
|
-
Version: 10.
|
|
3
|
+
Version: 10.14.0
|
|
4
4
|
Summary: Automatic Piecewise Linear Regression
|
|
5
5
|
Home-page: https://github.com/ottenbreit-data-science/aplr
|
|
6
6
|
Author: Mathias von Ottenbreit
|
|
@@ -15,8 +15,7 @@ Description-Content-Type: text/markdown
|
|
|
15
15
|
License-File: LICENSE
|
|
16
16
|
Requires-Dist: numpy>=1.11
|
|
17
17
|
Provides-Extra: plots
|
|
18
|
-
Requires-Dist:
|
|
19
|
-
Requires-Dist: matplotlib; extra == "plots"
|
|
18
|
+
Requires-Dist: matplotlib>=3.0; extra == "plots"
|
|
20
19
|
Dynamic: author
|
|
21
20
|
Dynamic: author-email
|
|
22
21
|
Dynamic: classifier
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
aplr_cpp.cpython-311-i386-linux-gnu.so,sha256=mZt8P7RIpVmJgwcknv58bEUW-XgUNQRFF1EeDHmtM1A,32243084
|
|
2
|
+
aplr-10.14.0.dist-info/METADATA,sha256=mQHAdFrGE447S4f98ECp8T8VXyY2mPkMRbO8DvPxbWU,2559
|
|
3
|
+
aplr-10.14.0.dist-info/top_level.txt,sha256=DXVC0RIFGpzVnPeKWAZTXQdJheOEZL51Wip6Fx7zbR4,14
|
|
4
|
+
aplr-10.14.0.dist-info/WHEEL,sha256=y7GVc00kjUHoY3TG47dN57V1vJtURKgKlGi6LDqgGJg,147
|
|
5
|
+
aplr-10.14.0.dist-info/RECORD,,
|
|
6
|
+
aplr-10.14.0.dist-info/licenses/LICENSE,sha256=g4qcQtkSVPHtGRi3T93DoFCrssvW6ij_emU-2fj_xfY,1113
|
|
7
|
+
aplr/__init__.py,sha256=rRfTgNWnYZlFatyA920lWqBcjwmQUI7FcvEPFUTJgzE,20
|
|
8
|
+
aplr/aplr.py,sha256=ZID8qOCi4UoE6sm9vSIUZvX1W1mrRsnzMacSOAhfl4Q,32828
|
|
Binary file
|
aplr-10.13.0.dist-info/RECORD
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
aplr_cpp.cpython-311-i386-linux-gnu.so,sha256=GzFsdfC6QRf1QsoGF4rV0jN2-W6fxwDXdz0Iw0fidSA,32243084
|
|
2
|
-
aplr-10.13.0.dist-info/METADATA,sha256=T8C_-jreoBSoWJuQap5KassYfloS06hmEXKH5gdZxNw,2594
|
|
3
|
-
aplr-10.13.0.dist-info/top_level.txt,sha256=DXVC0RIFGpzVnPeKWAZTXQdJheOEZL51Wip6Fx7zbR4,14
|
|
4
|
-
aplr-10.13.0.dist-info/WHEEL,sha256=y7GVc00kjUHoY3TG47dN57V1vJtURKgKlGi6LDqgGJg,147
|
|
5
|
-
aplr-10.13.0.dist-info/RECORD,,
|
|
6
|
-
aplr-10.13.0.dist-info/licenses/LICENSE,sha256=g4qcQtkSVPHtGRi3T93DoFCrssvW6ij_emU-2fj_xfY,1113
|
|
7
|
-
aplr/__init__.py,sha256=rRfTgNWnYZlFatyA920lWqBcjwmQUI7FcvEPFUTJgzE,20
|
|
8
|
-
aplr/aplr.py,sha256=m1Lv4I_tWoWSUqOgXzrM4vFiPcvmGOBZ1XIw_8bkKiA,32299
|
|
File without changes
|
|
File without changes
|
|
File without changes
|