Code using sklearn cannot be executed in PyCharm

Asked 1 years ago, Updated 1 years ago, 62 views

By executing code similar to the following in 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("Predicted Results:", pre)

ok = 0; total = 0
for idx, answer in enumerate (label):
p=pre[idx]
ifp==answer: ok+=1
total + = 1
print("correct answer rate:",ok,"/",total,"=",ok/total)

The following error will appear:

C:\Users\000\PycharmProjects\test1\venv\Scripts\python.exe C:/Users/000/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\000\PycharmProjects\test1\venv\lib\site-packages\sklearn\init.py", line 134, in <module>
from.base import clone
File "C:\Users\000\PycharmProjects\test1\venv\lib\site-packages\sklearn\base.py", line 11, in <module>
from scope import sparse
ModuleNotFoundError: No module named 'scipy'

Process finished with exit code 1

What should I do?

python python3 anaconda scikit-learn

2022-09-30 19:05

1 Answers

I simply did not install scipy.I'm sorry.


2022-09-30 19:05

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.