簡體   English   中英

Python 中的高錯誤機器學習回歸器算法 - XGBOOST 回歸器

[英]High error machine learning regressor algorithm in Python - XGBOOST Regressor

我有一個 dataframe 和來自佛羅里達的真實 state 數據,它包括單間公寓和建築物數據:

在此處輸入圖像描述

'TRUE_SITE_CITY': The city where the building is. variable: Miami, Aventura...;
'CONDO_FLAG': If it is a condominium or not, variable: yes/no;
'BEDROOM_COUNT': Number of total bethrooms, variable: integuer,
'BUILDING_actual_AREA': The area of the entire building, or apartment in the case that there are only one apartment or house. variable: integuer;
'FLOOR_COUNT': Number of the floors that the building has;
'DOR_CODE_CUR': the type of the building. Variable: categorical;
'UNIT_COUNT': Number of apartments or houses in the building. Variable: integuer;
'YEAR_BUILT': Year that the building or house or apartment was build: Variable: categorical;
'public_transport_min_distance': I have calculated the nearest stations of the public transport;
'Price': The variable that I want to predict.

我進行了探索性數據分析,我刪除了一些具有 null 值的數據和一些不正確的數據。 我也刪除了帶有異常值的值。

價格列(目標列)的基本統計:

在此處輸入圖像描述

我檢查了分類特征,每個特征都有足夠的變量將它們保存在 model 中。

我已經做了一個管道來為分類值制作一個熱編碼器,並為數值制作一個標准標准化。 在其中我包含了 XGBOOST 回歸:

from xgboost import XGBRegressor
from sklearn.model_selection import cross_val_score
from sklearn.model_selection import cross_validate
from sklearn import metrics
from sklearn import preprocessing, feature_extraction
from sklearn.pipeline import Pipeline
from sklearn import preprocessing, feature_extraction
from sklearn.pipeline import make_pipeline, make_union
from mlxtend.feature_selection import ColumnSelector
from sklearn.preprocessing import StandardScaler
from category_encoders import OneHotEncoder

x_numeric = df_x[['BEDROOM_COUNT','BATHROOM_COUNT',
       'HALF_BATHROOM_COUNT', 'FLOOR_COUNT','UNIT_COUNT','public_transport_min_distance','BUILDING_actual_AREA']]

x_categorical = df_x[['TRUE_SITE_CITY','CONDO_FLAG','YEAR_BUILT']]

categorical_col = x_categorical.columns

numeric_col = x_numeric.columns

estimator_pipeline = Pipeline([
    ('procesador', procesing_pipeline),
    ('estimador', estimator)
])

score2 = cross_validate(estimator_pipeline, X= df_x, y= df_y, scoring=scoring,return_train_score=False, cv=5,n_jobs=2)

但我得到了一個很高的錯誤。 價格的平均值幾乎是 200.000,我得到的錯誤是:

在此處輸入圖像描述

我已經使用 RFE 完成了特征選擇,但我也得到了一個很高的錯誤。

我也運行它做 RandomizedSearchCV

from sklearn.model_selection import RandomizedSearchCV

params = {"estimator__learning_rate"    : [0.05, 0.10, 0.15, 0.20, 0.25, 0.30 ] ,
 "estimator__max_depth"        : [ 3, 4, 5, 6, 8, 10, 12, 15],
 "estimator__min_child_weight" : [ 1, 3, 5, 7 ],
 "estimator__gamma"            : [ 0.0, 0.1, 0.2 , 0.3, 0.4 ],
 "estimator__colsample_bytree" : [ 0.3, 0.4, 0.5 , 0.7 ] }

random_search = RandomizedSearchCV(
    estimator=estimator_pipeline, 
    param_distributions=params, cv=5, refit=True,
    scoring="neg_mean_squared_error", n_jobs= 3,
    return_train_score=True,
    n_iter=50)

但我獲得了類似的錯誤值。

我能做什么?

我這邊的一些評論/建議。 希望它會幫助你。

  1. 不要將 YEAR_BUILT 變量用作分類變量,而是將其用作數值變量,您還可以將此變量轉換為描述建築物/公寓年齡的新變量,然后您可以嘗試不同的轉換,
  2. 您可以嘗試通過添加不同的變量來增加自變量的數量,這些變量是當前變量的轉換,例如使用平方值
  3. 一般來說,考慮到您只有 9 個自變量和大型數據集,我將專注於創建新的潛在變量
  4. 使用基於決策樹方法的算法,您不必對數值變量執行標准化
  5. 使用不同的提升算法,您應該專注於基礎估計器(淺決策樹)
  6. 嘗試不同的算法(例如簡單的決策樹或隨機森林)來比較結果

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM