metacountregressor 0.1.34__py3-none-any.whl → 0.1.36__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.
- metacountregressor/main.py +11 -11
- metacountregressor/metaheuristics.py +25 -17
- metacountregressor/pareto_file.py +22 -10
- metacountregressor/set_data.csv +3780 -3780
- metacountregressor/solution.py +53 -69
- metacountregressor-0.1.36.dist-info/METADATA +543 -0
- {metacountregressor-0.1.34.dist-info → metacountregressor-0.1.36.dist-info}/RECORD +8 -8
- metacountregressor-0.1.34.dist-info/METADATA +0 -104
- {metacountregressor-0.1.34.dist-info → metacountregressor-0.1.36.dist-info}/WHEEL +0 -0
@@ -1,104 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: metacountregressor
|
3
|
-
Version: 0.1.34
|
4
|
-
Summary: A python package for count regression of rare events assisted by metaheuristics
|
5
|
-
Author: zahern
|
6
|
-
Author-email: zeke.ahern@hdr.qut.edu.au
|
7
|
-
Requires-Python: >=3.10,<3.11
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
9
|
-
Classifier: Programming Language :: Python :: 3.10
|
10
|
-
Requires-Dist: latextable (>=1.0.0,<2.0.0)
|
11
|
-
Requires-Dist: matplotlib (>=3.7.1,<4.0.0)
|
12
|
-
Requires-Dist: numpy (>=1.24.3,<2.0.0)
|
13
|
-
Requires-Dist: pandas (>=2.0.2,<3.0.0)
|
14
|
-
Requires-Dist: psutil (>=5.9.5,<6.0.0)
|
15
|
-
Requires-Dist: scikit-learn (>=1.2.2,<2.0.0)
|
16
|
-
Requires-Dist: scipy (>=1.10.1,<2.0.0)
|
17
|
-
Requires-Dist: statsmodels (>=0.14.0,<0.15.0)
|
18
|
-
Requires-Dist: tabulate (>=0.9.0,<0.10.0)
|
19
|
-
Description-Content-Type: text/markdown
|
20
|
-
|
21
|
-
##### The Below code demonstrates how to set up automatic optimization assisted by the harmony search algorithm. Referencs to the Differential Evolution and Simulated Annealing has been mentioned (change accordingly)
|
22
|
-
|
23
|
-
|
24
|
-
```python
|
25
|
-
import pandas as pd
|
26
|
-
import numpy as np
|
27
|
-
|
28
|
-
from metacountregressor.solution import ObjectiveFunction
|
29
|
-
from metacountregressor.metaheuristics import (harmony_search_non_mp,
|
30
|
-
differential_evolution_non_mp,
|
31
|
-
simulated_annealing_non_mp)
|
32
|
-
|
33
|
-
```
|
34
|
-
|
35
|
-
#### Basic setup. Read in data, and select optimization algorithm
|
36
|
-
|
37
|
-
|
38
|
-
```python
|
39
|
-
|
40
|
-
# Read data from CSV file
|
41
|
-
df = pd.read_csv(
|
42
|
-
"https://raw.githubusercontent.com/zahern/data/main/Ex-16-3.csv")
|
43
|
-
X = df
|
44
|
-
y = df['FREQ'] # Frequency of crashes
|
45
|
-
X['Offset'] = np.log(df['AADT']) # Explicitley define how to offset the data, no offset otherwise
|
46
|
-
# Drop Y, selected offset term and ID as there are no panels
|
47
|
-
X = df.drop(columns=['FREQ', 'ID', 'AADT'])
|
48
|
-
|
49
|
-
#some example argument, these are defualt so the following line is just for claritity
|
50
|
-
arguments = {'algorithm': 'hs', 'test_percentage': 0.2, 'test_complexity': 6, 'instance_number':1}
|
51
|
-
# Fit the model with metacountregressor
|
52
|
-
obj_fun = ObjectiveFunction(X, y, **arguments)
|
53
|
-
#replace with other metaheuristics if desired
|
54
|
-
results = harmony_search_non_mp(obj_fun)
|
55
|
-
```
|
56
|
-
|
57
|
-
### Change the arguments.
|
58
|
-
#### Reduce down the list sizes where nescessary
|
59
|
-
|
60
|
-
|
61
|
-
```python
|
62
|
-
#Solution Arguments
|
63
|
-
arguments = {
|
64
|
-
'algorithm': 'hs',
|
65
|
-
'test_percentage': 0.2,
|
66
|
-
'test_complexity': 6, #or list based [0, 1, 2, 6]
|
67
|
-
'instance_number': 'name',
|
68
|
-
'is_multi': 1,
|
69
|
-
'distribution': ['Normal', 'LnNormal', 'Triangular', 'Unifrom', 'Gamma', 'Lindley'],
|
70
|
-
'Model': [0,1,2], # or equivalently ['POS', 'NB', 'GP']
|
71
|
-
'transformations': ['no', 'sqrt', 'archsinh', 'asfactor'],
|
72
|
-
}
|
73
|
-
obj_fun = ObjectiveFunction(X, y, **arguments)
|
74
|
-
results = harmony_search_non_mp(obj_fun)
|
75
|
-
```
|
76
|
-
|
77
|
-
### Initial Solution Configurement
|
78
|
-
|
79
|
-
|
80
|
-
```python
|
81
|
-
#Model Decisions, Specify for Intial Optimization
|
82
|
-
manual_fit_spec = {
|
83
|
-
'fixed_terms': ['SINGLE', 'LENGTH'],
|
84
|
-
'rdm_terms': ['AADT:normal'],
|
85
|
-
'rdm_cor_terms': ['GRADEBR:uniform', 'CURVES:triangular'],
|
86
|
-
'grouped_terms': [],
|
87
|
-
'hetro_in_means': ['ACCESS:normal', 'MINRAD:normal'],
|
88
|
-
'transformations': ['no', 'no', 'log', 'no', 'no', 'no', 'no'],
|
89
|
-
'dispersion': 1
|
90
|
-
}
|
91
|
-
|
92
|
-
#Search Arguments
|
93
|
-
arguments = {
|
94
|
-
'algorithm': 'hs',
|
95
|
-
'test_percentage': 0.2,
|
96
|
-
'test_complexity': 6,
|
97
|
-
'instance_number': 'name',
|
98
|
-
'Manual_Fit': manual_fit_spec
|
99
|
-
}
|
100
|
-
obj_fun = ObjectiveFunction(X, y, **arguments)
|
101
|
-
```
|
102
|
-
|
103
|
-
|
104
|
-
|
File without changes
|