Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please only use numpy package in python here's an output sample Fill in the body of the functions below following their descriptions def getAccuracy(predictions, actual):
please only use numpy package in python
here's an output sample
Fill in the body of the functions below following their descriptions def getAccuracy(predictions, actual): IF IT IT (5 pts) function receives two single dimensional numpy arrays (predictions and actual) then returns the accuracy of the predictions compared with the actual labels. Note: accuracy is out of 100 percent. Parameters: predictions: 1-D numpy array with predictions (either 1, or -1) actual: 1-D numpy array with actual labels (either 1, or -1) return None def getError(predictions, actual): (3 pts) function receives two single dimensional numpy arrays (predictions and actual) then returns the ERROR of the predictions compared with the actual Labels. Note: error is out of 100 percent. Parameters: predictions: 1-D numpy array with predictions (either 1, or -1) actual: 1-D numpy array with actual labels (either 1, or -1) return None In [1]: import numpy as np In [2]: pred = np.array([1, -1, -1]) In [3]: actuals = np.array([1, 1, -1]) In [4]: import homework1solution as hw1 In [5]: hw1.getAccuracy(pred, actuals) Out[5]: 66.66666666666666 In [6]: hw1.getError(pred, actuals) Out[6]: 33.33333333333334Step 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