Machine Learning Question Bank
Machine Learning Question Bank
Python libraries play a crucial role in machine learning by providing tools for tasks ranging from numerical computations to data manipulation. NumPy offers capabilities for efficient numerical operations on arrays and matrices, crucial for any matrix-based data analysis or machine learning algorithm. Pandas offers sophisticated data manipulation tools, including data frames that allow for operations like filtering, grouping, and merging—a vital resource for preparing and wrangling datasets .
To classify a new instance using the Naïve Bayes Algorithm in the PlayTennis dataset, calculate the class probabilities for the instance given its feature values. For a new instance x' = (Outlook=Sunny, Temperature=Mild, Humidity=Normal, Wind=Strong), compute P(Yes|x') and P(No|x') by using the probabilities of each feature value conditioned on those classes multiplied by the prior probability for each class. The class with the higher posterior probability is chosen as the prediction .
Choosing the right K value in the KNN algorithm involves balancing overfitting and underfitting. A small K value may lead to noise affecting predictions and causing overfitting, whereas a large K can smooth out predictions too much, leading to underfitting. A common approach is to use cross-validation to iterate through various K values, observing which offers the best performance on validation data . Challenges include computational intensity with large datasets and deciding a proper distance metric, particularly in high-dimensional spaces.
Logistic regression differs from linear regression as it is used for binary classification problems rather than predicting continuous values. While linear regression predicts a dependent variable as a sum of weights and features (Y = mX + b), logistic regression applies a logistic function to ensure the output ranges between 0 and 1. A practical example of logistic regression is predicting whether a customer will purchase a product based on their previous behavior .
Entropy measures the impurity or uncertainty in a dataset. In decision trees, it is used to determine the best split by evaluating how each attribute's splitting influences the distribution of labels. Splits that result in lower entropy (more homogenous subsets) are preferred as they indicate a more informative division. By calculating entropy before and after a potential split, one can assess the attribute's effectiveness in contributing to a clear decision-making process, guiding the building of the decision tree .
Machine Learning differs from classical programming in that it focuses on constructing models from data rather than relying on predefined rules. In classical programming, logic and decisions are coded explicitly. In contrast, machine learning derives them from the data patterns. The main types of machine learning are supervised learning, which uses labeled data for training (e.g., regression, classification), unsupervised learning, that finds patterns or groupings without labeled responses (e.g., clustering, association), and reinforcement learning, where an agent learns to make decisions by receiving rewards for actions .
Reinforcement learning is distinct because it involves learning from feedback in the form of rewards or penalties, unlike supervised learning (which uses labeled data) and unsupervised learning (which looks for hidden structure in unlabeled data). The AI agent learns by interacting with its environment, maximizing cumulative reward through trial and error. Real-world applications include autonomous robotics, game AI development, and resource management, where the learning process derives from continuous interaction and adjustment .
A classification problem involves predicting a discrete label from a set of categories, while a regression problem involves predicting a continuous value. For example, predicting whether a certain company will declare bankruptcy (yes/no) is a classification problem . Predicting tomorrow's temperature in degrees is a regression problem as it requires predicting a continuous value .
Information Gain measures how much uncertainty in the target variable (entropy) is reduced by knowing the value of an attribute. It helps in constructing decision trees by selecting the attribute that provides the highest Information Gain at each node. For example, by calculating the Information Gain for various attributes like Color, Size, Act, and Age in the Balloons Dataset, one can identify the root node to start constructing the decision tree .
Treating stock market price prediction as a regression problem implies modeling the continuous price changes over time, focusing on quantitative predictions that involve patterns, trends, and numerical dependencies. In contrast, company bankruptcy prediction is a classification problem, focused on categorizing companies into binary outcomes (bankruptcy/no bankruptcy), which requires identifying patterns and risk factors that discriminate between these categories. The choice affects the type of model, evaluation metrics, and feature importance focus, which needs aligning to the nuances of financial forecasting .