lang-train.py When I ran lang-train.py on page 166, I got the following display.
root@057e36518a17:/c/Users/yuki/my_dir/wap_scraping/src/ch4# python3 lang-train.py
/opt/conda/lib/python3.5/site-packages/sklearn/utils/validation.py:395: DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and will raise ValueError in 0.19. Reshape your data either using X.reshape(-1, 1) if your data has a single feature or X.reshape(1, -1) if it contains a single sample.
DeprecationWarning)
Traceback (most recent call last):
File "lang-train.py", line 45, in <module>
clf.fit(data["freqs"], data["labels"])
File "/opt/conda/lib/python3.5/site-packages/sklearn/svm/base.py", line 151, in fit
X, y = check_X_y(X, y, dtype=np.float64, order='C', accept_sparse='csr')
File "/opt/conda/lib/python3.5/site-packages/sklearn/utils/validation.py", line 521, in check_X_y
ensure_min_features, warn_on_dtype, estimator)
File "/opt/conda/lib/python3.5/site-packages/sklearn/utils/validation.py", line 424, in check_array
context))
ValueError: Found array with 0 feature(s) (shape=(1, 0)) while a minimum of 1 is required.
It wasn't a big deal. Since the text stated that lang.zip should be decompressed under lang, it was literally decompressed under "lang". But in the sample code
data = load_files("./lang/train/*.txt")
test = load_files("./lang/test/*.txt")
There is. Since lang-train.py was running on ch4, it means that we couldn't load the data we wanted.
Sample coat
"./lang/train/*.txt"
not
"./lang/lang/train/*.txt"
I thought about it, but I didn't want to mess with the sample code so much, so The problem was solved by setting the decompression destination directly under "ch4" instead of under "lang".
lang-Webapp.py It is unsolved.
I ran the following command when docker started.
$ docker run -it -v $HOME:$HOME -p 8080:8080 <CONTAINER ID> /bin/bash
After booting, cd to ch4 and then execute the following command. The result is as follows
$ python3 -m http.server --cgi 8080
Serving HTTP on 0.0.0.0 port 8080 ...
Even if you open a web browser in this state and specify "http: //localhost:8080/cgi-bin/lang-Webapp.py", the page will not be displayed.
What should I do? ..
Recommended Posts