Skip to content

Instantly share code, notes, and snippets.

# 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)))
@aplz
aplz / draw_text_with_background_opencv.py
Last active February 3, 2025 23:46
draw text with background // opencv
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))
@nikitametha
nikitametha / installing_caffe.md
Last active June 4, 2025 16:15
Installing Caffe on Ubuntu 16.04 and above (CPU ONLY, WITHOUT CUDA OR GPU SUPPORT)

This is a guide on how to install Caffe for Ubuntu 16.04 and above, without GPU support (No CUDA required).

Prerequisites:

OpenCV

sudo apt-get install libopencv-dev python-opencv

OpenBLAS OR Atlas

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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")