Consider the task of predicting the closing price of a stock
Consider the task of predicting the closing price of a stock over the next 5 days. You store your predictions in an array with 5 entries corresponding to your predictions for each of the next 5 days. One week later, you decide to check how accurate your predictions were by comparing them to the actual closing prices over those 5 days, which you now know.One way to measure the accuracy of your predictions is by using the mean absolute percentage error (MAPE), defined by1??−??= ∑| ? ?|×100%,??=1 ??where ? is the actual closing price on day ?, ? is your predicted or forecasted closing price on day ?, and??? = 5 days in the current example.Part 1: Write a method to compute and return the MAPE given two arrays actual and predicted of arbitrary lengths and a user-specified tolerance value actualTol. The method should output the MAPE for your predictions, except in the following two cases:The lengths of actual and predicted do not match. In this case, return −1 and print the following message to the console: Error: Actual and predicted arrays are not of same length!A value in your actual array, i.e. one of your ??’s, is too close to 0, which may cause a divide-by- zero error. A value is too close to 0 if its absolute value is less than a specified tolerance value, e.g.10−9. In this case, return −1 and print the following message to the console (substituting a correct index for t): Error: Entry with index t in actual array is too close to 0!Your method should have the following header:public static double computeMAPE(double[] actual, double[] predicted, double actualTol)Part 2: Overload your method by creating a second version that predicts the same closing price for each of the days. Your actual closing price will still be an array, but your prediction will now be a single value. This overloaded method should have the following header:public static double computeMAPE(double[] actual, double predicted, double actualTol)Submit your source code in a file named MeanAbsPercentError.java! Do not include a main() methodin your submission!Sample output for the following code block:double[] actual = {1, 2, 3, 4};double[] predictedArray = {1, 1, 1, 1};double predicted = 1;System.out.println(computeMAPE(actual, predictedArray, 1e-9)); System.out.println(computeMAPE(actual, predicted, 1e-9));EECS 1510 Spring 2020 Sections 009/011/093 Instructor: Dr. Kevin S. Xu Introduction to Object-Oriented Programming47.91666666666666447.916666666666664
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.
