puthonでand.pyファイルが実行できません。
python and.pyを実行しようとすると次のエラーが出ます。
どうやらインポートが出来てないみたいなのですがこれは
どうしたらいいのでしょうか?
Traceback (most recent call last):
File "and.py", line 2, in <module>
from sklearn.svm import LinearSVC
ImportError: No module named 'sklearn'
and.pyのソース
python
1# ライブラリのインポート --- (*1) 2from sklearn.svm import LinearSVC 3from sklearn.metrics import accuracy_score 4 5# 学習用のデータと結果の準備 --- (*2) 6# X , Y 7learn_data = [[0,0], [1,0], [0,1], [1,1]] 8# X and Y 9learn_label = [0, 0, 0, 1] 10 11# アルゴリズムの指定(LinierSVC) --- (*3) 12clf = LinearSVC() 13 14# 学習用データと結果の学習 --- (*4) 15clf.fit(learn_data, learn_label) 16 17# テストデータによる予測 --- (*5) 18test_data = [[0,0], [1,0], [0,1], [1,1]] 19test_label = clf.predict(test_data) 20 21# 予測結果の評価 --- (*6) 22print(test_data , "の予測結果:" , test_label) 23print("正解率 = " , accuracy_score([0, 0, 0, 1], test_label))
回答1件
あなたの回答
tips
プレビュー