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
# -- consts -- | |
ECHARTS_CDN = "https://cdn.jsdelivr.net/npm/echarts@5.3.2/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 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 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 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 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() |