NEW
Font size
WorksheetsPrelimExam - AppDev - FCPC
Total questions: 43
Worksheet time: 43mins
Supervised learning is best described as:
Learning with no labeled data
Learning from labeled examples to predict outputs for new inputs
Learning to cluster similar items without labels
Learning by random guessing
Which of the following is a typical supervised learning task?
Clustering
Dimensionality reduction
Classification
Anomaly detection (unsupervised)
In supervised learning terminology, the input variables are called:
Targets
Labels
Features
Losses
In supervised learning terminology, the output variable we predict is called:
Features
Labels (or targets)
Hyperparameters
Pipelines
Which algorithm family does Naive Bayes belong to?
Instance-based learning
Probabilistic classifiers
Decision trees
Neural networks
The "naive" assumption in Naive Bayes refers to:
Features are sorted
Features are independent given the class label
Labels are independent of features
The algorithm uses no probabilities
Which Naive Bayes variant is typically used for continuous (real-valued) features?
MultinomialNB
BernoulliNB
GaussianNB
CategoricalNB
Which Naive Bayes variant is commonly used for text classification with word counts?
GaussianNB
MultinomialNB
BernoulliNB
KNeighborsNB
BernoulliNB is particularly suitable when features are:
Continuous numeric counts
Binary (presence/absence) indicators
Multi-class labels
Time series
In scikit-learn, which method trains a classifier?
transform()
fit()
predict_proba()
score()
In scikit-learn, which method is used to predict class labels for new samples?
fit()
transform()
predict()
inverse_transform()
Which scikit-learn function splits data into training and testing sets?
cross_val_score
GridSearchCV
train_test_split
KFold
The smoothing parameter (commonly called alpha) in MultinomialNB is used to:
Scale features
Prevent zero probabilities by Laplace smoothing
Normalize labels
Decrease training time
Which metric is most appropriate for balanced binary classification to measure overall correctness?
Precision
Recall
Accuracy
Log loss
The confusion matrix contains:
Feature correlations
Predicted vs actual counts for each class
Hyperparameter values
Loss per epoch
Which of the following transforms raw text to a matrix of token counts in scikit-learn?
StandardScaler
CountVectorizer
PCA
OneHotEncoder
TfidfVectorizer produces features that:
Are raw counts only
Are TF-IDF weighted scores for terms
Encode categorical variables
Perform feature selection automatically
In a typical text classification pipeline, the correct order is:
Vectorize → fit classifier → predict
Fit classifier → vectorize → predict
Predict → vectorize → fit classifier
Vectorize → predict → fit classifier
Which scikit-learn class implements Multinomial Naive Bayes?
GaussianNB
MultinomialNB
BernoulliNB
NaiveBayesClassifier
Which Naive Bayes variant models binary features (0/1) and can use smoothing?
GaussianNB only
BernoulliNB
MultinomialNB only
LinearNB
If a MultinomialNB model gives zero probability to a feature for a class, what happens without smoothing?
Nothing - model still works fine
The posterior probability for the class can become zero (ruin predictions)
Accuracy improves
The model converts to GaussianNB
Which scikit-learn function helps build a repeatable sequence of preprocessing and estimator steps?
GridSearchCV
Pipeline
fit_transform
cross_val_score
In Python, which library is commonly used for Naive Bayes and many supervised algorithms?
tensorflow
scikit-learn (sklearn)
nltk only
seaborn
Which method of a trained scikit-learn classifier gives a simple performance score on test data (by default accuracy)?
fit()
evaluate()
score()
transform()
In text classification, a "bag-of-words" representation means:
Word order is preserved exactly
Word counts or presence are used, ignoring order
Only the first word is used
Sentences are converted to audio
What is a prior in the context of Naive Bayes?
The loss function used for training
The prior probability of each class before seeing features
A metric for model selection
A tokenizer for text
The Naive Bayes posterior is proportional to:
Prior × Likelihood
Likelihood × Loss
Prior ÷ Likelihood
Only the likelihood
Which preprocessing is commonly necessary before GaussianNB?
Converting continuous features to counts
Scaling/standardizing continuous features (often useful)
Tokenizing text into words
One-hot encoding text into TF-IDF
How does MultinomialNB treat feature values?
As continuous Gaussian variables
As counts or frequencies (discrete non-negative)
As binary only
As time series signals
Which of these is a sign of overfitting?
High train accuracy, much lower test accuracy
Low training and high test accuracy
Identical train/test accuracies both low
Model training takes very little time
To save a trained scikit-learn model to disk, one common tool is:
pandas.to_csv
joblib.dump or pickle
numpy.load
matplotlib.savefig
If you want probability predictions and to choose a threshold other than 0.5, which output do you use?
predict()
fit()
predict_proba() (or decision_function for some models)
score()
For binary text sentiment classification using word presence (1 or 0), which model is a natural choice?
GaussianNB
BernoulliNB
MultinomialNB with continuous smoothing disabled
KMeans
Which tokenizer/transform pair converts text into TF-IDF features in scikit-learn?
OneHotEncoder + LabelEncoder
CountVectorizer + TfidfTransformer OR TfidfVectorizer
StandardScaler + PCA
MinMaxScaler + PolynomialFeatures
Which evaluation metric combines precision and recall into one number?
Accuracy
ROC AUC
F1-score
Mean Absolute Error
If classes are imbalanced, which scikit-learn parameter during train/test splitting helps preserve class proportions?
shuffle=False
stratify parameter in train_test_split
random_state=None
test_size=1.0
In scikit-learn, which object can bundle preprocessing and a classifier into one, allowing fit() to include both steps?
FeatureUnion
Pipeline
ColumnTransformer
TransformerMixin
Which of these is NOT true about Naive Bayes?
It is simple and fast to train
It always requires a lot of data preprocessing to run at all
It can work surprisingly well for text classification
It outputs class probabilities (for supported implementations)
When performing text classification, removing stop words generally:
Always hurts performance
Has no effect on pipeline runtime
May reduce feature size and sometimes improve performance
Converts text to lowercase automatically
Which Python code snippet shows the correct way to import MultinomialNB from scikit-learn?
from sklearn.naive_bayes import MultinomialNB
import sklearn.naive_bayes.MultinomialNB
from sklearn import MultinomialNB
from sklearn.classifier import MultinomialNB
Which of the following best explains why Naive Bayes is fast?
It avoids using probabilities
It computes class-conditional probabilities using simple counts and closed-form formulas (no iterative optimization)
It trains a deep neural network under the hood
It only supports binary classification
For new words in test data not seen in training, smoothing ensures:
An error is thrown
They are ignored completely during prediction
They receive a small non-zero probability instead of zero
They convert to uppercase automatically
When using scikit-learn with text data, a typical supervised workflow is:
Raw text → fit classifier → vectorize → predict
Raw text → vectorize → train (fit) classifier → evaluate on test set → predict on new text
Raw text → PCA → predict
Raw text → cluster → label → predict
