practice_paper_1

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 10

1. Which library in Python is commonly used for numerical computing?

a) Pandas
b) NumPy
c) Matplotlib
d) Seaborn
Answer: b) NumPy

2. What does the `axis` parameter specify in NumPy functions like `np.sum()`?
a) It specifies the range of values to include in the calculation
b) It specifies the dimension along which the operation will be performed
c) It specifies the type of operation to perform
d) It specifies the output data type
Answer: b) It specifies the dimension along which the operation will be
performed

3. Which of the following is a correct way to create a NumPy array from a Python
list?
a) `np.array(list)`
b) `numpy.array(list)`
c) `numpy.array([list])`
d) `array(list)`
Answer: a) `np.array(list)`

4. What does the `dtype` parameter specify in NumPy arrays?


a) It specifies the shape of the array
b) It specifies the data type of the array elements
c) It specifies the dimensionality of the array
d) It specifies the indexing scheme used for the array
Answer: b) It specifies the data type of the array elements

5. Which of the following functions is used to generate random numbers in NumPy?


a) `np.rand()`
b) `np.random()`
c) `np.random.rand()`
d) `np.randomize()`
Answer: c) `np.random.rand()`

6. What is the purpose of the `loc` function in Pandas?


a) It is used to access elements by label
b) It is used to access elements by index
c) It is used to access elements by position
d) It is used to perform logical operations on elements
Answer: a) It is used to access elements by label

7. Which of the following is a correct syntax to read a CSV file into a Pandas
DataFrame?
a) `pd.read_csv(file)`
b) `pandas.read_csv(file)`
c) `pd.read_excel(file)`
d) `pandas.read_file(file)`
Answer: a) `pd.read_csv(file)`

8. What does the `head()` function in Pandas DataFrame do?


a) It returns the first few rows of the DataFrame
b) It returns the last few rows of the DataFrame
c) It returns summary statistics of the DataFrame
d) It returns information about the columns of the DataFrame
Answer: a) It returns the first few rows of the DataFrame
9. Which of the following is used to plot data in Python?
a) NumPy
b) Pandas
c) Matplotlib
d) Seaborn
Answer: c) Matplotlib

10. What is the primary role of Matplotlib in data visualization?


a) To manipulate data
b) To analyze data
c) To visualize data
d) To clean data
Answer: c) To visualize data

11. Which of the following is a correct way to create a scatter plot in Matplotlib?
a) `plt.scatterplot(x, y)`
b) `plt.scatter(x, y)`
c) `plt.plot(x, y)`
d) `plt.bar(x, y)`
Answer: b) `plt.scatter(x, y)`

12. What does the `xlabel()` function in Matplotlib do?


a) It sets the label for the x-axis
b) It sets the title of the plot
c) It creates a legend for the plot
d) It adjusts the size of the plot
Answer: a) It sets the label for the x-axis

13. Which of the following is a correct way to create a bar plot in Seaborn?
a) `seaborn.barplot(x=data['X'], y=data['Y'])`
b) `seaborn.plot(x=data['X'], y=data['Y'])`
c) `seaborn.scatterplot(x=data['X'], y=data['Y'])`
d) `seaborn.histplot(x=data['X'], y=data['Y'])`
Answer: a) `seaborn.barplot(x=data['X'], y=data['Y'])`

14. What is the purpose of pair plots in Seaborn?


a) To show the distribution of a single variable
b) To show the relationship between two variables
c) To show the correlation between multiple variables
d) To show the distribution of categorical variables
Answer: c) To show the correlation between multiple variables

15. Which parameter controls the color palette in Seaborn plots?


a) `color`
b) `palette`
c) `hue`
d) `style`
Answer: b) `palette`

16. What is the primary goal of linear regression?


a) To predict continuous values
b) To predict categorical values
c) To perform clustering
d) To perform dimensionality reduction
Answer: a) To predict continuous values

17. Which of the following is a correct syntax to create a linear regression model
in Scikit-learn?
a) `model = sklearn.LinearRegression()`
b) `model = LinearRegression()`
c) `model = sklearn.regression.Linear()`
d) `model = linear_regression()`
Answer

: b) `model = LinearRegression()`

18. What is the purpose of the `fit()` method in a linear regression model?
a) To evaluate the model
b) To make predictions
c) To train the model
d) To transform the data
Answer: c) To train the model

19. Which parameter controls the regularization strength in linear regression


models?
a) `C`
b) `alpha`
c) `lambda`
d) `regularization`
Answer: b) `alpha`

20. What is the main advantage of using regularization in linear regression?


a) To increase the complexity of the model
b) To reduce the number of features
c) To prevent overfitting
d) To speed up the training process
Answer: c) To prevent overfitting

21. What is the primary purpose of logistic regression?


a) To predict continuous values
b) To predict categorical values
c) To perform clustering
d) To perform dimensionality reduction
Answer: b) To predict categorical values

22. Which of the following is a correct syntax to create a logistic regression


model in Scikit-learn?
a) `model = sklearn.LogisticRegression()`
b) `model = LogisticRegression()`
c) `model = sklearn.classification.Logistic()`
d) `model = logistic_regression()`
Answer: a) `model = sklearn.LogisticRegression()`

23. What is the purpose of the `predict()` method in a logistic regression model?
a) To evaluate the model
b) To make predictions
c) To train the model
d) To transform the data
Answer: b) To make predictions

24. Which parameter controls the regularization strength in logistic regression


models?
a) `C`
b) `alpha`
c) `lambda`
d) `regularization`
Answer: a) `C`
25. What is the primary goal of support vector machines (SVM)?
a) To perform clustering
b) To classify data into two or more categories
c) To predict continuous values
d) To perform dimensionality reduction
Answer: b) To classify data into two or more categories

26. Which of the following is a correct syntax to create an SVM model in Scikit-
learn?
a) `model = sklearn.SVM()`
b) `model = SVM()`
c) `model = sklearn.svm.SVC()`
d) `model = svm_model()`
Answer: c) `model = sklearn.svm.SVC()`

27. What does the term "kernel" refer to in SVM?


a) The central point of the data
b) The weights assigned to features
c) A function used to map data to a higher-dimensional space
d) The margin between support vectors
Answer: c) A function used to map data to a higher-dimensional space

28. Which of the following kernel functions is commonly used in SVM for non-linear
data?
a) Linear
b) Polynomial
c) Sigmoid
d) Normal
Answer: b) Polynomial

29. What is the primary purpose of decision trees in machine learning?


a) To perform clustering
b) To classify data into two or more categories
c) To predict continuous values
d) To perform dimensionality reduction
Answer: b) To classify data into two or more categories

30. Which of the following is a correct syntax to create a decision tree model in
Scikit-learn?
a) `model = sklearn.DecisionTree()`
b) `model = DecisionTree()`
c) `model = sklearn.tree.DecisionTreeClassifier()`
d) `model = decision_tree_model()`
Answer: c) `model = sklearn.tree.DecisionTreeClassifier()`

31. What does the term "entropy" refer to in decision trees?


a) The measure of impurity in a node
b) The measure of information gain
c) The measure of variance reduction
d) The measure of model complexity
Answer: a) The measure of impurity in a node

32. Which of the following is a correct syntax to create a random forest model in
Scikit-learn?
a) `model = sklearn.RandomForest()`
b) `model = RandomForest()`
c) `model = sklearn.ensemble.RandomForestClassifier()`
d) `model = random_forest_model()`
Answer: c) `model = sklearn.ensemble.RandomForestClassifier()`

33. What is the primary goal of principal component analysis (PCA)?


a) To increase the number of features
b) To reduce the number of features
c) To scale the features to a similar range
d) To add noise to the features
Answer: b) To reduce the number of features

34. Which of the following is a correct syntax to perform PCA in Scikit-learn?


a) `pca = PCA()`
b) `pca = sklearn.pca.PCA()`
c) `pca = sklearn.PCA()`
d) `pca = principal_component_analysis()`
Answer: c) `pca = sklearn.PCA()`

35. What does the term "explained variance ratio" refer to in PCA?
a) The percentage of total variance explained by each principal component
b) The number of principal components in the dataset
c) The amount of noise added to the dataset
d) The number of features after dimensionality reduction
Answer: a) The percentage of total variance explained by each principal
component

36. Which of the following is a correct syntax to create a neural network model in
Keras?
a) `model = keras.NeuralNetwork()`
b) `model = keras.Sequential()`
c) `model = keras.Model()`
d) `model = NeuralNetwork()`
Answer: b) `model = keras.Sequential()`

37. What is the purpose of the `compile()` method in Keras?


a) To train the model
b) To evaluate the model
c) To configure the model for training
d) To save the model
Answer: c) To configure the model for training

38. Which of the following is a correct syntax to compile a neural network model in
Keras?
a) `model.compile(loss='mse', optimizer='sgd', metrics=['accuracy'])`
b) `compile(model, loss='mse', optimizer='sgd', metrics=['accuracy'])`
c) `model.compile(loss='mse', sgd, ['accuracy'])`
d) `compile(loss='mse', optimizer='sgd', metrics=['accuracy'])`
Answer: a) `model.compile(loss='mse', optimizer='sgd', metrics=['accuracy'])`

39. What does the `fit()` method in Keras do?


a) Trains the model
b) Evaluates the model
c) Transforms the data
d) Plots the data
Answer: a) Trains the

model

40. Which parameter in Keras controls the number of training iterations?


a) `epochs`
b) `batch_size`
c) `learning_rate`
d) `dropout`
Answer: a) `epochs`

41. What is the purpose of the `evaluate()` method in Keras?


a) To train the model
b) To evaluate the model on a validation dataset
c) To make predictions
d) To compile the model
Answer: b) To evaluate the model on a validation dataset

42. Which of the following is a correct syntax to evaluate a neural network model
in Keras?
a) `model.evaluate(X_test, y_test)`
b) `evaluate(model, X_test, y_test)`
c) `model.evaluate(test_data)`
d) `evaluate(X_test, y_test)`
Answer: a) `model.evaluate(X_test, y_test)`

43. What is the purpose of the `predict()` method in Keras?


a) To train the model
b) To evaluate the model
c) To make predictions on new data
d) To compile the model
Answer: c) To make predictions on new data

44. Which parameter in Keras controls the learning rate in optimization algorithms?
a) `epochs`
b) `batch_size`
c) `learning_rate`
d) `dropout`
Answer: c) `learning_rate`

45. Which of the following is not a correct syntax to create a scatter plot in
Matplotlib?
a) `plot.scatter(x, y)`
b) `scatter(x, y)`
c) `scatterplot(x, y)`
d) `plot(x, y)`
Answer: d) `plot(x, y)`

46. What is the purpose of the `ylabel()` function in Matplotlib?


a) It sets the label for the x-axis
b) It sets the label for the y-axis
c) It sets the title of the plot
d) It creates a legend for the plot
Answer: b) It sets the label for the y-axis

47. Which of the following is not a correct syntax to create a bar plot in Seaborn?
a) `sns.barplot(x=data['X'], y=data['Y'])`
b) `barplot(x=data['X'], y=data['Y'])`
c) `seaborn.barplot(x=data['X'], y=data['Y'])`
d) `plot.bar(x=data['X'], y=data['Y'])`
Answer: d) `plot.bar(x=data['X'], y=data['Y'])`

48. What is the purpose of boxplots in data visualization?


a) To show the distribution of categorical variables
b) To show the distribution of continuous variables
c) To show the relationship between two variables
d) To show the correlation between variables
Answer: b) To show the distribution of continuous variables

49. Which of the following is not a correct syntax to create a histogram in


Matplotlib?
a) `plot.hist(data)`
b) `hist(data)`
c) `plt.hist(data)`
d) `matplotlib.hist(data)`
Answer: d) `matplotlib.hist(data)`

50. Which of the following is a correct syntax to create a line plot in Plotly?
a) `plotly.plot(data)`
b) `plotly.line(data)`
c) `plotly.plot(data, mode='lines')`
d) `plotly.graph_objects.Figure(data=graph_data)`
Answer: c) `plotly.plot(data, mode='lines')`

51. What does the term "dropout" refer to in neural networks?


a) Dropping out features with low importance
b) Dropping out neurons during training to prevent overfitting
c) Dropping out samples with missing values
d) Dropping out layers with high variance
Answer: b) Dropping out neurons during training to prevent overfitting

52. Which of the following is a correct syntax to create a neural network model in
TensorFlow?
a) `model = tf.keras.Model()`
b) `model = tf.keras.Sequential()`
c) `model = tf.keras.NeuralNetwork()`
d) `model = tf.NeuralNetwork()`
Answer: b) `model = tf.keras.Sequential()`

53. What is the primary role of the activation function in a neural network?
a) To normalize the input data
b) To control the learning rate
c) To introduce non-linearity
d) To compute the loss function
Answer: c) To introduce non-linearity

54. Which evaluation metric is commonly used for regression problems?


a) Accuracy
b) Precision
c) F1-score
d) Mean Squared Error (MSE)
Answer: d) Mean Squared Error (MSE)

55. What is the purpose of

the `fit()` method in a machine learning model?


a) To evaluate the model
b) To make predictions
c) To train the model
d) To transform the data
Answer: c) To train the model

56. Which of the following is a correct syntax to create a K-means clustering model
in Scikit-learn?
a) `model = sklearn.KMeans()`
b) `model = KMeans()`
c) `model = sklearn.cluster.KMeans()`
d) `model = kmeans_model()`
Answer: c) `model = sklearn.cluster.KMeans()`

57. What is the primary goal of K-means clustering?


a) To perform regression
b) To classify data into two or more categories
c) To predict continuous values
d) To partition data into clusters based on similarity
Answer: d) To partition data into clusters based on similarity

58. Which parameter in K-means clustering controls the number of clusters?


a) `k`
b) `clusters`
c) `centroids`
d) `labels`
Answer: a) `k`

59. Which of the following is a correct syntax to perform principal component


analysis (PCA) in Scikit-learn?
a) `pca = PCA()`
b) `pca = sklearn.decomposition.PCA()`
c) `pca = sklearn.PCA()`
d) `pca = principal_component_analysis()`
Answer: b) `pca = sklearn.decomposition.PCA()`

60. What is the primary goal of principal component analysis (PCA)?


a) To increase the number of features
b) To reduce the number of features
c) To scale the features to a similar range
d) To add noise to the features
Answer: b) To reduce the number of features

61. Which of the following is a correct syntax to create a neural network model in
TensorFlow?
a) `model = tf.keras.Model()`
b) `model = tf.keras.Sequential()`
c) `model = tf.keras.NeuralNetwork()`
d) `model = tf.NeuralNetwork()`
Answer: b) `model = tf.keras.Sequential()`

62. What is the primary role of the activation function in a neural network?
a) To normalize the input data
b) To control the learning rate
c) To introduce non-linearity
d) To compute the loss function
Answer: c) To introduce non-linearity

63. Which evaluation metric is commonly used for classification problems?


a) Mean Squared Error (MSE)
b) Accuracy
c) Root Mean Squared Error (RMSE)
d) R-squared
Answer: b) Accuracy

64. What is the purpose of the `fit()` method in a machine learning model?
a) To evaluate the model
b) To make predictions
c) To train the model
d) To transform the data
Answer: c) To train the model

65. Which of the following is a correct syntax to create a K-means clustering model
in Scikit-learn?
a) `model = sklearn.KMeans()`
b) `model = KMeans()`
c) `model = sklearn.cluster.KMeans()`
d) `model = kmeans_model()`
Answer: c) `model = sklearn.cluster.KMeans()`

66. What is the primary goal of K-means clustering?


a) To perform regression
b) To classify data into two or more categories
c) To predict continuous values
d) To partition data into clusters based on similarity
Answer: d) To partition data into clusters based on similarity

67. Which parameter in K-means clustering controls the number of clusters?


a) `k`
b) `clusters`
c) `centroids`
d) `labels`
Answer: a) `k`

68. Which of the following is a correct syntax to perform principal component


analysis (PCA) in Scikit-learn?
a) `pca = PCA()`
b) `pca = sklearn.decomposition.PCA()`
c) `pca = sklearn.PCA()`
d) `pca = principal_component_analysis()`
Answer: b) `pca = sklearn.decomposition.PCA()`

69. What is the primary goal of principal component analysis (PCA)?


a) To increase the number of features
b) To reduce the number of features
c) To scale the features to a similar range
d) To add noise to the features
Answer: b) To reduce the number of features

70. Which of the following is a correct syntax to create a neural network model in
TensorFlow?
a) `model = tf.keras.Model()`
b) `model = tf.keras.Sequential()`
c) `model = tf.keras.NeuralNetwork()`
d) `model = tf.NeuralNetwork()`
Answer: b) `model = tf.keras.Sequential()`

71. What is the primary role of the activation function in a neural network?
a) To normalize the input data
b) To control the learning rate
c) To introduce non-linearity
d) To compute the loss function
Answer: c) To introduce non-linearity

72. Which evaluation metric is commonly used for classification problems?


a) Mean Squared Error (MSE)
b) Accuracy
c) Root Mean Squared Error (RMSE)
d) R-squared
Answer: b) Accuracy

73. What is the purpose of the `fit()` method in a machine learning model?
a) To evaluate the model
b) To make predictions
c) To train the model
d) To transform the data
Answer: c) To train the model

74. Which of the following is a correct syntax to create a K-means clustering model
in Scikit-learn?
a) `model = sklearn.KMeans()`
b) `model = KMeans()`
c) `model = sklearn.cluster.KMeans()`
d) `model = kmeans_model()`
Answer: c) `model = sklearn.cluster.KMeans()`

75. What is the primary goal of K-means clustering?


a) To perform regression
b) To classify data into two or more categories
c) To predict continuous values
d) To partition data into clusters based on similarity
Answer: d) To partition data into clusters based on similarity

You might also like