Beispiel #1
0
def arquitetura(tam_entrada, tam_hidden, tam_saida):
    m = []
    matriz_hidden = mat_aleatoria(-1,1,tam_hidden,tam_entrada) # cada linha representa um neuronio da camada escondida
    matriz_saida = mat_aleatoria(-1,1, tam_saida, tam_hidden) # cada linha representa um neuronio da camada de saida
    m.append(matriz_hidden)
    m.append(matriz_saida)
    return m
Beispiel #2
0
def gpa():
    g = 0
    civ = []
    c = 0
    math = []
    m = 0
    lang = []
    l = 0
    sci = []
    s = 0
    civn = input("how many humanitities do you take?")
    for i in range(0, civn):
        civ.append(f(raw_input("whats your civ grade?")))
    mathn = input("how many maths do you take?")
    for j in range(0, mathn):
        math.append(f(raw_input("whats your math grade?")))
    langn = input("how many languages do you take?")
    for k in range(0, langn):
        lang.append(f(raw_input("whats your language grade?")))
    scin = input("how many sciences do you take?")
    for n in range(0, scin):
        sci.append(f(raw_input("whats your science grade?")))
    for ii in range(0, len(civ)):
        c = c + civ[ii]
    for jj in range(0, len(math)):
        m = m + math[jj]
    for kk in range(0, len(lang)):
        l = l + lang[kk]
    for nn in range(0, len(sci)):
        s = s + sci[nn]
    g = (c + m + l + s) / (len(civ) + len(math) + len(lang) + len(sci))
    print g
Beispiel #3
0
def read_data(fobj):
    reader = csv.DictReader(fobj, delimiter=',')
    math = []
    read = []
    write = []
    for line in reader:
        math.append(int(line['Math']))
        read.append(int(line['Reading']))
        write.append(int(line['Writing']))
    return math, read, write
Beispiel #4
0
def get_M(W, X, y_list):
    """
	Calculate the predict values and return missclassified data points set M
	"""
    M = []
    for i, xt in enumerate(X):
        pred_val = cal_h_W_Xt(W, xt)
        if not pred_val == y_list[i]:
            M.append(xt)
    return M
Beispiel #5
0
def matriz(arq):  # inicializa a matriz
    start = ""
    m = []
    i = 0
    for lin in arq:
        if (i > 5):  # descarta as 5 linhas iniciais
            m.append([float(x) for x in lin.split()])
        else:
            start += str(lin).replace("b'", "").replace("\\n'", "\n")
            i += 1
    return m, start  # retorna um array
Beispiel #6
0
def GP_model_test(sample_x, sample_y, sample_std, test_x, gamma, samples):
    sample_x = np.array(sample_x)
    cov_x = RBF_ker(sample_x, sample_x, gamma)
    d = np.diag(np.array(sample_std)**2)
    lower_cholesky = cholesky(cov_x + d, True)
    weighted_sample_y = cho_solve((lower_cholesky, True), sample_y)
    cov_te_sam = RBF_ker(test_x, sample_x, gamma)
    m = []
    for i in cov_te_sam:
        m.append(cho_solve((lower_cholesky, True), i))
    cov = RBF_ker(test_x, test_x, gamma) - np.dot(cov_te_sam, np.array(m).T)
    mean = np.dot(cov_te_sam, weighted_sample_y)
    N = np.random.multivariate_normal(mean, cov, samples)
    return N
Beispiel #7
0
def math():
    b, c = entry1.get(), entry2.get()
    b, c = float(b), float(c)
    x = float((b**2) - (4 * c))
    x = s(x)
    x = x / 2
    new = float((b**2) - (4 * c))
    new = s(new)
    new = (-b) - new
    new = new / 2
    math = []
    math.append(x)
    math.append(new)
    answer.delete(0, END)
    answer.insert(0, math)
Beispiel #8
0
def continue_math(count, yt, framerate):
    x = []
    math = []
    for i, data in enumerate(count):
        x.append(data)
        if (i + 1) % 2 == 0:
            y1 = yt[x[0]:x[1]]
            yf1 = abs(fft(y1)) / len(y1)
            yf2 = yf1[range(int(len(y1) / 2))]
            math_ = catch_number(yf2, framerate, x[1] - x[0])
            x = []
            if math_ == None:
                continue
            math.append(math_)

    return math
Beispiel #9
0
def math():
    b = entry1.get()
    b = float(b)
    c = entry2.get()
    c = float(c)
    x = float((b**2) - (4 * c))
    x = a(x)
    x = (-b) + x
    x = x / 2
    x1 = float((b**2) - (4 * c))
    x1 = a(x1)
    x1 = (-b) - x1
    x1 = x1 / 2
    math = []
    math.append(x)
    math.append(x1)
    answer.delete(0, END)
    answer.insert(0, math)
import math
#low=[]
#high=[]
#var=0
df = pd.read_excel('std4.xlsx')
#with pd.option_context('display.max_rows', None, 'display.max_columns', None):  # more options can be specified also
#print(df)
#for i in range(len(df)) :
#print(df.loc[i, "Sess1"], df.loc[i, "Subjects"])
#print(df.)
math = []
sum_math = 0
i = 0
j = 0
while i < len(df):
    math.append(df.iloc[i, 8])
    sum_math = sum_math + math[j]
    i = i + 5
    j = j + 1
#print(math,end="    ")
#print(sum_math)
i = 1
j = 0
phy = []
sum_phy = 0
while i < len(df):
    phy.append(df.iloc[i, 8])
    sum_phy = sum_phy + phy[j]
    i = i + 5
    j = j + 1
#print(phy)
Beispiel #11
0
        a0 = a0 + dela[0]
        a1 = a1 + dela[1]

#monte carlo using computer generated random numbers
#iterations=int(input("number of iterations: "))
iterations = 1000
cir = 0
sq = 0
m = []
n = []
cirx = []
ciry = []
for i in range(iterations):
    x = r.random()
    y = r.random()
    m.append(x)
    n.append(y)
    a = (x * x) + (y * y)
    if a <= 1:
        cirx.append(x)
        ciry.append(y)
        cir += 1
    sq = i
pi = 4 * (cir / sq)
print("{:0.6f}".format(pi))

#monte carlo using manually generated random numbers (32 bit)
x0 = 12356789
y0 = 87238971
c = 16807
N = 2147483641  #($2^31 - 1)