Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 37 additions & 46 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
import sys, os
import sphinx_bootstrap_theme


sys.path.insert(0, os.path.abspath('../../'))

#import your package to obtain the version info to display on the docs website
import mgwr


# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
Expand All @@ -32,17 +30,11 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [#'sphinx_gallery.gen_gallery',
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.viewcode',
'sphinxcontrib.bibtex',
'sphinx.ext.mathjax',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'numpydoc',
'matplotlib.sphinxext.plot_directive']

extensions = [ #'sphinx_gallery.gen_gallery',
'sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.viewcode',
'sphinxcontrib.bibtex', 'sphinx.ext.mathjax', 'sphinx.ext.doctest',
'sphinx.ext.intersphinx', 'numpydoc', 'matplotlib.sphinxext.plot_directive'
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand All @@ -66,8 +58,8 @@
# built documents.
#
# The full version.
version = mgwr.__version__ #should replace it with your PACKAGE_NAME
release = mgwr.__version__ #should replace it with your PACKAGE_NAME
version = mgwr.__version__ #should replace it with your PACKAGE_NAME
release = mgwr.__version__ #should replace it with your PACKAGE_NAME

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down Expand Up @@ -104,32 +96,35 @@
# (Optional) PySAL favicon
html_favicon = "_static/images/pysal_favicon.ico"


# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
html_theme_options = {

# Navigation bar title. (Default: ``project`` value)
'navbar_title': "mgwr", # string of your project name, for example, 'giddy'
'navbar_title':
"mgwr", # string of your project name, for example, 'giddy'

# Render the next and previous page links in navbar. (Default: true)
'navbar_sidebarrel': False,
'navbar_sidebarrel':
False,

# Render the current pages TOC in the navbar. (Default: true)
#'navbar_pagenav': True,
#'navbar_pagenav': False,

# No sidebar
'nosidebar': True,
'nosidebar':
True,

# Tab name for the current pages TOC. (Default: "Page")
#'navbar_pagenav_name': "Page",

# Global TOC depth for "site" navbar tab. (Default: 1)
# Switching to -1 shows all levels.
'globaltoc_depth': 2,
'globaltoc_depth':
2,

# Include hidden TOCs in Site navbar?
#
Expand All @@ -138,38 +133,41 @@
# will break.
#
# Values: "true" (default) or "false"
'globaltoc_includehidden': "true",
'globaltoc_includehidden':
"true",

# HTML navbar class (Default: "navbar") to attach to <div> element.
# For black navbar, do "navbar navbar-inverse"
#'navbar_class': "navbar navbar-inverse",

# Fix navigation bar to top of page?
# Values: "true" (default) or "false"
'navbar_fixed_top': "true",

'navbar_fixed_top':
"true",

# Location of link to source.
# Options are "nav" (default), "footer" or anything else to exclude.
'source_link_position': 'footer',
'source_link_position':
'footer',

# Bootswatch (http://bootswatch.com/) theme.
#
# Options are nothing (default) or the name of a valid theme
# such as "amelia" or "cosmo", "yeti", "flatly".
'bootswatch_theme': "yeti",
'bootswatch_theme':
"yeti",

# Choose Bootstrap version.
# Values: "3" (default) or "2" (in quotes)
'bootstrap_version': "3",
'bootstrap_version':
"3",

# Navigation bar menu
'navbar_links': [
("Installation", "installation"),
("API", "api"),
("References", "references"),
],

("Installation", "installation"),
("API", "api"),
("References", "references"),
],
}

# Add any paths that contain custom static files (such as style sheets) here,
Expand All @@ -184,8 +182,7 @@
# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'mgwr'+'doc'

htmlhelp_basename = 'mgwr' + 'doc'

# -- Options for LaTeX output ---------------------------------------------

Expand All @@ -211,33 +208,26 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'mgwr.tex', u'mgwr Documentation',
u'pysal developers', 'manual'),
(master_doc, 'mgwr.tex', u'mgwr Documentation', u'pysal developers',
'manual'),
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'mgwr', u'mgwr Documentation',
[author], 1)
]

man_pages = [(master_doc, 'mgwr', u'mgwr Documentation', [author], 1)]

# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'mgwr', u'mgwr Documentation',
author, 'mgwr', 'multiscale gwr',
'Miscellaneous'),
(master_doc, 'mgwr', u'mgwr Documentation', author, 'mgwr',
'multiscale gwr', 'Miscellaneous'),
]


# -----------------------------------------------------------------------------
# Autosummary
# -----------------------------------------------------------------------------
Expand All @@ -252,9 +242,10 @@
# display the source code for Plot directive
plot_include_source = True


def setup(app):
app.add_stylesheet("pysal-styles.css")


# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/3.6/': None}

2 changes: 1 addition & 1 deletion mgwr/__init__.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "2.0.2"
__version__ = "2.1.0"

from . import gwr
from . import sel_bw
Expand Down
28 changes: 17 additions & 11 deletions mgwr/diagnostics.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from scipy import linalg
from spglm.family import Gaussian, Poisson, Binomial


def get_AICc(gwr):
"""
Get AICc value
Expand All @@ -20,13 +21,15 @@ def get_AICc(gwr):
k = gwr.tr_S
#sigma2 = gwr.sigma2
if isinstance(gwr.family, Gaussian):
aicc = -2.0*gwr.llf + 2.0*n*(k + 1.0)/(n-k-2.0) #equivalent to below but
aicc = -2.0 * gwr.llf + 2.0 * n * (k + 1.0) / (
n - k - 2.0) #equivalent to below but
#can't control denominator of sigma without altering GLM familt code
#aicc = n*np.log(sigma2) + n*np.log(2.0*np.pi) + n*(n+k)/(n-k-2.0)
elif isinstance(gwr.family, (Poisson, Binomial)):
aicc = get_AIC(gwr) + 2.0 * k * (k+1.0) / (n - k - 1.0)
aicc = get_AIC(gwr) + 2.0 * k * (k + 1.0) / (n - k - 1.0)
return aicc


def get_AIC(gwr):
"""
Get AIC calue
Expand All @@ -36,16 +39,17 @@ def get_AIC(gwr):
GWGLM: AIC(G)=D(G) + 2K(G), where D and K denote the deviance and the effective
number of parameters in the model with bandwidth G, respectively.

"""
"""
k = gwr.tr_S
#deviance = -2*log-likelihood
y = gwr.y
mu = gwr.mu
if isinstance(gwr.family, Gaussian):
aic = -2.0 * gwr.llf + 2.0 * (k+1)
aic = -2.0 * gwr.llf + 2.0 * (k + 1)
elif isinstance(gwr.family, (Poisson, Binomial)):
aic = np.sum(gwr.family.resid_dev(y, mu)**2) + 2.0 * k
return aic
return aic


def get_BIC(gwr):
"""
Expand All @@ -57,16 +61,17 @@ def get_BIC(gwr):
GWGLM: BIC = dev + tr_S * log(n)

"""
n = gwr.n # (scalar) number of observations
k = gwr.tr_S
n = gwr.n # (scalar) number of observations
k = gwr.tr_S
y = gwr.y
mu = gwr.mu
if isinstance(gwr.family, Gaussian):
bic = -2.0 * gwr.llf + (k+1) * np.log(n)
bic = -2.0 * gwr.llf + (k + 1) * np.log(n)
elif isinstance(gwr.family, (Poisson, Binomial)):
bic = np.sum(gwr.family.resid_dev(y, mu)**2) + k * np.log(n)
return bic


def get_CV(gwr):
"""
Get CV value
Expand All @@ -79,11 +84,12 @@ def get_CV(gwr):
Modification: sum of residual squared is divided by n according to GWR4 results

"""
aa = gwr.resid_response.reshape((-1,1))/(1.0-gwr.influ)
cv = np.sum(aa**2)/gwr.n
aa = gwr.resid_response.reshape((-1, 1)) / (1.0 - gwr.influ)
cv = np.sum(aa**2) / gwr.n
return cv


def corr(cov):
invsd = np.diag(1/np.sqrt(np.diag(cov)))
invsd = np.diag(1 / np.sqrt(np.diag(cov)))
cors = np.dot(np.dot(invsd, cov), invsd)
return cors
Loading