1.
what are the steps involved in creating a ml project
ans:
step1: find (see or identifying) the problem statement
step2: data preprocessing
-> data cleaning - removing or cleaning the null values or the empty values or rows
-> EDA - visualizing the data in picture format or an image format for the better
understanding of data
-> feature engineering - Feature engineering transforms raw data into meaningful
features that improve a machine learning model's accuracy, efficiency, and ability
to learn. It helps the model better understand patterns, handles data preparation
(like encoding or scaling), and incorporates domain knowledge to enhance
performance.
step3: model training
step4: model building
-> supervised ( Classification - category, regression - continues).
-> unsupervised
-> reinforcement
step5: model evaluation
example project
-> label encoding
*setosa-0
*versicolor-1
*virginica-2
#.fit()-finds all the uniqe species names and assings them integer labels
#transform()-converts all the species names in the column to those integer labels
step3: model training
x= input
y= output(column-species, value-setosa,versicolor,virginica)
#split into training and testing sets
X_train , x_test , Y_train , Y_test = train_test_split(x,y,
test_size=0.2,random_state=42)
|__> how many times the data is being looped for testing
21-06-2025 (SUPRISE TEST)
QUESTIONS
1. What will be the output of the following code?
a = [1, 2, 3]
b = a
[Link](4)
print(a)
[1 2 3 4]
[4 3 21]
1
Error
2. Which of the following data structures is mutable in Python?
Tuple
String
List
Integer
3. Which Python built-in function returns the number of items in an object?
size()
count()
length()
len()
4. Which data type is best suited to store unique values only?
List
Tuple
Dictionary
Set
5. What will the following code output?
x = {1, 2, 3}
y = {3, 4, 5}
print(x & y)
{1 2 3 4 5}
{3}
None
{}
6. Which keyword is used to define a function in Python?
func
def
define
function
7. What is the output of the following code?
print(bool("False"))
False
True
None
0
8. What does the following list comprehension do?
[x for x in range(5) if x % 2 == 0]
Filters even numbers from 0 to 4
Filters odd numbers from 0 to 4
Generates numbers 0 to 5
Syntax error
9. Which of the following is not a valid Python data structure?
Stack
List
Dictionary
Set
10. How do you access the first element of a list data?
data[1]
[Link]()
data[0]
[Link](0)
11. Which of the following is used to check missing values in pandas?
[Link]()
[Link]()
[Link]()
[Link]()
12. How to drop duplicate rows in a Data Frame df?
df.remove_duplicates()
df.drop_duplicates()
df.clean_duplicates()
df.clear_duplicates()
13. Which method is used to fill missing values with the mean in a DataFrame?
fillna(mean())
[Link]([Link]())
[Link]([Link]())
[Link](mean())
14. In NumPy, what does [Link]((3, 2)) create?
1D array of 3 zeros
3x2 array filled with zeros
2x3 array filled with ones
None of the above
15. Which attribute gives the shape of a NumPy array?
size
dim
shape
array_shape
16. What is the output of [Link]()?
Only mean and std
Summary statistics
Data types of columns
Column names
17. What will df[df['col'] > 100] return?
Rows where col > 100
Columns greater than 100
All columns
Error
18. Which of the following merges two DataFrames based on a common column?
[Link]()
[Link]()
[Link]()
[Link]()
19. Which command converts a NumPy array to a DataFrame?
[Link](array)
DataFrame(array)
[Link](array)
[Link](array)
20. How to get the number of non-null values per column?
[Link]()
[Link]()
[Link]()
[Link]()
21. Which method removes rows with missing values?
dropna()
fillna()
isnull()
drop()
22. Which encoding method is preferred for categorical features with no ordinal
relationship?
Label Encoding
One-Hot Encoding
Binary Encoding
Hash Encoding
23. What is the purpose of standardization in feature engineering?
To scale features between 0 and 1
To reduce features
To convert features to a standard format
To make mean = 0 and std = 1
24. Which of the following is a form of feature scaling?
Log Transformation
One-Hot Encoding
Min-Max Normalization
PCA
25. Which transformation is best for skewed distributions?
StandardScaler
LabelEncoder
Log Transformation
Count Encoding
26. Which method is used to find correlation between numerical features?
[Link]()
[Link]()
[Link]()
[Link]()
27. Which technique is used to reduce the number of input features?
Feature Selection
Feature Encoding
Feature Expansion
Label Encoding
28. Which sklearn module contains data preprocessing tools?
[Link]
[Link]
sklearn.model_selection
sklearn.linear_model
29. Which scaler transforms features by removing the median and scaling by the IQR?
StandardScaler
RobustScaler
MinMaxScaler
PowerTransformer
30. When should you use Label Encoding?
When features are numerical
When features are images
When categorical values are ordinal
When features are missing
31. Which function creates a histogram in Matplotlib?
plot()
scatter()
hist()
bar()
32. Which type of plot is best to show distribution of a numerical feature?
Bar plot
Pie chart
Box plot
Line chart
33. Which Matplotlib function is used to display the plot?
show()
display()
draw()
render()
34. Mean, median, and mode are examples of:
Inferential Statistics
Descriptive Statistics
Predictive Statistics
Regression Statistics
35. Which measure of central tendency is least affected by outliers?
Mean
Median
Mode
Variance
36. Variance measures:
Central value
Shape of the distribution
Spread of the data
Count of values
37. A high standard deviation indicates:
Data points are close to the mean
Less spread in data
More spread in data
All data points are equal
38. The p-value helps determine:
Correlation
Statistical significance
Accuracy
Standard deviation
39. Which statistical test is used to compare means of two independent samples?
Z-test
Chi-square test
t-test
ANOVA
[Link] does a correlation coefficient close to -1 indicate?
No correlation
Strong positive correlation
Strong negative correlation
Weak correlation
[Link] does the following Pandas expression do?
[Link][:, [Link]().mean() > 0.3]
Selects rows with more than 30% missing values
Drops columns with more than 30% missing values
Selects columns with more than 30% missing values
Fills missing values with 0
[Link] does [Link](df['col'] > 100, 1, 0) return?
The indexes of rows where col > 100
Replaces values >100 with 1 and others with 0
Filters rows where col > 100
Drops values >100
[Link] feature selection, what does a VarianceThreshold of 0.0 do?
Removes all features
Keeps all features
Removes features with zero variance
Removes features with null values
[Link] plot is best to detect multivariate outliers?
Boxplot
Histogram
Pairplot
Scatterplot Matrix
[Link] encoding technique is best for high-cardinality nominal features?
One-Hot Encoding
Label Encoding
Target Encoding
Ordinal Encoding
[Link]’s the output shape of this code?
[Link](4, 1) * [Link](1, 5)
(4, 5)
(1, 1)
(4, 1)
Error
[Link] method can handle both numerical and categorical missing data efficiently
during imputation?
SimpleImputer
IterativeImputer
KNNImputer
fillna()
[Link] metric is best when data has many outliers?
Mean
Variance
Median Absolute Deviation (MAD)
Standard Deviation
[Link] standardization, if a feature has a std deviation of 0, what happens?
All values become NaN
All values become 0
Division by zero error
The feature is scaled between 0 and 1
[Link] Python, how do you apply a row-wise lambda to two columns in a DataFrame?
df['new'] = [Link](lambda x: x[0] + x[1])
df['new'] = [Link](lambda x: x['a'] + x['b'])
df['new'] = [Link](lambda x: x['a'] + x['b'], axis=1)
df['new'] = df['a'] + df['b']
[Link] is the goal of dimensionality reduction?
Increase accuracy
Reduce number of features with minimal loss of information
Remove outliers
Increase number of features
[Link] your data has multicollinearity, which approach is most suitable?
Imputation
Log transformation
Principal Component Analysis (PCA)
MinMax Scaling
[Link] does .pivot_table() in pandas allow you to do that .groupby() does not?
Group by categorical only
Group by multiple columns
Use multiple aggregation functions with reshaped format
Faster processing
[Link] does [Link](arr, 10, 20) do?
Drops values <10 and >20
Replaces values <10 with 10 and >20 with 20
Normalizes values
Makes array binary
[Link] is the drawback of one-hot encoding high-cardinality features?
Memory efficiency
Speed improvement
Reduced interpretability
Low variance
[Link] Pandas function can reshape long data to wide format?
melt()
reshape()
pivot()
explode()
[Link] does a p-value < 0.05 typically indicate in hypothesis testing?
Accept the null hypothesis
Insufficient evidence
Strong evidence to reject null hypothesis
High confidence in null
[Link] scaling method is robust to outliers?
StandardScaler
MinMaxScaler
Normalizer
RobustScaler
[Link] a left-skewed distribution, the relationship is:
Mean > Median > Mode
Mean < Median < Mode
Mean = Median = Mode
Mean > Mode > Median
[Link] of the following operations is not vectorized in NumPy?
Element-wise addition
Dot product
Broadcasting
Loop over rows using for-loop
ANSWER
🧠 Data Analysis and Preprocessing
1. ✅ [1, 2, 3, 4]
2. ✅ List
3. ✅ len()
4. ✅ Set
5. ✅ {3}
6. ✅ def
7. ✅ True
8. ✅ Filters even numbers from 0 to 4
9. ✅ Stack
10. ✅ data[0]
11. ✅ [Link]()
12. ✅ df.drop_duplicates()
13. ✅ [Link]([Link]())
14. ✅ 3x2 array filled with zeros
15. ✅ shape
16. ✅ Summary statistics
17. ✅ Rows where col > 100
18. ✅ [Link]()
19. ✅ [Link](array)
20. ✅ [Link]()
21. ✅ dropna()
22. ✅ One-Hot Encoding
23. ✅ To make mean = 0 and std = 1
24. ✅ Min-Max Normalization
25. ✅ Log Transformation
26. ✅ [Link]()
27. ✅ Feature Selection
28. ✅ [Link]
29. ✅ RobustScaler
30. ✅ When categorical values are ordinal
📊 Visualization and Statistics
31. ✅ hist()
32. ✅ Box plot
33. ✅ show()
34. ✅ Descriptive Statistics
35. ✅ Median
36. ✅ Spread of the data
37. ✅ More spread in data
38. ✅ Statistical significance
39. ✅ t-test
40. ✅ Strong negative correlation
🧩 Advanced Feature Engineering and Transformation
41. ✅ Selects columns with more than 30% missing values
42. ✅ Replaces values >100 with 1 and others with 0
43. ✅ Removes features with zero variance
44. ✅ Scatterplot Matrix
45. ✅ Target Encoding
46. ✅ (4, 5)
47. ✅ IterativeImputer
48. ✅ Median Absolute Deviation (MAD)
49. ✅ Division by zero error
50. ✅ df['new'] = [Link](lambda x: x['a'] + x['b'], axis=1)
📉 Dimensionality Reduction, Statistical Testing, and Efficiency
51. ✅ Reduce number of features with minimal loss of information
52. ✅ Principal Component Analysis (PCA)
53. ✅ Use multiple aggregation functions with reshaped format
54. ✅ Replaces values <10 with 10 and >20 with 20
55. ✅ Memory efficiency
56. ✅ pivot()
57. ✅ Strong evidence to reject null hypothesis
58. ✅ RobustScaler
59. ✅ Mean < Median < Mode
60. ✅ Loop over rows using for-loop