Gentle Introduction to Developing modern web apps in R & Python WiFi - Block 71 Bandung - Username: blk71 - Password: blk71bdg
- Username: blk71daily
- Password: innovationfactory
Schedule and Deliverables: https://algorit.ma/kickstart-introduction-developing-modern-web-apps/
Web App template (download link): https://github.com/onlyphantom/darkershiny
-
What do we want in a "modern" web app?
- Functionalities
- Work with any kind of input sources
- Get machine learning functionalities
- Prediction
- Get visualization functionalities
- Embed visualization into our app
- Security features (production code)
- Cloud deployment
- Version control
- Authentication
- [Optional] Administration
- Appearance and UX
- Mobile-friendly
- Customized with own CSS / JS
- Functionalities
-
How do we gain the skills required for objective #1
-
Introduction to R and Python
- R and Python are programming languages
- RStudio is IDE (editor)
- Visual Studio Code, Jupyter Notebook and Labs
- Terminal (Linux)
-
Introduction to the tools we'll use
- Visual Studio Code
- Download link: https://code.visualstudio.com/download
- RStudio
- Download link: https://www.rstudio.com/products/rstudio/download/
- SQL Editor / App
- Use any free / open source
- https://tableplus.io
- Cloud deployment
- Microsoft Azure
- https://azure.microsoft.com/en-us/free/
- If shiny: https://www.rstudio.com/products/shiny/shiny-server/
- Version Control
- GitHub
- https://github.com/
- GitLens for VS Code
- Cheatsheet for Shiny
- Shiny Proxy
- Visual Studio Code
-
Developer productivity and deployment
- Git and version control
- Virtual environment
- Linux servers and cloud options
- DON'T: environment variables
-
Code along: WebGuard
Demo 1:
- TensorFlow as a web app (HousingApp)
Demo 2:
- Shiny on SQL (Limitless)
Demo 3:
- Shiny in action (Quadrant)
Demo 4:
- Authentication and Continuous Delivery (Pedagogy)
Demo 5:
- Telco app (Confidence)
-
Download the web app template
-
Unzip the file
-
Right-click on app.R and open > open in RStudio
-
Click on "run app" green button in RStudio
-
Click on "open in web browser"
-
Open RStudio
-
Click on New > New File > Shiny Web App
-
Click on "Run App"
-
Create our Visualization
plot(x, y)
orggplot()
-
Assign that plot to a variable
myplot <- plot(x,y)
-
Use
renderPlot({ myplot })
to render plot in Shiny -
Click on the Publish button next to Run app
- Use a microframework like Flask
- If you don't have it installed yet:
pip install flask
- If you don't have it installed yet:
- Use virtual environments
- Or alternatively: conda environments
- Use a modern IDE
- Has github integration
- Simple code completion / intellisense
- Create
app.py
and the boilerplate:
from flask import Flask
app = Flask(__name__)
@app.route('login')
...
Use flask run
to run the app
-
Python: In a microframework or framework like Django or Flask, you write separate code for each of:
- html
- js
- css
- py
-
R: Use shiny and write everything in R
- app.R
-
In R: two options for deployment
- Free shinyapps.io (Publish button)
- samuelc.shinyapps.io/predictor
- Shiny Server (open source) deployed on an Ubuntu machine
- Free shinyapps.io (Publish button)
-
In Python:
- pythonanywhere
- Docker (container): alpine linux
- Run on Linux machine
-
Advantages
-
R
- data manipulation if often one line of code and built in without any reliance on any external libraries
ggplot2
and other cool visualization libraries- Shiny is super easy to use (literally three steps)
-
Python
- Ease of deployment (any linux server or container)
- Access to pandas, numpy, sk-learn, tf..
- More "general" so a lot of libraries outside of the data science world
-
-
R and Python are both equally good choice
- Any big companies releasing open source AI tools
- Have both R and Python
- Any big companies releasing open source AI tools
-
Pick up visualization
- R: lattice plot, ggplot and base plot in R
- Python: matplotlib
-
Pick up machine learning
- Sk-learn, tensorflow or keras or mxnet, caret or algorithms implemented in R
-
Get familiar with Shiny or Flask
-
Learn cloud deployment and version control
-
Choices:
- AWS (Amazon web services)
- Microsoft Azure
- Google Cloud
- ...
-
Sign up for github.com
-
-
Reference Materials
-
For Shiny:
-
For Flask:
-
My Github has a lot of content for:
- Learning ggplot
- Learning text mining
- Learning sentiment analysis
- Learning pandas and python for data science
- Learning shiny apps
- Free templates
-