Decision Tree and Logistic Regression Analysis
Decision Tree and Logistic Regression Analysis
A least-squares regression line is determined by minimizing the sum of squared differences between observed and predicted values. The line's equation is Y=a+bX, where 'b' is the slope calculated by (Σ(xy) - n*x̄*ȳ) / (Σ(x²) - n*x̄²), and 'a' is the y-intercept calculated by ȳ - b*x̄. This line represents the best linear approximation of the relationship between variables. For prediction, substitute the independent variable value (e.g., new car registrations) into this equation to estimate the dependent variable (e.g., sales tax collections). For instance, using a=1.786 and b=0.131 for X=22000, the estimated sales tax collection is 167939 .
Information gain for an attribute is calculated by subtracting the weighted average entropy of possible outcomes from the total entropy of the system. Given a dataset S, it involves computing Entropy(S), then for each attribute (e.g., A), dividing S into subsets (e.g., S_A=0 and S_A=1) and computing entropy for those subsets, weighted by their sizes relative to |S|. The final information gain for attribute A is InfGain(A) = Entropy(S) - (|S_A=0|/|S|)Entropy(S_A=0) - (|S_A=1|/|S|)Entropy(S_A=1). The attribute with the highest information gain is selected as the root. In this scenario, B was chosen over A because it provided higher information gain. Substituting different values in place of “*” demonstrated that B consistently offered higher information gain, indicating that “*” could not be determined solely from information gain comparison .
Given a logistic regression model σ(x,y)=1/(1+exp(-w0-7.5*x-7.5*y)), to achieve 100% classification accuracy, we solve for the conditions that differentiate the classes perfectly. For class 0 (actual output 0), the logistic function's result must be less than 0.5, and for class 1 (actual output 1), it must be 0.5 or greater. Evaluating each condition: For x=y=0, w0 must be such that 1/(1+exp(-w0)) < 0.5 implies w0 < 0; for either x=1 or y=1, w0 < -7.5 is required; and for x=y=1, w0 must satisfy w0 > -15. These conditions combine to form the range -15 < w0 < -7.5 for 100% classification accuracy .
The initial step involves computing the weighted sum WTX = W0 + W1X1 + W2X2 + W3X3 using given initial weights (e.g., W0 = 0.25, W1 = 2.5, W2 = -3.5, W3 = 2.5). For each data instance, compute the hypothesis value using the logistic function 1/(1 + exp(-WTX)). Calculate the gradient of the cost function (partial derivatives with respect to each weight), and update each weight by subtracting the product of the learning rate (e.g., 0.5) and its gradient from the original weight. After updating, compute the new cost function's value, representing the prediction error. The hypothesis is updated accordingly .
Precision is calculated as the number of true positive predictions divided by the sum of true positive and false positive predictions. Recall is the number of true positive predictions divided by the sum of true positive and false negative instances. The F1 measure, or F1 score, is the harmonic mean of precision and recall, calculated as 2*(precision*recall)/(precision+recall). To apply these definitions to the dataset, you identify instances where the model correctly predicts positives and negatives (true positives, true negatives) as well as where it fails (false positives, false negatives) to compute the precision, recall, and subsequently the F1 measure .
Root Mean Square Error (RMSE) measures the average magnitude of the error between predicted values and actual values. It is calculated by taking the square root of the average of squared differences between predictions and actuals, representing the differences in the units of actual values. Mean Absolute Error (MAE) calculates the average absolute differences between predicted values and actual values, providing interpretable performance assessment since it's in the same units as the data. Lower values for both RMSE and MAE indicate better model performance. RMSE is more sensitive to outliers due to squaring the errors. For the given regression model, these metrics assess how well Y=3-4X+2X^2 fits the data .