การสร้าง RESTful API สำหรับใช้งานจริง ง่าย ๆ ด้วย Flask และ Waitress

จาก From LAB to Production – จาก Machine Learning Model สู่ Flask RESTful ซึ่งได้นำ Machine Learning แบบ Statistical Approach อย่าง Logistic Regression ที่สร้างโมเดล และ Train กับข้อมูลเรียบร้อยแล้ว (บนเครื่อง Development) จากนั้น ได้นำโมเดลออกมาใช้งาน โดยใช้ วิธีการ Serialization ด้วย joblib ในภาษา Python ได้เป็นไฟล์ออกมา แล้วจึงนำไปใช้เพื่อใช้ในการทำนาย (predict) ชนิดของดอก Iris บนเครื่อง Production โดยรับ Input จากผู้ใช้ผ่าน HTTP Protocol ทั้ง GET/POST ที่ TCP/5000 ตัวอย่างดังกล่าว ยังเป็นเพียงการ … Read more

Stencil : Styling

Shadow DOM Shadow DOM เป็น API ที่อยู่ใน browser ที่ให้ความสามารถในทำ DOM encapsulation และ style encapsulation โดย Shadow DOM จะแยก component ออกจากภายนอก ทำให้ไม่ต้องกังวลกับ scope ของ css หรือผลกระทบกับ component ภายนอก หรือ component ภายนอกจะกระทบกับ component ภายใน ใน Stencil ค่า default การใช้งาน Shadow DOM ใน web component ที่สร้างด้วย Stencil จะถูกปิดอยู่  หากต้องการเปิดใช้งาน Shadow DOM ใน web component ต้องกำหนดค่า shadow param ใน … Read more

python #02 – ติดตั้ง Tensorflow และ Keras

ต่อจาก python #01 – ติดตั้ง jupyter notebook บน Windows ต่อไปเราจะใช้ Machine Learning Library “Tensorflow” และใช้ “Keras” ซึ่งเป็น High-level Neuron Network API ซึ่งจะไปเรียกใช้ Backend คือ Tensorflow อีกชั้นหนึ่ง จาก jupyter notebook ทำตามขั้นตอนต่อไปนี 1.  คำสั่งต่อไปนี้ เพื่อติดตั้ง Tensorflow 2.  คำสั่งต่อไปนี้ เพื่อติดตั้ง Keras จะได้ผลประมาณนี้ สร้าง Neural Network ด้วย Keras เริ่มจาก import ส่วนต่าง ๆ ได้แก่ Models และ Layers สมมุติเราจะสร้าง Model แบบนี้ เสร็จแล้วก็ต้อง … Read more

python #01 – ติดตั้ง jupyter notebook บน Windows

jupyter Notebook เป็น Open Source Web Application ให้เราสามารถเขียนภาษา python ได้ง่ายขึ้น สามารถ Share ได้ด้วย และยังสามารถใส่คำอธิบาย (Markdown) ได้ด้วย ติดตั้งลงในเครื่องส่วนตัวได้ ในบทความนี้ แสดงวิธีติดตั้งและใช้งานบน Microsoft Windows ดังนี้ 1. ขั้นแรก ต้องมี Python ก่อน (หมายเหตุ: ณ เวลานี้ 27/11/61 รุ่นล่าสุดคือ 3.7.1 แต่เนื่องจากจะแนะนำการใช้งาน Tensorflow, Keras จึงยังต้องเลือกใช้ Python 3.6.7) https://www.python.org/ftp/python/3.6.7/python-3.6.7.exe เมื่อติดตั้งแล้ว ควร Restart เครื่องสักหนึ่งครั้ง 2. ติดตั้ง pip ซึ่งใช้ในการติดตั้งเครื่องมือต่าง ๆเปิด Windows Console (กดปุ่ม Win + R) … Read more

Stencil : JSX

Stencil component ใช้ JSX template syntax ในการกำหนดรูปแบบการแสดงผลที่จะถูก render ของ component  ซึ่งแต่ละ component จะมี render function ที่จะทำหน้าที่ return โครงสร้างของ component ที่จะเปลี่ยนเป็น DOM ตอน runtime เพื่อแสดงผลบนหน้าจอ class MyComponent { render() { return ( <div> <h1>Hello World</h1> <p>This is JSX!</p> </div> ); } } จาก class Mycomponent ด้านบน render function จะ return div element ที่ภายในประกอบไปด้วย h1 และ p … Read more