0

I am trying to execute the following statements in PyCharm on Windows. I get the error message in the 4th line importing GaussianNB - sklearn: Unresolved Reference. Is there any package needed to be included or some other way to resolve this?

import numpy as np
X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])
Y = np.array([1, 1, 1, 2, 2, 2])
from sklearn.naive_bayes import GaussianNB
clf = GaussianNB()
clf.fit(X, Y)
print(clf.predict([[-0.8, -1]]))
PS Nayak
  • 409
  • 8
  • 20
  • Does your code run or not? Anyway, this is almost certainly a [duplicate](https://stackoverflow.com/questions/11725519/pycharm-shows-unresolved-references-error-for-valid-code) – juanpa.arrivillaga Jul 28 '17 at 06:21
  • No, the code is not running. It is showing the error - Unresolved Reference at sklearn and GaussianNB. – PS Nayak Jul 28 '17 at 06:46
  • what version of python and sklearn are you using? have you tried updating to current sklearn? – Max Power Jul 28 '17 at 07:06
  • Python: 3.6.2121.1013; PyCharm 2017.1.5; PIP:9.0.1; scikit-learn: 0.19b2; sklearn: 0.0. – PS Nayak Jul 28 '17 at 07:28
  • @PSNayak that is not a Python error, that is your IDE giving you a warning. – juanpa.arrivillaga Jul 28 '17 at 07:38
  • This is the error I am getting after running the code: Traceback (most recent call last): File "C:/PN/Python/MLGoogle/ML1.py", line 4, in from sklearn.naive_bayes import GaussianNB File "C:\Python36\lib\site-packages\sklearn\__init__.py", line 129, in from .base import clone File "C:\Python36\lib\site-packages\sklearn\base.py", line 10, in from scipy import sparse ModuleNotFoundError: No module named 'scipy' – PS Nayak Jul 28 '17 at 07:43
  • You need scipy to run Sklearn. On the [installation page](http://scikit-learn.org/stable/install.html) it is specifically listed as a requirement. – error Jul 28 '17 at 08:46

1 Answers1

0

From your last comment it seems that SciPy module is missing.

After installing scipy the error should not appear.

The most common scipy - pycharm installation problems have been answered here (just in case that you get any error while trying to install scipy)

See here 1

See here 2

seralouk
  • 30,938
  • 9
  • 118
  • 133