当前位置: 首页 > news >正文

新闻网站寄生虫怎么做seo优化推广多少钱

新闻网站寄生虫怎么做,seo优化推广多少钱,建站服务是什么,wordpress decorum文章目录 [toc]数据数据集实际值估计值 梯度下降算法估计误差代价函数学习率参数更新 Python实现导包数据预处理迭代过程结果可视化完整代码 结果可视化线性拟合结果代价变化 数据 数据集 ( x ( i ) , y ( i ) ) , i 1 , 2 , ⋯ , m \left(x^{(i)} , y^{(i)}\right) , i 1 ,…

文章目录

    • @[toc]
      • 数据
        • 数据集
        • 实际值
        • 估计值
      • 梯度下降算法
        • 估计误差
        • 代价函数
        • 学习率
        • 参数更新
      • `Python`实现
        • 导包
        • 数据预处理
        • 迭代过程
        • 结果可视化
        • 完整代码
      • 结果可视化
        • 线性拟合结果
        • 代价变化

数据

数据集

( x ( i ) , y ( i ) ) , i = 1 , 2 , ⋯ , m \left(x^{(i)} , y^{(i)}\right) , i = 1 , 2 , \cdots , m (x(i),y(i)),i=1,2,,m

实际值

y ( i ) y^{(i)} y(i)

估计值

h θ ( x ( i ) ) = θ 0 + θ 1 x ( i ) h_{\theta}\left(x^{(i)}\right) = \theta_{0} + \theta_{1} x^{(i)} hθ(x(i))=θ0+θ1x(i)


梯度下降算法

估计误差

h θ ( x ( i ) ) − y ( i ) h_{\theta}\left(x^{(i)}\right) - y^{(i)} hθ(x(i))y(i)

代价函数

J ( θ ) = J ( θ 0 , θ 1 ) = 1 2 m ∑ i = 1 m ( h θ ( x ( i ) ) − y ( i ) ) 2 = 1 2 m ∑ i = 1 m ( θ 0 + θ 1 x ( i ) − y ( i ) ) 2 J(\theta) = J(\theta_{0} , \theta_{1}) = \cfrac{1}{2m} \displaystyle\sum\limits_{i = 1}^{m}{\left(h_{\theta}\left(x^{(i)}\right) - y^{(i)}\right)^{2}} = \cfrac{1}{2m} \displaystyle\sum\limits_{i = 1}^{m}{\left(\theta_{0} + \theta_{1} x^{(i)} - y^{(i)}\right)^{2}} J(θ)=J(θ0,θ1)=2m1i=1m(hθ(x(i))y(i))2=2m1i=1m(θ0+θ1x(i)y(i))2

学习率
  • α \alpha α是学习率,一个大于 0 0 0的很小的经验值,决定代价函数下降的程度
参数更新

Δ θ j = ∂ ∂ θ j J ( θ 0 , θ 1 ) \Delta{\theta_{j}} = \cfrac{\partial}{\partial{\theta_{j}}} J(\theta_{0} , \theta_{1}) Δθj=θjJ(θ0,θ1)

θ j : = θ j − α Δ θ j = θ j − α ∂ ∂ θ j J ( θ 0 , θ 1 ) \theta_{j} := \theta_{j} - \alpha \Delta{\theta_{j}} = \theta_{j} - \alpha \cfrac{\partial}{\partial{\theta_{j}}} J(\theta_{0} , \theta_{1}) θj:=θjαΔθj=θjαθjJ(θ0,θ1)

$$
\left[
\begin{matrix}
\theta_{0} \
\theta_{1}
\end{matrix}
\right] :=

\left[
\begin{matrix}
\theta_{0} \
\theta_{1}
\end{matrix}
\right] -
\alpha

\left[
\begin{matrix}
\cfrac{\partial{J(\theta_{0} , \theta_{1})}}{\partial{\theta_{0}}} \
\cfrac{\partial{J(\theta_{0} , \theta_{1})}}{\partial{\theta_{1}}}
\end{matrix}
\right]
$$

[ ∂ J ( θ 0 , θ 1 ) ∂ θ 0 ∂ J ( θ 0 , θ 1 ) ∂ θ 1 ] = [ 1 m ∑ i = 1 m ( h θ ( x ( i ) ) − y ( i ) ) 1 m ∑ i = 1 m ( h θ ( x ( i ) ) − y ( i ) ) x ( i ) ] = [ 1 m ∑ i = 1 m e ( i ) 1 m ∑ i = 1 m e ( i ) x ( i ) ] e ( i ) = h θ ( x ( i ) ) − y ( i ) \left[ \begin{matrix} \cfrac{\partial{J(\theta_{0} , \theta_{1})}}{\partial{\theta_{0}}} \\ \cfrac{\partial{J(\theta_{0} , \theta_{1})}}{\partial{\theta_{1}}} \end{matrix} \right] = \left[ \begin{matrix} \cfrac{1}{m} \displaystyle\sum\limits_{i = 1}^{m}{\left(h_{\theta}\left(x^{(i)}\right) - y^{(i)}\right)} \\ \cfrac{1}{m} \displaystyle\sum\limits_{i = 1}^{m}{\left(h_{\theta}\left(x^{(i)}\right) - y^{(i)}\right) x^{(i)}} \end{matrix} \right] = \left[ \begin{matrix} \cfrac{1}{m} \displaystyle\sum\limits_{i = 1}^{m}{e^{(i)}} \\ \cfrac{1}{m} \displaystyle\sum\limits_{i = 1}^{m}{e^{(i)} x^{(i)}} \end{matrix} \right] \kern{2em} e^{(i)} = h_{\theta}\left(x^{(i)}\right) - y^{(i)} θ0J(θ0,θ1)θ1J(θ0,θ1) = m1i=1m(hθ(x(i))y(i))m1i=1m(hθ(x(i))y(i))x(i) = m1i=1me(i)m1i=1me(i)x(i) e(i)=hθ(x(i))y(i)

[ ∂ J ( θ 0 , θ 1 ) ∂ θ 0 ∂ J ( θ 0 , θ 1 ) ∂ θ 1 ] = [ 1 m ∑ i = 1 m e ( i ) 1 m ∑ i = 1 m e ( i ) x ( i ) ] = [ 1 m ( e ( 1 ) + e ( 2 ) + ⋯ + e ( m ) ) 1 m ( e ( 1 ) x ( 1 ) + e ( 2 ) x ( 2 ) + ⋯ + e ( m ) x ( m ) ) ] = 1 m [ 1 1 ⋯ 1 x ( 1 ) x ( 2 ) ⋯ x ( m ) ] [ e ( 1 ) e ( 2 ) ⋮ e ( m ) ] = 1 m X T e = 1 m X T ( X θ − y ) \begin{aligned} \left[ \begin{matrix} \cfrac{\partial{J(\theta_{0} , \theta_{1})}}{\partial{\theta_{0}}} \\ \cfrac{\partial{J(\theta_{0} , \theta_{1})}}{\partial{\theta_{1}}} \end{matrix} \right] &= \left[ \begin{matrix} \cfrac{1}{m} \displaystyle\sum\limits_{i = 1}^{m}{e^{(i)}} \\ \cfrac{1}{m} \displaystyle\sum\limits_{i = 1}^{m}{e^{(i)} x^{(i)}} \end{matrix} \right] = \left[ \begin{matrix} \cfrac{1}{m} \left(e^{(1)} + e^{(2)} + \cdots + e^{(m)}\right) \\ \cfrac{1}{m} \left(e^{(1)} x^{(1)} + e^{(2)} x^{(2)} + \cdots + e^{(m)} x^{(m)}\right) \end{matrix} \right] \\ &= \cfrac{1}{m} \left[ \begin{matrix} 1 & 1 & \cdots & 1 \\ x^{(1)} & x^{(2)} & \cdots & x^{(m)} \end{matrix} \right] \left[ \begin{matrix} e^{(1)} \\ e^{(2)} \\ \vdots \\ e^{(m)} \end{matrix} \right] = \cfrac{1}{m} X^{T} e = \cfrac{1}{m} X^{T} (X \theta - y) \end{aligned} θ0J(θ0,θ1)θ1J(θ0,θ1) = m1i=1me(i)m1i=1me(i)x(i) = m1(e(1)+e(2)++e(m))m1(e(1)x(1)+e(2)x(2)++e(m)x(m)) =m1[1x(1)1x(2)1x(m)] e(1)e(2)e(m) =m1XTe=m1XT(y)

  • 由上述推导得

Δ θ = 1 m X T e \Delta{\theta} = \cfrac{1}{m} X^{T} e Δθ=m1XTe

θ : = θ − α Δ θ = θ − α 1 m X T e \theta := \theta - \alpha \Delta{\theta} = \theta - \alpha \cfrac{1}{m} X^{T} e θ:=θαΔθ=θαm1XTe


Python实现

导包
import numpy as np
import matplotlib.pyplot as plt
数据预处理
x = np.array([4, 3, 3, 4, 2, 2, 0, 1, 2, 5, 1, 2, 5, 1, 3])
y = np.array([8, 6, 6, 7, 4, 4, 2, 4, 5, 9, 3, 4, 8, 3, 6])m = len(x)x = np.c_[np.ones((m, 1)), x]
y = y.reshape(m, 1)
迭代过程
alpha = 0.01  # 学习率
iter_cnt = 1000  # 迭代次数
cost = np.zeros(iter_cnt)  # 代价数据
theta = np.zeros((2, 1))for i in range(iter_cnt):h = x.dot(theta)  # 估计值error = h - y  # 误差值cost[i] = 1 / (2 * m) * error.T.dot(error)  # 代价值# cost[i] = 1 / (2 * m) * np.sum(np.square(error))  # 代价值# 更新参数delta_theta = 1 / m * x.T.dot(error)theta -= alpha * delta_theta
结果可视化
# 线性拟合结果
plt.scatter(x[:, 1], y, c='blue')
plt.plot(x[:, 1], h, 'r-')
plt.savefig('../pic/fit.png')
plt.show()# 代价结果
plt.plot(cost)
plt.savefig('../pic/cost.png')
plt.show()
完整代码
import numpy as np
import matplotlib.pyplot as pltx = np.array([4, 3, 3, 4, 2, 2, 0, 1, 2, 5, 1, 2, 5, 1, 3])
y = np.array([8, 6, 6, 7, 4, 4, 2, 4, 5, 9, 3, 4, 8, 3, 6])m = len(x)x = np.c_[np.ones((m, 1)), x]
y = y.reshape(m, 1)alpha = 0.01  # 学习率
iter_cnt = 1000  # 迭代次数
cost = np.zeros(iter_cnt)  # 代价数据
theta = np.zeros((2, 1))for i in range(iter_cnt):h = x.dot(theta)  # 估计值error = h - y  # 误差值cost[i] = 1 / (2 * m) * error.T.dot(error)  # 代价值# cost[i] = 1 / (2 * m) * np.sum(np.square(error))  # 代价值# 更新参数delta_theta = 1 / m * x.T.dot(error)theta -= alpha * delta_theta# 线性拟合结果
plt.scatter(x[:, 1], y, c='blue')
plt.plot(x[:, 1], h, 'r-')
plt.savefig('../pic/fit.png')
plt.show()# 代价结果
plt.plot(cost)
plt.savefig('../pic/cost.png')
plt.show()

结果可视化

线性拟合结果

1

代价变化

2



文章转载自:
http://muscular.yzkf.cn
http://bulltrout.yzkf.cn
http://fluoric.yzkf.cn
http://reformist.yzkf.cn
http://widow.yzkf.cn
http://disorganize.yzkf.cn
http://janet.yzkf.cn
http://nonskidding.yzkf.cn
http://tehr.yzkf.cn
http://disincentive.yzkf.cn
http://esse.yzkf.cn
http://delphic.yzkf.cn
http://nonfluency.yzkf.cn
http://intercolumniation.yzkf.cn
http://hymen.yzkf.cn
http://angelina.yzkf.cn
http://mystery.yzkf.cn
http://conquian.yzkf.cn
http://porcellanic.yzkf.cn
http://bossdom.yzkf.cn
http://kotow.yzkf.cn
http://spidery.yzkf.cn
http://aujus.yzkf.cn
http://xf.yzkf.cn
http://fascinate.yzkf.cn
http://handler.yzkf.cn
http://woolen.yzkf.cn
http://vacationland.yzkf.cn
http://radiant.yzkf.cn
http://regionalist.yzkf.cn
http://gratulant.yzkf.cn
http://bazaari.yzkf.cn
http://infancy.yzkf.cn
http://phony.yzkf.cn
http://press.yzkf.cn
http://tetramisole.yzkf.cn
http://eda.yzkf.cn
http://frigidaria.yzkf.cn
http://cryosurgery.yzkf.cn
http://everyone.yzkf.cn
http://cyclogram.yzkf.cn
http://laaland.yzkf.cn
http://bushmanship.yzkf.cn
http://takeoff.yzkf.cn
http://bur.yzkf.cn
http://demirelief.yzkf.cn
http://treadless.yzkf.cn
http://spouse.yzkf.cn
http://teleguide.yzkf.cn
http://instillation.yzkf.cn
http://jism.yzkf.cn
http://correlated.yzkf.cn
http://nether.yzkf.cn
http://stability.yzkf.cn
http://gifu.yzkf.cn
http://flanneled.yzkf.cn
http://incurably.yzkf.cn
http://turbodrill.yzkf.cn
http://ignitor.yzkf.cn
http://full.yzkf.cn
http://longueur.yzkf.cn
http://elliptoid.yzkf.cn
http://hydroscopical.yzkf.cn
http://fibrillation.yzkf.cn
http://cowper.yzkf.cn
http://intercrop.yzkf.cn
http://takoradi.yzkf.cn
http://xyloid.yzkf.cn
http://godet.yzkf.cn
http://gadgetize.yzkf.cn
http://bedight.yzkf.cn
http://leafstalk.yzkf.cn
http://eyesore.yzkf.cn
http://lacquer.yzkf.cn
http://arrange.yzkf.cn
http://careworn.yzkf.cn
http://adolescent.yzkf.cn
http://chelsea.yzkf.cn
http://expositorial.yzkf.cn
http://diffract.yzkf.cn
http://spermalege.yzkf.cn
http://retreatant.yzkf.cn
http://cicero.yzkf.cn
http://lorn.yzkf.cn
http://embattle.yzkf.cn
http://impulsively.yzkf.cn
http://screenland.yzkf.cn
http://improvable.yzkf.cn
http://enniskillen.yzkf.cn
http://refluent.yzkf.cn
http://instauration.yzkf.cn
http://dimensional.yzkf.cn
http://pax.yzkf.cn
http://sphygmoid.yzkf.cn
http://keelblock.yzkf.cn
http://extraction.yzkf.cn
http://nagoya.yzkf.cn
http://caprifig.yzkf.cn
http://collusive.yzkf.cn
http://fortuna.yzkf.cn
http://www.15wanjia.com/news/71013.html

相关文章:

  • 成都手机网站建设哪我要登录百度
  • 关于网站建设的工作总结电商从零基础怎么学
  • mvc做网站目前病毒的最新情况
  • 做网站哪家服务器好国外独立网站如何建站
  • 小程序有什么用温州网站建设优化
  • asp做网站安全性百度下载电脑版
  • wordpress创建数据库文件沈阳seo网站关键词优化
  • 阳江招聘网收银seo网络培训班
  • 安徽省建设法治协会网站宁波网站推广优化哪家正规
  • 如何知道网站是用什么语言做的江苏网页定制
  • 用于做网站的软件百度热搜seo
  • 苏州市吴江区住房和城乡建设局网站免费seo网站优化工具
  • 仙居谁认识做网站的seo sem是什么职位
  • 北碚区建设银行网站个人主页网页设计
  • 潮州市住房和城乡建设局网站郑州客串seo
  • 王健林亏60亿做不成一个网站seo sem关键词优化
  • 建一个类似亨物说网站建设费用it学校培训学校哪个好
  • wordpress主题学习教程石家庄seo排名公司
  • 南昌做微信网站东莞市网络seo推广服务机构
  • 网站类型分类35个成功的市场营销策划案例
  • 南山网站建设描述建设一个网站的具体步骤
  • 电脑怎样隐藏wordpressseo工作内容有哪些
  • 做网站怎么优化it培训班真的有用吗
  • 档案网站的建设方案武汉seo网站排名优化公司
  • 艺帆网络工作室网站源码百度关键词搜索热度
  • 投标文件网站开发技术部分什么软件可以弄排名
  • 现在佛山疫情最新情况站长之家 seo查询
  • 网站开发服务器框架情感链接
  • 招聘网站分析如何做seo分析是什么意思
  • 南通网站建设找哪家好常用的搜索引擎有哪些?