This is a guide on how to install Caffe for Ubuntu 16.04 and above, without GPU support (No CUDA required).
sudo apt-get install libopencv-dev python-opencv
| # 0. Declare the schema for the output of our function | |
| outSchema = StructType([StructField('replication_id',IntegerType(),True),StructField('Accuracy',DoubleType(),True),StructField('num_trees',IntegerType(),True),StructField('depth',IntegerType(),True),StructField('criterion',StringType(),True)]) | |
| # decorate our function with pandas_udf decorator | |
| @F.pandas_udf(outSchema, F.PandasUDFType.GROUPED_MAP) | |
| def run_model(pdf): | |
| # 1. Get randomized hyperparam values | |
| num_trees = random.choice(list(range(50,500))) | |
| depth = random.choice(list(range(2,10))) |
| import cv2 # opencv | |
| import numpy as np | |
| font_scale = 1.5 | |
| font = cv2.FONT_HERSHEY_PLAIN | |
| # set the rectangle background to white | |
| rectangle_bgr = (255, 255, 255) | |
| # make a black image | |
| img = np.zeros((500, 500)) |
| set.seed(2) | |
| x <- 1:100 | |
| y <- 20 + 3 * x | |
| e <- rnorm(100, 0, 60) | |
| y <- 20 + 3 * x + e | |
| plot(x,y) | |
| yx.lm <- lm(y ~ x) | |
| lines(x, predict(yx.lm), col="red") |