import fun_mac A = fun_mac.random_randint_m(5, 5, 1) B = fun_mac.make_m(5, 1, 0) fun_mac.print_m(A) print("") fun_mac.print_m(B) print("") C = fun_mac.expand_m(A, B, 3) fun_mac.print_m(C) print("") C = fun_mac.expand_m(C, B, 0) fun_mac.print_m(C)
import fun_mac A = fun_mac.random_randint_m(2, 50) fun_mac.print_m(A) print("") fun_mac.print_m(fun_mac.negative_avr(A, False))
import fun_mac A = fun_mac.random_uniform_m(5, 600) As = fun_mac.statistic_m(A) fun_mac.print_m(A) print("") fun_mac.print_m(As)
def kolor(x): kolor = [None] * len(x) for i in range(len(x)): if x[i] == 0: kolor[i] = "red" else: kolor[i] = "blue" return kolor Z = copy.deepcopy(C) Z = transpozycja(Z) plt.scatter(B[0], B[1], color=kolor(c)) import fun_mac fun_mac.print_m(Z) dupa = [None] * len(Z[0]) for i in range(len(Z[0])): dupa[i] = (Z[0][i] - Z[0][0]) #* (Z[0][len(Z[0])-1]/6) print(kolor(l)) plt.scatter(Z[0], dupa, marker=".", color=kolor(l), alpha="0.9") plt.savefig("output.png", dpi=90) #4 ocena jakości klasyfikatora #4.6 T = [] f = open("test_wine.csv", "r") for row in csv.reader(f): for i in range(len(row)): row[i] = float(row[i])
import fun_mac A = fun_mac.random_randint_m(50, 2) fun_mac.print_m(A) print("") fun_mac.print_m(fun_mac.negative_avr(A))
import fun_mac A = fun_mac.random_uniform_m(5, 600, -50, 50) V = fun_mac.average_vector_m(A) #fun_mac.print_m(A, 4) #print("") fun_mac.print_m(fun_mac.expand_m(A, V, 0), 4)
import fun_mac A = fun_mac.random_randint_m(50, 10, 0, 1) fun_mac.standarization_m(A) print(f"min: {fun_mac.min_m(A)}") print(f"max: {fun_mac.max_m(A)}") fun_mac.print_m(A, 3)
import fun_mac n = int(input("Podaj wymiar:")) m = fun_mac.make_m(n) for i in range(len(m)): for j in range(len(m[0])): m[i][j] = 1 / ((i + 1) + (j + 1) - 1) fun_mac.print_m(m, 4)
import fun_mac A = fun_mac.make_m(3) fun_mac.read_m(A, "magic_sq1.txt") fun_mac.print_m(A) print(fun_mac.is_magic_sq_m(A)) print("") B = fun_mac.make_m(3) fun_mac.read_m(B, "magic_sq2.txt") fun_mac.print_m(B) print(fun_mac.is_magic_sq_m(B)) print("") C = fun_mac.make_m(7) fun_mac.read_m(C, "magic_sq3.txt") fun_mac.print_m(C, 6) print(fun_mac.is_magic_sq_m(C)) print("")
0.2459 1.325 2.0259 """ #sr_m[0] = [5, 3.4, 1.4, 0.25] d = [[[0] * 50 for i in range(3)] for j in range(3)] """ d: Sa takie 3: 0.14 0.44 0.41 ... 3.98 3.57 4.13 ... 5.23 4.13 5.26 ... """ for k in range(3): for i in range(3): for j in range(50): d[k][i][j] = euk(t_sr_m[k], t_iris[i * 50 + j]) jaki_kwiat = [[None] * 50 for i in range(3)] for k in range(3): for j in range(50): mini = math.inf kwiat = None for i in range(3): if d[k][i][j] < mini: mini = d[k][i][j] jaki_kwiat[k][j] = i fun_mac.print_m(jaki_kwiat) #druk_do_pliku(iris, sr_m)
y = {"jabuszko", "gruszka"} y2 = {"gruszka", "gruszka"} print("jabuszko" in y) print(y & y2) print(y | y2) print(y - y2) print(y.issubset(y2)) print(y.issubset(y2|y)) import fun_mac as fm #t = [ i**2 for i in range(10) if x % 2 == 1 ] t = [ [i*j for i in range(10)] for j in range(10) ] fm.print_m(t) #dict comprehensions s = { str(i%2):i**2 for i in range(7) } print(s) print(help(list)) krotka = 1,2,3,4 print(krotka) print(4 in krotka) print(krotka[-1]) napis = "123456789" print("78" in napis)
import fun_mac x = [1, 2, 3] y = [[4, 5, 6]] #W = fun_mac.multiplication_m( x, fun_mac.transpose_m(y) ) #nie dziala, bo to wektorki,trzeba poprawic z portfolio W = fun_mac.multiplication_m(x, y) fun_mac.print_m(W)
def multiplication_m(A, k): if str(type([[0], [0]])) == str(type(k)): k = "macierz" if str(type(3)) == str(type(k)) or str(type(3.3)) == str(type(k)): B = [[None] * len(A[0]) for i in range(len(A))] for i in range(len(A)): for j in range(len(A[0])): B[i][j] = A[i][j] * k return B else: return None import fun_mac fun_mac.print_m(multiplication_m(fun_mac.make_m(5, 6, 1 / 5), 1 / 5), 4)
import fun_mac """ mac1 = fun_mac.make_m(3, 5) fun_mac.read_m(mac1) fun_mac.print_m(mac1, None, "inp.txt.txt") """ mac2 = fun_mac.make_m(5, 3) fun_mac.read_m(mac2) fun_mac.print_m(mac2, None, "inp.txt.txt")
return out def proste(dane): out = [[["b", "a"]] * len(dane) for i in range(len(dane))] for i in range(len(out)): for j in range(len(out[0])): srx = srednia(dane[i]) sry = srednia(dane[j]) sum2 = 0 sumx = 0 for k in range(len(dane[i])): sumx += (dane[i][k] - srx)**2 sum2 += (dane[i][k] - srx) * (dane[j][k] - sry) out[i][j][0] = sum2 / sumx out[i][j][1] = sry - out[i][j][0] * srx return out t = wczytanie() druk_do_pliku(t) """ fun_mac.print_m(mac_kor(t), 6) print("") fun_mac.print_m(proste(t)) """
def diagonal_matrix(A): if len(A) != len(A[0]): return None d = [None] * len(A) for i in range(len(A)): d[i] = A[i][i] return d import fun_mac mat = fun_mac.make_m(5, 5, 3) rand = fun_mac.random_randint_m(5) fun_mac.print_m(mat) print("") fun_mac.print_m(rand) print("") print(diagonal_matrix(mat)) print("") print(diagonal_matrix(rand))
import fun_mac A = fun_mac.random_randint_m(5, 6, 0) fun_mac.print_m(A) print("") D = fun_mac.delete_r_c_m(A, 3, 2) fun_mac.print_m(D) print("\n\n") W = fun_mac.make_m(8, 7) fun_mac.read_m(W, "inp.txt") fun_mac.print_m(W) print("") fun_mac.print_m(fun_mac.delete_r_c_m(W, 5, 4))