楼主: ReneeBK
1194 0

[Case Study]Random RDD using Python [推广有奖]

  • 1关注
  • 62粉丝

VIP

已卖:4897份资源

学术权威

14%

还不是VIP/贵宾

-

TA的文库  其他...

R资源总汇

Panel Data Analysis

Experimental Design

威望
1
论坛币
49635 个
通用积分
55.6937
学术水平
370 点
热心指数
273 点
信用等级
335 点
经验
57805 点
帖子
4005
精华
21
在线时间
582 小时
注册时间
2005-5-8
最后登录
2023-11-26

楼主
ReneeBK 发表于 2015-11-16 08:11:10 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
  1. """
  2. Randomly generated RDDs.
  3. """
  4. from __future__ import print_function

  5. import sys

  6. from pyspark import SparkContext
  7. from pyspark.mllib.random import RandomRDDs


  8. if __name__ == "__main__":
  9.     if len(sys.argv) not in [1, 2]:
  10.         print("Usage: random_rdd_generation", file=sys.stderr)
  11.         exit(-1)

  12.     sc = SparkContext(appName="PythonRandomRDDGeneration")

  13.     numExamples = 10000  # number of examples to generate
  14.     fraction = 0.1  # fraction of data to sample

  15.     # Example: RandomRDDs.normalRDD
  16.     normalRDD = RandomRDDs.normalRDD(sc, numExamples)
  17.     print('Generated RDD of %d examples sampled from the standard normal distribution'
  18.           % normalRDD.count())
  19.     print('  First 5 samples:')
  20.     for sample in normalRDD.take(5):
  21.         print('    ' + str(sample))
  22.     print()

  23.     # Example: RandomRDDs.normalVectorRDD
  24.     normalVectorRDD = RandomRDDs.normalVectorRDD(sc, numRows=numExamples, numCols=2)
  25.     print('Generated RDD of %d examples of length-2 vectors.' % normalVectorRDD.count())
  26.     print('  First 5 samples:')
  27.     for sample in normalVectorRDD.take(5):
  28.         print('    ' + str(sample))
  29.     print()

  30.     sc.stop()
  31. Status API Training Shop Blog About Pricing
  32. © 2015 GitHub, Inc. Terms Privacy Security Contact Help
复制代码

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Case study python random Using study generated examples Random number future

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-31 14:10