Skip to content

Instantly share code, notes, and snippets.

Meher Ranjan H meherranjan

Block or report user

Report or block meherranjan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View fetch-random-input.js
const getRandomIndex = till => Math.floor(Math.random() * till);
View train-model-2.js
for (let i = 0; i < 50000; i++) {
...
...
const weightedSum = getWeightedInputSum(weights, input, bias);
const weightedSumWRTweight0 = input[0];
const weightedSumWRTweight1 = input[1];
const weightedSumWRTbias = 1;
const prediction = compose(
sigmoid,
View train-model.js
const trainModel = data => {
let weights = getRandomWeights();
let bias = getRandomBias();
for (let i = 0; i < 50000; i++) {
const randomIndex = getRandomIndex(data.length);
const input = getInput(data, randomIndex);
const target = getTarget(input);
View sigmoid.js
const sigmoid = sum => 1 / (1 + Math.exp(-sum));
View weighted-input-sum.js
const getWeightedInputSum = (input, weight, bias) => weight[0] * input[0] + weight[1] * input[1] + bias;
View get-input-target.js
const getInput = (data, index) => data[index];
const getTarget = input => [...input].pop();
View generate-weights-and-bias.js
const getRandomWeights = () => Array.from({ length: 2 }, () => Math.random() * 0.5 - 0.2)
const getRandomBias = () => Math.random() * 0.5 - 0.2
View training-data.js
const trainingData = [
[4, 8, 0],
[4, 2, 0],
[5, 7, 0],
[7, 4, 0],
[9, 9, 1],
[7, 10, 1],
[10, 12, 1],
[3, 12, 1]
];
@meherranjan
meherranjan / recursive-binary-search.js
Last active Feb 4, 2019
Recursive Binary Search in JavaScript
View recursive-binary-search.js
sortedList = [11, 24, 33, 64, 95, 106, 217, 228, 299, 310]
const getMid = (low, high) => {
return Math.floor((high + low) / 2)
}
const recursiveBS = (list, item, low, high) => {
(!low && !high ) && (low = 0, high = list.length - 1)
let found = false
You can’t perform that action at this time.