Algorithms for Data Science
In this assignment, you will be using dynamic programming to select a set of investment options
that maximize your return on investment. You will be given a file of investment options along
with the estimated return on investment for each one. You also have a given amount of money
The specific file of investment options you will be given will vary, but you will always
have the following three pieces of information you can obtain from the file:
Investment Name, Investment Cost, Estimated Return On Investment
Start by putting all your code in a file called portfolio.py. Create a function called
load Investments that takes in the investment Filename and returns a list of possible investment
options: name, cost, and estimated return. You will be given a file of actual investment options
along with specific directions for that file on how to obtain the three pieces of information
necessary for this assignment.
Then make a function called optimize Investments that takes the list of possible investments
along with the amount of money available to spend. This function should return both the
optimal return on investment amount as well as the actual investments selected to achieve this
optimal return. Implement this function using dynamic programming.
For dynamic programming, one needs a recursive breakdown of the problem. We have a
number of possible investments and an amount we are able to spend. At each step we can
decide to either include investment x or exclude it.
If we include it, then we are left with a smaller problem of finding the optimal return with all the possible investments without investment x with a smaller amount we are able to spend (because we purchased investment x). If we exclude it, then we are left with a smaller problem of finding the optimal return with all the possible investments without investment x but with the same amount of money to spend as we had before. A DAC solution could be attempted, but it ends up having too much repeated work. Therefore, we will implement our solution with dynamic programming. Note that this is a 2-D problem (number of investments and amount of money to spend). Thus, we will need a 2-D table.
The second step is filling in the base cases. Note that when we don’t select any investments, no
matter how much money we have to spend (top row), then we get no return on investment.
This is a natural base case. The third step is to identify the goal location in the table. This will be
the position where we are allowed to include all investments with our full allocation of funds to
spend. This will be the lower-right corner.
The last step in computing any optimal table is to determine the order in which to fill in the table, keeping in mind that one always needs all the results for the recursive subproblems available to fill in the next location.
After the optimal table is computed, a traceback table needs to be added to the
implementation so we can find the actual investments that produce the optimal. Recall that
traceback tables store the “winning” options at each step and are then used at the end to trace
back through these winning options.
Your code should return the optimal return on investment number as well as a list of the investment names used to obtain this optimal number. Note that this is a similar problem to the 0/1 Knapsack problem, and you should use that idea to help guide you through your implementation
Why Choose Us
Premium Quality Papers
We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.
Professional Assignment Writers
We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.
Free Unlimited Revisions
If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.
Timely Delivery and 100% Money-Back-Guarantee
All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed
Original & Confidential
We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.
Customer Support 24/7
Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.
Try it now!
How it works?
Fill in the order form and provide all details of your assignment:
Place your order
Fill in the order form and provide all details of your assignment.
Proceed with the payment
Choose the payment system that suits you most.
Receive the final file
Once your paper is ready, we will email it to you.
Our Assignment Writing Help Services
No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.
No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.
Admission and Business Papers
An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.
Editing and Proofreading
Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.
If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.