質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
import

自身のプラットフォーム・プログラム・データセットに対して、外部ソースを取り込むプロセスをimportと呼びます。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

機械学習

機械学習は、データからパターンを自動的に発見し、そこから知能的な判断を下すためのコンピューターアルゴリズムを指します。人工知能における課題のひとつです。

Q&A

解決済

1回答

1148閲覧

PyCharmにmglearnをインストールしたい

ammtjm

総合スコア7

import

自身のプラットフォーム・プログラム・データセットに対して、外部ソースを取り込むプロセスをimportと呼びます。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

機械学習

機械学習は、データからパターンを自動的に発見し、そこから知能的な判断を下すためのコンピューターアルゴリズムを指します。人工知能における課題のひとつです。

0グッド

0クリップ

投稿2020/03/08 08:34

編集2020/03/08 09:19

前提・実現したいこと

PyCharmにmglearnというモジュールをインストールしたい

発生している問題・エラーメッセージ

C:\Users\xxx\Anaconda3\python.exe C:/Users/xxx/PycharmProjects/プログラミング練習/機械/kikaip32.py C:\Users\xxx\Anaconda3\lib\site-packages\sklearn\externals\six.py:31: DeprecationWarning: The module is deprecated in version 0.21 and will be removed in version 0.23 since we've dropped support for Python 2.7. Please rely on the official version of six (https://pypi.org/project/six/). "(https://pypi.org/project/six/).", DeprecationWarning) C:\Users\xxx\Anaconda3\lib\site-packages\sklearn\externals\joblib\__init__.py:15: DeprecationWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib. If this warning is raised when loading pickled models, you may need to re-serialize those models with scikit-learn 0.21+. warnings.warn(msg, category=DeprecationWarning) C:\Users\xxx\Anaconda3\lib\site-packages\sklearn\utils\deprecation.py:85: DeprecationWarning: Function make_blobs is deprecated; Please import make_blobs directly from scikit-learn warnings.warn(msg, category=DeprecationWarning) Traceback (most recent call last): File "C:/Users/xxx/PycharmProjects/プログラミング練習/機械/kikaip32.py", line 7, in <module> plt.legend(["Class 0","Class 1"],loc=4) TypeError: 'module' object is not callable プロセスは終了コード 1 で完了しました

該当のソースコード

import mglearn import matplotlib as plt #データセットの生成 X,y = mglearn.datasets.make_forge() #データセットをプロット mglearn.discrete_scatter(X[:,0],X[:,1],y) plt.legend(["Class 0","Class 1"],loc=4) plt.xlabel("First feature") plt.ylabel("Second feature") print("X.shape:{}".format(X.shape))

試したこと

まず,プロジェクトインタープリターで検索し該当するものがありませんでした.
そのため,ターミナルで"pip install mglearn"を記述して,mglearnをインストールしました.(c:\users\xxx\anaconda3\lib\site-pa
ckages (0.1.7))
その後プロジェクトインタープリター(Python 3.7 c:\users\xxx\anaconda3\python.exe )でmglearn0.1.7を確認しました.

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

7行目でmoduleが呼べないというエラーが出ています。

File "C:/Users/xxx/PycharmProjects/プログラミング練習/機械/kikaip32.py", line 7, in <module>
plt.legend(["Class 0","Class 1"],loc=4)
TypeError: 'module' object is not callable

7行目でplt.legend()を呼んでいますが、legendは「matplotlib.pyplot」のモジュールです。

matplotlib.pyplot
https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.html

なので、2行目の
import matplotlib as plt

import matplotlib.pyplot as plt
と書いてください。

投稿2020/03/08 09:27

technocore

総合スコア7225

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

ammtjm

2020/03/08 09:42

ご回答ありがとうございます。ご指摘の通りに変更した結果エラーメッセージに変化がありました. ---- C:\Users\xxx\Anaconda3\python.exe C:/Users/xxx/PycharmProjects/プログラミング練習/機械/kikaip32.py C:\Users\xxx\Anaconda3\lib\site-packages\sklearn\externals\six.py:31: DeprecationWarning: The module is deprecated in version 0.21 and will be removed in version 0.23 since we've dropped support for Python 2.7. Please rely on the official version of six (https://pypi.org/project/six/). "(https://pypi.org/project/six/).", DeprecationWarning) C:\Users\xxx\Anaconda3\lib\site-packages\sklearn\externals\joblib\__init__.py:15: DeprecationWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib. If this warning is raised when loading pickled models, you may need to re-serialize those models with scikit-learn 0.21+. warnings.warn(msg, category=DeprecationWarning) C:\Users\xxx\Anaconda3\lib\site-packages\sklearn\utils\deprecation.py:85: DeprecationWarning: Function make_blobs is deprecated; Please import make_blobs directly from scikit-learn warnings.warn(msg, category=DeprecationWarning) X.shape:(26, 2) プロセスは終了コード 0 で完了しました ----
technocore

2020/03/08 09:51

残りのエラーメッセージは全部ワーニングですね。 しかも最後は終了コード 0で正常終了していると思われます。 kikaip32.pyというpyスクリプトでプログラムを実行されていますが、 図形を描くプログラムなので、jupyter notebook上で動かしてみては いかがでしょう?
ammtjm

2020/03/08 10:14

目的としては学習の成果をここで確認できるようにしたかったのでPyCharmにこだわってしまいました.おっしゃる通りjupyter notebook上で動作させることを前提に教科書として使用している書籍の方でも話が進められていました.
ammtjm

2020/03/08 10:17

jupyter notebookで取り組んで行こうと思います.
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問