代做FIT5202 DATA PROCESSING FOR BIG DATA Semester Two 2019代写R编程

FIT5202

DATA PROCESSING FOR BIG DATA

Semester Two 2019

Question 1

a. What is Apache Spark? What are the two advantages of unified stack in Spark? (1 + 2 = 3 Marks)

b. Define RDD. RDDs are lazily evaluated. What does it mean? Can RDDs be shared between SparkContexts? Please explain. Give two examples of how RDD can be created using SparkContext (assume ‘sc’ as a SparkContext object). (1 + 1 + 1 + 2 = 5 Marks)

c. Write a program that does word count of the words ERROR and WARN found in the web server logs called “logs.txt”. The contents of “logs.txt” file is shown below. Please complete the program in the space provided. (2 Marks)

INFO This is a message with content

INFO This is some other content

WARN This is a warning

ERROR Something bad happened

WARN More details on the bad thing

from pyspark import SparkContext

# Start your code here

sc = SparkContext(master=“local[2]”, appName=“Errors and warnings Count”)

lines = sc.textFile(“logs.txt”)

Question 2

a. What are broadcast variables? Why do we need broadcast variables when working with Apache Spark? (1 + 1 = 2 Marks)

b. We want to perform. a log analysis. The input data consists of log messages of varying degrees of severity, along with some blank lines. We want to compute how many log messages appear at each level of severity. The contents of “input.txt” file is shown below.

INFO This is a message with content

INFO This is some other content

(empty line)

INFO Here are more messages

WARN This is a warning

(empty line)

ERROR Something bad happened

WARN More details on the bad thing

INFO back to normal messages

The expected output of the operations is as below.

[(‘INFO’, 4), (‘WARN’, 2), (‘ERROR’, 1)]

Write the code that will produce the expected output Assume spark context object ‘sc’ has already been initialised. (5 Marks)

from pyspark import SparkContext

# Start your code here

sc = SparkContext(master=“local[2]”, appName=“Errors and warnings Count”)

Input = ssc.textFile(“input.txt”)

c. List four different sections of Spark Web UI and briefly explain all of them. (1 + 2 = 3 Marks)

Question 3:

a. What is data visualisation? List two importance of data visualisation? What are the factors you need to be aware of before visualising the data? Please explain. (1 + 1 + 2 = 4 Marks)

b. What are the benefits of using Apache Spark and MongoDB together? Assume you have a database named “FIT5202” and a collection named “zips” in MongoDB database. The information on the attributes are as follows

● The _id field holds the zip code as a string.

● The city field holds the city name. A city can have more than one zip code associated with it as different sections of the city can each have a different zip code.

● The state field holds the two-letter state abbreviation.

● The pop field holds the population.

● The loc field holds the location as a latitude longitude pair.

Assume that spark session object (i.e. spark) has been initialised. The analysis required is “Find the states with populations above 10 Million”. Alice, our data analyst, is only familiar with SQL queries so she provided you with the following SQL query:

SELECT state, SUM(pop) AS totalPop

FROM zips

GROUP BY state

HAVING totalPop >= (10*1000*1000)

You read the data from the MongoDB using the command below:

zips_df = spark.read.format("com.mongodb.spark.sql.DefaultSource").load()

Use the functions provided by dataframe. to find the states with populations above 10 million. (1 + 5 = 6 Marks)

Question 4

a. What is Machine Learning and why should you use machine learning with Spark? In Apache Spark, machine learning pipelines provide a uniform. set of high-level APIs built on top of DataFrames. It makes easier to combine multiple algorithms into a single pipeline, or workflow. The key concepts introduced by the Pipelines API are DataFrame, Transformer, Estimator, Pipeline, and Parameter. What is a Transformer and an Estimator? (2 + 2 = 4 Marks)

b. Suppose we have a set of data comprising; height, weight and shoe size of some customers. The aim is to predict the shoe size of a new customer given only height and weight information.

Height (in cm)

Weight (in kg)

Shoe Size

158

58

36

158

59

36

158

63

36

160

59

38

160

60

38

163

60

38

163

61

38

163

64

40

165

64

40

165

61

40

165

62

40

168

65

40

168

62

40

Write the formula to calculate the Euclidean distance? A new customer named “Matthew” has height 161 cm and weight 61 kg. Using kNN, for k = 5, what is the (most) unlikely shoes size of Matthew? (2 + 4 = 10 Marks)

Question 5

a. What is the difference between Supervised Learning and Unsupervised Learning?

Mention any two differences. (2 Marks)

b. Consider the following data set consisting of the scores of two variables on each of seven individuals:

Use the k-means algorithm to cluster the data in two clusters. The distance of each data point and the centroid (or mean) is calculated using Euclidean distance. The formula to calculate the euclidean distance is given below. (8 Marks)

Question 6

a. ‘People who bought this also bought…’ recommendations seen on Amazon is based on which algorithm? What is the difference between Association Rules and Collaborative Filtering? (1 + 1 = 2 Marks)

b. A simplistic implementation using ALS (Alternating Least Squares) is given below. The goal is to recommend movies to users. Details of the dataset is given below. The full data set (“u.data”), 100000 ratings by 943 users on 1682 items. Each user has rated at least 20 movies. Users and items are numbered consecutively from 1. The data is randomly ordered. This is a tab separated list of

user id | item id | rating | timestamp

The time stamps are unix seconds since 1/1/1970 UTC. The sample data contents of “u.data” file is shown below.

196   242   3   881250949

186   302   3   891717742

22     377   1   878887116

244   51     2   880606923

166   346   1   886397596

Write the necessary code below to develop an ALS based recommendation model for movie recommendations. First examine the dataset and perform. necessary steps to convert the dataset into DataFrame. to make it ready for the algorithm. (8 Marks)

from pyspark import SparkContext

from pyspark.sql import SparkSession, Row

from pyspark.ml.recommendation import _______________________________

from pyspark.ml.evaluation import_____________________________________

appName="Collaborative Filtering with PySpark"

# initialize the spark session

spark = SparkSession.builder.appName(appName).getOrCreate()

# get sparkcontext from the sparksession

sc = spark.sparkContext

# Step1: the data is loaded to an RDD

movielens_rdd =

# Step 2: process the data into appropriate structure

# Step 3: convert the rdd to dataframes

# Step 4: split the dataset into training and test data (70% training and 30% test)

(trainingData, testData) =

# Step 5: build the recommendation model using ALS on the training data

# Use maxIter = 5, regParam = 0.01, coldStartStrategy = “drop”,

# implicitPrefs = False

# Step 6: predict the top movies for some selected users predictions = model.transform(testData)

# Step 7: find and print the accuracy of the model




热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图