locpick 0.0.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.
- locpick/__init__.py +27 -0
- locpick/__init__.pyi +153 -0
- locpick/_jax/__init__.py +55 -0
- locpick/_jax/__init__.pyi +62 -0
- locpick/_jax/builders.py +1607 -0
- locpick/_jax/data.py +361 -0
- locpick/_jax/diag_precompute.py +516 -0
- locpick/_jax/kernels.py +905 -0
- locpick/_jax/objective.py +296 -0
- locpick/_jax/sar_kernels.py +1008 -0
- locpick/_jax/sparse_backends.py +232 -0
- locpick/_jax/sparse_solve.py +429 -0
- locpick/_jax/transforms.py +275 -0
- locpick/_kernels/__init__.py +14 -0
- locpick/_kernels/__init__.pyi +20 -0
- locpick/_kernels/constants.py +31 -0
- locpick/_kernels/mnl_numpy.py +232 -0
- locpick/_kernels/sar_mnl_numpy.py +259 -0
- locpick/_sampling/__init__.py +9 -0
- locpick/_sampling/__init__.pyi +33 -0
- locpick/_sampling/correction.py +75 -0
- locpick/_sampling/inclusion.py +130 -0
- locpick/_sampling/kernels.py +441 -0
- locpick/_solvers/__init__.py +12 -0
- locpick/_solvers/__init__.pyi +39 -0
- locpick/_solvers/lbfgs.py +165 -0
- locpick/_solvers/optax.py +255 -0
- locpick/_solvers/optimagic.py +164 -0
- locpick/_solvers/optimistix.py +479 -0
- locpick/_solvers/protocol.py +171 -0
- locpick/_solvers/trust_ncg.py +151 -0
- locpick/data/__init__.py +45 -0
- locpick/data/__init__.pyi +60 -0
- locpick/data/arrays.py +128 -0
- locpick/data/choicetable.py +1118 -0
- locpick/data/dataset.py +330 -0
- locpick/data/distance.py +260 -0
- locpick/data/format.py +302 -0
- locpick/data/problem.py +265 -0
- locpick/dgp.py +2055 -0
- locpick/models/__init__.py +17 -0
- locpick/models/__init__.pyi +36 -0
- locpick/models/_spatial.py +185 -0
- locpick/models/_spatial_weights.py +126 -0
- locpick/models/base.py +858 -0
- locpick/models/choice_model.py +2258 -0
- locpick/models/mixed.py +621 -0
- locpick/models/nested.py +357 -0
- locpick/models/scl.py +276 -0
- locpick/py.typed +0 -0
- locpick/results/__init__.py +14 -0
- locpick/results/__init__.pyi +35 -0
- locpick/results/diagnostics.py +713 -0
- locpick/results/fit_result.py +268 -0
- locpick/spec/__init__.py +9 -0
- locpick/spec/__init__.pyi +14 -0
- locpick/spec/model_spec.py +330 -0
- locpick/spec/terms.py +107 -0
- locpick-0.0.0.dist-info/METADATA +105 -0
- locpick-0.0.0.dist-info/RECORD +63 -0
- locpick-0.0.0.dist-info/WHEEL +5 -0
- locpick-0.0.0.dist-info/licenses/LICENSE +27 -0
- locpick-0.0.0.dist-info/top_level.txt +1 -0
locpick/__init__.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""LocPick: modern location and destination choice modeling.
|
|
2
|
+
|
|
3
|
+
The package exposes data assembly, model specification, estimation,
|
|
4
|
+
and inference tools for discrete choice models with large alternative sets.
|
|
5
|
+
|
|
6
|
+
Submodules and attributes are loaded lazily following SPEC 1
|
|
7
|
+
(https://scientific-python.org/specs/spec-0001/) so that ``import locpick``
|
|
8
|
+
is cheap and does not eagerly import JAX, Numba, or Optimistix. The public API
|
|
9
|
+
surface is declared in the sibling ``__init__.pyi`` stub for static type
|
|
10
|
+
checkers and IDE autocomplete.
|
|
11
|
+
|
|
12
|
+
Examples
|
|
13
|
+
--------
|
|
14
|
+
Import a model class directly from the package namespace::
|
|
15
|
+
|
|
16
|
+
from locpick import ChoiceModel, ChoiceTable
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
import contextlib
|
|
20
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
21
|
+
|
|
22
|
+
import lazy_loader as _lazy
|
|
23
|
+
|
|
24
|
+
__getattr__, __dir__, __all__ = _lazy.attach_stub(__name__, __file__)
|
|
25
|
+
|
|
26
|
+
with contextlib.suppress(PackageNotFoundError):
|
|
27
|
+
__version__ = version("locpick")
|
locpick/__init__.pyi
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"""Public API stub for locpick.
|
|
2
|
+
|
|
3
|
+
The top-level namespace exposes only user-facing symbols. Internal
|
|
4
|
+
subpackages (jax, kernels, sampling, solvers) remain importable directly
|
|
5
|
+
for advanced use but are not advertised as public API.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from . import data as data
|
|
9
|
+
from . import dgp as dgp
|
|
10
|
+
from . import models as models
|
|
11
|
+
from . import results as results
|
|
12
|
+
from . import spec as spec
|
|
13
|
+
from ._sampling.kernels import sample_alternatives as sample_alternatives
|
|
14
|
+
from .data import (
|
|
15
|
+
ChoiceArrays as ChoiceArrays,
|
|
16
|
+
)
|
|
17
|
+
from .data import (
|
|
18
|
+
ChoiceTable as ChoiceTable,
|
|
19
|
+
)
|
|
20
|
+
from .data import (
|
|
21
|
+
EstimationProblem as EstimationProblem,
|
|
22
|
+
)
|
|
23
|
+
from .data import (
|
|
24
|
+
distance_bands as distance_bands,
|
|
25
|
+
)
|
|
26
|
+
from .data import (
|
|
27
|
+
distance_matrix as distance_matrix,
|
|
28
|
+
)
|
|
29
|
+
from .data import (
|
|
30
|
+
euclidean_distance_matrix as euclidean_distance_matrix,
|
|
31
|
+
)
|
|
32
|
+
from .data import (
|
|
33
|
+
format_coefficient_table as format_coefficient_table,
|
|
34
|
+
)
|
|
35
|
+
from .data import (
|
|
36
|
+
format_fit_statistics as format_fit_statistics,
|
|
37
|
+
)
|
|
38
|
+
from .data import (
|
|
39
|
+
format_side_by_side as format_side_by_side,
|
|
40
|
+
)
|
|
41
|
+
from .data import (
|
|
42
|
+
great_circle_distance_matrix as great_circle_distance_matrix,
|
|
43
|
+
)
|
|
44
|
+
from .data import (
|
|
45
|
+
nearest_neighbors as nearest_neighbors,
|
|
46
|
+
)
|
|
47
|
+
from .data import (
|
|
48
|
+
pairwise_distance as pairwise_distance,
|
|
49
|
+
)
|
|
50
|
+
from .dgp import (
|
|
51
|
+
MixedMNLDataset as MixedMNLDataset,
|
|
52
|
+
)
|
|
53
|
+
from .dgp import (
|
|
54
|
+
MixedNestedMNLDataset as MixedNestedMNLDataset,
|
|
55
|
+
)
|
|
56
|
+
from .dgp import (
|
|
57
|
+
MNLDataset as MNLDataset,
|
|
58
|
+
)
|
|
59
|
+
from .dgp import (
|
|
60
|
+
MNSCLDataset as MNSCLDataset,
|
|
61
|
+
)
|
|
62
|
+
from .dgp import (
|
|
63
|
+
MSCLDataset as MSCLDataset,
|
|
64
|
+
)
|
|
65
|
+
from .dgp import (
|
|
66
|
+
NestedMNLDataset as NestedMNLDataset,
|
|
67
|
+
)
|
|
68
|
+
from .dgp import (
|
|
69
|
+
NestedSCLDataset as NestedSCLDataset,
|
|
70
|
+
)
|
|
71
|
+
from .dgp import (
|
|
72
|
+
SARMNLDataset as SARMNLDataset,
|
|
73
|
+
)
|
|
74
|
+
from .dgp import (
|
|
75
|
+
SCLDataset as SCLDataset,
|
|
76
|
+
)
|
|
77
|
+
from .dgp import (
|
|
78
|
+
simulate_mixed_logit as simulate_mixed_logit,
|
|
79
|
+
)
|
|
80
|
+
from .dgp import (
|
|
81
|
+
simulate_mixed_nested_logit as simulate_mixed_nested_logit,
|
|
82
|
+
)
|
|
83
|
+
from .dgp import (
|
|
84
|
+
simulate_mnl as simulate_mnl,
|
|
85
|
+
)
|
|
86
|
+
from .dgp import (
|
|
87
|
+
simulate_mnscl as simulate_mnscl,
|
|
88
|
+
)
|
|
89
|
+
from .dgp import (
|
|
90
|
+
simulate_mscl as simulate_mscl,
|
|
91
|
+
)
|
|
92
|
+
from .dgp import (
|
|
93
|
+
simulate_nested_logit as simulate_nested_logit,
|
|
94
|
+
)
|
|
95
|
+
from .dgp import (
|
|
96
|
+
simulate_nested_scl as simulate_nested_scl,
|
|
97
|
+
)
|
|
98
|
+
from .dgp import (
|
|
99
|
+
simulate_sar_mnl as simulate_sar_mnl,
|
|
100
|
+
)
|
|
101
|
+
from .dgp import (
|
|
102
|
+
simulate_scl as simulate_scl,
|
|
103
|
+
)
|
|
104
|
+
from .models import (
|
|
105
|
+
ChoiceModel as ChoiceModel,
|
|
106
|
+
)
|
|
107
|
+
from .models import (
|
|
108
|
+
NestingTree as NestingTree,
|
|
109
|
+
)
|
|
110
|
+
from .models import (
|
|
111
|
+
NestSpec as NestSpec,
|
|
112
|
+
)
|
|
113
|
+
from .models import (
|
|
114
|
+
ParamDistribution as ParamDistribution,
|
|
115
|
+
)
|
|
116
|
+
from .models import (
|
|
117
|
+
naturalize_nest_params as naturalize_nest_params,
|
|
118
|
+
)
|
|
119
|
+
from .results import (
|
|
120
|
+
FitResult as FitResult,
|
|
121
|
+
)
|
|
122
|
+
from .results import (
|
|
123
|
+
HausmanTest as HausmanTest,
|
|
124
|
+
)
|
|
125
|
+
from .results import (
|
|
126
|
+
LikelihoodRatioTest as LikelihoodRatioTest,
|
|
127
|
+
)
|
|
128
|
+
from .results import (
|
|
129
|
+
WaldTest as WaldTest,
|
|
130
|
+
)
|
|
131
|
+
from .results import (
|
|
132
|
+
hausman_test as hausman_test,
|
|
133
|
+
)
|
|
134
|
+
from .results import (
|
|
135
|
+
lr_test as lr_test,
|
|
136
|
+
)
|
|
137
|
+
from .results import (
|
|
138
|
+
wald_test as wald_test,
|
|
139
|
+
)
|
|
140
|
+
from .spec import (
|
|
141
|
+
InteractionTerm as InteractionTerm,
|
|
142
|
+
)
|
|
143
|
+
from .spec import (
|
|
144
|
+
ModelSpec as ModelSpec,
|
|
145
|
+
)
|
|
146
|
+
from .spec import (
|
|
147
|
+
ScopedTerm as ScopedTerm,
|
|
148
|
+
)
|
|
149
|
+
from .spec import (
|
|
150
|
+
interaction as interaction,
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
__version__: str
|
locpick/_jax/__init__.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""JAX-accelerated backend for locpick choice models.
|
|
2
|
+
|
|
3
|
+
This package provides:
|
|
4
|
+
|
|
5
|
+
- :class:`ChoiceDataJAX` — JAX-ready estimation data container
|
|
6
|
+
- :class:`EdgeDataJAX` — JAX-ready spatial edge structure
|
|
7
|
+
- :class:`Objective` — unified optimization objective (LL + gradient + Hessian)
|
|
8
|
+
- :class:`ParamTransform` — parameter transformation utilities
|
|
9
|
+
- Pure JAX probability kernels (:func:`mnl_log_probs`, :func:`mnl_probs`, :func:`scl_log_probs`,
|
|
10
|
+
:func:`nested_log_probs`, :func:`mixed_logit_ll`)
|
|
11
|
+
- Objective builders (:func:`build_mnl_objective`, :func:`build_scl_objective`,
|
|
12
|
+
:func:`build_mscl_objective`, :func:`build_nested_objective`,
|
|
13
|
+
:func:`build_mixed_logit_objective`)
|
|
14
|
+
|
|
15
|
+
The kernels are standalone, testable, composable JAX functions that can be
|
|
16
|
+
JIT-compiled and vmap'd independently of any model class.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from .builders import (
|
|
20
|
+
build_mixed_logit_objective,
|
|
21
|
+
build_mnl_objective,
|
|
22
|
+
build_mscl_objective,
|
|
23
|
+
build_nested_objective,
|
|
24
|
+
build_scl_objective,
|
|
25
|
+
)
|
|
26
|
+
from .data import ChoiceDataJAX, EdgeDataJAX
|
|
27
|
+
from .kernels import (
|
|
28
|
+
mixed_logit_ll,
|
|
29
|
+
mnl_log_probs,
|
|
30
|
+
mnl_probs,
|
|
31
|
+
nested_log_probs,
|
|
32
|
+
scl_log_probs,
|
|
33
|
+
)
|
|
34
|
+
from .objective import Objective
|
|
35
|
+
from .transforms import Identity, ParamTransform, Sigmoid, SoftPlus
|
|
36
|
+
|
|
37
|
+
__all__ = [
|
|
38
|
+
"ChoiceDataJAX",
|
|
39
|
+
"EdgeDataJAX",
|
|
40
|
+
"Objective",
|
|
41
|
+
"ParamTransform",
|
|
42
|
+
"Sigmoid",
|
|
43
|
+
"SoftPlus",
|
|
44
|
+
"Identity",
|
|
45
|
+
"mnl_log_probs",
|
|
46
|
+
"mnl_probs",
|
|
47
|
+
"scl_log_probs",
|
|
48
|
+
"nested_log_probs",
|
|
49
|
+
"mixed_logit_ll",
|
|
50
|
+
"build_mnl_objective",
|
|
51
|
+
"build_scl_objective",
|
|
52
|
+
"build_mscl_objective",
|
|
53
|
+
"build_nested_objective",
|
|
54
|
+
"build_mixed_logit_objective",
|
|
55
|
+
]
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from . import builders as builders
|
|
2
|
+
from . import data as data
|
|
3
|
+
from . import kernels as kernels
|
|
4
|
+
from . import objective as objective
|
|
5
|
+
from . import transforms as transforms
|
|
6
|
+
from .builders import (
|
|
7
|
+
build_mixed_logit_objective as build_mixed_logit_objective,
|
|
8
|
+
)
|
|
9
|
+
from .builders import (
|
|
10
|
+
build_mnl_objective as build_mnl_objective,
|
|
11
|
+
)
|
|
12
|
+
from .builders import (
|
|
13
|
+
build_mscl_objective as build_mscl_objective,
|
|
14
|
+
)
|
|
15
|
+
from .builders import (
|
|
16
|
+
build_nested_objective as build_nested_objective,
|
|
17
|
+
)
|
|
18
|
+
from .builders import (
|
|
19
|
+
build_scl_objective as build_scl_objective,
|
|
20
|
+
)
|
|
21
|
+
from .data import (
|
|
22
|
+
ChoiceDataJAX as ChoiceDataJAX,
|
|
23
|
+
)
|
|
24
|
+
from .data import (
|
|
25
|
+
EdgeDataJAX as EdgeDataJAX,
|
|
26
|
+
)
|
|
27
|
+
from .kernels import (
|
|
28
|
+
compute_ll as compute_ll,
|
|
29
|
+
)
|
|
30
|
+
from .kernels import (
|
|
31
|
+
compute_utilities as compute_utilities,
|
|
32
|
+
)
|
|
33
|
+
from .kernels import (
|
|
34
|
+
mixed_logit_ll as mixed_logit_ll,
|
|
35
|
+
)
|
|
36
|
+
from .kernels import (
|
|
37
|
+
mnl_log_probs as mnl_log_probs,
|
|
38
|
+
)
|
|
39
|
+
from .kernels import (
|
|
40
|
+
mnl_probs as mnl_probs,
|
|
41
|
+
)
|
|
42
|
+
from .kernels import (
|
|
43
|
+
nested_log_probs as nested_log_probs,
|
|
44
|
+
)
|
|
45
|
+
from .kernels import (
|
|
46
|
+
scl_log_probs as scl_log_probs,
|
|
47
|
+
)
|
|
48
|
+
from .objective import (
|
|
49
|
+
Objective as Objective,
|
|
50
|
+
)
|
|
51
|
+
from .transforms import (
|
|
52
|
+
Identity as Identity,
|
|
53
|
+
)
|
|
54
|
+
from .transforms import (
|
|
55
|
+
ParamTransform as ParamTransform,
|
|
56
|
+
)
|
|
57
|
+
from .transforms import (
|
|
58
|
+
Sigmoid as Sigmoid,
|
|
59
|
+
)
|
|
60
|
+
from .transforms import (
|
|
61
|
+
SoftPlus as SoftPlus,
|
|
62
|
+
)
|