Public
Edited
Oct 20, 2022
1 star
Insert cell
Insert cell
Insert cell
data = [
{ input: { r: 0.62, g: 0.72, b: 0.88 }, output: { light: 1 } },
{ input: { r: 0.1, g: 0.84, b: 0.72 }, output: { light: 1 } },
{ input: { r: 0.33, g: 0.24, b: 0.29 }, output: { dark: 1 } },
{ input: { r: 0.74, g: 0.78, b: 0.86 }, output: { light: 1 } },
{ input: { r: 0.31, g: 0.35, b: 0.41 }, output: { dark: 1 } },
{ input: { r: 1, g: 0.99, b: 0 }, output: { light: 1 } },
{ input: { r: 1, g: 0.42, b: 0.52 }, output: { dark: 1 } },
{ input: { r: 0, g: 0.25, b: 1 }, output: { light: 1 } },
{ input: { r: 0, g: 0.45, b: 1 }, output: { light: 1 } },
{ input: { r: 0.5, g: 0.5, b: 0.5 }, output: { inconclusive: 1 } },
{ input: { r: 0.6, g: 0.4, b: 0.4 }, output: { inconclusive: 1 } },
{ input: { r: 0.55, g: 0.45, b: 0.52 }, output: { inconclusive: 1 } }
]
Insert cell
Insert cell
Insert cell
Insert cell
predictColor = d3.color(predict)
Insert cell
testData = ({
r: predictColor.r / 255,
g: predictColor.g / 255,
b: predictColor.b / 255
})
Insert cell
prediction = trainedNetwork.run(testData)
Insert cell
Insert cell
config = ({
// Defaults values --> expected validation
iterations: 10000, // the maximum times to iterate the training data --> number greater than 0
errorThresh: 0.005, // the acceptable error percentage from training data --> number between 0 and 1
log: false, // true to use console.log, when a function is supplied it is used --> Either true or a function
learningRate: 0.12, // scales with delta to effect training rate --> number between 0 and 1
momentum: 0.12, // scales with next layer's change value --> number between 0 and 1
timeout: Infinity // the max number of milliseconds to train for --> number greater than 0
})
Insert cell
trainedNetwork = {
const network = new brain.NeuralNetwork();
//network.train(data,config);
network.train(data);

return network;
}
Insert cell
Insert cell
brain = require("brain.js")
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more