Question: Problem 4 b: Plotting the Prediction line Now, we ll use the predict _ need function to plot the best - fit line for US
Problem b: Plotting the Prediction line
Now, well use the predictneed function to plot the bestfit line for US consumption and a prediction out to years from now.
For this problem Problem b add a line of code to call plotlinearpredictiondata "USA" in your main code near the bottom of fishing.py it must come after the call to parsedata Running your program should then result in no errors and a new file named USAneedprediction.pngbeing created in the same folder as your program.
The plotlinearpredictiondata countrycode function is given to you in the utils.py starter file. This function takes the return value from parsedata as its first parameter and a country code egUSA as its second parameter. It then calls the predictneed function you wrote in Problem a with the production need data for the given country code, and then plots the bestfit line and prediction. You do not need to write this function; its already been written for you. But it does rely on correct implementations for previous problems.
This function has no return value, but calling plotlinearpredictiondata "USA" should produce a plot that resembles the following:
Problem : Total Worldwide Production Need
Problem a:
So now that weve done all that work, how much seafood will the entire world need to produce years from now?
For this problem, write a function called totalproductionneeddata yearstopredict that returns a single number: how many metric tonnes will the world need to produce yearstopredict years from now?
This function should do the following:
Take as input the data returned from Problem s parsedata and a number of years in the future to predict.
For each country code, predict the production need for yearstopredictyears from now using Problem as predictneed function.
Get the last value in the predicted values.
For example, if you assign the return value from predictneed to prediction, you should be able to get the last value with predictionvalues
Sum up all of the predicted values.
Return the total.
Running your program with small.csv as the input file to parsedata, totalproductionneed should return a total production need of Your degree of precision may vary.
Problem b: Running with the large file:
At this point, its time to run with the larger data file. Change the call to parsedata to use "large.csv as its input. Then, at the very end of your program, add a print statement to print out the total you return from totalproductionneed. Your program should print the following:
Metric tonnes of seafood needed to be produced in years:
Info
You can format very large numbers using Pythons fstring syntax. For example, if total doing printftotalneed:,f would print
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
