sklearn を使ったコードが PyCharm で実行できない
PyCharmで下のようなコードを実行すると
from sklearn import svm
xor_data = [
P, Q, result
[0, 0, 0],
[0, 1, 1],
[1, 0, 1],
[1, 1, 0]
]
data = []
label = []
for row in xor_data:
p = row[0]
q = row[1]
r = row[2]
data.append([p, q])
label.append(r)
clf = svm.SVC()
clf.fit(data, label)
pre = clf.predict(data)
print("予測結果:", pre)
ok = 0; total = 0
for idx, answer in enumerate(label):
p = pre[idx]
if p == answer: ok += 1
total += 1
print("正解率:", ok, "/", total, "=", ok/total)
下のようなエラーが出てしまいます。
C:\Users\〇〇〇\PycharmProjects\test1\venv\Scripts\python.exe C:/Users/〇〇〇/PycharmProjects/test1/hello.py
Traceback (most recent call last):
File "C:/Users/〇〇〇/PycharmProjects/test1/hello.py", line 1, in <module>
from sklearn import svm
File "C:\Users\〇〇〇\PycharmProjects\test1\venv\lib\site-packages\sklearn\init.py", line 134, in <module>
from .base import clone
File "C:\Users\〇〇〇\PycharmProjects\test1\venv\lib\site-packages\sklearn\base.py", line 11, in <module>
from scipy import sparse
ModuleNotFoundError: No module named 'scipy'
Process finished with exit code 1
どうしたらいいですか?