This file contains hidden or 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 os | |
import subprocess | |
from moviepy.editor import VideoFileClip | |
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip | |
from tqdm import tqdm | |
import imageio | |
from rich.progress import track, SpinnerColumn, Progress | |
from rich import print | |
This file contains hidden or 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
# -- consts -- | |
ECHARTS_CDN = "https://cdn.jsdelivr.net/npm/[email protected]/dist/echarts.min" | |
ECHARTS_REQUIREJS_CONF = f"requirejs.config({{paths: {{echarts: '{ECHARTS_CDN}',}}}});" | |
ECHARTS_TEMPLATE = f""" | |
<div id="{{ID}}" style="width: {{WIDTH}};height:{{HEIGHT}};"></div> | |
<script type="module"> | |
{ECHARTS_REQUIREJS_CONF} | |
requirejs(["echarts"], (echarts) => {{ | |
let myChart = echarts.init(document.getElementById('{{ID}}')); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
from keras.layers import Dense, Dropout, Input, BatchNormalization | |
from keras.models import Model | |
def get_nn_model(dropout=0.6): | |
inp = Input(shape = (90,)) | |
x = Dense(100, activation='relu')(inp) | |
x = BatchNormalization()(x) | |
x = Dropout(dropout)(x) | |
x = Dense(50, activation='relu')(x) | |
x = BatchNormalization()(x) |
This file contains hidden or 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
def is_nuc(nuc): | |
try: | |
n1, n2 = nuc.split(':') | |
if not n1 in 'ATGC' and n2 in 'ATGC': | |
return np.nan | |
else: | |
return nuc | |
except: | |
return np.nan | |
This file contains hidden or 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
from sklearn.metrics import confusion_matrix | |
import seaborn as sns | |
forest.fit(x,y) | |
predict = forest.predict(x) | |
cm = pd.DataFrame(confusion_matrix(y, predict), columns=forest.classes_, index=forest.classes_) | |
sns.heatmap(cm) |
This file contains hidden or 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
from sklearn.ensemble import RandomForestClassifier | |
from sklearn.model_selection import cross_val_score | |
forest = RandomForestClassifier(n_estimators=30, class_weight='balanced') | |
x = encoded[[c for c in encoded.columns if 'snp' in c]].values | |
y = classes.values | |
scores = cross_val_score(forest, x, y, cv=5) | |
scores.mean(), scores.std() |