-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy path__main__.py
98 lines (74 loc) · 2.93 KB
/
__main__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import os
import click
import fastgwr
@click.group()
@click.version_option("0.2.9")
def main():
pass
@main.command()
@click.option("-np", default=4, required=True)
@click.option("-data", required=True)
@click.option("-out", default="fastgwr_rslt.csv", required=False)
@click.option("-adaptive/-fixed" ,default=True, required=True)
@click.option("-bw", required=False)
@click.option("-minbw", required=False)
@click.option("-mgwr", default=False, required=False, is_flag=True)
@click.option("-chunks", required=False)
@click.option("-estonly", default=False, is_flag=True)
def run(np, data, out, adaptive, bw, minbw, mgwr, chunks, estonly):
"""
Fast(M)GWR
-np: number of processors to use. (default: 4)
-data: input data matrix containing y and X. Can be URL:
e.g. https://raw.github.com/Ziqi-Li/FastGWR/master/Zillow-test-dataset/zillow_1k.csv
-out: output GWR results (default: "fastgwr_rslt.csv").
-adaptive/-fixed: using an adaptive bisquare kernel (default) or a fixed gaussian kernel.
-bw: using a pre-specified bandwidth to fit GWR.
-minbw: lower bound in the golden section search in GWR.
-mgwr: fitting an MGWR model.
-chunks: number of chunks for MGWR computation (default: 1).
Increase the number if run out of memory but should keep it as low as possible.
-estonly: output the parameter estimation only for MGWR, no standard errors of the estimates
and model diagnostics. Ideal for quick model checking (default: False).
"""
mpi_path = os.path.dirname(fastgwr.__file__) + '/fastgwr_mpi.py'
command = 'mpiexec ' + ' -np ' + str(np) + ' python ' + mpi_path + ' -data ' + data + ' -out ' + out
command += ' -c '
if mgwr:
command += ' -mgwr '
if adaptive:
command += ' -a '
else:
command += ' -f '
if bw:
command += (' -bw ' + bw)
if minbw:
command += (' -minbw ' + minbw)
if chunks:
command += (' -chunks ' + chunks)
if estonly:
command += (' -estonly ')
os.system(command)
pass
@main.command()
def testgwr():
"""
Testing GWR with zillow data
"""
print("Testing GWR with zillow data:")
mpi_path = os.path.dirname(fastgwr.__file__) + '/fastgwr_mpi.py'
command = "mpiexec -np 2 python " + mpi_path + " -data https://raw.github.com/Ziqi-Li/FastGWR/master/Zillow-test-dataset/zillow_1k.csv -c"
os.system(command)
pass
@main.command()
def testmgwr():
"""
Testing MGWR with zillow data
"""
print("Testing MGWR with zillow data:")
mpi_path = os.path.dirname(fastgwr.__file__) + '/fastgwr_mpi.py'
command = "mpiexec -np 2 python " + mpi_path + " -data https://raw.github.com/Ziqi-Li/FastGWR/master/Zillow-test-dataset/zillow_1k.csv -mgwr -c"
os.system(command)
pass
if __name__ == '__main__':
main()