This file contains 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 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) |
This file contains 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
#!/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 |
This file contains 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
! 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 |
This file contains 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
################################### 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 |
This file contains 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
#' 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 |
This file contains 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
#' 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 |
This file contains 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
#' 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 |
This file contains 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
# 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,] |
This file contains 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
# Quiz 4 | |
# Question 1. | |
library(ElemStatLearn) | |
library(randomForest) | |
library(caret) | |
data(vowel.train) | |
data(vowel.test) |
This file contains 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
# Question 1 | |
library(AppliedPredictiveModeling) | |
library(caret) | |
data(segmentationOriginal) | |
set.seed(125) | |
#inTrain <- createDataPartition(segmentationOriginal$Case, list=FALSE) | |
inTrain <- data$Case == "Train" |
NewerOlder