sklearn.linear_model.GammaRegressor?
class sklearn.linear_model.GammaRegressor(*, alpha=1.0, fit_intercept=True, max_iter=100, tol=0.0001, warm_start=False, verbose=0)
具有Gamma分布的廣義線性模型。
在用戶指南中閱讀更多內容。
參數 | 說明 |
---|---|
alpha | float, default=1 該常數乘以懲罰項,從而確定正則化強度。 alpha = 0 等同于未懲罰的GLM。在這種情況下,設計矩陣X 必須具有全列秩(無共線性)。 |
fit_intercept | bool, default=True 指定是否將常數(即,偏置或截距)添加到線性預測模型(X @ coef +截距)。 |
max_iter | int, default=100 求解器的最大迭代次數。 |
tol | float, default=1e-4 停止標準。對于lbfgs求解器,當 max{g_j,j = 1, ..., d} <= tol ,其中g_j 為目標函數的梯度(導數)的第j個分量,迭代將停止。 |
warm_start | bool, default=False 如果設置為 True ,重用前面調用的解決方案進行fit ,作為coef_ 和intercept_ 的初始化。 |
verbose | int, default=0 對于lbfgs求解器,請將verbose設置為代表詳細程度的任何正數。 |
屬性 | 說明 |
---|---|
coef_ | array of shape (n_features,) GLM中線性預測模型( X @ coef_ + intercept_ )的估計系數。 |
intercept_ | float 已添加到線性預測模型中的截距(又稱偏置)。 |
n_iter_ | int 求解器中使用的實際迭代數。 |
方法 | 說明 |
---|---|
fit (X, y[, sample_weight]) |
擬合廣義線性模型。 |
get_params ([deep]) |
獲取此估計器的參數。 |
predict (X) |
使用GLM與特征矩陣X進行預測。 |
score (X, y[, sample_weight]) |
計算D ^ 2,說明偏差百分比。 |
set_params (**params) |
設置此估計器的參數。 |
__init__(*, alpha=1.0, fit_intercept=True, max_iter=100, tol=0.0001, warm_start=False, verbose=0)
初始化self, 請參閱help(type(self))以獲得準確的說明。
fit(X, y, sample_weight=None)
[源碼]
擬合廣義線性模型。
參數 | 說明 |
---|---|
X | {array-like, sparse matrix} of shape (n_samples, n_features) 訓練數據。 |
y | array-like of shape (n_samples,) 目標值。 |
sample_weight | array-like of shape (n_samples,), default=None 樣本權重 |
返回值 | 說明 |
---|---|
self | returns an instance of self. |
get_params(deep=True)
[源碼]
獲取此估計器的參數。
參數 | 說明 |
---|---|
deep | bool, default=True 如果為True,則將返回此估算器和所包含子對象的參數。 |
返回值 | 說明 |
---|---|
params | mapping of string to any 參數名稱映射到其值。 |
predict(X)
[源碼]
使用GLM與特征矩陣X進行預測。
參數 | 說明 |
---|---|
X | {array-like, sparse matrix} of shape (n_samples, n_features) 樣本數據 |
返回值 | 說明 |
---|---|
y_pred | array of shape (n_samples,) 返回預測值。 |
score(X, y, sample_weight=None)
[源碼]
計算D ^ 2,說明偏差百分比。
D ^ 2是確定系數R ^ 2的推廣。R ^ 2使用平方誤差,D ^ 2使用偏差。請注意,對于family='normal'
,這兩個是相等的。
D ^ 2定義為, 是零偏差,即僅具有截距的模型的偏差,對應于 。均值由sample_weight取平均值。最佳可能得分為1.0,并且可能為負(因為該模型可能會更差)。
參數 | 說明 |
---|---|
X | {array-like, sparse matrix} of shape (n_samples, n_features) 測試樣本。 |
y | array-like of shape (n_samples,) 目標的真實值。 |
sample_weight | array-like of shape (n_samples,), default=None 樣本權重。 |
返回值 | 說明 |
---|---|
score | float 預測值與真實值的D^2。 |
set_params(**params)
[源碼]
設置此估計器的參數。
該方法適用于簡單的估計器以及嵌套對象(例如管道)。后者具有形式為 <component>__<parameter>
的參數,這樣就可以更新嵌套對象的每個組件。
參數 | 說明 |
---|---|
**params | dict 估計器參數。 |
返回值 | 說明 |
---|---|
self | object 估計器實例。 |