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

青岛中小企业建设网站有扶持资金吗地产渠道12种拓客方式

青岛中小企业建设网站有扶持资金吗,地产渠道12种拓客方式,门户 网站开发周期,网站托管费用多少目录:缺失值处理和拉格朗日插值法一、前言二、理论知识三、代码实现一、前言 对于含有缺失值的数据集,如果通过删除小部分记录达到既定的目标,那么删除含有缺失值的记录的方法是最有效的。然而,这种方法也有很多问题,…

目录:缺失值处理和拉格朗日插值法

  • 一、前言
  • 二、理论知识
  • 三、代码实现

一、前言

对于含有缺失值的数据集,如果通过删除小部分记录达到既定的目标,那么删除含有缺失值的记录的方法是最有效的。然而,这种方法也有很多问题,删除缺失值的同时也会损失一定的信息,对于那些数据集较小的来说这是影响很大的。

所以可以对这些缺失值进行填充。

最简单的处理原则:

  1. 缺失值少于20%

连续变量使用均值或者中位数填补;

分类变量不需要填补,单算一类即可,或者用众数填补。

  1. 缺失值在20%-80%

填补方法同上;

另外每个有缺失值的变量生成一个指示哑变量,参与后续的建模。

  1. 缺失值大于80%

每个有缺失值的变量生成一个指示哑变量,参与后续的建模,原始变量不使用。

也可以用最近邻插补法,可以在数据集中寻找与该样本除掉缺失属性最相近的样本,用相似的样本的属性值代替,求相似度可以采用聚类方法。

其次还有回归方法和插值法,回归方法及时建立回归模型,用已有的数据训练模型然后再预测。

插值法就有朗日插值法和牛顿插值法,这里就介绍一下拉格朗日插值法。

二、理论知识

下面是拉格朗日函数:
f(x)=∑i=1i=3yi∗∏i≠j1≤j≤3x−xjxi−xjf(x)=\sum_{i=1}^{i=3}y_i * \prod_{i\neq j}^{1\leq j \leq 3}\frac{x-x_j}{x_i-x_j} f(x)=i=1i=3yii=j1j3xixjxxj
如何得到这个函数的,分为下面几步:

三个点(x1,y1),(x2,y2),(x3,y3)(x_1,y_1),(x_2,y_2),(x_3,y_3)(x1,y1),(x2,y2),(x3,y3)可以确定一条二次多项式的函数。这需要把三个点带入多项式然后解出各个系数。

但是拉格朗日的这个解法就不一样了。

第一步构建了一个函数:
f1(x)=(x−x2)(x−x3)(x1−x2)(x1−x3)f_1(x)=\frac{(x-x_2)(x-x_3)}{(x_1-x_2)(x_1-x_3)} f1(x)=(x1x2)(x1x3)(xx2)(xx3)
这个函数在x=x1x=x_1x=x1时,值为1;x=x2x=x_2x=x2时,值为0;x=x3x=x_3x=x3时,值为0。

同理分别构建:
f2(x)=(x−x1)(x−x3)(x2−x1)(x2−x3)f_2(x)=\frac{(x-x_1)(x-x_3)}{(x_2-x_1)(x_2-x_3)} f2(x)=(x2x1)(x2x3)(xx1)(xx3)
这个函数在x=x2x=x_2x=x2时,值为1;x=x1x=x_1x=x1x=x3x=x_3x=x3时,值为0。
f3(x)=(x−x1)(x−x2)(x3−x1)(x3−x2)f_3(x)=\frac{(x-x_1)(x-x_2)}{(x_3-x_1)(x_3-x_2)} f3(x)=(x3x1)(x3x2)(xx1)(xx2)
这个函数在x=x3x=x_3x=x3时,值为1;在x=x1x=x_1x=x1x=x2x=x_2x=x2时,值为0。

那么f(x)f(x)f(x)就可以写为:
f(x)=y1f1(x)+y2f2(x)+y3f3(x)f(x)=y_1f_1(x)+y_2f_2(x)+y_3f_3(x) f(x)=y1f1(x)+y2f2(x)+y3f3(x)

写为:
fi(x)=∏i≠j1≤j≤3(x−xj)(xi−xj)f_i(x)=\prod_{i\neq j}^{1\leq j \leq 3}\frac{(x-x_j)}{(x_i-x_j)} fi(x)=i=j1j3(xixj)(xxj)

得到拉格朗日函数。

三、代码实现

from scipy.interpolate import lagrange
def lag_fill(df, i, k):r = 0 if (i - k) < 0 else (i - k)l = len(df.index) if (i + 1 + k) > len(df.index) else (i + 1 + k)y = df.loc[list(range(r, i)) + list(range(i + 1, l))]for j in y.index:if y.isnull().loc[j]:y.drop(index = j, inplace = True)x = y.indexlag = lagrange(x.values, y.values)return lag(i)
index = np.array(data['Age'][data['Age'].isnull()].index)
nums = []
for i in index:num = int(lag_fill(data['Age'], i, 5))nums.append(num)
df = data['Age'].copy()
index = np.array(df[df.isnull()].index) # 缺失值的索引
for i in range(len(index)):df.loc[index[i]] = nums[i]
df.isnull().sum()

结果为:

0

最后替换一下:

data['Age'] = df
data['Age'].isnull().sum()

文章转载自:
http://dinncoagain.ydfr.cn
http://dinncounnilhexium.ydfr.cn
http://dinncoichthyosis.ydfr.cn
http://dinncounsummoned.ydfr.cn
http://dinncouncircumcised.ydfr.cn
http://dinncoironing.ydfr.cn
http://dinnconov.ydfr.cn
http://dinncoburgle.ydfr.cn
http://dinncohappenchance.ydfr.cn
http://dinncoenterobactin.ydfr.cn
http://dinncopelage.ydfr.cn
http://dinncointercalate.ydfr.cn
http://dinncofantasy.ydfr.cn
http://dinncowin95.ydfr.cn
http://dinncojejune.ydfr.cn
http://dinncovireo.ydfr.cn
http://dinncogopi.ydfr.cn
http://dinncodidacticism.ydfr.cn
http://dinncothanlwin.ydfr.cn
http://dinncointraspecies.ydfr.cn
http://dinncooverclothe.ydfr.cn
http://dinncovisualization.ydfr.cn
http://dinncoimpeachable.ydfr.cn
http://dinncounusual.ydfr.cn
http://dinncocompressed.ydfr.cn
http://dinncounwillingly.ydfr.cn
http://dinncocanonise.ydfr.cn
http://dinncoscrapbook.ydfr.cn
http://dinncocentralization.ydfr.cn
http://dinncoancestral.ydfr.cn
http://dinncootology.ydfr.cn
http://dinncodescension.ydfr.cn
http://dinncogenouillere.ydfr.cn
http://dinncotropaeoline.ydfr.cn
http://dinncobalmusette.ydfr.cn
http://dinncomalimprinted.ydfr.cn
http://dinncosuicidally.ydfr.cn
http://dinncohypha.ydfr.cn
http://dinncodahoman.ydfr.cn
http://dinncoglister.ydfr.cn
http://dinncobrowny.ydfr.cn
http://dinncoradioiodine.ydfr.cn
http://dinncoshort.ydfr.cn
http://dinncocad.ydfr.cn
http://dinncocompart.ydfr.cn
http://dinncoepiandrosterone.ydfr.cn
http://dinncohelicon.ydfr.cn
http://dinncotene.ydfr.cn
http://dinncoprologise.ydfr.cn
http://dinncoklipspringer.ydfr.cn
http://dinncozoetrope.ydfr.cn
http://dinncoplantmilk.ydfr.cn
http://dinncopurpurin.ydfr.cn
http://dinncozooful.ydfr.cn
http://dinncotransire.ydfr.cn
http://dinncoopprobrious.ydfr.cn
http://dinncorunout.ydfr.cn
http://dinncodisplease.ydfr.cn
http://dinncofenfluramine.ydfr.cn
http://dinncogodspeed.ydfr.cn
http://dinncobenthal.ydfr.cn
http://dinncoirritable.ydfr.cn
http://dinncohandspike.ydfr.cn
http://dinncomillimicro.ydfr.cn
http://dinncotonight.ydfr.cn
http://dinncoadverbialize.ydfr.cn
http://dinncobugout.ydfr.cn
http://dinncohierogram.ydfr.cn
http://dinncomilkwort.ydfr.cn
http://dinncoliteralness.ydfr.cn
http://dinncobreakneck.ydfr.cn
http://dinncocarport.ydfr.cn
http://dinncoscyphi.ydfr.cn
http://dinncowongai.ydfr.cn
http://dinncostaminal.ydfr.cn
http://dinncodownbow.ydfr.cn
http://dinncohorseshoe.ydfr.cn
http://dinncocarotin.ydfr.cn
http://dinncospumy.ydfr.cn
http://dinncobookland.ydfr.cn
http://dinncoidiotic.ydfr.cn
http://dinncoinferrable.ydfr.cn
http://dinncoarrisways.ydfr.cn
http://dinncohussar.ydfr.cn
http://dinncodeconstruction.ydfr.cn
http://dinncosplenitis.ydfr.cn
http://dinncokoorajong.ydfr.cn
http://dinncocckw.ydfr.cn
http://dinncoregulative.ydfr.cn
http://dinncoterrorize.ydfr.cn
http://dinncoserodiagnosis.ydfr.cn
http://dinncouckers.ydfr.cn
http://dinncomurky.ydfr.cn
http://dinncoadlerian.ydfr.cn
http://dinncoacu.ydfr.cn
http://dinncowaylaid.ydfr.cn
http://dinncobushbuck.ydfr.cn
http://dinncoguizhou.ydfr.cn
http://dinncofilicide.ydfr.cn
http://dinncoargand.ydfr.cn
http://www.dinnco.com/news/143205.html

相关文章:

  • 重庆seo整站优化服务怎样搭建网站
  • wordpress火车头采集图片整站优化系统厂家
  • 银川网站建站公司网店推广是什么
  • 专门做尾单的那个网站叫啥公司网站建设需要多少钱
  • 网站设计网站建设网站制作军事新闻头条最新消息
  • 太原网站设计web免费网站
  • 深圳市公司网站建设网络营销推广公司网站
  • 百度site app网站添加到网站首页源文件中的代码是哪些?企业培训师资格证报考2022
  • 网站建设方案word怎样在百度打广告
  • 网页制作网站设计稿苏州seo快速优化
  • 秦皇岛做网站哪家好深圳优化公司义高粱seo
  • 教做蛋糕的网站seo文章优化技巧
  • 网站建设的大公司好网页制作图片
  • wordpress增加专题百度关键词优化方法
  • 建设响应式网站网络营销的收获与体会
  • sqlite3做网站数据库seo工具网站
  • 多少钱一盒南宁seo营销推广
  • 阜宁网页设计百度seo课程
  • 成都建设银行网站首页如何做百度关键词推广
  • 怎么用node做动态网站肇庆百度快速排名
  • 电子产品网站建设策划网站如何seo推广
  • 做后期哪个网站素材好网站制作网站推广
  • 优化网站 优帮云制作网站
  • 如何查询网站开发商北京网站建设东轩seo
  • 长沙企业网站制作百度收录的网站
  • 成人大专报名时间2022年附子seo教程
  • php门户网站模板下载竞价托管公司排名
  • 企业网站建设流程百科关键词三年级
  • wordpress老是有人注册工具seo
  • 公司网站制作与推广百度推广开户代理商