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:”?
- What is the meaning of ‘for _ in range()
- SyntaxError: unexpected EOF while parsing
- How to use filter, map, and reduce in Python 3
- Praw & Discord.py: The bot keep sending the same meme. I want the bot to send different meme whenever it is asked
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- How to install pip with Python 3?
- Import Error: No module named numpy
- 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 is Anaconda related to Python?
- FileNotFoundError: [WinError 2] The system cannot find the file specified:
- Using Python 3 in virtualenv
- How to correct TypeError: Unicode-objects must be encoded before hashing?
- How to install python3 version of package via pip on Ubuntu?
- Updating a dictionary in python
- Local variable referenced before assignment?
- Can’t fix “zipimport.ZipImportError: can’t decompress data; zlib not available” when I type in “python3.6 get-pip.py”
- TypeError: ‘float’ object not iterable
- ‘method’ object is not subscriptable. Don’t know what’s wrong
- Importing class from another file [duplicate]
- NameError: global name ‘xrange’ is not defined in Python 3
- What does “SyntaxError: Missing parentheses in call to ‘print'” mean in Python?
- How to upgrade pip3?
- TypeError: Missing 1 required positional argument: ‘self’
- What is __pycache__?
- SystemError: Parent module ” not loaded, cannot perform relative import
- TypeError: ‘<=' not supported between instances of 'str' and 'int' [duplicate]
- TypeError: unsupported operand type(s) for -: ‘str’ and ‘int’
- What is __pycache__?
- How to Read .txt in Pandas
- TypeError: can’t use a string pattern on a bytes-like object in re.findall()
- Pinging servers in Python
- Add Legend to Seaborn point plot
- How to install pip3 on Windows?
- How to pass arguments to a Button command in Tkinter?
- How to remove specific substrings from a set of strings in Python?
- Python Setup Disabling Path Length Limit Pros and Cons?
- Type error: cannot convert the series to
- What is the purpose of “pip install –user …”?
- How to remove punctuation marks from a string in Python 3.x using .translate()?
- Subplot for seaborn boxplot
- What is the difference between sparse_categorical_crossentropy and categorical_crossentropy?
- Infinite integer in Python
- enumerate() for dictionary in python
- Why Python 3.6.1 throws AttributeError: module ‘enum’ has no attribute ‘IntFlag’?
- How to use sys.exit() in Python
- installing urllib in Python3.6
- What is sys.maxint in Python 3?
- What is the difference between np.mean and tf.reduce_mean?
- Python: can’t assign to literal
- “Initializing” variables in python?
- Difference between except: and except Exception as e:
- “Unicode Error “unicodeescape” codec can’t decode bytes… Cannot open text files in Python 3
- How to downgrade python from 3.7 to 3.6
- How to return dictionary keys as a list in Python?
- How to save a dictionary to a file?
- ValueError: x and y must be the same size
- Python: AttributeError: ‘_io.TextIOWrapper’ object has no attribute ‘split’
- Youtube_dl : ERROR : YouTube said: Unable to extract video data
- Using Look Up Tables in Python
- Anaconda Installed but Cannot Launch Navigator
- ImportError: No module named ‘yaml’
- TypeError: ‘_io.TextIOWrapper’ object is not subscriptable
- How to print multiple lines of text with Python
- ImportError: No module named ‘cv2’ Python3
- Django Rest Framework — no module named rest_framework
- Unsupported operation :not writeable python
- Object of type ‘map’ has no len() in Python 3
- How do I run pip on python for windows?
- how to exit a python script in an if statement
- Scikit-learn GridSearch giving “ValueError: multiclass format is not supported” error
- How to fix ‘RuntimeWarning: divide by zero encountered in double_scalars’
- What does {0} mean in this Python string?
- Tab Error in Python
- Not able to pip install pickle in python 3.6
- Using unicode character u201c
- Python 3.5.1 urllib has no attribute request
- Decode Hex String in Python 3
- built-in range or numpy.arange: which is more efficient?
- Printing subscript in python
- How to clear Tkinter Canvas?
- TypeError: ‘range’ object does not support item assignment
- What is the meaning of “int(a[::-1])” in Python?
- install csv package in pycharm
- dump() missing 1 required positional argument: ‘fp’ in python json
- Meaning of list[-1] in Python
- TypeError: module.__init__() takes at most 2 arguments (3 given)
- Tkinter error: Couldn’t recognize data in image file
- How to install Openpyxl with pip
- Python cant convert ‘list’ object to str error [closed]
- Generate a random letter in Python
- What’s the correct way to convert bytes to a hex string in Python 3?
- During handling of the above exception, another exception occurred
- ValueError: multiclass format is not supported
- Error loading MySQLdb module: No module named ‘MySQLdb’
- ‘module’ has no attribute ‘urlencode’
- Python-3.2 coroutine: AttributeError: ‘generator’ object has no attribute ‘next’
- How to install PyQt4 on Windows using pip?
- How to install PyQt4 on Windows using pip?