Code Monkey home page Code Monkey logo

Comments (3)

ljwolf avatar ljwolf commented on June 20, 2024

Could you provide a benchmark against the existing implementation & against the scipy stuff? I think we should probably (in future) default to the scipy implementation where we can.

from gwr.

ljwolf avatar ljwolf commented on June 20, 2024

If you use http://mortada.net/easily-profile-python-code-in-jupyter.html it should be real simple to see the savings. Hope that's alright.

from gwr.

Ziqi-Li avatar Ziqi-Li commented on June 20, 2024

Thanks @ljwolf for pointing out the profiling tool

Before:

Timer unit: 1e-06 s

Total time: 19.7563 s
File: /Users/Ziqi/Desktop/developer/gwr/gwr/sel_bw.py
Function: _bw at line 281

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   281                                               def _bw(self):
   282         1            5      5.0      0.0          gwr_func = lambda bw: self._fast_fit(bw,constant=self.constant)[self.criterion]
   283         1            1      1.0      0.0          if self.search == 'golden_section':
   284         1          989    989.0      0.0              a,c = self._init_section(self.X_glob, self.X_loc, self.coords,self.constant)
   285         1            1      1.0      0.0              delta = 0.38197 #1 - (np.sqrt(5.0)-1.0)/2.0
   286         1     19755331 19755331.0    100.0              self.bw = golden_section(a, c, delta, gwr_func, self.tol,self.max_iter, self.int_score)
   287                                                   elif self.search == 'interval':
   288                                                       self.bw = equal_interval(self.bw_min, self.bw_max, self.interval,gwr_func, self.int_score)
   289                                                   else:
   290                                                       raise TypeError('Unsupported computational search method ', search)

After:

Timer unit: 1e-06 s

Total time: 9.73623 s
File: /Users/Ziqi/Desktop/developer/gwr/gwr/sel_bw.py
Function: _bw at line 281

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   281                                               def _bw(self):
   282         1           13     13.0      0.0          gwr_func = lambda bw: self._fast_fit(bw,constant=self.constant)[self.criterion]
   283         1            1      1.0      0.0          if self.search == 'golden_section':
   284         1          938    938.0      0.0              a,c = self._init_section(self.X_glob, self.X_loc, self.coords,self.constant)
   285         1            1      1.0      0.0              delta = 0.38197 #1 - (np.sqrt(5.0)-1.0)/2.0
   286         1      9735279 9735279.0    100.0              self.bw = golden_section(a, c, delta, gwr_func, self.tol,self.max_iter, self.int_score)
   287                                                   elif self.search == 'interval':
   288                                                       self.bw = equal_interval(self.bw_min, self.bw_max, self.interval,gwr_func, self.int_score)
   289                                                   else:
   290                                                       raise TypeError('Unsupported computational search method ', search)

19755331.0/9735279.0 ~ 2.03x speed up from golden_section()

from gwr.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.