MONETIZING MACHINE LEARNING: quickly turn python ml ideas into web applications on the ... serverless cloud
معرفی کتاب «MONETIZING MACHINE LEARNING: quickly turn python ml ideas into web applications on the ... serverless cloud» نوشتهٔ Mehdi Roopaei; Manuel Amunategui; [Amunategui, Manuel; Roopaei, Mehdi]، منتشرشده توسط نشر Apress : Imprint: Apress در سال 2018. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است.
Take your Python machine learning ideas and create serverless web applications accessible by anyone with an Internet connection. Some of the most popular serverless cloud providers are covered in this book—Amazon, Microsoft, Google, and PythonAnywhere. You will work through a series of common Python data science problems in an increasing order of complexity. The practical projects presented in this book are simple, clear, and can be used as templates to jump-start many other types of projects. You will learn to create a web application around numerical or categorical predictions, understand the analysis of text, create powerful and interactive presentations, serve restricted access to data, and leverage web plugins to accept credit card payments and donations. You will get your projects into the hands of the world in no time. Each chapter follows three steps: modeling the right way, designing and developing a local web application, and deploying onto a popular and reliable serverless cloud provider. You can easily jump to or skip particular topics in the book. You also will have access to Jupyter notebooks and code repositories for complete versions of the code covered in the book. What You'll Learn Extend your machine learning models using simple techniques to create compelling and interactive web dashboards Leverage the Flask web framework for rapid prototyping of your Python models and ideas Create dynamic content powered by regression coefficients, logistic regressions, gradient boosting machines, Bayesian classifications, and more Harness the power of TensorFlow by exporting saved models into web applications Create rich web dashboards to handle complex real-time user input with JavaScript and Ajax to yield interactive and tailored content Create dashboards with paywalls to offer subscription-based access Access API data such as Google Maps, OpenWeather, etc. Apply different approaches to make sense of text data and return customized intelligence Build an intuitive and useful recommendation site to add value to users and entice them to keep coming back Utilize the freemium offerings of Google Analytics and analyze the results Take your ideas all the way to your customer's plate using the top serverless cloud providers Who This Book Is For Those with some programming experience with Python, code editing, and access to an interpreter in working order. The book is geared toward entrepreneurs who want to get their ideas onto the web without breaking the bank, small companies without an IT staff, students wanting exposure and training, and for all data science professionals ready to take things to the next level. Table of Contents......Page 4 About the Authors......Page 18 About the Technical Reviewers......Page 19 Acknowledgments......Page 20 Introduction......Page 21 Chapter 1: Introduction to Serverless Technologies......Page 40 Step 2: Start a Virtual Environment......Page 41 Step 5: View in Browser......Page 42 Step 6: A Slightly Faster Way......Page 43 Introducing Serverless Hosting on Microsoft Azure......Page 44 Step 2: Download Source Files......Page 45 Step 3: Install Git......Page 46 Step 4: Open Azure Cloud Shell......Page 47 Step 5: Create a Deployment User......Page 49 Step 7: Create an Azure Service Plan......Page 50 Step 8: Create a Web App......Page 51 Check Your Website Placeholder......Page 52 Step 9: Pushing Out the Web Application......Page 53 Step 10: View in Browser......Page 54 Introducing Serverless Hosting on Google Cloud......Page 55 Step 2: Download Source Files......Page 56 Step 3: Open Google Cloud Shell......Page 58 Step 4: Upload Flask Files to Google Cloud......Page 59 Step 5: Deploy Your Web Application on Google Cloud......Page 61 Step 6: Don’t Forget to Delete Your Web Application!......Page 62 Conclusion and Additional Information......Page 64 Step 1: Get an Account on Amazon AWS......Page 65 Step 3: Create an Access Account for Elastic Beanstalk......Page 66 Step 4: Install Elastic Beanstalk (EB)......Page 69 Step 5: EB Command Line Interface......Page 70 Step 6: Take if for a Spin......Page 71 Step 7: Don’t Forget to Turn It Off!......Page 72 Introducing Hosting on PythonAnywhere......Page 73 Step 2: Set Up Flask Web Framework......Page 74 Summary......Page 76 Chapter 2: Client-Side Intelligence Using Regression Coefficients on Azure......Page 77 Exploring the Bike Sharing Dataset......Page 79 Working with Jupyter Notebooks......Page 81 Exploring the Data......Page 83 A Closer Look at Our Outcome Variable......Page 85 Quantitative Features vs. Rental Counts......Page 86 Let’s Look at Categorical Features......Page 88 A Simple Model......Page 90 Modeling with Polynomials......Page 92 Creating Dummy Features from Categorical Data......Page 94 Even More Complex Feature Engineering—Leveraging Time-Series......Page 96 Extracting Regression Coefficients from a Simple Model—an Easy Way to Predict Demand without Server-Side Computing......Page 99 R-Squared......Page 100 Predicting on New Data Using Extracted Coefficients......Page 101 Building a Local Flask Application......Page 105 Downloading and Running the Bike Sharing GitHub Code Locally......Page 108 Debugging Tips......Page 110 Git—Getting All Projects in Git......Page 112 The azure-cli Command Line Interface Tool......Page 114 Step 1: Logging In......Page 115 Step 4: Create Your Azure App Service Plan......Page 116 Step 5: Create Your Web App......Page 117 Step 6: Push git Code to Azure......Page 118 Important Cleanup!......Page 120 Troubleshooting......Page 121 Steps Recap......Page 123 main.py......Page 124 /templates/index.html folder and script......Page 126 Conclusion......Page 128 Additional Resources......Page 129 Chapter 3: Real-Time Intelligence with Logistic Regression on GCP......Page 130 Data Wrangling......Page 132 Dealing with Categorical Data......Page 137 Creating Dummy Features from Categorical Data......Page 141 Train/Test Split......Page 143 Logistic Regression......Page 144 Predicting Survivorship......Page 146 Abstracting Everything in Preparation for the Cloud......Page 147 Interactivity with HTML Forms......Page 148 Creating Dynamic Images......Page 149 Downloading the Titanic Code......Page 150 Google Cloud Flexible App Engine......Page 152 Google App Engine......Page 153 Step 1: Fire Up Google Cloud Shell......Page 154 Step 2: Zip and Upload All Files to the Cloud......Page 155 Step 3: Create Working Directory on Google Cloud and Unzip Files......Page 156 Step 5: Deploying the Web Application......Page 157 Troubleshooting......Page 158 main.py......Page 159 app.yaml......Page 161 requirements.txt......Page 162 Steps Recap......Page 163 Conclusion......Page 164 Chapter 4: Pretrained Intelligence with Gradient Boosting Machine on AWS......Page 165 Exploring the Wine-Quality Dataset......Page 167 Working with Imbalanced Classes......Page 171 Modeling with Gradient Boosting Classifiers......Page 173 Evaluating the Model......Page 175 Persisting the Model......Page 179 Predicting on New Data......Page 180 Designing a Web Application to Interact and Evaluate Wine Quality......Page 182 Introducing AJAX – Dynamic Server-Side Web Rendering......Page 183 Working in a Virtual Environment—a Sandbox for Experimentation, Safety and Clarity......Page 184 Amazon Web Services (AWS) Elastic Beanstalk......Page 186 Create an Access Account for Elastic Beanstalk......Page 187 Elastic Beanstalk......Page 189 EB Command Line Interface......Page 190 Fix the WSGIApplicationGroup......Page 192 Take if for a Spin......Page 194 Don’t Forget to Turn It Off!......Page 195 Steps Recap......Page 198 Access the Logs......Page 199 SSH into your Instance......Page 200 Conclusion......Page 201 Chapter 5: Case Study Part 1: Supporting Both Web and Mobile Browsers......Page 203 The Pair-Trading Strategy......Page 204 Downloading and Preparing the Data......Page 205 Preparing the Data......Page 207 Pivoting by Symbol......Page 208 Percent Change and Cumulative Sum......Page 209 Plotting the Spread......Page 210 Finding Extreme Cases......Page 211 Making Recommendations......Page 213 Calculating the Number of Shares to Trade......Page 215 Fluid Containers......Page 217 Running the Local Flask Version......Page 219 Bootstrap Input Field Validation......Page 221 Running on PythonAnywhere......Page 222 Source Code......Page 225 WSGI Configuration......Page 226 Reload Web Site......Page 227 Troubleshooting PythonAnywhere......Page 228 Conclusion......Page 229 Chapter 6: Displaying Predictions with Google Maps on Azure......Page 230 Exploring the Dataset on SF Crime Heat Map on DataSF......Page 232 Rebalancing the Dataset......Page 234 Exploring by Day-of-the-Week......Page 237 Creating a Month-of-the-Year Feature......Page 238 Creating Time Segments......Page 240 Exploring by Time Segment......Page 241 Visualizing Geographical Data......Page 243 Rounding Geocoordinates to Create Zone Buckets......Page 244 Using the Past to Predict the Future......Page 247 Google Maps Introduction......Page 251 Heatmap Layer......Page 252 Google Maps with Crime Data......Page 253 Abstracting Our Crime Estimator......Page 254 Designing a Web Application to Enable Viewers to Enter a Future Date and Visualize Crime Hotspots......Page 255 Add Your Google API Key......Page 256 Take It for a Spin......Page 257 Git for Azure......Page 258 The azure-cli Command Line Interface Tool......Page 260 Step 1: Logging In......Page 261 Step 3: Create Your Resource Group......Page 262 Step 5: Create your Web App......Page 263 Step 6: Push Git Code to Azure......Page 264 Troubleshooting......Page 266 Conclusion......Page 269 Chapter 7: Forecasting with Naive Bayes and OpenWeather on AWS......Page 271 Exploring the Dataset......Page 272 Naive Bayes......Page 274 Sklearn’s GaussianNB......Page 275 Realtime OpenWeatherMap......Page 276 Forecasts vs. Current Weather Data......Page 279 Translating OpenWeatherMap to “Golf|Weather Data”......Page 280 Download the Web Application......Page 285 Fix the WSGIApplicationGroup......Page 288 Take It for a Spin......Page 289 Don’t Forget to Turn It Off!......Page 291 Accessing OpenWeatherMap Data......Page 293 Handling User-Entered-Data......Page 294 Chapter 8: Interactive Drawing Canvas and Digit Predictions Using TensorFlow on GCP......Page 296 The MNIST Dataset......Page 298 Modeling with TensorFlow and Convolutional Networks......Page 301 Building Modeling Layers......Page 302 Instantiating the Session......Page 303 Running the Script......Page 304 Running a Saved TensorFlow Model......Page 306 Drawing Canvas......Page 307 From Canvas to TensorFlow......Page 308 Testing on New Handwritten Digits......Page 309 Download the Web Application......Page 311 Step 1: Fire Up Google Cloud Shell......Page 314 Step 2: Zip and Upload All Files to the Cloud......Page 315 Step 3: Create Working Directory on Google Cloud and Unzip Files......Page 316 Step 5: Deploying the Web Application......Page 317 Closing Up Shop......Page 319 TensorFlow......Page 320 Design......Page 321 Chapter 9: Case Study Part 2: Displaying Dynamic Charts......Page 322 Creating Stock Charts with Matplotlib......Page 324 Exploring the Pair-Trading Charts......Page 325 Designing a Web Application......Page 328 Mobile Friendly with Tables......Page 330 Uploading our Web Application to PythonAnywhere......Page 332 Conclusion......Page 336 Chapter 10: Recommending with Singular Value Decomposition on GCP......Page 337 Planning Our Web Application......Page 338 More from the MovieLens Dataset’s Liner Notes......Page 339 Overview of “ratings.csv” and “movies.csv”......Page 341 Understanding Reviews and Review Culture......Page 345 Getting Recommendations......Page 349 Euclidean Distance......Page 352 Cosine Similarity Distance......Page 353 Centering User Ratings Around Zero......Page 355 A Look at SVD in Action......Page 356 Downloading and Running the “What to Watch Next?” Code Locally......Page 359 main.py......Page 361 index.html......Page 364 Step 1: Fire Up Google Cloud Shell......Page 365 Step 2: Zip and Upload All Files to The Cloud......Page 366 Step 3: Create Working Directory on Google Cloud and Unzip Files......Page 367 Step 5: Deploying the Web Application......Page 368 Troubleshooting......Page 370 Closing Up Shop......Page 371 Conclusion......Page 372 Chapter 11: Simplifying Complex Concepts with NLP and Visualization on Azure......Page 373 Planning our Web Application—the Cost of Eliminating Spam......Page 374 Data Exploration......Page 375 Text-Based Feature Engineering......Page 376 Text Wrangling for TFIDF......Page 379 NLP and Regular Expressions......Page 380 Using an External List of Typical Spam Words......Page 381 Feature Extraction with Sklearn’s TfidfVectorizer......Page 382 Preparing the Outcome Variable......Page 383 Modeling with Sklearn’s RandomForestClassifier......Page 384 Measuring the Model’s Performance......Page 385 Interacting with the Model’s Threshold......Page 389 Interacting with Web Graphics......Page 391 Building Our Web Application—Local Flask Version......Page 393 Git for Azure......Page 395 Step 1: Logging In......Page 399 Step 3: Create Your Resource Group......Page 400 Step 5: Create Your Web App......Page 401 Step 6: Push Git Code to Azure......Page 402 Important Cleanup!......Page 403 Troubleshooting......Page 404 Conclusion and Additional Resources......Page 406 Chapter 12: Case Study Part 3: Enriching Content with Fundamental Financial Information......Page 407 Accessing Listed Stocks Company Lists......Page 409 Building a Dynamic FinViz Link......Page 411 Exploring Fundamentals......Page 413 Designing a Web Application......Page 414 Uploading Web Application to PythonAnywhere......Page 417 Conclusion......Page 423 Create a Google Analytics Account......Page 424 JavaScript Tracker......Page 426 Reading Your Analytics Report......Page 427 Traffic Sources......Page 428 Pages......Page 429 Conclusion and Additional Resources......Page 430 Chapter 14: A/B Testing on PythonAnywhere and MySQL......Page 431 A/B Testing......Page 432 UUID......Page 434 MySQL......Page 435 Command Line Controls......Page 437 MySQL Command Line Monitor......Page 438 Creating a Table......Page 439 Creating A Database User......Page 441 SELECT SQL Statement......Page 442 INSERT SQL Statement......Page 443 Abstracting the Code into Handy Functions......Page 444 Designing a Web Application......Page 447 Setting Up MySQL on PythonAnywhere......Page 448 A/B Testing on PythonAnywhere......Page 450 A/B Testing Results Dashboard......Page 453 Conclusion......Page 454 Chapter 15: From Visitor to Subscriber......Page 455 Flask-HTTPAuth—Hard-Coded Account......Page 456 Digest Authentication Example......Page 458 Digest Authentication Example with an External Text File......Page 460 Memberful......Page 462 Create a Real Web Page to Sell a Fake Product......Page 466 Checking Your Vendor Dashboard......Page 468 Taking Donations with PayPal......Page 469 Making a Purchase with Stripe......Page 472 Conclusion......Page 477 Chapter 16: Case Study Part 4: Building a Subscription Paywall with Memberful......Page 478 Upgrading Memberful......Page 479 Pip Install Flask-SSLify......Page 483 Memberful Authentication......Page 484 Authentication Step 1......Page 485 Authentication Step 2......Page 486 Calling Memberful Functions......Page 489 Designing a Subscription Plan on Memberful.com......Page 492 Replacing Memberful and MySQL with Your Own Credentials......Page 495 main.py......Page 496 index.html......Page 497 Conclusion......Page 498 Google Cloud (App Engine)......Page 499 Amazon Web Services (Beanstalk)......Page 500 Microsoft Azure (AWS)......Page 502 Memberful.com......Page 503 Index......Page 505 Take your Python machine learning ideas and create serverless web applications accessible by anyone with an Internet connection. Some of the most popular serverless cloud providers are covered in this book - Amazon, Microsoft, Google, and PythonAnywhere. You will work through a series of common Python data science problems in an increasing order of complexity. The practical projects presented in this book are simple, clear, and can be used as templates to jump-start many other types of projects. You will learn to create a web application around numerical or categorical predictions, understand the analysis of text, create powerful and interactive presentations, serve restricted access to data, and leverage web plugins to accept credit card payments and donations. You will get your projects into the hands of the world in no time. Each chapter follows three steps: modeling the right way, designing and developing a local web application, and deploying onto a popular and reliable serverless cloud provider. You can easily jump to or skip particular topics in the book. You also will have access to Jupyter notebooks and code repositories for complete versions of the code covered in the book
دانلود کتاب MONETIZING MACHINE LEARNING: quickly turn python ml ideas into web applications on the ... serverless cloud