From the course: Data Science on Google Cloud Platform: Predictive Analytics

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Modify code to work with GCP

Modify code to work with GCP - Google Cloud Tutorial

From the course: Data Science on Google Cloud Platform: Predictive Analytics

Start my 1-month free trial

Modify code to work with GCP

- Let's take a look at how we can modify the model building code for propensity to work with DCP. The code is available in the file, propensity-cloud.py. This code should be run from the Cloud Shell or from a Compute Engine command line. Let's look at the key changes required to enable cloud here. First, in line 15, we need to read the file from cloud storage. The part for the file in cloud storage is available in this variable data file, then we use an OS command in line number 17 to call the gsutil command and do a copy of this file from cloud into a local file. So the file is being copied from Google Cloud Storage to a local data tree. Then the model building process continues as original. Finally, once the model is built, we need to save that generated model into cloud storage. For that, we go to line number 57. The model file has to be created with the name model.joblib. Then we dump the model that we created into this variable. We then upload this file into cloud storage, we…

Contents