Previous question · 959
NFL Draft Count
easyDatabase
Next question · 961
Regular Expression Matching
hardAlgorithms
Random coding question

960. Binning continuous variables

easy
GeneralGeneral
senior
Function contract
Inputs
x
np.ndarray
num_bins
int
Returns
value
tuple

Examples

Input
{
  "x": [
    1,
    2,
    2.9,
    3,
    4
  ],
  "num_bins": 3
}
Output
[
  [
    0,
    1,
    1,
    2,
    2
  ],
  [
    [
      1,
      0,
      0
    ],
    [
      0,
      1,
      0
    ],
    [
      0,
      1,
      0
    ],
    [
      0,
      0,
      1
    ],
    [
      0,
      0,
      1
    ]
  ]
]

Constraints

Hint 1
Hint 2
Hint 3
Roles
ML Engineer
AI Engineer
Data Scientist
Research Scientist
Analytics Engineer
Companies
GeneralGeneral
Levels
senior
entry
Tags
discretization
equal-width-binning
one-hot-encoding
numpy

Similar Questions

Linear Regressionmedium
ML Coding
Activation function relueasy
ML Coding
Text normalizationmedium
ML Coding
32 people are solving this problem
Loading editor for the selected language
Ln 1, Col 1
Program Output
DATAINTERVIEW
Interactive coding terminal
Python / NumPy environment ready.
Type a command below or run code from the editor.
run scriptExecute the current editor contents
submitGrade the current editor contents against all solution test cases
python ("print hello world")Run an isolated Python command
helpShow all available commands