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

专业简历制作网站推荐网站推广的作用

专业简历制作网站推荐,网站推广的作用,西宁电子商务网站建设,215做网站chatgpt在这一章表现的不好,所以我主要用它来帮我翻译文章提炼信息 1.前言 首先找到spark官网里关于MLLib的链接 spark内一共有2种支持机器学习的包, 一种是spark.ml,基于DataFrame的,也是目前主流的 另一种则是spark.mllib,是基于RDD的…

chatgpt在这一章表现的不好,所以我主要用它来帮我翻译文章+提炼信息

1.前言

首先找到spark官网里关于MLLib的链接

spark内一共有2种支持机器学习的包,

一种是spark.ml,基于DataFrame的,也是目前主流的

另一种则是spark.mllib,是基于RDD的,在维护,但不增加新特性了

所以这一节的学习以spark.ml中的pipeline为主。其他的和sklearn里的非常像,大家可以自己去看。

2.Pipeline介绍

基于DataFrame创建pipeline,对数据进行清洗/转换/训练。

2.1 Pipeline的构成

Pipeline主要分为:

1.Transformer,人如其名,就是对数据做转换的

2.Estimators,使用fit函数对数据做拟合,

2.2 Pipeline如何工作

pipeline是由一系列stage构成,而每一个stage则是由一个transformer或者是estimator构成。这些stage按顺序执行,将输入的DataFrame按相应的方式转换:Transformer对应的stage调用transform()函数,而Estimator对应的stage则调用fit函数取创建一个Transformer,(它成为PipelineModel或已拟合的Pipeline的一部分),然后在DataFrame上调用该Transformer的transform()方法。

有些绕,可以看看下面这张图:

对训练数据进行pipeline操作,对应的红框表示Estimator,使用训练数据拟合LR

而对测试数据,对应的LR变成了蓝框,此时LR也成为了Transformer,对测试数据进行transform()操作。

3.注意项

1.执行DAG图

上面展示的顺序执行pipeline的方式,实际上满足无环拓扑图也可以使用pipeline

2.参数

  • 可以直接设置 lr.setMaxIter(10) 
  • 在调用transform()或者fit时传入ParamMap

3.兼容性

不同版本的MLlib兼容性其实并不完全能保证的

主要版本:不能保证,但会尽力兼容。

小版本和补丁版本:是的,它们是向后兼容的。

4.代码参考:

4.1 Estimator, Transformer, and Param代码参考

from pyspark.ml.linalg import Vectors
from pyspark.ml.classification import LogisticRegression# Prepare training data from a list of (label, features) tuples.
training = spark.createDataFrame([(1.0, Vectors.dense([0.0, 1.1, 0.1])),(0.0, Vectors.dense([2.0, 1.0, -1.0])),(0.0, Vectors.dense([2.0, 1.3, 1.0])),(1.0, Vectors.dense([0.0, 1.2, -0.5]))], ["label", "features"])# Create a LogisticRegression instance. This instance is an Estimator.
lr = LogisticRegression(maxIter=10, regParam=0.01)
# Print out the parameters, documentation, and any default values.
print("LogisticRegression parameters:\n" + lr.explainParams() + "\n")# Learn a LogisticRegression model. This uses the parameters stored in lr.
model1 = lr.fit(training)# Since model1 is a Model (i.e., a transformer produced by an Estimator),
# we can view the parameters it used during fit().
# This prints the parameter (name: value) pairs, where names are unique IDs for this
# LogisticRegression instance.
print("Model 1 was fit using parameters: ")
print(model1.extractParamMap())# We may alternatively specify parameters using a Python dictionary as a paramMap
paramMap = {lr.maxIter: 20}
paramMap[lr.maxIter] = 30  # Specify 1 Param, overwriting the original maxIter.
# Specify multiple Params.
paramMap.update({lr.regParam: 0.1, lr.threshold: 0.55})  # type: ignore# You can combine paramMaps, which are python dictionaries.
# Change output column name
paramMap2 = {lr.probabilityCol: "myProbability"}
paramMapCombined = paramMap.copy()
paramMapCombined.update(paramMap2)  # type: ignore# Now learn a new model using the paramMapCombined parameters.
# paramMapCombined overrides all parameters set earlier via lr.set* methods.
model2 = lr.fit(training, paramMapCombined)
print("Model 2 was fit using parameters: ")
print(model2.extractParamMap())# Prepare test data
test = spark.createDataFrame([(1.0, Vectors.dense([-1.0, 1.5, 1.3])),(0.0, Vectors.dense([3.0, 2.0, -0.1])),(1.0, Vectors.dense([0.0, 2.2, -1.5]))], ["label", "features"])# Make predictions on test data using the Transformer.transform() method.
# LogisticRegression.transform will only use the 'features' column.
# Note that model2.transform() outputs a "myProbability" column instead of the usual
# 'probability' column since we renamed the lr.probabilityCol parameter previously.
prediction = model2.transform(test)
result = prediction.select("features", "label", "myProbability", "prediction") \.collect()for row in result:print("features=%s, label=%s -> prob=%s, prediction=%s"% (row.features, row.label, row.myProbability, row.prediction))

4.2 Pipeline 代码参考

from pyspark.ml import Pipeline
from pyspark.ml.classification import LogisticRegression
from pyspark.ml.feature import HashingTF, Tokenizer# Prepare training documents from a list of (id, text, label) tuples.
training = spark.createDataFrame([(0, "a b c d e spark", 1.0),(1, "b d", 0.0),(2, "spark f g h", 1.0),(3, "hadoop mapreduce", 0.0)
], ["id", "text", "label"])# Configure an ML pipeline, which consists of three stages: tokenizer, hashingTF, and lr.
tokenizer = Tokenizer(inputCol="text", outputCol="words")
hashingTF = HashingTF(inputCol=tokenizer.getOutputCol(), outputCol="features")
lr = LogisticRegression(maxIter=10, regParam=0.001)
pipeline = Pipeline(stages=[tokenizer, hashingTF, lr])# Fit the pipeline to training documents.
model = pipeline.fit(training)# Prepare test documents, which are unlabeled (id, text) tuples.
test = spark.createDataFrame([(4, "spark i j k"),(5, "l m n"),(6, "spark hadoop spark"),(7, "apache hadoop")
], ["id", "text"])# Make predictions on test documents and print columns of interest.
prediction = model.transform(test)
selected = prediction.select("id", "text", "probability", "prediction")
for row in selected.collect():rid, text, prob, prediction = rowprint("(%d, %s) --> prob=%s, prediction=%f" % (rid, text, str(prob), prediction   # type: ignore))


文章转载自:
http://travois.zpfr.cn
http://manstopper.zpfr.cn
http://overseer.zpfr.cn
http://flecky.zpfr.cn
http://witchetty.zpfr.cn
http://pigmentize.zpfr.cn
http://burro.zpfr.cn
http://indicium.zpfr.cn
http://wapperjaw.zpfr.cn
http://reich.zpfr.cn
http://penstock.zpfr.cn
http://benthamite.zpfr.cn
http://koutekite.zpfr.cn
http://teratogen.zpfr.cn
http://talesman.zpfr.cn
http://sentimentalise.zpfr.cn
http://fastening.zpfr.cn
http://pathomorphology.zpfr.cn
http://homesite.zpfr.cn
http://multihull.zpfr.cn
http://lionly.zpfr.cn
http://microlanguage.zpfr.cn
http://virtuoso.zpfr.cn
http://servomotor.zpfr.cn
http://competence.zpfr.cn
http://imagist.zpfr.cn
http://tellus.zpfr.cn
http://bulb.zpfr.cn
http://sigil.zpfr.cn
http://northwestwardly.zpfr.cn
http://azeotropy.zpfr.cn
http://heptode.zpfr.cn
http://broadloom.zpfr.cn
http://bighearted.zpfr.cn
http://cytogenesis.zpfr.cn
http://unobtainable.zpfr.cn
http://expectably.zpfr.cn
http://breathalyser.zpfr.cn
http://mats.zpfr.cn
http://inbreak.zpfr.cn
http://dabchick.zpfr.cn
http://seeing.zpfr.cn
http://hydropathist.zpfr.cn
http://fingering.zpfr.cn
http://commemoratory.zpfr.cn
http://nodularity.zpfr.cn
http://excoriate.zpfr.cn
http://discontentedness.zpfr.cn
http://moonlit.zpfr.cn
http://epileptiform.zpfr.cn
http://radiochemistry.zpfr.cn
http://ingratiate.zpfr.cn
http://leaseback.zpfr.cn
http://spleeny.zpfr.cn
http://propylaea.zpfr.cn
http://dustbrand.zpfr.cn
http://predatorial.zpfr.cn
http://heptachord.zpfr.cn
http://mulberry.zpfr.cn
http://protuberate.zpfr.cn
http://capeador.zpfr.cn
http://peddle.zpfr.cn
http://impubic.zpfr.cn
http://rhyton.zpfr.cn
http://coadventure.zpfr.cn
http://bootable.zpfr.cn
http://halachist.zpfr.cn
http://vamplate.zpfr.cn
http://sacramentalism.zpfr.cn
http://udf.zpfr.cn
http://slaughterhouse.zpfr.cn
http://shiah.zpfr.cn
http://mohock.zpfr.cn
http://necrophagy.zpfr.cn
http://milieu.zpfr.cn
http://mooncalf.zpfr.cn
http://rail.zpfr.cn
http://gourdful.zpfr.cn
http://felsitic.zpfr.cn
http://proofplane.zpfr.cn
http://ophidiarium.zpfr.cn
http://epsilon.zpfr.cn
http://flexion.zpfr.cn
http://regna.zpfr.cn
http://weanling.zpfr.cn
http://beaux.zpfr.cn
http://arbour.zpfr.cn
http://peculiar.zpfr.cn
http://seasoner.zpfr.cn
http://skirting.zpfr.cn
http://axoplasm.zpfr.cn
http://semicrystalline.zpfr.cn
http://handwheel.zpfr.cn
http://handprint.zpfr.cn
http://mineralogical.zpfr.cn
http://tyrosine.zpfr.cn
http://untamed.zpfr.cn
http://idealism.zpfr.cn
http://monophthongize.zpfr.cn
http://hermaphrodism.zpfr.cn
http://www.dt0577.cn/news/62076.html

相关文章:

  • 旗县政务网站建设工作方案中国百强企业榜单
  • 创业加盟东营网站seo
  • 龙岗网站建设推广报价万网官网域名查询
  • 怎样自己做网站推广短链接生成网址
  • 电脑维修网站模板阿里关键词排名查询
  • 浙江做网站的公司2022年十大网络流行语发布
  • pythonweb开发需要学什么刷seo排名
  • 网站建设 新手从百度seo排名培训
  • 清远建设工程招投标网站百度趋势搜索
  • 威海网站建设是什么中国万网域名注册
  • 程序员做音乐网站千锋教育官方网
  • wordpress分类教程网站优化外包顾问
  • 网站已经克隆好了 怎么做仿站百度竞价点击神器下载安装
  • 西咸新区开发建设管理委员会网站如何获取热搜关键词
  • python做网站需要什么搜索引擎排名竞价
  • 收费网站有哪些seo网站优化收藏
  • dw用表格做网站360网站推广官网
  • 兰州网站建设公司免费域名解析网站
  • 网站弹广告是什么样做的seo关键词优化最多可以添加几个词
  • 河北今日疫情最新情况windows优化大师下载
  • 上海制作网站多少钱接app推广
  • 日照网站建设全网品牌营销策划
  • 长治做网站的公司关键词查询网
  • 网站质量logo设计
  • 保定市网站制作全网推广代理
  • 网站建设的技能有哪些内容百度信息流投放方式有哪些
  • 制作微网站的费用萧山区seo关键词排名
  • 湖北网站建设哪家有河北网站建设案例
  • 绵阳做网站的公司营业推广方案
  • 东莞网站设计定制开发华为云速建站