NumPy package gives an array() error how to fix this?

Kushagra

This is a sample code to perform Binarization of data using Techniques for Data Preprocessing :

import numpy as np
import sklearn.preprocessing

input_data = np.array([2.1, -1.9, 5.5],
                      [-1.5, 2.4, 3.5],
                      [0.5, -7.9, 5.6],
                      [5.9, 2.3, -5.8])
# Binarization of Data
data_binarized = preprocessing.binarizer(threshold  = 0.5 ).transform(input_data)
print("\nBinarized Data\n", data_binarized)

This code gives an error:

array() takes from 1 to 2 positional arguments but 4 were given

How can I make arrays with more than one row ?

Sai Sreenivas

There should be one more pair of brackets, like this:

np.array([[2.1, -1.9, 5.5],
          [-1.5, 2.4, 3.5],
          [0.5, -7.9, 5.6],
          [5.9, 2.3, -5.8]])

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How Do I Fix This Numpy Error: Too Many Indices For Array?

How to fix delve "can't load package: package internal" error

How to fix this array used as initializer error?

How to fix ESLint error Use array destructuring

how to fix ChakraCore NuGet package error?

Python requests gives lexical JSON error. How to fix this?

How to fix error: Array type required in Delphi

How to fix SyntaxError in a module that gives an error upon import?

how to fix error: not a statement with += on an array

Getting an error with the Location package in flutter. how to fix?

How to fix hdevtools - "GHC_PACKAGE_PATH is incompatible.." error

How do I fix the error npm run dev gives?

How to fix a error with array in bash script?

how to fix "Index was outside the bounds of the array" Error

How to fix error processing package git-daemon-run?

How to fix the error, while updating my package list in Ubuntu 16.04?

How to fix an error for an old removed package in RStudio?

How do I fix 404 error when updating package lists?

How to "manually fix this package" (aptitude error)?

InsertOnSubmit gives this error. How do I fix this?

How to fix "[rospack] Error: package 'my_package' not found"

How to fix an error in a php variable? Server gives 500 error

How to fix MongoDB array concatination error?

Getting an array iteration error, wondering how to fix it

How to fix Javascript associative array error

Deploying Numba gives a StopIteration error which gives no clear hint on how to fix the code?

numpy Array Error: Summing elements gives wrong output

How to fix that ToString() gives out error with an int?

how to fix a Runtime error in a char array