What is a p-value?
A p-value measures how compatible the observed data are with the null hypothesis. It is not the probability that either hypothesis is true, and it is not an effect size.
练习 60 道原创数据科学面试题,覆盖统计、概率、Python、pandas、SQL、机器学习、指标与 A/B 测试,每题附答案与解析。
A p-value measures how compatible the observed data are with the null hypothesis. It is not the probability that either hypothesis is true, and it is not an effect size.
The normal distribution is symmetric and bell-shaped. Exponential and Poisson distributions are right-skewed, and a uniform distribution is flat.
Standard deviation quantifies how much values vary around the mean. The center is measured by the mean or median, the mode is the most frequent value, and quartiles describe distribution shape.
A two-sample t-test compares means of two independent groups. A paired t-test compares related measurements, ANOVA compares three or more groups, and chi-square tests categorical associations.
Correlation quantifies the strength and direction of a linear relationship between two variables. It does not prove causation, measure mean differences, or describe variance alone.
A correlation of 0 means no linear relationship. Values near 1 indicate a strong positive relationship, and values near -1 indicate a strong negative relationship.
A confidence interval estimates a range for a population parameter with a confidence level such as 95%. It is not a sample range, effect size, or single prediction.
The median is less affected by extreme values than the mean. The mode is the most frequent value, and the range is a spread measure, not central tendency.
P(A|B) is the conditional probability of A occurring when B is known to have occurred. It is not the joint, union, or reverse conditional probability.
Bayes theorem calculates a posterior probability by combining a prior with evidence. It is not for means, correlation, or dimensionality reduction.
The Poisson distribution models the number of events in a fixed interval when events occur independently. Binomial models counts of successes in trials, and normal and uniform are continuous.
A type I error is rejecting the null hypothesis when it is actually true, also called a false positive. Failing to reject a false null is a type II error.
pd.read_csv() reads a CSV file into a DataFrame. The other method names do not exist in pandas.
.head() returns the first rows, defaulting to five. .tail() returns the last rows; the other names are not pandas methods.
.dropna() removes missing values, while .fillna() fills them with a value. .isna() identifies missing values, and .replace() swaps values.
.fillna() replaces missing values with a specified value or method. .dropna() removes them, .notna() checks for present values, and .rename() changes labels.
.groupby() splits data into groups and lets you aggregate with methods such as sum, mean, or count. .merge() combines tables, .pivot() reshapes, and .sort_values() sorts.
.merge() joins DataFrames on keys, similar to SQL joins. .concat() stacks them, .append() is deprecated for rows, and .stack() reshapes columns.
.value_counts() returns counts for each unique value in a Series. Sorting, filling missing values, and means are separate operations.
.apply() applies a function to each element or row. .sum() aggregates, .describe() gives summary statistics, and .dtypes shows data types.
A DataFrame is a two-dimensional labeled data structure with rows and columns. A Series is one-dimensional, and a database or plot is a different concept.
.describe() computes statistics such as count, mean, standard deviation, min, and quartiles. .head() shows rows, .shape gives dimensions, and .columns lists column labels.
NumPy provides ndarray objects for numerical computation. Requests handles HTTP, Flask builds web apps, and Selenium automates browsers.
Matplotlib is a core plotting library, often paired with Seaborn for statistical graphics. Pandas handles data, SciPy provides scientific functions, and scikit-learn provides machine learning models.
WHERE filters individual rows before grouping. HAVING filters groups, GROUP BY creates groups, and ORDER BY sorts results.
GROUP BY groups rows by one or more columns so aggregates can be computed. WHERE filters rows, HAVING filters groups, and LIMIT restricts rows.
HAVING filters grouped results after aggregation, while WHERE filters rows before grouping. GROUP BY creates groups, and JOIN combines tables.
LEFT JOIN keeps all left rows and fills unmatched right values with null. INNER JOIN keeps only matches, RIGHT JOIN keeps all right rows, and FULL OUTER JOIN keeps all rows from both.
COUNT() counts rows or non-null values. SUM() adds numeric values, AVG() computes the average, and MAX() returns the largest value.
AVG() returns the mean of a numeric column. COUNT() counts rows, SUM() totals values, and DISTINCT is a keyword, not an aggregate function.
SELECT DISTINCT returns unique combinations. UNIQUE is not a standard query keyword in most SQL dialects, and FILTER or ONLY are not used this way.
ORDER BY sorts rows by one or more columns in ascending or descending order. GROUP BY groups rows, WHERE filters, and LIMIT restricts the number of rows.
LIMIT restricts the number of rows in PostgreSQL, MySQL, and SQLite. TOP is used in SQL Server, OFFSET skips rows, and COUNT aggregates.
LIKE matches patterns with wildcards such as % and _. Equality, IN, and BETWEEN test exact or range values, not patterns.
A primary key uniquely identifies each row and cannot contain null values. A foreign key references another table, and indexes improve performance.
INNER JOIN returns only rows where the join condition matches in both tables. LEFT and RIGHT joins include unmatched rows from one side, and FULL OUTER JOIN includes all rows.
Supervised learning trains on labeled examples to predict target outcomes. Clustering is unsupervised, dimensionality reduction transforms features, and generation creates new data.
Classification predicts discrete labels, while regression predicts continuous values. Clustering finds groups and dimensionality reduction compresses features.
Regression predicts numeric outcomes such as price or temperature. Classification predicts categories, clustering groups data, and association finds rules.
Logistic regression models the probability of a binary outcome. K-means clusters, Apriori finds associations, and PCA reduces dimensions.
Overfitting happens when a model captures noise in training data and performs poorly on new data. Underfitting is when a model is too simple.
Limiting depth, pruning, and regularization reduce overfitting. Increasing depth and adding features usually make overfitting worse.
Cross-validation splits data into folds and evaluates the model across folds for a more stable estimate. Training once on all data leaves no independent evaluation.
Precision is TP / (TP + FP), the share of positive predictions that are correct. Recall is TP / (TP + FN), the share of actual positives found.
Recall is TP / (TP + FN), measuring how many actual positives were captured. Precision is TP / (TP + FP), and F1 combines precision and recall.
F1 is the harmonic mean of precision and recall, balancing both. Accuracy and error are separate measures, and F1 is not a sum or ratio of negatives.
F1 is useful for imbalanced data because accuracy can be misleading when one class dominates. MSE and R-squared are for regression.
Feature engineering creates, transforms, or selects features so models learn better patterns. It is separate from sample size and hyperparameter tuning.
K-means partitions data into clusters based on distance. Linear and logistic regression are supervised, and decision trees can be used for classification or regression.
A/B testing randomly assigns users to versions and measures the effect of a change. It is not model evaluation, data splitting, or database comparison.
A metric is a quantifiable measure such as conversion rate or retention. It is not a column, model, or test, although models are evaluated with metrics.
Conversion rate is the share of visitors who complete a desired action, such as purchase or sign-up. The other formulas describe different metrics.
Retention measures how many users come back after a defined period. New users, cancellations, and session length are separate metrics.
Churn is the loss of customers or users over time. Referrals, purchases, and email opens are different behaviors.
Cohort analysis follows groups, such as users acquired in the same month, to compare behavior over time. It is not A/B testing, algorithm testing, or a simple mean.
The null hypothesis states there is no effect or difference, and experiments test whether evidence supports rejecting it. The alternative hypothesis claims an effect exists.
NumPy, pandas, and Matplotlib are used for data analysis and visualization. Flask is a web framework, not a data analysis library.
COUNT, AVG, and SUM are aggregate functions. DISTINCT is a keyword used with SELECT, not an aggregate function.
A low p-value provides evidence against the null hypothesis, but it does not prove the alternative hypothesis. Results depend on study design, assumptions, and effect size.
Precision is TP / predicted positives, recall is TP / actual positives, F1 balances precision and recall, and accuracy is correct predictions divided by total predictions.