Skip to content

Instantly share code, notes, and snippets.

View Mohamad-Jaallouk's full-sized avatar

Mohamad Jaallouk Mohamad-Jaallouk

  • Sweden
View GitHub Profile
@keithmcnulty
keithmcnulty / python_functions.py
Created April 12, 2021 12:55
Functions for running k-fold cross-validated XGBoost on an arbitrary dataset
import pandas as pd
from scipy import stats
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import RandomizedSearchCV, KFold
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report
from xgboost import XGBClassifier
# spit data into train test
def split_data(df: pd.DataFrame, parameters: dict) -> dict:
import os
import glob
import tensorflow as tf
save_path = 'tf_serving_warmup_requests'
tfrecords_path = glob.glob('*_human_activities_*.tfrecords')
dataset = tf.data.TFRecordDataset(tfrecords_path)
writer = tf.data.experimental.TFRecordWriter(save_path)
writer.write(dataset)
@ihoromi4
ihoromi4 / seed_everything.py
Created February 5, 2020 11:49
pytorch - set seed everything
def seed_everything(seed: int):
import random, os
import numpy as np
import torch
random.seed(seed)
os.environ['PYTHONHASHSEED'] = str(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
@korakot
korakot / new_gpu.py
Last active November 9, 2022 11:51
Repeat reset until you get P100 GPU in Colab
# reset all จนกว่าจะได้ ดีกว่า K80
from IPython.display import HTML
from subprocess import getoutput
s = getoutput('nvidia-smi')
if 'K80' in s:
gpu = 'K80'
elif 'T4' in s:
gpu = 'T4'
elif 'P100' in s:
gpu = 'P100'