pysal.model.mgwr.gwr.
GWR
(coords, y, X, bw, family=<pysal.model.spglm.family.Gaussian object>, offset=None, sigma2_v1=True, kernel='bisquare', fixed=False, constant=True, dmat=None, sorted_dmat=None, spherical=False)[源代码]¶地理加权回归。目前可以估计高斯模型、泊松模型和逻辑模型(基于GLM框架)。gwr对象准备模型输入。fit方法执行估计并返回gwresults对象。
参数: |
|
---|
实例
#基本模型校准
>>> import pysal.lib as ps
>>> from mgwr.gwr import GWR
>>> data = ps.io.open(ps.examples.get_path('GData_utm.csv'))
>>> coords = list(zip(data.by_col('X'), data.by_col('Y')))
>>> y = np.array(data.by_col('PctBach')).reshape((-1,1))
>>> rural = np.array(data.by_col('PctRural')).reshape((-1,1))
>>> pov = np.array(data.by_col('PctPov')).reshape((-1,1))
>>> african_amer = np.array(data.by_col('PctBlack')).reshape((-1,1))
>>> X = np.hstack([rural, pov, african_amer])
>>> model = GWR(coords, y, X, bw=90.000, fixed=False, kernel='bisquare')
>>> results = model.fit()
>>> print(results.params.shape)
(159, 4)
#在未完成的位置进行预测
>>> index = np.arange(len(y))
>>> test = index[-10:]
>>> X_test = X[test]
>>> coords_test = np.array(coords)[test]
>>> model = GWR(coords, y, X, bw=94, fixed=False, kernel='bisquare')
>>> results = model.predict(coords_test, X_test)
>>> print(results.params.shape)
(10, 4)
属性: |
|
---|
方法
fit \([iniu params,tol,maxu iter,solve,…]) |
使模型与特定的估计程序相匹配的方法。 |
predict \(点,p [,exog 刻度,exog 剩余,…]) |
预测非采样点因变量值的方法 |
df_model | |
df_resid |
__init__
(coords, y, X, bw, family=<pysal.model.spglm.family.Gaussian object>, offset=None, sigma2_v1=True, kernel='bisquare', fixed=False, constant=True, dmat=None, sorted_dmat=None, spherical=False)[源代码]¶初始化类
方法
__init__ \(坐标,Y ,X ,BW [,族,偏移量,…]) |
初始化类 |
df_model () |
|
df_resid () |
|
fit \([iniu params,tol,maxu iter,solve,…]) |
使模型与特定的估计程序相匹配的方法。 |
predict \(点,p [,exog 刻度,exog 剩余,…]) |
预测非采样点因变量值的方法 |
属性
mean_y |
|
std_y |