Professional Documents
Culture Documents
Pythonca Hafta 14 Bilimsel Kutups Son
Pythonca Hafta 14 Bilimsel Kutups Son
●
Bilgisayar programları kullanılarak sayısal teknikler ile mühendislik
ve bilimsel problemlerin analizi ve çözümlemesi
Diller ve Araçlar
●
Web Geliştime (Django, Pyramid, Flask)
●
Veri Analizi (Seaborn, Mapplotlib)
●
Oyun Geliştirme (Pygame)
●
Robotik Uygulamalar
Araçlar
●
IDLE, Spyder (Geliştirme Ortamları)
●
Numpy, Matplotlib, Pandas… yüzlerce (Kütüphaneler)
Numpy
●
Python Kütüphanesidir
●
Arraylarla çalışır
●
(Num)erical (Py)thon → NumPy
Neden Var?
●
Pythonda diziler var, ama yavaş çalışıyor
●
Yaklaşık 50 kat daha hızlı
●
Yardımcı birçok metot var
●
Veri biliminde genellikle dizilerle çalışılır
Numpy- arrays
import numpy as np
arr = np.array([1, 2, 3, 4, 5])
print(arr)
print(type(arr))
●
zeros = np.zeros(5)
●
zeros=np.zeros(5,4)
●
ones = np.ones(5)
●
ones = np.ones((5, 4))
●
random = np.random.rand(2, 3)
●
random = np.random.randint(50, 100, 5)
Numpy Metotları
index:
arr = np.array([[1,2,3,4,5], [6,7,8,9,10]])
print('2nd element on 1st row: ', arr[0, 1])
slice:
arr = np.array([1, 2, 3, 4, 5, 6, 7])
print(arr[1:5])
print(arr[-3:-1])
type:
arr = np.array([1, 2, 3, 4], dtype='S') or ‘i4’
Numpy Index
import numpy as np
arr = np.array([1, 2, 3])
for x in arr:
print(x)
arr2 = np.array([[1, 2, 3], [4, 5, 6]])
for x in arr2:
for y in x:
print(y)
Numpy nditer
import numpy as np
arr = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
for x in np.nditer(arr):
print(x)
Numpy where
Tüm
import numpy as np
arr = np.array([1, 2, 3, 4, 5, 4, 4])
x = np.where(arr == 4)
print(x)
Numpy where-2
import numpy as np
arr = np.array([1, 2, 3, 4, 5, 6, 7, 8])
x = np.where(arr%2 == 0)
print(x)
Numpy Sort
import numpy as np
arr = np.array(['banana', 'cherry', 'apple'])
print(np.sort(arr))
Mapplotlib
●
İki boyutlu çizim kütüphanesi
Matplotlib -Örnek
plt.plot(xpoints, ypoints)
plt.show()
numpy-matplot
import numpy as np
import matplotlib.pyplot as plt
f = lambda x: np.exp(-x**2)*np.sin(x)
x = np.linspace(-3, 3, 101)
plt.plot(x, f(x))
plt.show()
Örnek-2
plt.plot(ypoints)
plt.show()
Örnek-Histogram
import numpy as np
x = np.random.normal(170, 10, 250)
print(x)
Pie Chart
plt.pie(y)
plt.show()
Python