Comments (7)
Given that the mutation rate parameter is compared against a value sampled randomly between 0 and 1 mutation will be applied in proportion to the mutation rate value provided. E.g. for mutation rate set to 0.6, mutation will be applied ~60% of the times given that the random value is uniformly sampled between 0 and 1.
from ml-from-scratch.
Run this experimental code.
import numpy
mutation_rate = 0.6
times = 0
for i in range(10):
if numpy.random.random() < mutation_rate:
times += 0.1
print(times)
The random value is uniformly sampled but it isn't applied 60% of the time. It is also random.
from ml-from-scratch.
It's applied 100% of the time but it's true roughly 60% of the time. See below.
Eriks-MacBook-Pro:~ erik$ python3
Python 3.7.0 (default, Jun 29 2018, 20:13:13)
[Clang 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> val = 0
>>> for _ in range(100000):
... if np.random.random() < 0.6:
... val += 1
...
>>> print (val)
59966
from ml-from-scratch.
Run it multiple times and compare the results. Numpy's random value generation is independent of boolean comparisons.
from ml-from-scratch.
Mutation rate is commonly implemented as a probability of mutation with respect to the mutation rate parameter. Because of this it's implemented as a comparison between a random value and the parameter.
from ml-from-scratch.
You don't understand what I was trying to communicate, anyways, you did a good job.
from ml-from-scratch.
This is handled similarly to what I've seen in several other reference implementations of GA. Check https://blog.sicara.com/getting-started-genetic-algorithms-python-tutorial-81ffa1dd72f9 in the section where mutation is implemented for instance. The argument that setting a higher mutation rate would not have an impact is clearly false as the statement np.random.random() < mutation_rate
would be true more often and mutation would thereby be applied more often.
from ml-from-scratch.
Related Issues (20)
- Project dependencies may have API risk issues
- Nestrov Accelerated Gradient Descent HOT 1
- Linear Regression Regularization bias HOT 1
- (A doubt NOT an issue) Gradient of loss function having different sign after performing first-degree differentiation of LogisticLoss
- Naive Bayes
- python setup.py install does not work on Windows 10
- Missing number of neurons in grad_w for dense layer
- Error in MLP HOT 1
- BN layer and dropout
- why LassoRegression need X = normalize(polynomial_features(X, degree=self.degree)) code in LassoRegression class?
- Implementations
- ModuleNotFoundError: No module named 'mlfromscratch'
- Linear Discriminant Analysis HOT 1
- TypeError: make_blobs() got an unexpected keyword argument 'n_smaples'
- Adam mhat and vhat updates
- can you add code for intercept /bias to regressions HOT 1
- How to save the model? HOT 2
- No lambda, gamma for XGBoostRegressionTree?
- cross entropy is correct? HOT 2
- ML from scratch HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ml-from-scratch.