Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
while true
do
cat /proc/loadavg | ts | tee -a loadavg.csv
free -m | grep Mem | tr -s " " | cut -d " " -f2,3,4,5,6,7 | ts | tee -a memory.csv
iostat | awk '/avg-cpu/ {getline; $1=$1; print}' | ts | tee -a iostat.csv
top -b -n 1 | head | awk -F' ' 'FNR == 3 {print $2, $4, $6, $8, $10, $12, $14}' | ts | tee -a cpu_monitor.csv
sleep 1
done
from locust import HttpUser, task, between, SequentialTaskSet, events
from locust.exception import StopUser
import time
import logging
from bs4 import BeautifulSoup
import csv
import itertools
import json
import random
from locust import HttpUser, task, between, SequentialTaskSet, events
from locust.exception import StopUser
import time
import logging
from bs4 import BeautifulSoup
import csv
import itertools
import json
import random
@Ruborcalor
Ruborcalor / neural_net.py
Created May 3, 2020 03:39
Methylation: Neural Network Architecture
# Basic neural net with 4 dense layers
model = tf.keras.models.Sequential([
tf.keras.layers.Dense(1024, activation='relu', input_shape=(25,)),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(1024, activation='relu'),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(1024, activation='relu'),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(1)
])
@Ruborcalor
Ruborcalor / dimension_reduction.py
Created May 3, 2020 03:38
Methylation: Dimension Reduction Code
# Split data
train_annotated, test_annotated = train_test_split(data_annotated, test_size=0.10)
# Calculate correlation matrix
corr_array = []
for col in train_annotated.columns:
corr_array.append(train_annotated[col].corr(train_annotated["Age"]))
print(len(corr_array))
corr_df = pd.DataFrame(corr_array, columns=["Correlation"], index=train_annotated.columns)
@Ruborcalor
Ruborcalor / download.py
Created May 3, 2020 03:35
Code To Download Dataset
# Get dataset. It's is too big to come as a single file
!wget -O "./GSE87571_Matrix_Avg_Beta.txt.gz" "https://www.ncbi.nlm.nih.gov/geo/download/?acc=GSE87571&format=file&file=GSE87571%5Fmatrix1of2%2Etxt%2Egz"
!wget -O "./GSE87571_Matrix_Avg_Beta2.txt.gz" "https://www.ncbi.nlm.nih.gov/geo/download/?acc=GSE87571&format=file&file=GSE87571%5Fmatrix2of2%2Etxt%2Egz
# Extract dataset
!gunzip "./GSE87571_Matrix_Avg_Beta.txt.gz"
!gunzip "./GSE87571_Matrix_Avg_Beta2.txt.gz
# Merge data set files into one
!cut -d$'\t' -f1 --complement "./GSE87571_Matrix_Avg_Beta2.txt" > newFile && mv newFile "./GSE87571_Matrix_Avg_Beta2.txt"