daily pastebin goal
89%
SHARE
TWEET

PythonFull

lancernik Mar 26th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # 1   Jest
  2. # 2   Jest
  3. # 3   Jest
  4. # 4   Jest
  5. # 5   xxx
  6. # 6   xxx
  7. # 7   Jest
  8. # 8   Jest
  9. # 9   50 %
  10. # 10  Jest
  11. # 11  Jest
  12. # 12  
  13. # 13  Jest
  14. # 14
  15. # 15
  16.  
  17. #          ZADANIE 1
  18. #import numpy as np
  19. #
  20. #array_1 = np.arange(0, 101)
  21. #array_2 = np.arange(100, -1, -1)
  22. #print(array_1)
  23. #print(array_2)
  24. #print(array_1 + array_2)
  25. #print(array_1 - array_1)
  26. #print(array_1 * array_2)
  27. #print(array_1[:10] - array_1[-10:])
  28. #print(array_1[array_1 % 3 == 0])
  29.  
  30.  
  31. #000000000000000000000000000000000000000000000000000000000000000000000000000
  32.  
  33. #          ZADANIE 2
  34.  
  35. #import numpy as np
  36. #import time
  37. #import csv
  38. #
  39. #
  40. #b_t = time.time()
  41. #for item in list_1:
  42. #   list_2.append(item*item)
  43. #e_t = time.time()
  44. #print("Elapsed time: ", e_t - b_t)
  45. #
  46. #list_1 = list(range(0, 10000000))
  47. #b_t = time.time()
  48. #list_2 = [item*item for item in list_1]
  49. #e_t = time.time()
  50. #print("Elapsed time: ", e_t - b_t)
  51. #
  52. #array_1 = np.arange(0, 10000000)
  53. #b_t = time.time()
  54. #array_2 = array_1 * array_1
  55. #e_t = time.time()
  56. #print("Elapsed time: ", e_t - b_t)
  57.  
  58.  
  59.  
  60. #000000000000000000000000000000000000000000000000000000000000000000000000000
  61.  
  62. #           ZADANIE 3
  63. #import random
  64. #import numpy as np
  65. #import matplotlib.pyplot as plt
  66. #
  67. #
  68. #tab = np.random.normal(50,20,(7,7))
  69. #tab1 =np.round(tab)
  70. #
  71. #
  72.  
  73. #count, bins, ignored = plt.hist(tab1, 30, density=True)
  74. #plt.plot(bins, 1/(20 * np.sqrt(2 * np.pi)) *
  75. #               np.exp( - (bins - 50)**2 / (2 * 20**2) ),
  76. #         linewidth=3, color='r')
  77. #plt.show()
  78.  
  79.  
  80. #print("Wyznacznik: {}".format(np.linalg.det(tab1)))
  81. #print("Slad: {}".format(np.trace(tab1)))
  82. #print("Wartosci i wketory wlasne {}".format(np.linalg.eig(tab)))
  83. #print("Wektory wlasne: {}".format(np.dot(tab1)))
  84.  
  85. #Elementy tablicy razy wektor
  86. #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])))
  87.  
  88. #RevTab = np.linalg.inv(tab1)     #Macierz odwrotna
  89.  
  90. #Przkątna macierzy do kwadratu
  91. #print("Na przekatnej macierzy mamy:\n{}".format(np.square(np.diagonal(tab1))))
  92.  
  93. #print(np.linalg.svd(tab1))    <-- SVD macierzy
  94.  
  95. #000000000000000000000000000000000000000000000000000000000000000000000000000
  96.  
  97.  
  98.  
  99. #Zadanie 4
  100. #import os
  101. #import numpy as np
  102. #import csv
  103. #
  104. #
  105. #current_dir = os.path.abspath(os.path.dirname(__file__))
  106. #data_folder = os.path.join(current_dir, "Data")
  107. #csv_path = os.path.join(data_folder, "iris.csv")
  108. #
  109. #
  110. #with open(csv_path) as csv_file:
  111. #   output_dict = dict()
  112. #   reader = csv.reader(csv_file)
  113. #   first_row = next(reader)
  114. #   for key in first_row:
  115. #       output_dict[key] = []
  116. #   for row in reader:
  117. #       for i in range(len(first_row)):
  118. #           try:
  119. #               output_dict[first_row[i]].append(float(row[i]))
  120. #           except:
  121. #               output_dict[first_row[i]].append(row[i])
  122. #
  123. #   for key in output_dict.keys():
  124. #       output_dict[key] = np.array(output_dict[key])
  125. #
  126. #print("Septal Length mean: ", np.mean(output_dict['sepal.length']))
  127. #print("Septal Length std: ", np.std(output_dict['sepal.length']))
  128. #print("Septal Width mean: ", np.mean(output_dict['sepal.width']))
  129. #print("Septal Width std: ", np.std(output_dict['sepal.width']))
  130. #print("Petal length mean: ", np.mean(output_dict['petal.width']))
  131. #print("Petal length std: ", np.std(output_dict['petal.length']))
  132. #print("Petal width mean: ", np.mean(output_dict['petal.length']))
  133. #print("Petal width std: ", np.std(output_dict['petal.length']))
  134. #            
  135.  
  136.  
  137. #000000000000000000000000000000000000000000000000000000000000000000000000000
  138.  
  139. # ZADANIE 5
  140.  
  141. #current_dir = os.path.abspath(os.path.dirname(__file__))
  142. #data_path = os.path.join(current_dir, "Data")
  143. #csv_path = os.path.join(data_path, ".png")
  144. ##print(current_dir)
  145. #try:
  146. #    data_file = open(csv_path)
  147. #except:
  148. #    pass
  149. #finally:
  150. #    pass
  151. #with open(csv_path) as csv_file:
  152. #    reader = csv.reader(csv_file)
  153. #    print(reader)
  154. #    #print(dir(reader))
  155. #    for item in reader:
  156. #        print(item)  
  157.  
  158. #000000000000000000000000000000000000000000000000000000000000000000000000000
  159.  
  160. #Zadanie 7 , blad MSE
  161. #
  162. #import numpy as np
  163. #
  164. ##array_1 = np.arange(1000, dtype=np.float32)
  165. #array_1 = np.float32(np.random.normal((1000,1)))
  166. #array_1_export = array_1 * 1000
  167. #
  168. #array_1_export.tofile('zad7.txt')
  169. #
  170. #array_2_import = np.fromfile('zad7.txt',dtype=np.float32)
  171. #array_2 = array_2_import /1000
  172. #
  173. ##print(array_2[:25])
  174. #
  175. #ax=0
  176. #mse = (np.square(array_1 - array_2)).mean(axis=ax)
  177. #print("MSE: {}".format(mse))
  178. #
  179. #
  180. #000000000000000000000000000000000000000000000000000000000000000000000000000
  181. ##Zadanie 8
  182. #import numpy as np        
  183. #  
  184. #tab_1 = np.ndarray((100,100,50))
  185. #
  186. #for i in range(50):
  187. #    tab_1[:,:,i] = np.asmatrix(np.random.rand(100,100))
  188. #    print("Wyznacznik macierzy (", i,"):",np.linalg.det(tab_1[:,:,i]))
  189. #
  190. #wektory = np.asmatrix(np.random.rand(50,100))      
  191. #000000000000000000000000000000000000000000000000000000000000000000000000000
  192. ##Zadanie 9
  193. #import numpy as np
  194. #
  195. #tab = np.random.rand(5,5)
  196. #tab1 = np.random.rand(5,5)
  197. #tab2=tab*tab1
  198. #print(np.diag(tab*tab1))   #Metoda 1
  199.  
  200. #j=-1
  201. #for i in range(0,len(tab)):
  202. #    j = j + 1
  203. #    print(tab2[i,j])
  204.    
  205. #000000000000000000000000000000000000000000000000000000000000000000000000000
  206. #Zadanie 10
  207. #import numpy as np
  208. #
  209. #vector = np.arange(0,10)
  210. #for i in range(0,len(vector)):
  211. #    if i % 2 == 0:
  212. #        vector[i] = vector[i] * vector[i]
  213. #    else:
  214. #        vector[i] = 0
  215. #        
  216. #print(vector)
  217. #
  218.  
  219.  
  220.  
  221. #000000000000000000000000000000000000000000000000000000000000000000000000000
  222. #Zadanie 11
  223. #import numpy as np
  224. #
  225. #def largest_num(array,count):
  226. #    array_out = []
  227. #    for i in range(0,count):
  228. #        array_out.append(np.amax(array))
  229. #        array = np.delete(array,array.argmax(axis=0))
  230. #    return array_out
  231. #        
  232. #array_1 = np.arange(0,1000)  
  233. #print(largest_num(array_1,3))
  234. #
  235. #000000000000000000000000000000000000000000000000000000000000000000000000000
  236.  
  237. #   Zadanie 12
  238.  
  239. #N = 10
  240. #array = np.random.rand(N)
  241. ##print(array)
  242. #array.flags.writeable =  False
  243. #try:
  244. #    array[5] = 7
  245. #except Exception as e:
  246. #    print(e)
  247.  
  248.  
  249. #Zadanie 13
  250. #import numpy as np
  251. #
  252. #def rank(A, eps=1e-12):
  253. #    u, s, vh = np.linalg.svd(A)
  254. #    return len([x for x in s if abs(x) > eps])
  255. #
  256. #array_1 = ([1,2,3],[3,4,5],[5,3,3])
  257. #print(rank(array_1))
  258. #print(np.linalg.matrix_rank(array_1))
  259.  
  260.  
  261. #000000000000000000000000000000000000000000000000000000000000000000000000000
  262.  
  263.                
  264. #Zadannie 14
  265. #Zdefiniuj ustrukturyzowana tablice zawierajaca w kazdym polu pozycje (x, y, z), a nastepnie wypełnij ja
  266. #losowymi wartosciami.
  267.  
  268.  
  269. #N=random.randint(0,9)
  270. #print(N)
  271. #x = np.random.rand()
  272. #y = np.random.rand()
  273. #z = np.random.rand()
  274. #
  275. #array =[(x, y, z) for i in range(N)]
  276. #print(array)
  277.  
  278.  #000000000000000000000000000000000000000000000000000000000000000000000000000
  279.  
  280. #Zadanie 15
  281. #Zdefiniuj losowy wektor liczb zmiennoprzecinkowych o losowej długosci. Zamien wszystkie wartosci stanowiace
  282. # wartosc minimalna wartoscia srednia. Powtórz tak długo az nie zostania dokonana zadna zmiana.
  283.  
  284. #N = random.randrange(0,9) #losowanie dlugosci wektora
  285. ##print(N)
  286. #vector = np.random.rand(N)
  287. ##print(vector)
  288. #minimum = np.amin(vector)
  289. ##print(minimum)
  290. #mean_value = np.mean(vector)
  291. ##print(mean_value)
  292. #for i in range(0, N):
  293. #    vector[i]= mean_value
  294. #print(vector)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top