Skip to content

Error on Python 3 #4

@Pauldic

Description

@Pauldic

Am trying reuse this demo in python 3, but got error exactly on this line resutl = classifier.predict_proba(numpy.array(vector)) while same code work for Python 2.7. Please any idea on what I need to do to get this working on Python 3x

>>> data['is_duplicates'] = Hash.predict(vector) Traceback (most recent call last): File "<input>", line 1, in <module> data['is_duplicates'] = Hash.predict(vector) File "/path/to/python/comparer/apps/core/hash_utils.py", line 111, in predict resutl = classifier.predict_proba(numpy.array(vector)) File "/path/to/python/comparer/venv/lib/python3.6/site-packages/sklearn/linear_model/logistic.py", line 1336, in predict_proba return super(LogisticRegression, self)._predict_proba_lr(X) File "/path/to/python/comparer/venv/lib/python3.6/site-packages/sklearn/linear_model/base.py", line 338, in _ predict_proba_lr prob = self.decision_function(X) File "/path/to/python/comparer/venv/lib/python3.6/site-packages/sklearn/linear_model/base.py", line 300, in d ecision_function X = check_array(X, accept_sparse='csr') File "/path/to/python/comparer/venv/lib/python3.6/site-packages/sklearn/utils/validation.py", line 441, in ch eck_array "if it contains a single sample.".format(array)) ValueError: Expected 2D array, got 1D array instead: array=[1 0 0 0 1 0 1 0]. Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions