Skip to content

Instantly share code, notes, and snippets.

View minghao2016's full-sized avatar

Ming Hao minghao2016

View GitHub Profile
@minghao2016
minghao2016 / run_python_script_in_conda_env.bat
Created August 25, 2021 21:37 — forked from maximlt/run_python_script_in_conda_env.bat
Run a Python script in a conda environment from a batch file
@echo OFF
rem How to run a Python script in a given conda environment from a batch file.
rem It doesn't require:
rem - conda to be in the PATH
rem - cmd.exe to be initialized with conda init
rem Define here the path to your conda installation
set CONDAPATH=C:\ProgramData\Miniconda3
rem Define here the name of the environment
@minghao2016
minghao2016 / custom-focal-loss-keras.R
Created June 18, 2021 20:59 — forked from PsycheShaman/custom-focal-loss-keras.R
Custom Loss Function for R: Focal Loss (to Account for Imbalanced Classes During Classification), adapted from https://github.com/umbertogriffo/focal-loss-keras, since I could not find an equivalent loss function for R
require(keras)
require(tensorflow)
K <- keras::backend()
# Custom Focal Loss
focalLoss <- function(gamma=2., alpha=.25){
@minghao2016
minghao2016 / Hello PyTorch.ipynb
Created June 7, 2021 02:05 — forked from santi-pdp/Hello PyTorch.ipynb
Toy example in pytorch for binary classification
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@minghao2016
minghao2016 / biotools_packages.txt
Created February 12, 2021 19:19 — forked from dansondergaard/biotools_packages.txt
Package names from bio.tools and various conda channels (anaconda, conda-forge, bioconda, r).
KNIME - Cellular phenotyping
Galaxy Image Analysis
COMPSs
YEASTRACT
WormBase
Reactome knowledgebase of biological pathways
PRIDE
PANTHER
AnalysisServiceService
Kyoto encyclopedia of genes and genomes KEGG
@minghao2016
minghao2016 / plot_rf_tree.R
Created November 6, 2020 18:32 — forked from sillasgonzaga/plot_rf_tree.R
Plot a tree from a Random Forest Model
plot_rf_tree <- function(final_model, tree_num, shorten_label = TRUE) {
# source: https://shiring.github.io/machine_learning/2017/03/16/rf_plot_ggraph
# get tree by index
tree <- randomForest::getTree(final_model,
k = tree_num,
labelVar = TRUE) %>%
tibble::rownames_to_column() %>%
# make leaf split points to NA, so the 0s won't get plotted
@minghao2016
minghao2016 / Tetherheavy.ipynb
Created August 21, 2020 21:54 — forked from ptosco/Tetherheavy.ipynb
TetherHeavy
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.
@minghao2016
minghao2016 / GBDT_LR.py
Created August 11, 2020 19:41 — forked from SS1031/GBDT_LR.py
GBDT-LogisticRegression
"""
GBDT + LogisticRegression
"""
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
import seaborn as sns
from sklearn.datasets import make_moons
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@minghao2016
minghao2016 / dockedpose.py
Created July 29, 2020 14:33 — forked from baoilleach/dockedpose.py
Using Open Babel to calculate the symmetry-corrected RMSD of a docked pose from a crystal structure
import math
import pybel
def squared_distance(coordsA, coordsB):
"""Find the squared distance between two 3-tuples"""
sqrdist = sum( (a-b)**2 for a, b in zip(coordsA, coordsB) )
return sqrdist
def rmsd(allcoordsA, allcoordsB):
"""Find the RMSD between two lists of 3-tuples"""