python廣義線性模型是什么

這篇文章主要講解了“python廣義線性模型是什么”,文中的講解內(nèi)容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“python廣義線性模型是什么”吧!

目前創(chuàng)新互聯(lián)公司已為千余家的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)絡(luò)空間、網(wǎng)站運營、企業(yè)網(wǎng)站設(shè)計、澠池網(wǎng)站維護等服務(wù),公司將堅持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。

廣義線性模型:

廣義線性模型[generalize linear model]線性模型的擴展,通過聯(lián)結(jié)函數(shù)建立響應(yīng)變量的數(shù)學期望值與線性組合的預(yù)測變量之間的關(guān)系。其特點是不強行改變數(shù)據(jù)的自然度量,數(shù)據(jù)可以具有非線性和非恒定方差結(jié)構(gòu)。是線性模型在研究響應(yīng)值的非正態(tài)分布以及非線性模型簡潔直接的線性轉(zhuǎn)化時的一種發(fā)展

import matplotlib.pyplot as pltimport numpy as npfrom sklearn import datasets, linear_modelfrom sklearn.metrics import mean_squared_error, r2_score
# Load the diabetes datasetdiabetes = datasets.load_diabetes()

# Use only one featurediabetes_X = diabetes.data[:, np.newaxis, 2]
# Split the data into training/testing setsdiabetes_X_train = diabetes_X[:-20]diabetes_X_test = diabetes_X[-20:]
# Split the targets into training/testing setsdiabetes_y_train = diabetes.target[:-20]diabetes_y_test = diabetes.target[-20:]
# Create linear regression objectregr = linear_model.LinearRegression()
# Train the model using the training setsregr.fit(diabetes_X_train, diabetes_y_train)
# Make predictions using the testing setdiabetes_y_pred = regr.predict(diabetes_X_test)
# The coefficientsprint('Coefficients: \n', regr.coef_)# The mean squared errorprint("Mean squared error: %.2f"      % mean_squared_error(diabetes_y_test, diabetes_y_pred))# Explained variance score: 1 is perfect predictionprint('Variance score: %.2f' % r2_score(diabetes_y_test, diabetes_y_pred))
# Plot outputsplt.scatter(diabetes_X_test, diabetes_y_test,  color='black')plt.plot(diabetes_X_test, diabetes_y_pred, color='blue', linewidth=3)
plt.xticks(())plt.yticks(())
plt.show()

感謝各位的閱讀,以上就是“python廣義線性模型是什么”的內(nèi)容了,經(jīng)過本文的學習后,相信大家對python廣義線性模型是什么這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識點的文章,歡迎關(guān)注!

文章名稱:python廣義線性模型是什么
網(wǎng)站URL:http://muchs.cn/article8/jpjsip.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站面包屑導(dǎo)航、定制網(wǎng)站、動態(tài)網(wǎng)站、移動網(wǎng)站建設(shè)、云服務(wù)器

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運營