This file contains hidden or 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
# Parallel Cross-Validation Example | |
library(foreach) # install.packages('foreach') | |
library(caret) # install.packages('caret', dependencies = c("Depends", "Suggests")) | |
library(doParallel) # install.packages('doParallel') | |
registerDoParallel(makeCluster(4)) # Use 4 cores for parallel CV | |
data <- read.csv(…) # Assuming this is your dataset | |
cv <- caret::createFolds(nrow(data), k=10, list=T) # Create 10 folds |
This file contains hidden or 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
# As an administrative user, run the following on command line (paths need to be adjusted to local jre version): | |
root> export JAVA_HOME='/Library/Java/JavaVirtualMachines/jdk1.7.0_91.jdk/Contents/Home/jre' | |
root> export LD_LIBRARY_PATH='/Library/Java/JavaVirtualMachines/jdk1.7.0_91.jdk/Contents/Home/jre/lib/server' | |
root> export PATH=$PATH:$JAVA_HOME/bin | |
root> R CMD javareconf JAVA_CPPFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers | |
# On the R command line (launched as admin), run the following | |
R> install.packages('rJava','http://www.rforge.net/') |
This file contains hidden or 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
# These instructions were used to create a CUDA 9.1 compatible EC2 instance for the sake of | |
# running experiments with [imagej-ops-experiments]([ops-experiment](https://github.com/imagej/ops-experiments) | |
# deconvolution algorithms (via YacuDecu) | |
# Step 1) Create Instance | |
# Start instance for image: https://aws.amazon.com/marketplace/pp/B07BFSMQ32 | |
# - Choose p2.xlarge type | |
# - Make sure to have at least 30G of disk space | |
# Step 2) Install Java/Maven |
This file contains hidden or 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
#' Get density associated with points in 2D space | |
#' | |
#' @param x Vector of numeric values | |
#' @param y Vector of numeric values; must have equal length to \code{x} | |
#' @param nbins Grid size used for 2D kde. Larger numbers mean density bins are | |
#' more continuous and at around 50 visible discretization begins to disappear | |
#' in scatterplots (though lower numbers will improve speed) | |
#' @param limit Maximum number of points to use for kde estimation | |
#' @param ... Other arguments for MASS::kde2d | |
#' @return A vector of densities with length equal to length of \code{x} and \code{y}. |
This file contains hidden or 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
RUN mkdir $HOME/.nodeenv && \ | |
cd $HOME/.nodeenv && \ | |
pip install nodeenv && \ | |
nodeenv jupyterlab && \ | |
. jupyterlab/bin/activate && \ | |
pip install itkwidgets && \ | |
jupyter labextension install @jupyter-widgets/jupyterlab-manager itk-jupyter-widgets |
This file contains hidden or 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
from sklearn.model_selection import train_test_split | |
import numpy as np | |
def _get_stratified_split(splits, idx, values, proportions): | |
# Return immediately if there are fewer than 2 proportions use in splits | |
if len(proportions) <= 1: | |
splits.append(idx) | |
return splits | |
This file contains hidden or 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 numpy as np | |
from io import BytesIO | |
from PIL import Image | |
def png_bytes_to_numpy(png): | |
"""Convert png bytes to numpy array | |
Example: | |
>>> fig = go.Figure(go.Scatter(x=[1], y=[1])) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer