Exemple #1
0
def aubio(source_filename):

    # print("Usage: %s <source_filename> [samplerate] [win_s] [hop_s] [mode]" % sys.argv[0])
    # print("  where [mode] can be 'delta' or 'ddelta' for first and second derivatives")7

    n_filters = 40  # must be 40 for mfcc
    n_coeffs = 26
    win_s = 512
    hop_s = win_s // 4
    # mode = "default"
    samplerate = 0

    s = source(source_filename, samplerate, hop_s)
    samplerate = s.samplerate
    p = pvoc(win_s, hop_s)
    m = mfcc(win_s, n_filters, n_coeffs, samplerate)

    mfccs = zeros([
        n_coeffs,
    ])
    frames_read = 0
    while True:
        samples, read = s()
        spec = p(samples)
        mfcc_out = m(spec)
        mfccs = vstack((mfccs, mfcc_out))
        frames_read += read
        if read < hop_s: break

    return mfccs
Exemple #2
0
def polyfit(x, y, degree):
    
    results = {}

    coeffs = np.polyfit(x, y, degree)

    # Polynomial Coefficients
     
    results['polynomial'] = coeffs.tolist()

    # r-squared
    
    p = np.poly1d(coeffs)
    
    # fit values, and mean
    
    yhat = p(x) 
    
    ybar = np.sum(y)/len(y)
    
    ssreg = np.sum((yhat-ybar)**2)
    
    sstot = np.sum((y - ybar)**2)
    
    results['determination'] = ssreg / sstot

    return results
def obj_one_side_MSE(beta, X, Y):
    p = np.poly1d(beta)
    error = sum([one_side_MSE(p(X[i]), Y[i]) for i in range(X.size)]) / X.size
    return (error)
Exemple #4
0
def objective_function(beta, X, Y):
    p=np.poly1d(beta)
    error = sum([loss_function(p(X[i]), Y[i]) for i in range(X.size)])/X.size
    return(error)
Exemple #5
0
def poly4(x_data,beta):
        p=np.poly1d(beta)
        return p(x_data)
Exemple #6
0
import fileinput as fi
import pprint as p

# for line in fi.FileInput("a.md",inplace=1):
#     print(line)

# for i,line in enumerate(fi.FileInput("a.md",inplace=1)):
# # for line in fi.FileInput("a.md",inplace=1):
#     # print(line, end='')
#     if 37<i<43:
#         # print(i+1, line, end='')
#         # print("type of line: ",type(line))
#         # line=""
#         print("deleted")

temp = {}
for line in fi.input("a.md"):
    if 38 < fi.lineno() < 44:
        temp[fi.lineno()] = line
        print(temp[fi.lineno()], end='')

p(temp.values)
    ##################
    ####################curve fitting after removing respective x when y is nan

    y_n = Y[np.logical_not(np.isnan(Y))]
    x_n = X[np.logical_not(np.isnan(Y))]
    #    plt.plot(X,Y)
    #    plt.show()
    from numpy.polynomial import Polynomial as P
    #    import numpy as np
    x = np.array(x_n)
    y = np.array(y_n)
    p = P.fit(x, y, 5)

    #CGMSeriesLunchPat1[6,:].replace(to_replace = np.nan, value = 5)  ##write exception
    #replacing nans with respective p(X)
    Y[np.isnan(Y)] = p(X[np.isnan(Y)])
#    plt.figure()
#    plt.plot(X,Y)

###############################################################
CGMDatenumLunchPat2.to_csv("preprocessed_CGMDatenumLunchPat2.csv",
                           index=False,
                           header=False)
CGMSeriesLunchPat2.to_csv("preprocessed_CGMSeriesLunchPat2.csv",
                          index=False,
                          header=False)

#

#Draw graph for one sample
#plt.cla()
Exemple #8
0
from p import *
variable = 39
string = f"I am {variable} years old"
p(string)
Exemple #9
0
# # for line in fi.FileInput("a.md",inplace=1):
#     # print(line, end='')
#     if 37<i<43:
#         # print(i+1, line, end='')
#         # print("type of line: ",type(line))
#         # line=""
#         print("deleted")

new = [1, 2, 3, 4, 5]
temp = {}
# for line in fi.input("a.md"):
#     if 38<fi.lineno()<44:
#         temp[fi.lineno()] = line
#         # print(temp[fi.lineno()],end='')

# READING
with open('a.md', 'r') as f:
    for i, line in enumerate(f):
        if 37 < i < 43:
            temp[i] = line

# WRITING
# for line in fi.FileInput("a.md",inplace=1):
#     for i in temp:
#         if temp[i] == line:
#             line=str(new[i-38])+"\n"
#     print(line,end='')

p(temp)
# p.pprint(temp)
Exemple #10
0
from p import *
a = 12
b = 3
c = 5
#ruturns float
p(a // b)
#modulo
p(a % b)

for i in range(1, 4):
    p(i)
    #doesn't include last integer
Exemple #11
0
from p import *
for i in range(1, 12):
    p(i)
Exemple #12
0
from p import *
name = input("please enter your name: ")
age = int(input(
    "how old are you , {0}? ".format(name)))  #changes string to integer

if age >= 18 and age <= 60:
    p('you are able to work')
elif age < 18:
    p("{1}, please come back in {0} years".format(18 - age, name))
else:
    p('you are too old to work')
Exemple #13
0
from p import *
p('day' in 'today')

#types of booleans that equate to false, bool(x)
p(bool(None))
p(bool(0))
p(bool(0.0))
p(bool([]))  #epmty list
p(bool(()))  #empty tuple
p(bool(''))  #empty string
p(bool({}))  #empty mapping
Exemple #14
0
import webbrowser as w
import time as t
import playsound as p
a = 30
b = 2
while True:
    for i in range(60):
        print(b, ":", a, ":", i)
        t.sleep(1)
    a += 1
    if a == 60:
        b += 1
        a = 0
    if b == 2 and a == 31:
        w.open('https://mail.google.com/mail/u/0/#inbox', new=1)
        w.open('https://mail.google.com/mail/u/1/#inbox')
        w.open('https://classroom.google.com/u/1/c/NjgxNjM4Mzc4NTha')
        w.open('https://classroom.google.com/u/0/h')
        p("Twin-bell-alarm-clock.mp3")
        break
print("done")
Exemple #15
0
def positive_mse_loss(beta, X, Y):
    p=np.poly1d(beta)
    error = sum([positive_mse(p(X[i]), Y[i]) for i in range(X.size)])/X.size
    return(error)
Exemple #16
0
from p import *
splits = "split \n strings \n everywhere"
p(splits)

tabs = "1\t2\t3\t"
p(tabs)

single_quote_apostrophe_interpolation = 'bruce said "he\'s got this"'
double_quote_quote_interpolation = "bruce said \"he's got this\""
p(single_quote_apostrophe_interpolation)
p(double_quote_quote_interpolation)

triple_quote_split = """this is going
to be
split over
a couple of lines"""
p(triple_quote_split)

triple_quote_quote_interpolation = """bruce said "he's got this" """
#leaves a space at the end
p(triple_quote_quote_interpolation)
triple_quote_quote_interpolation2 = '''bruce said "he's got this"'''
p(triple_quote_quote_interpolation2)

#3.6 interpolation
age = 39
string = f"I am {age} years old"
p(string)

parrot = 'norwiegen blue'
p(parrot[6])
Exemple #17
0
from p import *

print('hello')
p('hello')