Comments (11)
How would you like it normalized?
from brain.js.
To fit the brain input/output. If my variables are greater than 1 I want it to normalize the data to be within a range of 0 to 1.
from brain.js.
I've been thinking about this for a bit, currently there is something like this built into brain.js. Consider the current README.md:
var net = new brain.NeuralNetwork();
net.train([{input: { r: 0.03, g: 0.7, b: 0.5 }, output: { black: 1 }},
{input: { r: 0.16, g: 0.09, b: 0.2 }, output: { white: 1 }},
{input: { r: 0.5, g: 0.5, b: 1.0 }, output: { white: 1 }}]);
var output = net.run({ r: 1, g: 0.4, b: 0 }); // { white: 0.99, black: 0.002 }
Here r
, g
, and b
are normalized to the layers associated with them. This may not be exactly what you want, especially if you have thousands or more types. Another way you could do it, say if you had an object with the properties that you'd like to normalize:
var keys = mySuperObject.keys();
var normalizedValues = keys.map(function(key, i) {
return i / keys.length;
});
from brain.js.
Lets say I have 10 mapped keys. If the value of one of those keys is 30 and I'm dividing that by 10 then the returned value is 3. That's not between 0 and 1.
A way I've found is iterating through your csv and finding the highest value. Then going back through the list again and dividing all values by this max value. This becomes slow when you have many values.
Maybe we can use some variation of the sigmoid function and tailor it to our needs?
from brain.js.
There is probably a better way, but try something like this:
var values = [];
for (var i = 0, max = 10000; i < max; i++) {
values.push(i);
}
var normalizedInputValues = [];
values.forEach(function(value, index) {
normalizedInputValues.push(index / values.length);
});
for (i = 0, max = normalizedInputValues.length; i < max; i++) {
if (normalizedInputValues[i] > 1) throw new Error('This should never happen, but there is a value above 1 here at index of ' + i);
}
//have fun
from brain.js.
In the above mentioned:
var net = new brain.NeuralNetwork();
net.train([{input: { r: 0.03, g: 0.7, b: 0.5 }, output: { black: 1 }},
{input: { r: 0.16, g: 0.09, b: 0.2 }, output: { white: 1 }},
{input: { r: 0.5, g: 0.5, b: 1.0 }, output: { white: 1 }}]);
var output = net.run({ r: 1, g: 0.4, b: 0 }); // { white: 0.99, black: 0.002 }
The data is sort of normalized, but by layer, would this work for you?
var net = new brain.NeuralNetwork();
net.train([
{input: { one: 0.03, two: 0.7, ... thirty: 0.5 }, output: { isValid: 1 }},
{input: { one: 1, two: 0.02, ... thirty: 0.33 }, output: { isValid: 1 }},
{input: { one: 0.3, two: 0.2, ... thirty: 0.2 }, output: { isValid: 0 }}
]);
var output = net.run({ one: 0.03, two: 0.8, ... thirty: 0.6 }); // { isValid: .89 }
Does this help?
from brain.js.
The other option at this point could be to use a recurrent neural net, such as an LSTM, but this is more for data translation and less about math.
from brain.js.
I've found another solution. Thank you for your attention.
from brain.js.
Care to share? We always want to improve for usefulness.
from brain.js.
I went with a different library: scikit-learn
from brain.js.
ty for the pointer!
from brain.js.
Related Issues (20)
- Deno Support?
- The Recurrent class will not function without a GPU HOT 1
- Unable to install Brain.js on PopOS HOT 22
- GPU powered AI demo is a 404 HOT 2
- "Forecasting" demo is a 404 HOT 2
- tree process
- Freezing when training NeuralNetworkGPU (async).
- Train with NeuralNetworkGPU more slower than CPU HOT 3
- Always the same output data on NeuralNetwork HOT 1
- Unable to install on MacOS Ventura HOT 1
- Did you try the built in distance calc?
- need to update URL for example
- MacOS node 20.10.0 build failing HOT 2
- Fatal error while installing via NPM package HOT 1
- Most example links are broken HOT 4
- Summary()
- Type 'InputType' is not assignable to type 'Partial<INumberHash>'... and many others
- stream-example.js page not found error HOT 1
- Npm i brain.js || node-gyp error
- Brain.js to detect bad words 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 brain.js.