0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

「Pythonによるスクレイピング&機械学習」を読んで

Last updated at Posted at 2017-08-02

こちらの本の補足情報を書いています。

Pythonによるスクレイピング&機械学習 開発テクニック BeautifulSoup,scikit-learn,TensorFlowを使ってみよう

公式の正誤情報

4章あたり

.sh
pip3 install sklearn scipy pandas
python3 xor-train.py

deprecation

.diff
diff iris-train2.py{.bk,}
2c2
< from sklearn import svm, metrics, cross_validation
---
> from sklearn import svm, metrics, model_selection
13c13
<     cross_validation.train_test_split(csv_data, csv_label)
---
>     model_selection.train_test_split(csv_data, csv_label)
.diff
diff mnist-train.py{bk,}
1c1
< from sklearn import cross_validation, svm, metrics
---
> from sklearn import svm, metrics

言語判定

pip3 install matplotlib numpy pandas
export MPLBACKEND="agg"
python3 lang-plot.py
open lang-plot.png

BMI判定

.diff
diff bmi-test.py{.bk,}
1c1
< from sklearn import cross_validation, svm, metrics
---
> from sklearn import model_selection, svm, metrics
16c16
<     cross_validation.train_test_split(wh, label)
---
>     model_selection.train_test_split(wh, label)

5章

.diff
diff mnist-deep.py{.bk,}                                                                                                  
91c91
<     sess.run(tf.initialize_all_variables())
---
>     sess.run(tf.global_variables_initializer())
93c93
<     tw = tf.train.SummaryWriter('log_dir', graph=sess.graph)
---
>     tw = tf.summary.FileWriter('log_dir', graph=sess.graph)

7章

画像OCR

.diff
diff font_draw.py{.bk,} 
26c26
< if not os.path.exists("./image/num"): os.makedires("./image/num")
---
> if not os.path.exists("./image/num"): os.makedirs("./image/num")
$ diff caltech101_makedata.py{.bk,}
1c1
< from sklearn import cross_validation
---
> from sklearn import model_selection, svm, metrics
40c40
<     cross_validation.train_test_split(X, Y)
---
>     model_selection.train_test_split(X, Y)

もしOpenCV4を使用しているならエラーが出てしまうので修正

$ python ocr1.py
Traceback (most recent call last):
  File "ocr1.py", line 18, in <module>
    x, y, w, h = cv2.boundingRect(cnt) # --- (※5)
cv2.error: OpenCV(4.1.0) /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/shapedescr.cpp:743: error: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32S) in function 'pointSetBoundingRect'
$ diff ocr1.py{.bk,}
14c14
<     thresh, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)[1]
---
>     thresh, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)[0]
$ diff ocr3.py{.bk,}
19c19
<     cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)[1]
---
>     cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)[0]

Caltech101データセット

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?