Skip to content

Instantly share code, notes, and snippets.

@tobigithub
tobigithub / pubchem_convert_SMILES_to_IUPAC.py
Created October 15, 2021 18:08 — forked from mbohun/pubchem_convert_SMILES_to_IUPAC.py
pubchem_convert_SMILES_to_IUPAC.py use pubchem PUG REST to get IUPAC names/strings for SMILES
import sys
import requests
from lxml import etree
if __name__=="__main__":
smiles = sys.argv[1]
html_doc = requests.get("https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/" + smiles + "/record/XML")
root = etree.XML(html_doc.text)
@tobigithub
tobigithub / xyz2om2.py
Created January 7, 2021 20:16 — forked from andersx/xyz2om2.py
XYZ to OM2
#!/usr/bin/env python2
import numpy as np
import sys
elements = dict()
elements["H"] = 1
elements["C"] = 6
elements["N"] = 7
elements["O"] = 8
elements["F"] = 9
@tobigithub
tobigithub / xyz2om2.f90
Created January 7, 2021 20:13 — forked from andersx/xyz2om2.f90
Stupid xyz2om2 converter in fortran (cuz it was slow to do 1M files with a python converter)
! PUBLIC DOMAIN LICENSE 2017 BY ANDERS S. CHRISTENSEN
!
! I WROTE THIS BECAUSE I WAS BORED - I DON'T RECOMMEND
! WRITING FILE PARSERS IN FORTRAN BECAUSE IT IS NOT
! PRODUCTIVE.
program convert
implicit none
@tobigithub
tobigithub / MNIST_Keras2DML.py
Created March 1, 2019 23:58 — forked from NiloyPurkait/MNIST_Keras2DML.py
An example of using Apache SparkML to train a convolutional neural network in parallel using the MNIST dataset, on IBM watson studio. Written for medium article: https://medium.com/@niloypurkait/how-to-train-your-neural-networks-in-parallel-with-keras-and-apache-spark-ea8a3f48cae6
################################### Keras2DML: Parallely training neural network with SystemML#######################################
import tensorflow as tf
import keras
from keras.models import Sequential
from keras.layers import Input, Dense, Conv1D, Conv2D, MaxPooling2D, Dropout,Flatten
from keras import backend as K
from keras.models import Model
import numpy as np
import matplotlib.pyplot as plt
@tobigithub
tobigithub / nbaParallel.R
Created November 2, 2015 00:51
Wrapper for caret package to train multiple models in one call
#' Basketball: A function to run a lot of different models
#'
#' This function allows you to run a lot of different models from the caret package
#' @param method The methods to use i.e c("glm", "rf")
#' @param formula The formula to use
#' @param data The data frame to use. Can leave blank if supplying independent training and testing
#' @param regression Logical TRUE if type of model is "regression"
#' @param metric Metic to use. For example, "RMSE" if regression and "Accuracy" if classification
#' @param Train Do you want to supply a training set bypassing the partitioning
#' @param Test If you bypassed partition need to also supply testing set
@tobigithub
tobigithub / tabstatR
Created November 2, 2015 00:42
tabstat in R (summary statistics latex)
#' Advanced Summary Statistics Table with Description Option
#'
#' This function allows you to output a summary table much like tabstat. Statistics are based on the columns/variables of the dataframe. Only works when the number of columns is greater than 1.
#' @param data.frame Data frame object
#' @param variables Number or vector of variables/ variable names to include
#' @param table Type of table to return. Options are "simple"/"table" or "latex"/"xtable"
#' @param caption Caption to include underneath the table if "latex"/"xtable"
#' @param digits Digits to display if "latex"/"xtable"
#' @param stats Statistics to include: 'count','sum','max','min','range','sd','var', 'cv','semean','skewness','kurtosis', 'q1','q5','q10','q25','median', 'q75','q90','q95','q99','iqr'
#' @param description Further description for each variable to be included in the table
@tobigithub
tobigithub / loadPackages.R
Created November 2, 2015 00:39
Install and Load Packages
#' Load packages and install packages that are not installed before loading
#'
#' This function allows you to check install packages then load
#' @param packages Vector of packages names to be installed
#' @param dependencies Logical. Return package dependencies?
#' @param repos Repository for install.packages()
#' @keywords install.packages
#' @keywords require
#' @keywords library
#' @export
@tobigithub
tobigithub / caret.R
Created October 4, 2015 02:22 — forked from primaryobjects/caret.R
Example of training a glm model on a spam data-set, using the caret library.
# Example of training a glm model on a spam data-set, using the caret library.
library(caret)
library(kernlab)
# Load spam dataset.
data(spam)
# Split the data into a training/test set by 60% training/40% test.
inTrain <- createDataPartition(y = spam$type, p=0.6, list=FALSE)
training <- spam[inTrain,]
# Quiz 4
# Question 1.
library(ElemStatLearn)
library(randomForest)
library(caret)
data(vowel.train)
data(vowel.test)
@tobigithub
tobigithub / q3.R
Created October 4, 2015 02:21 — forked from primaryobjects/q3.R
Practical Machine Learning Quiz 3.
# Question 1
library(AppliedPredictiveModeling)
library(caret)
data(segmentationOriginal)
set.seed(125)
#inTrain <- createDataPartition(segmentationOriginal$Case, list=FALSE)
inTrain <- data$Case == "Train"