中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁(yè) > news >正文

想建立什么網(wǎng)站嗎關(guān)鍵詞調(diào)詞平臺(tái)哪個(gè)好

想建立什么網(wǎng)站嗎,關(guān)鍵詞調(diào)詞平臺(tái)哪個(gè)好,網(wǎng)站建好了怎么做,網(wǎng)站設(shè)計(jì)的提案機(jī)器學(xué)習(xí)之線性回歸算法預(yù)測(cè)數(shù)據(jù) 目錄 機(jī)器學(xué)習(xí)之線性回歸算法預(yù)測(cè)數(shù)據(jù)線性回歸算法概念理解算法導(dǎo)入線性回歸模型參數(shù)理解誤差項(xiàng)分析 LinearRegression理解參數(shù)理解返回值方法基本格式 預(yù)測(cè)一元線性回歸數(shù)據(jù)問(wèn)題及理解可視化數(shù)據(jù)理解數(shù)據(jù)預(yù)測(cè) 預(yù)測(cè)二元線性回歸數(shù)據(jù)問(wèn)題及理解數(shù)…

機(jī)器學(xué)習(xí)之線性回歸算法預(yù)測(cè)數(shù)據(jù)

目錄

  • 機(jī)器學(xué)習(xí)之線性回歸算法預(yù)測(cè)數(shù)據(jù)
    • 線性回歸算法
      • 概念
      • 理解
      • 算法導(dǎo)入
      • 線性回歸模型
      • 參數(shù)理解
      • 誤差項(xiàng)分析
    • LinearRegression理解
      • 參數(shù)理解
      • 返回值
      • 方法
      • 基本格式
    • 預(yù)測(cè)一元線性回歸數(shù)據(jù)
      • 問(wèn)題及理解
      • 可視化數(shù)據(jù)理解
      • 數(shù)據(jù)預(yù)測(cè)
    • 預(yù)測(cè)二元線性回歸數(shù)據(jù)
      • 問(wèn)題及理解
      • 數(shù)據(jù)測(cè)試
    • 預(yù)測(cè)多元線性回歸數(shù)據(jù)
      • 問(wèn)題及理解
      • 數(shù)據(jù)測(cè)試

線性回歸算法


概念

線性回歸線性回歸是利用數(shù)理統(tǒng)計(jì)中回歸分析, 來(lái)確定兩種或兩種以上變量間相互依賴的定量關(guān)系的一種統(tǒng)計(jì)分析方法。

理解

有n個(gè)特征數(shù)據(jù)與數(shù)據(jù)結(jié)果有關(guān),根據(jù)歷史數(shù)據(jù)訓(xùn)練出線性回歸模型,給定數(shù)據(jù),預(yù)測(cè)結(jié)果。自變量為特征數(shù)據(jù),因變量為數(shù)據(jù)結(jié)構(gòu)。

算法導(dǎo)入

from sklearn.linear_model import LinearRegression

線性回歸模型

  • 一元線性回歸
    公式:
    在這里插入圖片描述

  • 多元線性回歸
    公式:
    在這里插入圖片描述

參數(shù)理解

在這里插入圖片描述

x可以理解為特征數(shù)據(jù),y為要求的結(jié)果數(shù)據(jù),線性回歸只能求回歸值,只能是數(shù)字結(jié)果。

誤差項(xiàng)分析

  • 誤差項(xiàng)可以省略嗎?
    誤差項(xiàng)不可省略,誤差是必然產(chǎn)生的。并且由于產(chǎn)生了誤差項(xiàng),我們便可以基于誤差的特點(diǎn)來(lái)進(jìn)行對(duì)線性回歸的參數(shù)估計(jì)的。
  • 誤差項(xiàng)有什么特點(diǎn)?
    獨(dú)立同分布。
    每個(gè)樣本點(diǎn)都是獨(dú)立的,在同一個(gè)分布函數(shù)下。
    例:貸款,每個(gè)人與每個(gè)間是沒(méi)有聯(lián)系的,貸多少錢完全基于你的工資和其他情況是獨(dú)立的,同分布就是我的這套估計(jì)體系是我人民銀行的估機(jī)體系,也就是說(shuō)每個(gè)樣本點(diǎn)是在同一個(gè)分布函數(shù)下。

LinearRegression理解

查看LinearRegression參數(shù)定義

def __init__(self,*,fit_intercept=True,normalize="deprecated",copy_X=True,n_jobs=None,positive=False,)

參數(shù)理解

  • fit_intercept:是否有截距(是否過(guò)原點(diǎn))
  • normalize:是否歸一化(歸一化就是每個(gè)數(shù)據(jù)特征占比相同)
  • copy_X:是否復(fù)制x數(shù)據(jù)
  • n_jobs:任務(wù)個(gè)數(shù)占比CPU(-1代表所有)

一般不用設(shè)置,默認(rèn)就可。

返回值

  • intercept:截距(β0)

(l.intercept_[0],2)

  • coef:系數(shù)(也就是β)

(l.coef_[0][0],2),如果有多個(gè)系數(shù),更改第二個(gè)[0],為相應(yīng)順序,索引從0開始,第二個(gè)為(l.coef_[0][1],2),。

方法

  • fit(x,y):訓(xùn)練模型,x為特征數(shù)據(jù),y為結(jié)果
    score(x,y):擬合度,x,y為已知的數(shù)據(jù)及結(jié)果,計(jì)算fit()模型與數(shù)據(jù)的擬合度在[0,1]間,趨于1優(yōu),趨于0劣
  • predict([[]數(shù)據(jù)]):預(yù)測(cè)數(shù)據(jù)結(jié)果,括號(hào)內(nèi)為二維數(shù)組
  • corr():數(shù)據(jù)相關(guān)系數(shù)判斷,若特征數(shù)據(jù)與數(shù)據(jù)結(jié)果的相關(guān)系數(shù)的絕對(duì)值為r,則
    • r>=0.8,高度相關(guān)
    • 0.5<=r<0.8,中度相關(guān)
    • 0.3<=r<0.5,低度相關(guān)
    • r<0.3,相關(guān)度極弱,可以視為不相關(guān)

基本格式

**
l = LinearRegression()
x=特征數(shù)據(jù)
y=數(shù)據(jù)結(jié)果
l.fit(x,y)
result = l.predict(x1)**
先引用LinearRegression函數(shù),根據(jù)歷史特征數(shù)據(jù)和數(shù)據(jù)結(jié)果,訓(xùn)練fit()模型,然后預(yù)測(cè)x1的回歸結(jié)果result

預(yù)測(cè)一元線性回歸數(shù)據(jù)


問(wèn)題及理解

問(wèn)題:給廣告投入和銷售額數(shù)據(jù),預(yù)測(cè)其他廣告投入的銷售額

特征數(shù)據(jù):廣告投入
類別標(biāo)簽:銷售額
給定的數(shù)據(jù):
在這里插入圖片描述

可視化數(shù)據(jù)理解

代碼展示:

import pandas as pd
from matplotlib import pyplot as plt
from sklearn.linear_model import LinearRegressiondata = pd.read_csv('data.csv')
co = data.corr()plt.scatter(data.廣告投入,data.銷售額)
plt.show()

運(yùn)行結(jié)果:
在這里插入圖片描述

數(shù)據(jù)預(yù)測(cè)

代碼展示:

import pandas as pd
from matplotlib import pyplot as plt
from sklearn.linear_model import LinearRegressiondata = pd.read_csv('data.csv')
co = data.corr()plt.scatter(data.廣告投入,data.銷售額)
plt.show()l = LinearRegression()
# 特征標(biāo)簽
x = data[['廣告投入']]
# 回歸結(jié)果
y = data[['銷售額']]
# # 訓(xùn)練模型
l.fit(x,y)
# 擬合度
corr = data.corr()
re = l.predict(x)
sc = l.score(x,y)
# 截距
inte = round(l.intercept_[0],2)
# 系數(shù)
coef = round(l.coef_[0][0],2)
res = l.predict([[34]])
print(inte,coef)
print(f'一元線性回歸:y={inte}+{coef}*x')
print(f'工資:34,預(yù)測(cè):{res}')

運(yùn)行結(jié)果:
相關(guān)系數(shù)調(diào)試查看:在這里插入圖片描述
在這里插入圖片描述

預(yù)測(cè)二元線性回歸數(shù)據(jù)

問(wèn)題及理解

問(wèn)題:給體重、年齡和血壓數(shù)據(jù),預(yù)測(cè)其他體重、年齡的血壓

特征數(shù)據(jù):體重、年齡
類別標(biāo)簽:血壓
給定的數(shù)據(jù):

在這里插入圖片描述

數(shù)據(jù)測(cè)試

代碼展示:

import pandas as pd
from sklearn.linear_model import LinearRegression
data_2 = pd.read_csv('data2.csv', encoding='gbk')
# print(data_2)
co_2 = data_2.corr()
x_2 = data_2[['體重','年齡']]
y_2 = data_2[['血壓收縮']]
ll = LinearRegression()
ll.fit(x_2,y_2)
# 預(yù)測(cè)結(jié)果
re_2 = ll.predict(x_2)
# 擬合度
sc_2 = ll.score(x_2,y_2)
# 截距
in_2 = round(ll.intercept_[0],2)
# 系數(shù)
coef_2 = round(ll.coef_[0][0],2)
coef_2_2 = round(ll.coef_[0][1],2)
print(in_2,coef_2,coef_2_2)
print(f'二元線性回歸:y={in_2}+{coef_2}*x+{coef_2_2}*x2')
# 測(cè)試
result = ll.predict([[76,50]])
print(f'體重:70,年齡:50,血壓預(yù)測(cè):{result}')

運(yùn)行結(jié)果:
在這里插入圖片描述

預(yù)測(cè)多元線性回歸數(shù)據(jù)

問(wèn)題及理解

問(wèn)題:給age,sex,bmi,bp,s1,s2,s3,s4,s5,s6和target數(shù)據(jù),預(yù)測(cè)其他age,sex,bmi,bp,s1,s2,s3,s4,s5,s6的target

特征數(shù)據(jù):age,sex,bmi,bp,s1,s2,s3,s4,s5,s6
類別標(biāo)簽:target
給定的數(shù)據(jù):
在這里插入圖片描述

數(shù)據(jù)測(cè)試

代碼展示:

import pandas as pd
from sklearn.linear_model import LinearRegression
tdata = pd.read_csv('tnb.csv')
# age,sex,bmi,bp,s1,s2,s3,s4,s5,s6,target
# 擬合度
corr = tdata.corr()
l = LinearRegression()# 特征數(shù)據(jù)
x = tdata[["age","sex","bmi","bp","s1","s2","s3","s4","s5","s6"]]
y = tdata[['target']]
l.fit(x,y)
sc = l.score(x,y) #0.51,0.49
print(sc)
inte = round(l.intercept_[0],2)
# 系數(shù)
coef1 = round(l.coef_[0][0],2)
coef2 = round(l.coef_[0][1],2)
coef3 = round(l.coef_[0][2],2)
coef4 = round(l.coef_[0][3],2)
coef5 = round(l.coef_[0][4],2)
coef6 = round(l.coef_[0][5],2)
coef7 = round(l.coef_[0][6],2)
coef8 = round(l.coef_[0][7],2)
coef9 = round(l.coef_[0][8],2)
coef10 = round(l.coef_[0][9],2)
#0.0380759064334241,0.0506801187398187,0.0616962065186885,0.0218723549949558,-0.0442234984244464,-0.0348207628376986,-0.0434008456520269,-0.00259226199818282,0.0199084208763183,-0.0176461251598052
re = l.predict([[0.0380759064334241,0.0506801187398187,0.0616962065186885,0.0218723549949558,-0.0442234984244464,-0.0348207628376986,-0.0434008456520269,-0.00259226199818282,0.0199084208763183,-0.0176461251598052]])
print(f'預(yù)測(cè):{re}')
print(f'線性回歸:y={inte}+{coef1}*x1+{coef2}*x2+{coef3}*x3+{coef4}*x4+{coef5}*x5+{coef6}*x6+{coef7}*x7+{coef8}*x8+{coef9}*x9+{coef10}+*x10')

運(yùn)行結(jié)果:

在這里插入圖片描述

http://www.risenshineclean.com/news/2103.html

相關(guān)文章:

  • 網(wǎng)站做二級(jí)站全網(wǎng)網(wǎng)絡(luò)營(yíng)銷
  • 織夢(mèng) 網(wǎng)站根目錄谷歌瀏覽器下載
  • 如何做網(wǎng)站走查一站式海外推廣平臺(tái)
  • 外貿(mào)網(wǎng)站建設(shè)推廣公司百度 營(yíng)銷推廣怎么做
  • 做網(wǎng)站運(yùn)營(yíng)這工作怎么樣注冊(cè)域名
  • 一搜同志網(wǎng)站建設(shè)電話百度登錄個(gè)人中心
  • wordpress vip 插件網(wǎng)站seo推廣seo教程
  • 深圳疫情最新消息今天seo指搜索引擎
  • 西安做網(wǎng)站公司網(wǎng)絡(luò)優(yōu)化師是什么工作
  • 安徽六安瓜片是什么茶百家號(hào)seo怎么做
  • 企業(yè)商城建站最新小組排名
  • 網(wǎng)站建設(shè)及發(fā)展成品視頻直播軟件推薦哪個(gè)好一點(diǎn)
  • 微信上如何做網(wǎng)站網(wǎng)絡(luò)服務(wù)提供者不履行法律行政法規(guī)規(guī)定
  • 做網(wǎng)站付多少定金seo推廣績(jī)效考核指標(biāo)是什么
  • XART視頻庫(kù)WordPressseo黑帽技術(shù)有哪些
  • 高唐做網(wǎng)站建設(shè)公司小程序拉新推廣平臺(tái)
  • 網(wǎng)上做論文的網(wǎng)站鄭州seo公司哪家好
  • 做商城網(wǎng)站簡(jiǎn)單嗎廣東百度seo關(guān)鍵詞排名
  • 臨沂高端網(wǎng)站建設(shè)百度官網(wǎng)地址
  • 網(wǎng)站做好后怎么做seo湖南靠譜seo優(yōu)化
  • 郵箱注冊(cè)網(wǎng)站查詢百度公司簡(jiǎn)介
  • 無(wú)錫網(wǎng)站制作楚天軟件所有代刷平臺(tái)推廣
  • 手機(jī)網(wǎng)站前端百度站長(zhǎng)工具網(wǎng)站提交
  • .com免費(fèi)網(wǎng)站怎么做東莞seo優(yōu)化seo關(guān)鍵詞
  • 福田做商城網(wǎng)站建設(shè)哪家技術(shù)好免費(fèi)建站系統(tǒng)哪個(gè)好用嗎
  • 華亞快印網(wǎng)站開發(fā)長(zhǎng)春網(wǎng)站公司哪家好
  • laravel 和wordpress百度seo軟件首選帝搜軟件
  • 建手機(jī)網(wǎng)站藥品網(wǎng)絡(luò)營(yíng)銷公司
  • 襄陽(yáng)做網(wǎng)站公司電話精準(zhǔn)引流怎么推廣
  • 網(wǎng)站推廣策劃案效果好在線之家