wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Large Scale Machine Learning using PySpark

Total questions: 35

Worksheet time: 3mins

Name
Class
Date
1.

What does inferSchema=True do in spark.read.csv()?

a)

Reads all columns as strings

b)

Automatically detects data types

c)

Removes nulls

d)

Formats columns

2.

If header=False, Spark assigns column names as:

a)

Based on first row

b)

Based on data types

c)

_c0, _c1, ...

d)

Blank

3.

Which function trims whitespaces in PySpark?

a)

clean()

b)

strip()

c)

trim()

d)

format()

4.

df.dropDuplicates() returns:

a)

Sorted rows

b)

Only numeric rows

c)

Unique rows

d)

Rows without nulls

5.

Which expression counts nulls in a column?

a)

sum(col(c).isNull())

b)

_sum(when(col(c).isNull(),1))

c)

countNull(c)

d)

dropNulls()

6.

Which function renames a column in PySpark?

a)

aliasColumn()

b)

renameColumn()

c)

withColumnRenamed()

d)

setName()

7.

What does StringIndexer do?

a)

Standardizes numbers

b)

Converts text → numeric index

c)

Drops missing values

d)

Creates vectors

8.

OneHotEncoder produces:

a)

Dense vectors

b)

Probabilities

c)

Sparse binary vectors

d)

Label indices

9.

Which merges all features into features column?

a)

FeatureMerger

b)

VectorAssembler

c)

FeatureAssembler

d)

VectorCreator

10.

Best scaler for Logistic Regression is:

a)

Normalizer

b)

StandardScaler

c)

VectorBinner

d)

MinMaxEncoder

11.

Indexed target variable is stored as:

a)

target

b)

output

c)

label

d)

y2

12.

With handleInvalid='keep' unseen labels are:

a)

Dropped

b)

Randomly encoded

c)

Assigned to last index

d)

Converted to null

13.

Output of VectorAssembler is:

a)

Scalar

b)

Multiple columns

c)

A single vector column

d)

List of numbers

14.

K-Means optimizes:

a)

Logistic loss

b)

Between-cluster variance

c)

Within-cluster SSE

d)

Accuracy

15.

Centroids represent:

a)

Outliers

b)

Cluster centers

c)

PCA components

d)

Maximum distance points

16.

K-Means stops when:

a)

Accuracy = 100%

b)

Clusters equal size

c)

Centroids stop changing

d)

Loss = 0

17.

Silhouette Score measures:

a)

Model accuracy

b)

Cluster cohesion & separation

c)

Computation time

d)

Outliers

18.

Silhouette score near 1 means:

a)

Poor clustering

b)

Perfect clustering

c)

Overfitted clusters

d)

Random labels

19.

PCA reduces dimensions by:

a)

Dropping rows

b)

Dropping columns

c)

Creating new orthogonal axes

d)

One-hot encoding

20.

Principal Components are:

a)

Raw features

b)

Random variables

c)

Linear combinations of original features

d)

Cluster labels

21.

PCA maximizes:

a)

Runtime

b)

Accuracy

c)

Variance captured

d)

Outliers removed

22.

Logistic Regression uses which function?

a)

tanh

b)

step

c)

sigmoid

d)

softmax

23.

Logistic Regression preferred because:

a)

Higher accuracy

b)

Output between 0 and 1

c)

Handles text

d)

Faster training

24.

If probability = 0.69 and threshold=0.5, prediction is:

a)

0

b)

1

c)

Unknown

d)

Depends

25.

Which evaluator computes ROC-AUC?

a)

RegressionEvaluator

b)

ModelEvaluator

c)

MulticlassEvaluator

d)

BinaryClassificationEvaluator

26.

Accuracy formula:

(a)  

27.

Which of the following is the correct formula for accuracy?

a)

TP/(TP+FN)

b)

TP/(TP+FP)

c)

(TP+TN)/Total

d)

FP/Total

28.

Precision measures:

a)

Correct predictions out of actual positives

b)

Correct predictions out of predicted positives

c)

Total negatives

d)

Recall

29.

Recall measures:

a)

Predicted positives correct

b)

Actual positives predicted positive

c)

Total observations predicted positive

d)

Outliers detected

30.

F1 score is the:

a)

Arithmetic mean

b)

Geometric mean

c)

Harmonic mean

d)

Maximum value

31.

ROC curve plots:

a)

Precision vs Recall

b)

TP vs FP

c)

TPR vs FPR

d)

Accuracy vs Recall

32.

What does VectorAssembler do in PySpark?

a)

Combines multiple columns into one feature vector

b)

Standardizes data

c)

Encodes strings

d)

Evaluates model

33.

The command

best_k = sorted(results, key=lambda x: x[1], reverse=True)[0][0]

returns:

a)

Cluster centers

b)

 Number of clusters with highest silhouette

c)

Distance threshold

d)

PCA components

34.

In anomaly detection, what does approxQuantile("dist_to_centroid", [0.99], 0.01) compute?

a)

Mean distance

b)

99th percentile distance

c)

 Median

d)

Cluster center

35.

Why do we scale features before K-Means?

a)

To avoid negative values

b)

To ensure equal contribution of features

c)

To normalize categorical data

d)

To improve PCA speed