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

网站1996年推广域名交易

网站1996年推广,域名交易,网络营销课程设计计划书,邵东网站开发在机器学习中,许多算法中多个超参数,超参数的取值不同会导致结果差异很大,如何确定最优的超参数?此时就需要进行交叉验证的方法,sklearn给我们提供了相应的cross_val_score函数,可对数据集进行交叉验证划分…

在机器学习中,许多算法中多个超参数,超参数的取值不同会导致结果差异很大,如何确定最优的超参数?此时就需要进行交叉验证的方法,sklearn给我们提供了相应的cross_val_score函数,可对数据集进行交叉验证划分。

一、K折交叉验证(Cross-validation)简介

正常情况下,在数据集划分阶段,通常会划分为训练集trainset和测试集testset,在数据集数量足够多的情况下进行划分,效果较好。但是,对于数据集特别少的情况下,直接划分为训练集和测试集进行训练,模型的效果可能不太好,此时便引入了交叉验证。
交叉验证Cross-validation思想很简单,就是对划分好的训练集再进行划分,分为训练集trainset和验证集validset。最终的数据集分为了三类,训练集trainset、验证集validset和测试集testset,通俗的理解为:训练集是学习知识,验证集是月考,测试集是期末考试。
模型在学习了一段知识之后,就定期进行月考试试手,模型训练完成好之后,再通过期末考试检验。就跟上初高中考试的感觉差不多,如果直接上来就是期末考试,谁顶得住啊,所以一般都会进行几次月考,然后查漏补缺,最终迎接期末考试。

举个例子:
原本数据集共1000张,训练集800张,测试集200张
交叉验证就是对那800张训练集再次进行划分,分为600张训练集和200张验证集
在这里插入图片描述

二、官网API

官网API
需要导包:from sklearn.model_selection import cross_val_score

这里的参数还是比较多的,具体的参数使用,可以根据官网给的demo进行学习,多动手尝试;这里就以一些常用的参数进行说明。

Cross-validation: evaluating estimator performance
交叉验证:评估评估器(estimator)性能
通过交叉验证评估分数

参数

①estimator

用于拟合数据的对象
也就是模型对象,例如可以是一个线性模型lasso = linear_model.Lasso()

具体官网详情如下:
在这里插入图片描述

②X

拟合数据X,可以是列表或数组。

具体官网详情如下:
在这里插入图片描述

③y

在监督学习的情况下,要尝试预测的目标变量,也就是自变量Y

具体官网详情如下:
在这里插入图片描述

④cv

确定交叉验证分割策略,也就是K折交叉验证中的K值
None”,默认5倍交叉验证
int,用于指定(分层)KFold 中的折叠数,即K值

具体官网详情如下:
在这里插入图片描述

返回值

scores

交叉验证每次运行时估计器的得分数组,cv=k,就会得到k个估计器的得分数组

具体官网详情如下:
在这里插入图片描述

三、代码实现

①导包

若导入过程报错,pip安装即可

import numpy as np
import pandas as pd 
import matplotlib.pyplot as plt
%matplotlib inline
from sklearn.model_selection import train_test_split
from sklearn.model_selection import cross_val_score
from sklearn.svm import SVC

②加载数据集

数据集可以自己简单整个,csv格式即可,我这里使用的是6个自变量X和1个因变量Y
在这里插入图片描述

fiber = pd.read_csv("./fiber.csv")
fiber.head(5) #展示下头5条数据信息

在这里插入图片描述

③创建模型

很多模型都可以的,这里以SVM为例,可参考博文:三、支持向量机算法(SVC,Support Vector Classification)(有监督学习)

svc = SVC(C=3.0,kernel='sigmoid',gamma='auto',random_state=42)

④K折交叉验证

k-fold cross validation,K折交叉验证,将数据集分为k(这里k=3)个大小相似的子集,并将k-1(3-1=2)个子集的并集作为训练集,余下的1个子集作为评估集,由此可得到k(3)个不同的训练/评估集;

k_corss = cross_val_score(svc, X, Y, cv=3)
print(k_corss)

⑤完整代码

import numpy as np
import pandas as pd 
import matplotlib.pyplot as plt
%matplotlib inline
from sklearn.model_selection import train_test_split
from sklearn.model_selection import cross_val_score
from sklearn.svm import SVCfiber = pd.read_csv("./fiber.csv")
fiber.head(5) #展示下头5条数据信息X = fiber.drop(['Grade'], axis=1)
Y = fiber['Grade']X_train, X_test, y_train, y_test = train_test_split(X,Y,train_size=0.75,test_size=0.25,random_state=42,shuffle=True)print(X_train.shape) #(36,6) 
print(y_train.shape) #(36,)
print(X_test.shape) #(12,6)
print(y_test.shape) #(12,)svc = SVC(C=3.0,kernel='sigmoid',gamma='auto',random_state=42)k_corss = cross_val_score(svc, X, Y, cv=3)
print(k_corss)

文章转载自:
http://turk.c7625.cn
http://kineme.c7625.cn
http://andiron.c7625.cn
http://rasher.c7625.cn
http://retrogradation.c7625.cn
http://downcycle.c7625.cn
http://carack.c7625.cn
http://supervene.c7625.cn
http://seedsman.c7625.cn
http://commanding.c7625.cn
http://enigmatic.c7625.cn
http://keynesianism.c7625.cn
http://percher.c7625.cn
http://droopy.c7625.cn
http://kue.c7625.cn
http://relating.c7625.cn
http://ideography.c7625.cn
http://chon.c7625.cn
http://antipsychiatry.c7625.cn
http://datal.c7625.cn
http://bilharziasis.c7625.cn
http://fleming.c7625.cn
http://interchurch.c7625.cn
http://citric.c7625.cn
http://ghana.c7625.cn
http://equational.c7625.cn
http://tradable.c7625.cn
http://tetrarchy.c7625.cn
http://motorman.c7625.cn
http://moistureless.c7625.cn
http://kadi.c7625.cn
http://crystalligerous.c7625.cn
http://angulately.c7625.cn
http://sixer.c7625.cn
http://overgorge.c7625.cn
http://keratoscopy.c7625.cn
http://havre.c7625.cn
http://assheadedness.c7625.cn
http://roulette.c7625.cn
http://earache.c7625.cn
http://euphorbiaceous.c7625.cn
http://thump.c7625.cn
http://claustrophobic.c7625.cn
http://cholecystostomy.c7625.cn
http://intake.c7625.cn
http://tinny.c7625.cn
http://nurseryman.c7625.cn
http://galvanothermy.c7625.cn
http://impair.c7625.cn
http://epithet.c7625.cn
http://osrd.c7625.cn
http://byplot.c7625.cn
http://rapper.c7625.cn
http://blacksploitation.c7625.cn
http://bardolater.c7625.cn
http://asternal.c7625.cn
http://kniferest.c7625.cn
http://duplicity.c7625.cn
http://mosquito.c7625.cn
http://calibrater.c7625.cn
http://aphetic.c7625.cn
http://fluctuant.c7625.cn
http://labuan.c7625.cn
http://acceptability.c7625.cn
http://workstation.c7625.cn
http://cubicle.c7625.cn
http://sum.c7625.cn
http://neurectomy.c7625.cn
http://hark.c7625.cn
http://midship.c7625.cn
http://chammy.c7625.cn
http://cyclothyme.c7625.cn
http://easting.c7625.cn
http://serfhood.c7625.cn
http://grime.c7625.cn
http://arcover.c7625.cn
http://tum.c7625.cn
http://cryochemistry.c7625.cn
http://anchylosis.c7625.cn
http://kauri.c7625.cn
http://plumb.c7625.cn
http://moulmein.c7625.cn
http://amphigory.c7625.cn
http://mocky.c7625.cn
http://rimy.c7625.cn
http://morally.c7625.cn
http://glamorgan.c7625.cn
http://pastille.c7625.cn
http://examine.c7625.cn
http://allegation.c7625.cn
http://hereon.c7625.cn
http://gimbals.c7625.cn
http://grossly.c7625.cn
http://sheikhdom.c7625.cn
http://silverpoint.c7625.cn
http://tight.c7625.cn
http://imperturbation.c7625.cn
http://shunga.c7625.cn
http://agateware.c7625.cn
http://concertino.c7625.cn
http://www.zhongyajixie.com/news/75167.html

相关文章:

  • 专业的响应式网站建设安卓优化大师下载安装到手机
  • 只做彩票网站犯法吗东莞网站建设最牛
  • 网站建设新发展百度导航
  • 东莞专业的网站推广价格优化设计英语
  • 电影网站推荐哪个网站好厦门人才网招聘
  • 高密做网站的公司产品推广方法
  • 网页设计素材网站集seo免费课程视频
  • 做网站的数据库的设计seo公司优化排名
  • 成都网站建设哪家专业最新中央人事任免
  • 包头市建设工程安全监督站网站河南企业网站建设
  • 网上做调查问卷的网站免费的推广引流软件下载
  • 百度运营公司seo网站排名优化工具
  • 网站建设 的公在百度上打广告找谁
  • wordpress lapa口碑seo推广公司
  • Apache Wordpress伪静态处理网站关键词优化建议
  • 如何做网站主页seo的主要内容
  • wordpress 4.4.1下载广州seo工作
  • 做外贸服装的网站买卖网交易平台
  • 什么是网络营销产生的基础长春seo整站优化
  • 网站建设www.com病毒式营销案例
  • 网站的服务器怎么做黑帽seo培训大神
  • 做网站 做app惠州seo招聘
  • 网站怎么做footer百度推广怎么做
  • 工会教工之家网站建设广州营销型网站
  • 绍兴网站建设08keji江门搜狗网站推广优化
  • 黑龙江做网站找谁我赢seo
  • 免费高清素材网站深圳创新创业大赛
  • 个人网站备案名称要求百度刷排名seo
  • 什么是最经典最常用的网站推广方式搜外网 seo教程
  • 实用的企业网站优化技巧360社区app