Esempio n. 1
0
    def header(self, cells):

        for index, cell in enumerate(cells):

            if '?' not in cell:

                self.valid_cols.append(index)
                self.names[index] = cell

                if re.match('[<>$]', cell):
                    self.nums[index] = Num()
                else:
                    self.syms[index] = Sym()

                if re.match('<', cell):
                    self.weights[index] = -1
                elif re.match('>', cell):
                    self.weights[index] = 1
                elif re.match('!', cell):
                    self.class_col = index
                else:
                    self.indeps.append(index)
    def header(self,cells):
        # self = self or Rows()
        # self.indep = []
        for c0,x in enumerate(cells):
            if not "?" in x:
                c = len(self._use)
                self._use.append(c0)
                self.name.append(x)
        
                if "$" in x or "<" in x or ">" in x:
                    self.nums[c] = Num([])
                else:
                	self.syms[c] = Sym([])

                if "<" in x:
                    self.w[c] = -1
                elif ">" in x:
                    self.w[c] = 1
                elif "!" in x:
                    self._class = c
                else:
                    self.indeps.append(c)
        return self
Esempio n. 3
0
def num_test():
    """
    Testing num.py ...
    """

    num = Num(30)

    num_list = [
        4, 10, 15, 38, 54, 57, 62, 83, 100, 100, 174, 190, 215, 225, 233, 250,
        260, 270, 299, 300, 306, 333, 350, 375, 443, 475, 525, 583, 780, 1000
    ]

    num.nums(num_list)

    print()

    print('MU', ':', num.mean)
    print('SD', ':', num.standard_deviation)

    assert close(num.mean, 270.3)
    assert close(num.standard_deviation, 231.946)

    print()
Esempio n. 4
0
 def header(self, cells):
     '''Checks for certain symbols at the beginning of the column name and structure then into sym and num objects'''
     self = self or Rows()
     self.indep = []
     for c0, x in enumerate(cells):
         if not "?" in x:
             c = len(self._use)
             self._use.append(c0)
             self.name.append(x)
             # Col names beginning with $,<,> are set as numeric columns
             if "$" in x or "<" in x or ">" in x:
                 self.nums[c] = Num([])
             else:
                 self.syms[c] = Sym([])
             if "<" in x:
                 self.w[c] = -1
             elif ">" in x:
                 self.w[c] = 1
             elif "!" in x:
                 self._class = c
             else:
                 self.indeps.append(c)
     return self
Esempio n. 5
0
    Comparacion de tiempo de corrida
    Karatsuba_Python
"""

from knum import KNum
from num import Num
import timeit

def tocomma(n):
	"""
		Reemplaza "." por "," 
	"""
	return str(n).replace(".",",")

if __name__=="__main__":
	numbers = [Num(x) for x in range(0, 500, 100)]
	Knumbers = [KNum(x) for x in range(0, 500, 100)]
	with open("../data/TiempoCorrida_Natural_Karatsuba.csv","w")as file:
		file.write("n;natural;karatsuba\n")
		for i in range(len(numbers)):
			print(f'\n\n***** Processing case {i} *****')
			print(f"\n NATURAL: {numbers[i]} * {numbers[i]}")
			time_natural = timeit.timeit("numbers[i] * numbers[i]", globals=globals(), number=1)
			print(f" Result: {numbers[i] * numbers[i]}")
			print(f" Time: {tocomma(time_natural)}")
			print(f"\n KARATSUBA: {Knumbers[i]} * {Knumbers[i]}")
			time_karatsuba = timeit.timeit("Knumbers[i] * Knumbers[i]", globals=globals(), number=1)
			print(f" Result: {Knumbers[i] * Knumbers[i]}")
			print(f" Time: {tocomma(time_karatsuba)}")
			file.write(f"{i};{tocomma(time_natural)};{tocomma(time_karatsuba)}\n")
	print("Done...")
Esempio n. 6
0
File: col.py Progetto: se4ai/code
 def __add__(i, x):
     for y in items(x):  # x could a single thing or list of items
         if y != my.data.ignore:
             if not i.has:
                 i.has = Num() if nump(y) else Sym()
             i.has + y
Esempio n. 7
0
 def get_var(c, lo, hi):
     numx = Num()
     for i in range(lo, hi + 1):
         numx.numInc(rows[i][goal])
     return (numx.sd)**2
Esempio n. 8
0
File: numeg.py Progetto: timm/duo
# vim: filetype=python ts=2 sw=2 sts=2 et :
from num import Num

n = Num(at=0,
        txt='aa',
        all=[9, 2, 5, 4, 12, 7, 8, 11, 9, 3, 7, 4, 12, 5, 4, 10, 9, 6, 9, 4])

assert 7 == n.mu
assert 3.06 < n.sd < 3.061
Esempio n. 9
0
File: oknum.py Progetto: se4ai/code
def _num():
    n = Num()
    for x in [9, 2, 5, 4, 12, 7, 8, 11, 9, 3, 7, 4, 12, 5, 4, 10, 9, 6, 9, 4]:
        n + x
    assert close(n.sd, 3.0608)
    assert n.mu == 7
Esempio n. 10
0
File: oknum.py Progetto: se4ai/code
"""

# oknum.py

"""

from ok import ok
from lib import *
from num import Num

n = Num()
for x in [1, 2, 3, 4]:
    n + x
print(n, n.sd)


@ok
def _num():
    n = Num()
    for x in [9, 2, 5, 4, 12, 7, 8, 11, 9, 3, 7, 4, 12, 5, 4, 10, 9, 6, 9, 4]:
        n + x
    assert close(n.sd, 3.0608)
    assert n.mu == 7
Esempio n. 11
0
File: oknum.py Progetto: se4ai/code
def _num1():
  n= Num([9,2,5,4,12,7,8,11,9,3,7,4,12,5,4,10,9,6,9,4])
  assert math.isclose(n.sd,3.0608,abs_tol=0.001)
  assert n.mu == 7
Esempio n. 12
0
def testNum():
    n = Num([
        4, 10, 15, 38, 54, 57, 62, 83, 100, 100, 174, 190, 215, 225, 233, 250,
        260, 270, 299, 300, 306, 333, 350, 375, 443, 475, 525, 583, 780, 1000
    ])
    assert n.mu == 270.3 and round(n.sd, 3) == 231.946