Question
Unfortunately the error message is still there when I run this line ( p_cc_given_loan = len(cc_loan_acceptors) / len(train_data[train_data['Loan'] == 1]) ZeroDivisionError: division by zero Can
Unfortunately the error message is still there when I run this line ( p_cc_given_loan = len(cc_loan_acceptors) / len(train_data[train_data['Loan'] == 1])
ZeroDivisionError: division by zero
Can you explain more ????
This is your Explanation:
Approach to solving the question:
To compute the requested probabilities, we need to manipulate the train_data DataFrame. Specifically, we need to filter it to select the relevant subsets, and then compute the proportions by dividing the lengths of these subsets by the lengths of other subsets.
For example, to compute P(CC = 1 | Loan = 1),
- We first filter the DataFrame to select the rows where Loan = 1 and CCAvg > 0.
- We then compute the proportion of these rows relative to the rows where Loan = 1.
- We do the same thing for P(Online = 1 | Loan = 1), P(CC = 1 | Loan = 0), P(Online = 1 | Loan = 0), and P(Loan = 1).
- To compute P(Loan = 0), we simply count the number of rows where Loan = 0 and divide it by the total number of rows in the data frame.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started