Buku Pegangan Ilmu Data Python

Mar 31 2023
.
  1. IPython: Melampaui Python Normal
  2. Pengantar NumPy
  3. Manipulasi Data dengan Panda
  4. Visualisasi dengan Matplotlib
  1. Memulai Pembelajaran Mesin
  2. Belajar dari Data
  3. Regresi linier
  4. Naif Bayes
  5. k-Tetangga Terdekat
  6. Pengantar Pembelajaran Mesin dengan Scikit-Learn
  7. Pembelajaran Mesin dalam Praktek
  8. Pengorbanan Bias-Varians
  9. Estimasi Kepadatan Kernel
  10. Analisis Komponen Utama
  11. Pembelajaran Manifold
  12. Kekelompokan
  13. Pohon Keputusan dan Hutan Acak
  14. Optimasi Berbasis Gradien
  15. Pengelompokan K-Means
  16. Mendalam: Klasifikasi Naive Bayes
  17. Mendalam: Regresi Linear
  18. Mendalam: Mendukung Mesin Vektor
  19. Mendalam: Pohon Keputusan dan Hutan Acak
  20. Mendalam: Analisis Komponen Utama
  21. Mendalam: Pembelajaran Manifold
  22. Mendalam: k-Means Clustering
  1. Tur Angin Puyuh Python
  2. Esensi Bahasa Python
  3. IPython: Melampaui Python Normal
  4. NumPy
  5. Lebih lanjut tentang Shell Sistem IPython
  6. Matplotlib
  7. SciPy
  8. Scikit-Pelajari
  9. Pembelajaran Mesin dengan Scikit-Learn
  10. Sumber Pembelajaran Mesin Lebih Lanjut
  11. Pembelajaran Mesin Praktis: Contoh Sederhana
  12. Bibliografi

import numpy as np

# create a 1D array
a = np.array([0, 1, 2, 3, 4])
print(a)

import pandas as pd

# create a Pandas DataFrame
data = {'name': ['Alice', 'Bob', 'Charlie', 'David'],
        'age': [25, 32, 18, 47],
        'gender': ['F', 'M', 'M', 'M']}
df = pd.DataFrame(data)
print(df)

# filter rows based on a condition
df_filtered = df[df['age'] > 30]
print(df_filtered)

# group data by a column and compute statistics
grouped_data = df.groupby('gender')['age'].mean()
print(grouped_data)

import matplotlib.pyplot as plt
import numpy as np

# create some data to plot
x = np.linspace(0, 10, 100)
y = np.sin(x)

# create a line plot
plt.plot(x, y)
plt.title('Sine Wave')
plt.xlabel('x')
plt.ylabel('y')
plt.show()

# create a scatter plot
x = np.random.randn(100)
y = np.random.randn(100)
plt.scatter(x, y)
plt.title('Random Data')
plt.xlabel('x')
plt.ylabel('y')
plt.show()

from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier

# load the iris dataset
iris = load_iris()

# split the data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(iris['data'], iris['target'], random_state=0)

# create a K-Nearest Neighbors classifier
knn = KNeighborsClassifier(n_neighbors=1)

# fit the classifier to the training data
knn.fit(X_train, y_train)

# predict the classes of the test data
y_pred = knn.predict(X_test)

# compute the accuracy of the classifier
accuracy = knn.score(X_test, y_test)
print('Accuracy:', accuracy)