You are just supposed to provide the predict
method with the same 2D array, but with one value that you want to process (or more). In short, you can just replace
[0.58,0.76]
With
[[0.58,0.76]]
And it should work.
EDIT: This answer became popular so I thought I’d add a little more explanation about ML. The short version: we can only use predict
on data that is of the same dimensionality as the training data (X
) was.
In the example in question, we give the computer a bunch of rows in X
(with 2 values each) and we show it the correct responses in y
. When we want to predict
using new values, our program expects the same – a bunch of rows. Even if we want to do it to just one row (with two values), that row has to be part of another array.
Related Posts:
- Error in Python script “Expected 2D array, got 1D array instead:”?
- Understanding the main method of python [duplicate]
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- PermissionError: [Errno 13] in Python
- ‘str’ object has no attribute ‘decode’. Python 3 error?
- What is the meaning of ‘for _ in range()
- How to draw a line with matplotlib?
- SyntaxError: unexpected EOF while parsing
- How to use filter, map, and reduce in Python 3
- Use Gif Logo For Loading Screen In Kivy
- Praw & Discord.py: The bot keep sending the same meme. I want the bot to send different meme whenever it is asked
- How can I make a time delay in Python? [duplicate]
- Python – TypeError: ‘int’ object is not iterable
- How to open a file using the open with statement
- Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)
- How to install pip with Python 3?
- What is the difference between rw+ and r+
- Convert bytes to a string
- How can I represent an ‘Enum’ in Python?
- Python – TypeError: ‘int’ object is not iterable
- Import Error: No module named numpy
- Python3 – ModuleNotFoundError: No module named ‘numpy’
- Relative imports – ModuleNotFoundError: No module named x
- Python: ‘ModuleNotFoundError’ when trying to import module from imported package
- Relative imports – ModuleNotFoundError: No module named x
- TypeError: a bytes-like object is required, not ‘str’ when writing to a file in Python3
- How to uninstall a package installed with pip install –user
- How do I upgrade the Python installation in Windows 10?
- not all arguments converted during string formatting.. NO % variables
- How do I use raw_input in Python 3
- Python Variable Declaration
- Relative imports in Python 3
- Python Math – TypeError: ‘NoneType’ object is not subscriptable
- Relative imports in Python 3
- working of \n in python [duplicate]
- Pip freeze vs. pip list
- Best way to convert string to bytes in Python 3?
- Best way to convert string to bytes in Python 3?
- What does the list() function do in Python?
- TypeError: not all arguments converted during string formatting python
- PermissionError: [Errno 13] Permission denied
- What is setup.py?
- How is Anaconda related to Python?
- FileNotFoundError: [WinError 2] The system cannot find the file specified:
- Invalid character in identifier
- Should I put #! (shebang) in Python scripts, and what form should it take?
- Should I put #! (shebang) in Python scripts, and what form should it take?
- Using Python 3 in virtualenv
- Relative imports in Python 3
- How to correct TypeError: Unicode-objects must be encoded before hashing?
- How to remove EOFError: EOF when reading a line?
- “If not” condition statement in python
- WinError 2 The system cannot find the file specified (Python)
- syntaxerror: “unexpected character after line continuation character in python” math
- hashlib.md5() TypeError: Unicode-objects must be encoded before hashing
- How can I sort a dictionary by key?
- TypeError: cannot unpack non-iterable NoneType object
- Is there a ‘foreach’ function in Python 3?
- Python inline if statement
- How to install python3 version of package via pip on Ubuntu?
- Updating a dictionary in python
- Could not find a version that satisfies the requirement tensorflow
- Convert bytes to a string
- How to copy a dictionary and only edit the copy
- How to print like printf in Python3?
- Could not find a version that satisfies the requirement tensorflow
- Local variable referenced before assignment?
- What are type hints in Python 3.5?
- AttributeError: ‘module’ object has no attribute ‘urlopen’
- Python Error: AttributeError: __enter__ [duplicate]
- Updating Python on Mac
- Python Logic of ListNode in Leetcode
- How can I write a `try`/`except` block that catches all exceptions?
- Can’t fix “zipimport.ZipImportError: can’t decompress data; zlib not available” when I type in “python3.6 get-pip.py”
- Plot logarithmic axes with matplotlib in python
- TypeError: ‘float’ object not iterable
- TypeError: ‘type’ object is not subscriptable when indexing in to a dictionary
- ‘method’ object is not subscriptable. Don’t know what’s wrong
- Expected 2D array, got 1D array instead error
- Invalid character in identifier
- Importing class from another file [duplicate]
- filedialog, tkinter and opening files
- pip or pip3 to install packages for Python 3?
- How can I one hot encode in Python?
- error UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xff in position 0: invalid start byte
- csv.Error: iterator should return strings, not bytes
- NameError: global name ‘xrange’ is not defined in Python 3
- Error: ” ‘dict’ object has no attribute ‘iteritems’ “
- What does “SyntaxError: Missing parentheses in call to ‘print'” mean in Python?
- ‘str’ object has no attribute ‘decode’. Python 3 error?
- Python Key Error=0 – Can’t find Dict error in code
- How to find all the indexes of a recurring item in a list?
- How to upgrade pip3?
- Name ‘xrange’ is not defined in Python 3 [duplicate]
- What’s the difference between torch.stack() and torch.cat() functions?
- Relative imports for the billionth time
- How do I use the yfinance API in Python to get today’s DJI open?
- TypeError: Missing 1 required positional argument: ‘self’
- what does the __file__ variable mean/do?