機械翻訳について

モデルのトレーニング

空間エラー・モデルでは、回帰方程式のエラー用語に空間ラグが導入されています。 残差に空間ラグを追加することによって、ネイバーのエラーが観察エラーに影響します。

次のコードでは、SpatialErrorRegressorのインスタンスを作成し、データを標準化するための前処理ステップがある空間パイプラインを使用してモデルをトレーニングします。

from oraclesai.regression import SpatialErrorRegressor
from oraclesai.pipeline import SpatialPipeline
from sklearn.preprocessing import StandardScaler
 
# Create the instance of SpatialErrorRegressor
spatial_error_model = SpatialErrorRegressor(spatial_weights_definition=weights_definition)
 
# Add the regressor to a spatial pipeline along with a pre-processing step
spatial_error_pipeline = SpatialPipeline([("scaler", StandardScaler()), ("spatial_error", spatial_error_model)])
 
# Train the Spatial Error model
spatial_error_pipeline.fit(X_train, "MEDIAN_INCOME")

レグレッサのsummaryプロパティには、モデルの様々な統計および推定パラメータが表示されます。 次のコードは、トレーニング済モデルを取得し、そのサマリーを出力します。

# Get the trained model
error_model_fit = spatial_error_pipeline.named_steps["spatial_error"]
 
# Print the summary of the trained model
print(error_model_fit.summary)
REGRESSION
----------
SUMMARY OF OUTPUT: MAXIMUM LIKELIHOOD SPATIAL ERROR (METHOD = FULL)
-------------------------------------------------------------------
Data set            :     unknown
Weights matrix      :     unknown
Dependent Variable  :     dep_var                Number of Observations:        2475
Mean dependent var  :  69640.3568                Number of Variables   :           5
S.D. dependent var  :  39961.9492                Degrees of Freedom    :        2470
Pseudo R-squared    :      0.6285
Sigma-square ML     :454661980.170                Log likelihood        :  -28246.730
S.E of regression   :   21322.804                Akaike info criterion :   56503.460
                                                 Schwarz criterion     :   56532.530

------------------------------------------------------------------------------------
            Variable     Coefficient       Std.Error     z-Statistic     Probability
------------------------------------------------------------------------------------
            CONSTANT    70782.1082416    1248.2789978      56.7037564       0.0000000
            MEAN_AGE    2575.5035983     588.8525955       4.3737662       0.0000122
MEAN_EDUCATION_LEVEL    11051.5768223    1050.1057765      10.5242511       0.0000000
         HOUSE_VALUE    19081.0829838     814.4699114      23.4276094       0.0000000
            INTERNET    7640.9119411     682.4557729      11.1962009       0.0000000
              lambda       0.6563181       0.0239453      27.4090149       0.0000000
------------------------------------------------------------------------------------
================================ END OF REPORT =====================================