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
- Use Gif Logo For Loading Screen In Kivy
- How can I make a time delay in Python? [duplicate]
- Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)
- How to install pip with Python 3?
- Import Error: No module named numpy
- Python3 – ModuleNotFoundError: No module named ‘numpy’
- TypeError: a bytes-like object is required, not ‘str’ when writing to a file in Python3
- Relative imports in Python 3
- Pip freeze vs. pip list
- Best way to convert string to bytes in Python 3?
- TypeError: not all arguments converted during string formatting python
- 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
- WinError 2 The system cannot find the file specified (Python)
- hashlib.md5() TypeError: Unicode-objects must be encoded before hashing
- Could not find a version that satisfies the requirement tensorflow
- Local variable referenced before assignment?
- AttributeError: ‘module’ object has no attribute ‘urlopen’
- 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
- ‘method’ object is not subscriptable. Don’t know what’s wrong
- How can I one hot encode in Python?
- error UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xff in position 0: invalid start byte
- Error: ” ‘dict’ object has no attribute ‘iteritems’ “
- How to upgrade pip3?
- Name ‘xrange’ is not defined in Python 3 [duplicate]
- How do I use the yfinance API in Python to get today’s DJI open?
- SystemError: Parent module ” not loaded, cannot perform relative import
- Error: ” ‘dict’ object has no attribute ‘iteritems’ “
- TypeError: ‘<=' not supported between instances of 'str' and 'int' [duplicate]
- TypeError: unsupported operand type(s) for -: ‘str’ and ‘int’
- How to upgrade pip3?
- Getting a map() to return a list in Python 3.x
- How to Read .txt in Pandas
- TypeError: cannot convert the series to
- Pinging servers in Python
- Pinging servers in Python
- Add Legend to Seaborn point plot
- ‘End of statement expected’ in pycharm
- How to pass arguments to a Button command in Tkinter?
- How to remove specific substrings from a set of strings in Python?
- Change figure size and figure format in matplotlib
- How can I concatenate str and int objects?
- error: Failed to load the native TensorFlow runtime
- ImportError: No module named ‘encodings’
- How do I correctly clean up a Python object?
- enumerate() for dictionary in python
- PermissionError: [WinError 5] Access is denied
- Converting int to bytes in Python 3
- Python 3 – ValueError: not enough values to unpack (expected 3, got 2)
- How can I install Python’s pip3 on my Mac?
- How to get the current working directory using python 3?
- min() arg is an empty sequence
- Python sockets error TypeError: a bytes-like object is required, not ‘str’ with send function
- Pipenv: Command Not Found
- Python: AttributeError: ‘_io.TextIOWrapper’ object has no attribute ‘split’
- Pip – Fatal error in launcher: Unable to create process using ‘”‘
- ImportError: No module named ‘yaml’
- TypeError: ‘_io.TextIOWrapper’ object is not subscriptable
- Properly formatted multiplication table
- python3 TypeError: ‘function’ object is not iterable
- Why is parenthesis in print voluntary in Python 2.7?
- How to print multiple lines of text with Python
- python 3 – x for x for loops – how do they work?
- How to compare individual characters in two strings in Python 3
- How do I run pip on python for windows?
- Need to install urllib2 for Python 3.5.1
- Scikit-learn GridSearch giving “ValueError: multiclass format is not supported” error
- ImportError: No module named ‘xlrd’
- Moving Average Pandas
- What does {0} mean in this Python string?
- Tab Error in Python
- Root mean square of a function in python
- Python 3.5.1 urllib has no attribute request
- matplotlib: plot multiple columns of pandas data frame on the bar chart
- Why do I get this error “TypeError: ‘method’ object is not iterable”?
- What is the purpose of dollar sign in this Python3 string formatting expression?
- What is the meaning of “int(a[::-1])” in Python?
- Getting a name error when trying to input a string [duplicate]
- How to install NumPy for Python 3.6
- What is the maximum float in Python?
- ValueError: multiclass format is not supported
- Error loading MySQLdb module: No module named ‘MySQLdb’
- How do you switch between python 2 and 3, and vice versa?
- Normalizing a list of numbers in Python
- Iterating over dictionary items(), values(), keys() in Python 3
- Python webbrowser.open() to open Chrome browser
- Undefined variable error in function
- Python 3 integer division [duplicate]
- Python – difference between two strings