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 e_step(dic): | |
numerator = dic['pb_pa'] * (1-dic['pc_pb']) | |
denorminator = numerator + (1 - dic['pb_pa'])*(1-dic['pc_nb']) | |
dic['pb_panc'] = round(numerator/denorminator,5) | |
return dic['pb_panc'] | |
def m_step(dic): | |
dic['pb_pa'] = round((dic['pb_panc'] + 1)/3, 5) |
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 numpy as np | |
def find_prob(prob_dic, string): | |
dic = {'p':'n', 'n':'p'} | |
neg_str = dic[string[0]] + string[1:] | |
prob = prob_dic.get(string) | |
# for key not exist, need to use neg_status prob to calc |
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
# coding=utf-8 | |
class TreeNode: | |
def __init__(self, name='root', data=None, parent=None, children=None): | |
self.name = name | |
self.data = data | |
if parent: | |
assert isinstance(parent, TreeNode) | |
parent.add_child(self) |
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 math import sqrt | |
from itertools import islice | |
from datetime import datetime | |
#%matplotlib inline | |
import numpy as np | |
import matplotlib.pyplot as plt | |
#################### iterable classes #################### | |
# method mentioned in previous class |
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
# Hello World program in Python | |
from math import sqrt | |
e_num = int(input()) | |
#print(e_num) | |
engineers = [] | |
for i in range(e_num): | |
a = input().split(" ") | |
b = [int(x) for x in a] |
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 time import sleep | |
from simpleeval import simple_eval | |
from termcolor import colored | |
import random | |
from googletrans import Translator | |
################# Define a BasicBot with few attributes which could be used for all classes ################## | |
class BasicBot: |