You are on page 1of 1

(AI-2151) -Artificial Intelligence

Assignment # 2

Curve fitting using Genetic Algorithms


We covered in class on how to find the best parameters for the line fitting example. In this
assignment you have to use the same ideas to find the parameters of the following equation:
𝑦 = 𝑎𝑥 5 + 𝑏𝑥 4 + 𝑐𝑥 3 + 𝑑𝑥 2 + 𝑒𝑥 + 𝑓
Please note that your genes in this case are: a, b, c, d, e, f
Use the following dataset:
(x, y) : {(1,1.5), (0.5, 1), (2, 1.5), (2.5, 2.5), (3, 3.5), (4, 5), (5, 5.5), (6, 5.6), (6.5, 5.8), (6.7, 5.9)}
You have to create a Python notebook, generate a initial random population of 100 individuals.
(For this you can generate random numbers between 0 and 10 using the randint function from the
random package). Then, you have to apply mutation 100 times to find the best parameter values.
Then, print the best gene values.
Note:
1. When you have to create a new individual, use the deepcopy function from the copy
package in Python.
2. To apply mutation i.e. to toggle k bit of a number n, you can define the following
function in your notebook:

3. Only submit jupyter notebook file.

You might also like