Skip to content

Commit

Permalink
update fig
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziqi authored and Ziqi committed Mar 28, 2021
1 parent 3309f27 commit 1642c4b
Show file tree
Hide file tree
Showing 11 changed files with 51,112 additions and 36 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The `fastgwr` program is dependent on `mpi4py` package and a working MPI impleme
$ conda install mpi4py
```

By installing `mpi4py`, `conda` will also install an MPI implementation based on your computer system (OpenMPI for Mac/Linux; MPICH for Windows). Users may want to check whether the MPI implementation is successfully installed and is on your path by running the `mpiexec` command. Then the `fastgwr` program can be installed from PyPi:
By installing `mpi4py`, `conda` will also install an MPI implementation based on your computer system (OpenMPI for Mac/Linux; MPICH/MS-MPI for Windows). Users may want to check whether the MPI implementation is successfully installed and is on your path by running the `mpiexec` command. Then the `fastgwr` program can be installed from PyPi:

```bash
$ pip install fastgwr
Expand Down
22 changes: 11 additions & 11 deletions fastgwr/FastGWR.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,16 @@ def parse_gwr_args(self):
self.minbw = int(parser_arg.minbw)

if self.comm.rank == 0:
print("-"*60)
print("Starting FastGWR with",self.comm.size,"Processors")
print("-"*60,flush=True)
print("Starting FastGWR with",self.comm.size,"Processors",flush=True)
if self.fixed:
print("Spatial Kernel: Fixed Gaussian")
print("Spatial Kernel: Fixed Gaussian",flush=True)
else:
print("Spatial Kernel: Adaptive Bisquare")
print("Spatial Kernel: Adaptive Bisquare",flush=True)

print("Data Input Path:",self.fname)
print("Output Result Path:",self.fout)
print("Intercept:",self.constant)
print("Data Input Path:",self.fname,flush=True)
print("Output Result Path:",self.fout,flush=True)
print("Intercept:",self.constant,flush=True)


def read_file(self):
Expand Down Expand Up @@ -299,7 +299,7 @@ def mpi_gwr_fit(self, y, X, bw, final=False, mgwr=False):
if self.comm.rank ==0:
data = np.vstack(Betas_list)

print("Fitting GWR Using Bandwidth:",bw)
print("Fitting GWR Using Bandwidth:",bw,flush=True)

RSS = np.sum(data[:,1]**2)
TSS = np.sum((y - np.mean(y))**2)
Expand Down Expand Up @@ -344,7 +344,7 @@ def mpi_gwr_fit(self, y, X, bw, final=False, mgwr=False):
trS = sum(trS_list)
aicc = self.compute_aicc(RSS, trS)
if not mgwr:
print("BW, AICc",bw, aicc)
print("BW, AICc",bw, aicc,flush=True)
return aicc

return
Expand All @@ -366,8 +366,8 @@ def fit(self, y=None, X=None, init_mgwr=False, mgwr=False):
if self.comm.rank ==0:
self.set_search_range(init_mgwr=init_mgwr,mgwr=mgwr)
if not mgwr:
print("Optimal Bandwidth Searching...")
print("Range:",self.minbw,self.maxbw)
print("Optimal Bandwidth Searching...",flush=True)
print("Range:",self.minbw,self.maxbw,flush=True)
self.minbw = self.comm.bcast(self.minbw,root=0)
self.maxbw = self.comm.bcast(self.maxbw,root=0)

Expand Down
12 changes: 6 additions & 6 deletions fastgwr/FastMGWR.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ def backfitting(self):
"""

if self.comm.rank ==0:
print("MGWR Backfitting...")
print("Data are standardized")
print("MGWR Backfitting...",flush=True)
print("Data are standardized",flush=True)

#Initalization
betas,bw = self.fit(init_mgwr=True,mgwr=True)

self.bw_init = bw

if self.comm.rank ==0:
print("Initialization Done...")
print("Initialization Done...",flush=True)
XB = betas*self.X
err = self.y.reshape(-1) - np.sum(XB,axis=1)
bws = [None]*self.k
Expand Down Expand Up @@ -116,8 +116,8 @@ def backfitting(self):
XB = newXB

if self.comm.rank ==0:
print("Iter:",mgwr_iters,"SOC:","{:.2e}".format(score))
print("bws:",bws)
print("Iter:",mgwr_iters,"SOC:","{:.2e}".format(score),flush=True)
print("bws:",bws,flush=True)

if score < 1e-5:
break
Expand Down Expand Up @@ -205,7 +205,7 @@ def mgwr_fit(self,n_chunks=2):
if self.estonly:
return
if self.comm.rank ==0:
print("Computing Inference with",n_chunks,"Chunk(s)")
print("Computing Inference with",n_chunks,"Chunk(s)",flush=True)
self.n_chunks = self.comm.size * n_chunks
self.chunks = np.arange(self.comm.rank*n_chunks, (self.comm.rank+1)*n_chunks)

Expand Down
5 changes: 3 additions & 2 deletions fastgwr/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import fastgwr

@click.group()
@click.version_option("0.2.8")
@click.version_option("0.2.9")
def main():
pass

Expand Down Expand Up @@ -86,8 +86,9 @@ 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
Expand Down
Loading

0 comments on commit 1642c4b

Please sign in to comment.