示例#1
0
def table_total(update, context):
    data = main.read_csv()
    table_string = main.get_table_total(data)

    context.bot.send_message(chat_id=update.effective_chat.id,
                             text=table_string)
    logging.info(" -- table total after request sent")
示例#2
0
def test_read_csv2():
    assert read_csv('test2.csv') == [
        ['house', 'origin', 'color', 'enemy'],
        ['Atreides', 'Atreus', 'green', 'Harkonnen'],
        ['Harkonnen', 'Hakkon', 'red', 'Atreides'],
        ['Ordos', 'Ordus', 'green', 'Everyone'],
        ['Boro', 'Camie', 'yellow', 'Atreides'],
        ['Corrino', 'Padisha', 'bronze', 'Harkonnen']
    ]
示例#3
0
    def __init__(self, parent=None):
        """Start."""
        # Step 1: Reading the data from the csv file
        x, y, n, m = mn.read_csv('Q1a.csv')

        # Take some random weights with the size(number of attributes+1)
        # w = np.random.uniform(low=0.5, high=13.3, size=(m+1))
        w = [0.45, 0.862, -2.15]
        w = np.array(w)
        w = self.perceptron_computation(x, y, w)
        self.plot_graphs(x, y, w)
示例#4
0
    def __init__(self, parent=None):
        """Start."""
        # Step 1: Reading the data from the csv file
        x, y, self.n, m = mn.read_csv('regdata.csv')

        # Take some random weights with the size(number of attributes+1)
        # w = np.random.uniform(low=0.5, high=13.3, size=(m+1))
        w = [0.45, 0.862, -2.15]
        w = np.array(w)

        # Step 2: Scaling the attributes.
        x, y = self.scale_attributes(x, y)

        # Step 3: Compute the error at each iteration and save the error values in vector.
        error_vector, w = self.regression_computation(x, y, w)
        print "Final weights: ", w

        # Step 4: Plot the error vector as a curve in the end.
        self.plot_graphs(error_vector)
示例#5
0
def f_vs_j(update, context):
    data = main.read_csv()
    f_vs_j_string = main.franken_vs_jecken(data)
    context.bot.send_message(chat_id=update.effective_chat.id,
                             text=f_vs_j_string)
    logging.info(" -- franken_vs_jecken after request sent")
示例#6
0
def test_read_csv():
    assert read_csv('test1.csv') == [['name', 'age', 'eye colour'],
                                     ['Bob', '5', 'blue'],
                                     ['Mary', '27', 'brown'],
                                     ['Vij', '54', 'green']]
示例#7
0
def test_read_csv3():
    assert read_csv('test3.csv') == []
示例#8
0
def test_read_csv2():
    assert read_csv('test2.csv') == [
        ['house', 'origin', 'color', 'enemy'],
        ['Atreides', 'Atreus', 'green', 'Harkonnen'],
        ['Harkonnen', 'Hakkon', 'red', 'Atreides'],
        ['Ordos', 'Ordus', 'green', 'Everyone'],
        ['Boro', 'Camie', 'yellow', 'Atreides'],
        ['Corrino', 'Padisha', 'bronze', 'Harkonnen']
    ]


def test_read_csv3():
    assert read_csv('test3.csv') == []


table = read_csv('test1.csv')
table2 = read_csv('test2.csv')
table3 = read_csv('test3.csv')


def test_header_map_1():
    hmap = header_map(table[0])
    assert hmap == {'name': 0, 'age': 1, 'eye colour': 2}


def test_header_map_2():
    hmap = header_map(table2[0])
    assert hmap == {'house': 0, 'origin': 1, 'color': 2, 'enemy': 3}


def test_header_map_3():