neverjpのぶらり日記

コンピューター関連の記事とぶらりと出かけた先の写真など

demo30.py関連図

f:id:neverjp:20190106194627j:plain

demo30.py関連図(program1,program2追加)

f:id:neverjp:20190106194859j:plain

login後/(スラッシュ)入力でdemo06.htmlが呼び出される

f:id:neverjp:20190106195129j:plain

/program1でdemo04.htmlが呼び出される

f:id:neverjp:20190106195317j:plain

/program2を入力するとdemo05.htmlが呼び出される

昨日今日とSQLを両PCでインストールしてみた。

flaskをインストールしていたPCにはmssqlをインストールしていたが失敗。

これにLAMPLinux,apache,MySQL,PHP)のインストールを試みたが失敗。

mssqlをremoveしたがこれも失敗、このPCでのインストールを断念した。

家内のPCを借りてMySQLをインストールしたがこれもまたpasswordを入力するところで失敗。これもまた断念することになった。

まる2日間費やしたが私にはSQLは不要の様だ。

そこでdemo29.pyに追加してdemo30.pyを構成してみたのがアイキャッチ画像のものだ。

人気ブログランキングへ←人気ブログランキングに参加しています。よろしければ1票を!

 

login,logout,user処理プログラムの関連

f:id:neverjp:20190104164831j:plain

login処理が終わった後user処理プログラムが走る

f:id:neverjp:20190104165039j:plain

user処理プログラム(demo06.html)login処理(demo29.py)関連図

login,logout,user処理プログラムの関連

demo29.pyでログイン・ログアウト処理をする。

chech29.htmlでform(入力フォーム)処理をする。

index29.htmlでloginの結果を表示する。

login成功で5000/で('/')を挿入するとdemo06.htmlが呼び出される。

人気ブログランキングへ←人気ブログランキングに参加しています。よろしければ1票を!

Flaskを使って今まで学習したこと

f:id:neverjp:20190103133943j:plain

伊豆旅行にて アールヌーボーの作品

今まで学習したこと

2019/01/03

① FlaskをWSLにインストールする

ディレクトリはflask(/)、templates、static、css、images、jsからなる。

Python Programの中で「app.route(‘/’)改行def index()」でデコレータ。

④ render_templateをimportすることでrender_template(‘demoxx.html’, name = ‘吉田’)をコーディングすることでnameパラメータによりhtmlファイルにデータを渡せる。

Python Programの先頭付近でapp = Flask(__name__)、最後にif __name__ == “__main__”改行、app.run(debug=True)を指定する。

⑥ demoxx.htmlの最後でjsを呼び出せる。

⑦ js内のalertでdialogMSGを表示させられる。

⑧ requestのimportでwho = request.args.get(“who”)をコーディングすることによりADR領域に/?who=xxxxxxをタイプインすることで.pyにて受け取れる。

⑨ return “yyyy”で画面にyyyyを表示できる。return whoでwhoの内容が表示される。

⑩ htmlの中で{% if name %}のように書くことで制御文が構成できる。{% else %}等。

ADR領域にパラメータが複数ある時には&をデリミターにすることができる。

⑫ url_for、redirectを使ってreturn redirect(url_for(“func”))とコーディングすることにより(‘/’)で入ってきてもfuncにリダイレクトできる。

⑬ html= “””と“”“ return htmlでPythonプログラムの中にhtmlファイルを含めることができる。

⑭ formの中にtype=”text”とすると入力がテキスト形式、passwordとすると入力が伏字になって「・・・」のようになって画面には表示されない。placeholder=”名前”のようにすると入力マスに薄い字で「名前」と表示される。

Python Programの中でcheckxx.htmlを呼びmy_email = request.form[“emel”]としreturn render_template(‘indexxx.html’,age=my_age…,eml=my_email,…)とすればデータの入力および結果の表示ができる。

⑯ 二次元ディクショナリのコーディングはif user_data[i][“pass”] == passwdのようにする。[i]のiはループカウントになる。

⑰ session管理はdemo29.py(demo28.py)のようにすればよい。

以上

人気ブログランキングへ←人気ブログランキングに参加しています。よろしければ1票を!

今年もよろしくお願いします

f:id:neverjp:20190101063249j:plain

ガレ作 伊万里写し花器 伊豆旅行にて

 

年頭のご挨拶

今年もよろしくお願いします。
年末、今後の5ヶ年計画を英語でブログにアップしたができる限りその計画に従うという意味です。
いい年をしてと皆さんは思われるでしょうけれどその通りです。
決して無理はしません。
身の程をわきまえて行動いたします。
皆さん、応援のほどよろしく願います。

人気ブログランキングへ←人気ブログランキングに参加しています。よろしければ1票を!

5-Year Plan revise up (ver3.0)

f:id:neverjp:20181231185947j:plain

ガレ作 風景文化瓶 伊豆旅行にて

Microsoft wordの翻訳システムを使いました。ご了承ください。

5-Year Plan revise up (ver3.0)

 

Since Qiita's article was on the CEO Tani, he was able to revitalize the five-year plan to become an AI engineer.Thank you for the article.

 

layout: "post"Title:

"Five-year plan ver3.0"date:

"2018-12-31 16:28"

 

Minimum knowledge required for AI engineers First,I saw the minimum knowledge required by AI engineers in six parts. Here, the future When doing business as an AI engineer, be sure to understand the overall picture of the basic knowledge of the six content.

(1) Programming skills- Python- numpy、pandas、matplotlib, Scikit. Translation-Learn TensorFlow and keras
Especially in this It is good to be proficient in pandas.This is a convenient library for data preprocessing, although data preprocessing is essential for machine learning.

(2) Mathematics- Differential、Linear algebra, vectors, matrices, probabilities, etc.

(3) Knowledge of statistics- Stdev, Variance, probability distribution, estimation, test, etc.

(4) Basic knowledge of machine learning
Supervised learning and unsupervised learningpretreatment, feature design, learning and evaluationSingle regression, multiple regression analysis, least squares method, Perceptron, logistic regressionDecision tree, random forest, support vector machine, K-meansImplementation skills and knowledge of deep learningscikit-learnKnowledge of frameworks such as TensorFlow and Keras.The flow to make a model that has been studied in Scikit-learn.

1. Data collection and preprocessing of data completion of missing values and removal of outliers.

2. Feature design (selection of feature quantity)

3. Model development (model selection and learning)

4. Model evaluation... cross test, evaluation by mixing matrix, etc.

 

(5) Knowledge of working with databases using SQL。-Select, insert, UPDATE, Delete, where, like, limit, SUM, AVG, Max, GROUP by, having, order by, table join, view, subquery, case, and so on.

(6) Cloud Knowledge-Knowledge of cloud infrastructure such as AWS and GCP and Azure.

Large Although it may seem that there are many other than six, it is recommended to squeeze it into two (1) and (4) first of all at once.The reason is that the program is actually written and visible, making it easier to learn.Because it is self-taught and it is frustrated when entering from the theory first.

The recommended way to study artificial intelligence by yourselfI introduced the necessary knowledge in the previous section, but how do I learn them?In order to learn from (1) to (6), we recommend that you acquire knowledge in the following sequence.

 

Phase1 python Learn about machine learning programming and artificial intelligence.Phase2 machine learning programming.Phase3 Challenge to Kaggle.Phase4 SQL, scraping and cloud technologies.Phase5 Use machine learning skills to produce products.Phase6 Teach (maybe I don't think this).
I believe that learning from each phase is the most rewarding and enjoyable way to learn.

Phase In 1, we refer to the programming beginners.If you are new to programming, come to the phase Please read through the first.

Phase2, based on what we actually learned in Phase 1, we will explain how to study machine learning programming.Already If you are doing machine learning programming using Scikit-learn, you may skip it.

Phase3 describes how to learn practical programming through competitions like Kaggle. (I don't think so either)

Phase4 In doing machine learning, retrieving data from the database is often done. SQL Knowledge is mandatory. In addition to SQL, this section introduces techniques such as scraping (data collection) and cloud technology. (First from Access)

Phase5 Use machine learning skills to get your product production. Those who reach this level often learn through the product.

Phase6 Teaching six people may clarify what you didn't know. So it is also a good idea to teach your friends about machine learning and deepen your understanding.
Since then, I will explain how to tackle these in each of the six phases, while introducing the recommended books.  

# Development Environment Construction

・Ipython, Python, atom settings on your PC

Atom debugging with Python alone

・Copy and paste the Web practice problem in WSL and Emacs

・Design and develop a Web top page

・Under the top page (index.html) developed demo.py demo.html Demo.css demo.js

・each demoxx.py design, demoxx.html design, Representative .css designStandardized module namesCreate a module list
2. Git, GitHub configuration

-selection of collaborators

・Learning GitHub (Binder stuff)
3. Document Planning

・Create a module list

Python Program Journal Organization

・HTML Journal Organization

・JS Program and Journal Organization
4. Development plan

1. Python acquisition plan

2. Actual Practice

3. Python Programming (Command prompt and on WSL)

4. Debugging

5. Model Building

6. Ipyton Debug (Jupyternotebook on WSL) developed it under Atom Environment (NumPy, pandas Acquisition)
 Ipython, Pyton, atom settings on PC
- Toshiba Dynabook Satellite B554/K use

-Documentation

-Test in development environment

- Blog up
# Git, GitHub configuration

-selection of collaborators
-GitHub Learning

-Request for collaborators

# Document Plan formulation
- Five-year Plan

-One year schedule

-Three-year schedule

-Final Plan

# reading Plan
-Qiita document conning (in progress)

-Why make object-oriented (purchased)

-New Linux textbooks (purchased-read after referring to the actual machine)

-Everyone's python (purchased-in-progress, early)

-Nikkei Linux (purchase)

-Making from scratch deep Learning

-theory and implementation of learning in Python (pre-purchased)

-Access Learning (create Address Book and learn about MySQL query)

-Copy and paste in Qiita document study (in progress)

-(Programming (Python), Statistical machine learning, deep learning (deep Learning), Mathematics for machine learning, probability and statistics)

-Easy to learn mathematics for understanding machine learning

-Ipython Interactive Computing and Visualization Cookbook (purchased-last)

-Other

人気ブログランキングへ←人気ブログランキングに参加しています。よろしければ1票を!

 

WSLへmssqlをインストールしてみた(失敗)

f:id:neverjp:20181230210033j:plain

北海道で撮ったスナップショット

 

  WSLへmssqlをインストールしてみた。 mssqlwebsiteではWSLはサポートしていないと書いてあったが、無理して私のPC環境にインストールしてみたが、見事にけられた。 余計な時間を使ってしまった。見かけ上はインストールは成功に見えたのだが。 ****************************

SQL install to Ubuntu on WSL

****************************

Ubuntu 18.04 にツールをインストールします。 SQL Server をインストールします。 UbuntuSQL Server を構成するには、ターミナルで次のコマンドを実行し、mssql-server パッケージをインストールします。 wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

Microsoft SQL ServerUbuntu リポジトリを登録します。

sudo add-apt-repository "$(wget -qO-https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list)"

上ではなしにプレビューを試したいときに。

sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-preview.list)"

SQL Server をインストールするには、次のコマンドを実行します。

sudo apt-get update sudo apt-get install -y mssql-server

パッケージのインストールが完了したら、mssql-conf setup の実行後に、SA パスワードの設定とエディションを選択する指示に従います。

sudo /opt/mssql/bin/mssql-conf setup

SA アカウントは強力なパスワードを指定していることを確認してください。(最小長さが 8 文字で、大文字と小文字のアルファベット、10 進数の数字や英数字以外の記号を含む)。 構成が完了したら、サービスが実行されていることを確認します。

systemctl status mssql-server

**********************************************************

1.パブリック リポジトリの GPG キーをインポートします。

curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

2.UbuntuMicrosoft リポジトリを登録します。

curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list

3.ソースの一覧を更新して、unixODBC 開発者のパッケージをインストール コマンドを実行します。

sudo apt-get update

sudo apt-get install mssql-tools unixodbc-dev

注意:最新バージョンに更新するmssql ツール次のコマンドを実行します。

sudo apt-get update

sudo apt-get install mssql-tools

4.省略可能な: 追加/opt/mssql-tools/bin/をパスbash シェル内の環境変数。させる

sqlcmd と bcpログイン セッションでは、bash シェルからアクセス可能な変更、パスで、 ~/.bash_profile次のコマンドでファイル。

echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile

させるsqlcmd と bcp対話型/非ログイン セッションでは、bash シェルからアクセス可能な変更、パスで、 ~/.bashrc次のコマンドでファイル。

echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc source ~/.bashrc **************************************************

CREATE DATABASE TestDB

SELECT Name from sys.Databases GO USE TestDB

CREATE TABLE Inventory (id INT, name NVARCHAR(50), quantity INT) INSERT INTO Inventory VALUES (1, 'banana', 150);

INSERT INTO Inventory VALUES (2, 'orange', 154);

GO

SELECT * FROM Inventory WHERE quantity > 152;

GO

sqlcmd コマンド プロンプトの終了

QUIT

****************************************************

エラーメッセージは

****************************************************

Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2749. Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..

人気ブログランキングへ←人気ブログランキングに参加しています。よろしければ1票を!

 

セッションの管理

セッションの管理

f:id:neverjp:20181227073405j:plain

画面1 login成功後demo03.htmlに飛んでいくところ



SQLが手に入らないのでセッションの管理コードだけでも埋め込もうと、丸2日間かかって仕上げた。
一番苦労したのは「Method Not Allowed」になってしまうことだった。
トラッパーやトレーサじみたコードを入れてアイソレートしていった。
テストした項目は
①rogin成功失敗
②logout
③ルートへのジャンプ
④login後の他HTMLへのジャンプ。
⑤demo28.pyからのパラメータの引継ぎ
⑥login中の各振る舞い
⑦logout中のふるまい

など多岐にわたってテストした。

*************************************************

demo28.py関連プログラム
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#demo28.py sessin managed
from flask import Flask, redirect, request, render_template, url_for, session

app = Flask(__name__)

@app.route('/login', methods=['GET', 'POST'])
def login():
・・if request.method == 'POST':
・・・・session['username'] = request.form['username']
・・・・return redirect(url_for('index'))
・・return render_template('check28.html')

@app.route('/reset', methods=['GET', 'POST'])
def reset():
・・session['username'] = 'zako'
・・return render_template('check28.html')

@app.route('/')
def func():
・・if 'username' in session:
・・・・html = render_template('demo03.html',name = str(session['username']))
・・・・return html
・・return 'You are not logged in'

@app.route('/check', methods=['GET', 'POST'])
def check():
・・if request.method == 'POST':
・・・・session['username'] = request.form['username']
・・・・return redirect(url_for('func'))
・・return render_template('check28.html')

@app.route('/',methods=['POST'])
def index():

・・success = False
・・name = request.form["username"]
・・passwd = request.form["pass"]
・・my_message = "「セッション処理のプログラムはどうでしたか?」"

・・user_data = [{"id":"zako", "pass":"week_pass"},{"id":"ikarochan", "pass":"kawaii"},{"id":"yoshiko", "pass":"ok"},{"\
\
id":"miku", "pass":"hatsune"}]

・・for i in range(0, 4):
・・・・if user_data[i]["id"] == name:
・・・・・・if user_data[i]["pass"] == passwd:
・・・・・・・・success = True
・・・・・・・・session['username'] = name
・・・・・・・・return render_template('index28.html',suc=success,name=name,pas=passwd,msg=my_message)
・・・・・・else:
・・・・・・・・continue
・・・・else:
・・・・・・continue
・・success = False
・・return render_template('index28.html',suc=success,name=name,pas=passwd,msg=my_message)

@app.route('/logout')
def logout():
・・session.pop('username', None)
・・return redirect(url_for('func'))

app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'

if __name__ == '__main__':
・・app.run(debug=True)
****************************************
<!DOCTYPE html> <!-- check28.html -->
<html lang="ja">
<head>
・・<meta charset="UTF-8">
・・<title>Loginフォーム</title>
<!-- <link rel="stylesheet" type="text/css" href="{{url_for('static', filename='style.css')}}" /> -->
・・<link rel="stylesheet" type="text/css" href="static/css/style.css" />
</head>
<body>

・・<form action="/" method="post">
・・・・<h1>Login</h1>
・・・・<input type="text" name="username" placeholder="Username" required/>
・・・・<input type="password" name="pass" placeholder="Password" required/>
・・・・<input type=submit value=Login>
・・</form>

</body>
</html>
****************************************
<!DOCTYPE html> <!-- index28.html -->
<html lang="ja">
・・<head>
・・・・<meta charset="UTF-8">
・・・・<title>Login</title>
<!-- <link rel="stylesheet" type="text/css" href="style.css" /> -->
・・・・<link rel="stylesheet" type="text/css" href="static/css/style-07.css" />
・・・・<!--[if lt IE 9]>
・・・・<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
・・・・<![endif]-->
・・</head>
・・<body>
・・・<h1>Login終了</h1>
・・・{% if suc %}
・・・<h1>Login OK</h1>
・・・<h1>Username is {{ name }}</h1>
・・・{% else %}
・・・Invalid Username or Password. Debug {{ name }},{{ pas }}
・・・{% endif %}
・・・</br>
・・・demo28.pyからのメッセージは:</br>
・・・{{ msg }}です。

・・</body>
</html>
****************************************
<!DOCTYPE html>
<html lang="ja">
<head>
・・<meta charset="UTF-8">
・・<link rel="stylesheet" href="/static/css/style-03.css">
・・<title>Deep Learning second TEST</title>
</head>
<body>
・・<title>Hello from Flask</title>
・・{% if name %}
・・・<h2>{{ name }}さん!テンプレートからのHello Worldだよ!</h2>
・・{% else %}
・・・<h2>テンプレートからのHello Worldだよ!</h2>
・・{% endif %}

・・<p>
・・・<img src="/static/images/plant_3.jpg" alt="pic03">
・・</p>

・・<script src="/static/js/main.js"></script>
</body>
</html>
****************************************
(function(){
・・'use strict';

・・alert('アラートですよ〜。');

})();
****************************************

**********************************************************************

以上

 

f:id:neverjp:20181227074604j:plain

画面2 loginしているところ

f:id:neverjp:20181227074744j:plain

画面3 login成功

f:id:neverjp:20181227074924j:plain

画面4 login失敗

f:id:neverjp:20181227075052j:plain

画面5 login成功後 '/'入力

f:id:neverjp:20181227075357j:plain

画面6 /logout入力後、セッションが切れている

人気ブログランキングへ←人気ブログランキングに参加しています。よろしければ1票を!