question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ensure that numberic values are between 0 and 1

See original GitHub issue

Hello,

To use Brain.js, I need to convert numeric values to 0 and 1. But I haven’t found a good solution to convert numeric values from large files. For example, I struggle with this dataset:

"Channel": 2,
"Region": 3
"Fresh": 12669,
"Milk": 9656,
"Grocery": 7561,
"Frozen": 214,
"DetergentsPaper": 2674,
 "Delicassen": 1338

Sometimes, I read that people divide values by 10, 100 or 1000, but I doubt it’s a relevant solution. Do you have ideas ?

Thank you,

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mattgrandecommented, Aug 3, 2018

I think what Robert was suggesting was to find the largest value for each thing beforehand. Snippet:

let maxChannel = 0;
// ... and all the other properties
customers.forEach(customer => {
    if (customer.Channel > maxChannel) {
        maxChannel = customer.Channel;
    }
    // ... and all the other properties
});

const customersData = customers.map(customer => {
    return {
        input: {
            ch: customers[i].Channel / maxChannel,
            ...
        }
    }
})

That will ensure that each value is between 0 and 1, and that the largest value for each property is exactly 1.

0reactions
mubaidrcommented, Aug 4, 2018

Great! Closing this issue, please feel free to open if you need any further help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to represent an unbounded variable as number between ...
The variable is a non-negative integer with no inherent bound. I map 0 to 0 but what can I map to 1 or...
Read more >
How to Normalize Data Between 0 and 1 - Statology
To normalize the values in a dataset to be between 0 and 1, you can use the following formula: zi = (xi –...
Read more >
How would I get a value between 0 and 1 depending on ...
I need to generate a number between 0 and 1 (used for opacity) that accurately reflects numbers on this scale:.
Read more >
Scale Data to Range Between Two Values in R (4 Examples)
Example 3: Convert Values to 0/1 Range Using scales Package. This example explains how to use the scales package to convert numerical values...
Read more >
Check if a numeric value falls between a range in R ...
between() function in R Language is used to check that whether a numeric value falls in a specific range or not.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found