This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
# from watson_machine_learning_client import WatsonMachineLearningAPIClient | |
from ibm_watson_machine_learning import APIClient | |
class WMLUtils: | |
def __init__(self, wml_credentials): | |
# self.client = WatsonMachineLearningAPIClient(wml_credentials) | |
self.client = APIClient(wml_credentials) | |
def set_deployment_space(self, deployment_space): |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create a conda config with the require libraries | |
config_yaml = """ | |
name: custom | |
channels: | |
- conda-forge | |
dependencies: | |
- r | |
- libiconv | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install specific version of xgboost to ensure the development and deployment environment have the same version | |
install.packages("https://cloud.r-project.org/src/contrib/Archive/xgboost/xgboost_1.5.2.1.tar.gz", repos=NULL, type="source") | |
library(xgboost) | |
data(iris) | |
species <- iris$Species | |
label <- as.integer(iris$Species) - 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env Rscript | |
library(xgboost) | |
library(jsonlite) | |
args <- commandArgs(trailingOnly = TRUE) | |
if (length(args) == 0) { | |
stop("Insufficient arguments.", call. = FALSE) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
params = { | |
"wml_credentials": wml_credentials, | |
"space_id": SPACE_ID, | |
"script": "predict.R", | |
"required_assets": ["iris_xgb.model"], | |
"r_packages": ["jsonlite", "xgboost"], | |
} | |
def r_function(params=params): | |
""" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config = { | |
"function_name": "lead scoring", | |
"script": "lead_scoring.R", | |
"required_assets": ["products.csv", "transactions.rds", "xgboost.rds", "mssql-jdbc-10.2.1.jre11.jar"], | |
"r_packages": ["dplyr", "RJDBC", "xgboost"], | |
} | |
payload = {"scoring": {"input_data": [{"values": [config]}]}, "deployment": {"id": deployment_id}, "space_id": SPACE_ID, "name": "lead_scoring_deployment"} | |
headers = {"Content-Type": "application/json", "Accept": "application/json", "Authorization": wml_client._get_headers()["Authorization"]} | |
params = {"version": "2021-06-24", "space_id": SPACE_ID} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Namespace | |
metadata: | |
name: ibm-common-services | |
--- | |
apiVersion: v1 | |
kind: Namespace | |
metadata: | |
name: cpd | |
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: databases.cpd.ibm.com/v1 | |
kind: Db2oltpService | |
metadata: | |
name: db2oltp-cr | |
namespace: cpd | |
spec: | |
license: | |
accept: true | |
license: Standard | |
--- |
OlderNewer