Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 1 Jest
- # 2 Jest
- # 3 Jest
- # 4 Jest
- # 5 xxx
- # 6 xxx
- # 7 Jest
- # 8 Jest
- # 9 50 %
- # 10 Jest
- # 11 Jest
- # 12
- # 13 Jest
- # 14
- # 15
- # ZADANIE 1
- #import numpy as np
- #
- #array_1 = np.arange(0, 101)
- #array_2 = np.arange(100, -1, -1)
- #print(array_1)
- #print(array_2)
- #print(array_1 + array_2)
- #print(array_1 - array_1)
- #print(array_1 * array_2)
- #print(array_1[:10] - array_1[-10:])
- #print(array_1[array_1 % 3 == 0])
- #000000000000000000000000000000000000000000000000000000000000000000000000000
- # ZADANIE 2
- #import numpy as np
- #import time
- #import csv
- #
- #
- #b_t = time.time()
- #for item in list_1:
- # list_2.append(item*item)
- #e_t = time.time()
- #print("Elapsed time: ", e_t - b_t)
- #
- #list_1 = list(range(0, 10000000))
- #b_t = time.time()
- #list_2 = [item*item for item in list_1]
- #e_t = time.time()
- #print("Elapsed time: ", e_t - b_t)
- #
- #array_1 = np.arange(0, 10000000)
- #b_t = time.time()
- #array_2 = array_1 * array_1
- #e_t = time.time()
- #print("Elapsed time: ", e_t - b_t)
- #000000000000000000000000000000000000000000000000000000000000000000000000000
- # ZADANIE 3
- #import random
- #import numpy as np
- #import matplotlib.pyplot as plt
- #
- #
- #tab = np.random.normal(50,20,(7,7))
- #tab1 =np.round(tab)
- #
- #
- #count, bins, ignored = plt.hist(tab1, 30, density=True)
- #plt.plot(bins, 1/(20 * np.sqrt(2 * np.pi)) *
- # np.exp( - (bins - 50)**2 / (2 * 20**2) ),
- # linewidth=3, color='r')
- #plt.show()
- #print("Wyznacznik: {}".format(np.linalg.det(tab1)))
- #print("Slad: {}".format(np.trace(tab1)))
- #print("Wartosci i wketory wlasne {}".format(np.linalg.eig(tab)))
- #print("Wektory wlasne: {}".format(np.dot(tab1)))
- #Elementy tablicy razy wektor
- #print("Matrix Tab przemnzona przez wektor [1,2,3,4,5,6,7]\n{}".format(np.dot(tab1,[1,2,3,4,5,6,7])))
- #RevTab = np.linalg.inv(tab1) #Macierz odwrotna
- #Przkątna macierzy do kwadratu
- #print("Na przekatnej macierzy mamy:\n{}".format(np.square(np.diagonal(tab1))))
- #print(np.linalg.svd(tab1)) <-- SVD macierzy
- #000000000000000000000000000000000000000000000000000000000000000000000000000
- #Zadanie 4
- #import os
- #import numpy as np
- #import csv
- #
- #
- #current_dir = os.path.abspath(os.path.dirname(__file__))
- #data_folder = os.path.join(current_dir, "Data")
- #csv_path = os.path.join(data_folder, "iris.csv")
- #
- #
- #with open(csv_path) as csv_file:
- # output_dict = dict()
- # reader = csv.reader(csv_file)
- # first_row = next(reader)
- # for key in first_row:
- # output_dict[key] = []
- # for row in reader:
- # for i in range(len(first_row)):
- # try:
- # output_dict[first_row[i]].append(float(row[i]))
- # except:
- # output_dict[first_row[i]].append(row[i])
- #
- # for key in output_dict.keys():
- # output_dict[key] = np.array(output_dict[key])
- #
- #print("Septal Length mean: ", np.mean(output_dict['sepal.length']))
- #print("Septal Length std: ", np.std(output_dict['sepal.length']))
- #print("Septal Width mean: ", np.mean(output_dict['sepal.width']))
- #print("Septal Width std: ", np.std(output_dict['sepal.width']))
- #print("Petal length mean: ", np.mean(output_dict['petal.width']))
- #print("Petal length std: ", np.std(output_dict['petal.length']))
- #print("Petal width mean: ", np.mean(output_dict['petal.length']))
- #print("Petal width std: ", np.std(output_dict['petal.length']))
- #
- #000000000000000000000000000000000000000000000000000000000000000000000000000
- # ZADANIE 5
- #current_dir = os.path.abspath(os.path.dirname(__file__))
- #data_path = os.path.join(current_dir, "Data")
- #csv_path = os.path.join(data_path, ".png")
- ##print(current_dir)
- #try:
- # data_file = open(csv_path)
- #except:
- # pass
- #finally:
- # pass
- #with open(csv_path) as csv_file:
- # reader = csv.reader(csv_file)
- # print(reader)
- # #print(dir(reader))
- # for item in reader:
- # print(item)
- #000000000000000000000000000000000000000000000000000000000000000000000000000
- #Zadanie 7 , blad MSE
- #
- #import numpy as np
- #
- ##array_1 = np.arange(1000, dtype=np.float32)
- #array_1 = np.float32(np.random.normal((1000,1)))
- #array_1_export = array_1 * 1000
- #
- #array_1_export.tofile('zad7.txt')
- #
- #array_2_import = np.fromfile('zad7.txt',dtype=np.float32)
- #array_2 = array_2_import /1000
- #
- ##print(array_2[:25])
- #
- #ax=0
- #mse = (np.square(array_1 - array_2)).mean(axis=ax)
- #print("MSE: {}".format(mse))
- #
- #
- #000000000000000000000000000000000000000000000000000000000000000000000000000
- ##Zadanie 8
- #import numpy as np
- #
- #tab_1 = np.ndarray((100,100,50))
- #
- #for i in range(50):
- # tab_1[:,:,i] = np.asmatrix(np.random.rand(100,100))
- # print("Wyznacznik macierzy (", i,"):",np.linalg.det(tab_1[:,:,i]))
- #
- #wektory = np.asmatrix(np.random.rand(50,100))
- #000000000000000000000000000000000000000000000000000000000000000000000000000
- ##Zadanie 9
- #import numpy as np
- #
- #tab = np.random.rand(5,5)
- #tab1 = np.random.rand(5,5)
- #tab2=tab*tab1
- #print(np.diag(tab*tab1)) #Metoda 1
- #j=-1
- #for i in range(0,len(tab)):
- # j = j + 1
- # print(tab2[i,j])
- #000000000000000000000000000000000000000000000000000000000000000000000000000
- #Zadanie 10
- #import numpy as np
- #
- #vector = np.arange(0,10)
- #for i in range(0,len(vector)):
- # if i % 2 == 0:
- # vector[i] = vector[i] * vector[i]
- # else:
- # vector[i] = 0
- #
- #print(vector)
- #
- #000000000000000000000000000000000000000000000000000000000000000000000000000
- #Zadanie 11
- #import numpy as np
- #
- #def largest_num(array,count):
- # array_out = []
- # for i in range(0,count):
- # array_out.append(np.amax(array))
- # array = np.delete(array,array.argmax(axis=0))
- # return array_out
- #
- #array_1 = np.arange(0,1000)
- #print(largest_num(array_1,3))
- #
- #000000000000000000000000000000000000000000000000000000000000000000000000000
- # Zadanie 12
- #N = 10
- #array = np.random.rand(N)
- ##print(array)
- #array.flags.writeable = False
- #try:
- # array[5] = 7
- #except Exception as e:
- # print(e)
- #Zadanie 13
- #import numpy as np
- #
- #def rank(A, eps=1e-12):
- # u, s, vh = np.linalg.svd(A)
- # return len([x for x in s if abs(x) > eps])
- #
- #array_1 = ([1,2,3],[3,4,5],[5,3,3])
- #print(rank(array_1))
- #print(np.linalg.matrix_rank(array_1))
- #000000000000000000000000000000000000000000000000000000000000000000000000000
- #Zadannie 14
- #Zdefiniuj ustrukturyzowana tablice zawierajaca w kazdym polu pozycje (x, y, z), a nastepnie wypełnij ja
- #losowymi wartosciami.
- #N=random.randint(0,9)
- #print(N)
- #x = np.random.rand()
- #y = np.random.rand()
- #z = np.random.rand()
- #
- #array =[(x, y, z) for i in range(N)]
- #print(array)
- #000000000000000000000000000000000000000000000000000000000000000000000000000
- #Zadanie 15
- #Zdefiniuj losowy wektor liczb zmiennoprzecinkowych o losowej długosci. Zamien wszystkie wartosci stanowiace
- # wartosc minimalna wartoscia srednia. Powtórz tak długo az nie zostania dokonana zadna zmiana.
- #N = random.randrange(0,9) #losowanie dlugosci wektora
- ##print(N)
- #vector = np.random.rand(N)
- ##print(vector)
- #minimum = np.amin(vector)
- ##print(minimum)
- #mean_value = np.mean(vector)
- ##print(mean_value)
- #for i in range(0, N):
- # vector[i]= mean_value
- #print(vector)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement