DBA Final Exam

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/20

encourage image

There's no tags or description

Looks like no tags are added yet.

21 Terms

1
New cards
  1. Topic 1 — Pandas Fundamentals | Introducing Pandas Objects | What is printed? Code: import pandas as pd; s = pd.Series([5, 10, 15], index=['x', 'y', 'z']); print(s['y'] + s['x']) | A. 10 | B. 5 | C. 15 | D. 25


C. 15 — Find the labels first: y = 10 and x = 5. Then add 10 + 5 = 15. Labels determine which values are selected.

2
New cards
  1. Topic 1 — Pandas Fundamentals | Operations in Pandas: Index Alignment | What value is printed? Code: A = pd.Series([4, 6, 8], index=['a', 'b', 'c']); B = pd.Series([1, 3, 5], index=['b', 'c', 'd']); print((A + B)['c']) | A. 13 | B. 11 | C. 9 | D. NaN


B. 11 — Match index labels, NOT positions. At c: A[c] = 8 and B[c] = 3, so 8 + 3 = 11. The unmatched labels a and d give NaN but c does not.

3
New cards
  1. Topic 1 — Pandas Fundamentals | Operations in Pandas: fill_value | What is printed? Code: A = pd.Series([4, 6], index=['a', 'b']); B = pd.Series([7, 2], index=['b', 'c']); print(A.add(B, fill_value=0)['c']) | A. 9 | B. 2 | C. NaN | D. 6

B. 2 — At index c, A has no value but B[c] = 2. The fill_value=0 treats the missing entry as zero: 0 + 2 = 2.

4
New cards
  1. Topic 1 — Pandas Fundamentals | Aggregation and Grouping: groupby | What is printed? Code: df = pd.DataFrame({'Type': ['A','B','A','B','A'], 'Value': [2,4,6,8,10]}); print(df.groupby('Type')['Value'].mean()['A']) | A. 8.0 | B. 6.0 | C. 4.0 | D. 18.0

B. 6.0 — Group A contains Value entries 2, 6, 10. Sum = 18. There are 3 A rows. Mean = 18 / 3 = 6.0. Do not average all five rows.

5
New cards
  1. Topic 2 — Matplotlib | Introduction to Matplotlib: Object-Oriented Interface | Where is the line drawn? Code: fig, ax = plt.subplots(2); ax[1].plot([0, 1], [2, 3]) | A. On a newly created third subplot | B. On the second subplot only | C. On the first subplot only | D. On both subplots

B. On the second subplot only — Python uses zero-based indexes: ax[0] is the first Axes, ax[1] the second. The plot call targets ax[1].

6
New cards
  1. Topic 2 — Matplotlib | Simple Line Plots: Axis Limits | What happens? Code: plt.plot([1,2,3], [3,6,9]); plt.xlim(4,0) | A. The vertical axis runs from 4 down to 0 | B. Matplotlib removes the plotted line | C. The horizontal axis runs from 4 down to 0 | D. All three x-values are permanently changed

C. The horizontal axis runs from 4 down to 0 — xlim controls x (horizontal) display limits. Reversing the limits reverses the axis direction. The original data stays unchanged.

7
New cards
  1. Topic 2 — Matplotlib | Simple Scatter Plots: Marker Properties | Which observation has the largest marker? Code: x=[1,2,3]; y=[4,5,6]; plt.scatter(x,y,s=[10,100,30],c=[0,1,2],alpha=0.4) | A. (3,6) | B. All same | C. (2,5) | D. (1,4)

C. (2,5) — The size array s matches the points in order: (1,4)→10, (2,5)→100, (3,6)→30. 100 is the largest. c sets color; alpha sets transparency.

8
New cards
  1. Topic 2 — Matplotlib | Histograms and Binning: 2D Histograms | What is the counts array shape? Code: counts, xedges, yedges = np.histogram2d(x, y, bins=4); print(counts.shape). Assume valid numeric x,y. | A. (8,) | B. (4,) | C. (16,) | D. (4,4)

D. (4,4) — A 2D histogram divides the x-axis into 4 bins and y-axis into 4 bins. The grid has 4 × 4 = 16 cells, arranged in a 2D array of shape (4,4).

9
New cards
  1. Topic 3 — Probability & Statistics | Nov 17 Lecture: Conditional Probability | Select a card uniformly from numbers 1–12. Given that the number is a multiple of 3, what is the probability it is even? | A. 1/4 | B. 2/12 | C. 1/3 | D. 1/2

D. 1/2 — First narrow the possible outcomes to multiples of 3: {3,6,9,12}. Then count the even ones: {6,12}. That's 2 successes out of 4 eligible outcomes = 2/4 = 1/2. Do not divide by all 12.

10
New cards
  1. Topic 3 — Probability & Statistics | Nov 17 Lecture: Bayes' Theorem | A test flags 80% of people with a condition and 10% without it. Prevalence is 20%. What is P(condition | positive), rounded to one decimal? | A. 80.0% | B. 16.0% | C. 66.7% | D. 20.0%

C. 66.7% — Imagine 100 people: 20 have condition, and 80% of 20 = 16 test positive. Of 80 without condition, 10% of 80 = 8 test positive. Total positives = 16 + 8 = 24. Of the 24 positives, 16 truly have it: 16/24 = 2/3 ≈ 66.7%.

11
New cards
  1. Topic 3 — Probability & Statistics | Nov 17 Lecture: Chebyshev's Inequality | For a distribution with finite variance, at least approximately what percent lies within 3 standard deviations of its mean? | A. 99.7% | B. 75.0% | C. 88.9% | D. 68.0%

C. 88.9% — Chebyshev: at least 1 − 1/k² within k standard deviations (k>1). Set k=3: 1 − 1/9 = 8/9 ≈ 88.9%. Don't confuse it with the normal distribution's 99.7% empirical rule.

12
New cards
  1. Topic 4 — Machine Learning Fundamentals | Nov 10 Lecture: Types of Learning | A retailer has purchase records but no predefined customer labels. Algorithm discovers similar groups. Which type of learning? | A. Unsupervised learning | B. Supervised classification | C. Reinforcement learning | D. Supervised regression

A. Unsupervised learning — The algorithm discovers patterns or groups without known output labels. Supervised learning would require labeled examples.

13
New cards
  1. Topic 4 — Machine Learning Fundamentals | Nov 12 Lecture: Classification vs. Regression | Model predicts rainy/sunny encoded as 0/1. What type of prediction is this? | A. Classification, because outputs represent categories | B. Unsupervised learning | C. Regression, because outputs are numbers | D. Reinforcement learning

A. Classification — 0 and 1 are codes for categories (sunny/rainy). Numeric coding does not turn a categorical target into continuous regression.

14
New cards
  1. Topic 4 — Machine Learning Fundamentals | Nov 10 Lecture: Training, Testing, Accuracy | 160 labeled observations; 75% training and 25% testing. Model gets 30 test predictions correct. What is test accuracy? | A. 80% | B. 25% | C. 18.75% | D. 75%

D. 75% — Step 1: 25% = 1/4, so test set size = 160 ÷ 4 = 40. Step 2: 30 of 40 predictions correct. Step 3: accuracy = 30/40 = 3/4 = 75%. Denominator is the TEST set, not all 160.

15
New cards
  1. Topic 5 — KNN & Cross-Validation | Nov 12 Lecture: Euclidean Distance | Query (1,2). Training points A=(4,6), B=(1,6), C=(4,2). Which is closest? | A. A | B. All equally close | C. B | D. C

D. Point C — Compare squared distances to avoid square roots: A=(4−1)²+(6−2)²=9+16=25; B=(1−1)²+(6−2)²=0+16=16; C=(4−1)²+(2−2)²=9+0=9. Smallest is C, distance 3.

16
New cards
  1. Topic 5 — KNN & Cross-Validation | Nov 12 Lecture: KNN Majority Voting | Five neighbors nearest→farthest: 1.0 Red, 1.2 Blue, 1.5 Blue, 1.8 Red, 2.0 Red. How does prediction change from K=3 to K=5? | A. Blue→Blue | B. Blue→Red | C. Red→Blue | D. Red→Red

B. Blue → Red — K=3: Red 1, Blue 2, so Blue wins. K=5: Red 3, Blue 2, so Red wins. Write two tally columns rather than track the counts mentally.

17
New cards
  1. Topic 5 — KNN & Cross-Validation | Nov 12 Lecture: Selecting K | What can happen when K increases from 1 to a much larger value? | A. Guarantees perfect predictions | B. Stops using training labels | C. Becomes more sensitive to one noisy point and uses fewer observations | D. Becomes less sensitive to noise but more biased toward common classes

D. Less sensitive to an individual noisy point, but potentially biased toward common classes — A larger K votes across more observations; it does not guarantee better accuracy.

18
New cards
  1. Topic 5 — KNN & Cross-Validation | Nov 10 Lecture: K-Fold Cross-Validation | 120 observations, 6 equal non-overlapping folds. How many test observations per round, and how often is each observation in testing? | A. 20, once | B. 100, six times | C. 100, once | D. 20, five times

A. 20, once — Fold size = 120 ÷ 6 = 20. Each fold is testing once; the other 100 observations train the model in that round. Every observation tests once and trains five times.

19
New cards
  1. Topic 6 — Human-Centric Data Science | Nov 19 Lecture: Bias & Fairness | Model is highly accurate overall but makes many more errors for a small demographic group. Which concern? | A. Physical infrastructure security | B. Economic dislocation | C. Data ownership/provenance | D. Model-driven bias and fairness

D. Model-driven bias and fairness — Good overall accuracy can hide much worse performance for a subgroup. The lecture emphasizes difficulties with minority classes and unequal model errors.

20
New cards
  1. Topic 6 — Human-Centric Data Science | Nov 19 Lecture: Integrity & Evaluation | Scientist tests model on 10 splits but reports only the best accuracy, hiding the rest. Which principle is violated? | A. Privacy in aggregated data | B. Integrity in communications and modeling | C. Computational efficiency | D. Independent crowd judgment

B. Integrity in communications and modeling — Showing only the best result is cherry-picking and conceals how variable the model's performance is across splits.

21
New cards