4 Menggunakan Media Sosial
To insert a logo into your Quarto website’s navigation menu, you need to modify the _quarto.yml configuration file. The logo typically appears to the left of the website title in the top navigation bar (navbar) or at the top of a sidebar. [1, 2]
5 Penjelasan Matriks
5.1 1. Definisi Matriks
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score, confusion_matrix, ConfusionMatrixDisplay
from sklearn.decomposition import PCA
# Set style visualisasi
plt.style.use('seaborn-v0_8-whitegrid')
sns.set_palette("Set2")
# 1. Memuat Dataset Iris
iris = datasets.load_iris()
X = iris.data
y = iris.target
feature_names = iris.feature_names
target_names = iris.target_names
# 2. Train-Test Split (Menggunakan Integer untuk keamanan)
# Dataset Iris memiliki 150 sampel, 20% = 30 sampel
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=30, random_state=42, stratify=y
)
# 3. Pelatihan Model
model = LogisticRegression(max_iter=200)
model.fit(X_train, y_train)
y_pred = model.predict(X_test)
# 4. Visualisasi
fig, axes = plt.subplots(2, 2, figsize=(14, 12))
# Scatter plot: Sepal
ax = axes[0, 0]
for class_idx, name in enumerate(target_names):
ax.scatter(X[y == class_idx, 0], X[y == class_idx, 1],
label=name, edgecolors='k', s=50, alpha=0.7)
ax.set_xlabel(feature_names[0])
ax.set_ylabel(feature_names[1])
ax.set_title('Sepal Length vs Sepal Width')
ax.legend()
ax.grid(True, alpha=0.3)
# Scatter plot: Petal
ax = axes[0, 1]
for class_idx, name in enumerate(target_names):
ax.scatter(X[y == class_idx, 2], X[y == class_idx, 3],
label=name, edgecolors='k', s=50, alpha=0.7)
ax.set_xlabel(feature_names[2])
ax.set_ylabel(feature_names[3])
ax.set_title('Petal Length vs Petal Width')
ax.legend()
ax.grid(True, alpha=0.3)
# Decision Boundary
ax = axes[1, 0]
X_2feat = X[:, :2]
model_2 = LogisticRegression(max_iter=200)
model_2.fit(X_2feat, y)
h = 0.02
x_min, x_max = X_2feat[:, 0].min() - 1, X_2feat[:, 0].max() + 1
y_min, y_max = X_2feat[:, 1].min() - 1, X_2feat[:, 1].max() + 1
xx, yy = np.meshgrid(np.arange(x_min, x_max, h),
np.arange(y_min, y_max, h))
Z = model_2.predict(np.c_[xx.ravel(), yy.ravel()])
Z = Z.reshape(xx.shape)
ax.contourf(xx, yy, Z, alpha=0.3, cmap='Set2')
for class_idx, name in enumerate(target_names):
ax.scatter(X_2feat[y == class_idx, 0], X_2feat[y == class_idx, 1],
label=name, edgecolors='k', s=50)
ax.set_xlabel(feature_names[0])
ax.set_ylabel(feature_names[1])
ax.set_title('Decision Boundary')
ax.legend()
ax.grid(True, alpha=0.3)
# Confusion Matrix
ax = axes[1, 1]
cm = confusion_matrix(y_test, y_pred)
disp = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=target_names)
disp.plot(ax=ax, cmap='Blues', values_format='d')
ax.set_title('Confusion Matrix')
plt.tight_layout()
plt.show()
# PCA Visualization
pca = PCA(n_components=2)
X_pca = pca.fit_transform(X)
plt.figure(figsize=(8, 6))
for class_idx, name in enumerate(target_names):
plt.scatter(X_pca[y == class_idx, 0], X_pca[y == class_idx, 1],
label=name, edgecolors='k', s=60, alpha=0.7)
plt.xlabel(f'PC1 ({pca.explained_variance_ratio_[0]:.2%})')
plt.ylabel(f'PC2 ({pca.explained_variance_ratio_[1]:.2%})')
plt.title('PCA Projection')
plt.legend()
plt.grid(True, alpha=0.3)
plt.show()
# Print Metrics
print(f"Akurasi: {accuracy_score(y_test, y_pred):.4f}")Embedded Sage Cells
Your own computations
Type your own Sage computation below and click “Evaluate”.6 Baru ini mencoba
Factorial
Click the “Activate” button below to calculate factorials.7
7.1 4. Implementasi di SageMath
# Membuat matriks 3x4
A = matrix([[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12]])
show("Matriks A:", A)
# Operasi dasar
B = matrix([[2, 0, 1, 3],
[1, 1, 0, 2],
[0, 2, 1, 1]])
show("A + B:", A + B)
show("2 * A:", 2 * A)
show("Transpose A:", A.transpose())
# Akses elemen dan slice
print("Elemen [baris-1, kolom-2]:", A[0, 1]) # Output: 2
show("Submatriks (2 baris pertama, kolom 2-3):", A[0:2, 1:3])
# Matriks persegi untuk operasi lanjut
C = matrix([[4, 2], [3, 1]])
show("Determinan C:", C.determinant())
show("Invers C:", C.inverse())
show("C * C^-1:", C * C.inverse()) # Harus menghasilkan matriks identitas
7.2
7.5 3. Using Brand.yml for Multiformat Logos [9]
For more advanced setups, such as different logos for light and dark modes or different sizes, you can use a _brand.yml file: [10, 11]
Define in
_brand.yml:logo: medium: light: "images/logo-light.png" dark: "images/logo-dark.png"Reference in
_quarto.yml:brand: _brand.yml website: navbar: logo: medium # Quarto automatically picks the correct light/dark version[12]
7.6 4. Adding a Favicon (Browser Tab Logo)
To ensure your logo or icon appears in the browser tab, use the favicon option under the website key: [2, 13]
website:
favicon: "favicon.ico" # Usually a .png or .ico file
For more detailed customization, you can refer to the official Quarto Website Navigation documentation. [14]
Would you like to know how to adjust the size of the logo or customize its position further using CSS?
[10] https://stackoverflow.com
[11] https://quarto.org
[12] https://quarto.org
[13] https://quarto.org
To insert an Instagram link into the left sidebar of your Quarto website, you can use the tools or footer options within the sidebar configuration in your _quarto.yml file.