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

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

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

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

Q&A

解決済

1回答

180閲覧

続きの命令を書きたいのですが書けません。

cunwe

総合スコア65

Python 3.x

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

0グッド

0クリップ

投稿2019/08/15 10:25

編集2019/08/15 12:12

参考書籍「詳細!Python3 入門ノート」の抜粋なのですが

>>> from sklearn import datasets >>> digits=datasets.load_digits() >>> dir(digits) ['DESCR', 'data', 'images', 'target', 'target_names'] >>> print(digits.DESCR) .. _digits_dataset: Optical recognition of handwritten digits dataset -------------------------------------------------- **Data Set Characteristics:** :Number of Instances: 5620 :Number of Attributes: 64 :Attribute Information: 8x8 image of integer pixels in the range 0..16. :Missing Attribute Values: None :Creator: E. Alpaydin (alpaydin '@' boun.edu.tr) :Date: July; 1998 This is a copy of the test set of the UCI ML hand-written digits datasets http://archive.ics.uci.edu/ml/datasets/Optical+Recognition+of+Handwritten+Digits The data set contains images of hand-written digits: 10 classes where each class refers to a digit. Preprocessing programs made available by NIST were used to extract normalized bitmaps of handwritten digits from a preprinted form. From a total of 43 people, 30 contributed to the training set and different 13 to the test set. 32x32 bitmaps are divided into nonoverlapping blocks of 4x4 and the number of on pixels are counted in each block. This generates an input matrix of 8x8 where each element is an integer in the range 0..16. This reduces dimensionality and gives invariance to small distortions. For info on NIST preprocessing routines, see M. D. Garris, J. L. Blue, G. T. Candela, D. L. Dimmick, J. Geist, P. J. Grother, S. A. Janet, and C. L. Wilson, NIST Form-Based Handprint Recognition System, NISTIR 5469, 1994. .. topic:: References - C. Kaynak (1995) Methods of Combining Multiple Classifiers and Their Applications to Handwritten Digit Recognition, MSc Thesis, Institute of Graduate Studies in Science and Engineering, Bogazici University. - E. Alpaydin, C. Kaynak (1998) Cascading Classifiers, Kybernetika. - Ken Tang and Ponnuthurai N. Suganthan and Xi Yao and A. Kai Qin. Linear dimensionalityreduction using relevance weighted LDA. School of Electrical and Electronic Engineering Nanyang Technological University. 2005. - Claudio Gentile. A New Approximate Maximal Margin Classification Algorithm. NIPS. 2000. >>> digits.data.shape (1797, 64) >>> digits.target.shape (1797,) >>> digits.data array([[ 0., 0., 5., ..., 0., 0., 0.], [ 0., 0., 0., ..., 10., 0., 0.], [ 0., 0., 0., ..., 16., 9., 0.], ..., [ 0., 0., 1., ..., 6., 0., 0.], [ 0., 0., 2., ..., 12., 0., 0.], [ 0., 0., 10., ..., 12., 1., 0.]]) >>> digits.data[0] array([ 0., 0., 5., 13., 9., 1., 0., 0., 0., 0., 13., 15., 10., 15., 5., 0., 0., 3., 15., 2., 0., 11., 8., 0., 0., 4., 12., 0., 0., 8., 8., 0., 0., 5., 8., 0., 0., 9., 8., 0., 0., 4., 11., 0., 1., 12., 7., 0., 0., 2., 14., 5., 10., 12., 0., 0., 0., 0., 6., 13., 10., 0., 0., 0.]) >>> digits.images[0] array([[ 0., 0., 5., 13., 9., 1., 0., 0.], [ 0., 0., 13., 15., 10., 15., 5., 0.], [ 0., 3., 15., 2., 0., 11., 8., 0.], [ 0., 4., 12., 0., 0., 8., 8., 0.], [ 0., 5., 8., 0., 0., 9., 8., 0.], [ 0., 4., 11., 0., 1., 12., 7., 0.], [ 0., 2., 14., 5., 10., 12., 0., 0.], [ 0., 0., 6., 13., 10., 0., 0., 0.]]) >>> import matplotlib.pyplot as plt >>> plt.matshow(digits.images[0],cmap="Greys") <matplotlib.image.AxesImage object at 0x0000026AA4F18438> >>>plt.show()

となって8×8の64マスのぼやっとした「0」が表示された後に書籍では本当に「0」を書いた手書き文字なのか確認するために

digits.target[0]

と打たなくてはいけないのですが

plt.show()

の後に<<<が現れません。。原因がわかる方、お答えいただけると嬉しいです。
自分では「plt.show()の後 書けない」や「anaconda prompt <<<が出ない」などで調べたのですがグラフが描画されないときの対処法など求めてる回答が得られませんでした。

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

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

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

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

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

hayataka2049

2019/08/15 10:33

ちょっと読みづらいので、質問文を編集してなんとかしてください。コード部分は<code>ボタンで挿入できるコードブロックに入れるといいでしょう。
cunwe

2019/08/15 12:13

ご指摘ありがとうございました!おっしゃるようにとても見づらかったですね、、
guest

回答1

0

ベストアンサー

plt.show() を実行すると、matplotlib のウィンドウが表示されると思いますが、ウィンドウを閉じるまでは plt.show() の行が実行中となっているため、次の命令は入力できないのではないでしょうか。

ウィンドウを閉じると次の命令が入力できるようになると思います。


ちなみにコンソールで1行ずつ入力するより、Jupyter Notebook を使ったほうがよいと思います。Anaconda に付属しています。

投稿2019/08/15 10:38

tiitoi

総合スコア21956

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

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

cunwe

2019/08/15 12:16

教えていただきありがとうございます!そのためのJupyter Notebookなのですね!そこからかって感じですいません。。
hayataka2049

2019/08/15 12:21

グラフのウィンドウが別に出ていますか? 出ていれば、閉じればプロンプトに戻ってきて入力ができるようになります。 何も出ていないとそれはそれで問題。
cunwe

2019/08/15 12:29

ウインドウ閉じたらできました!ありがとうございます!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問