Talk:Google Colab
Add topic| This article is rated Start-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||
| |||||||||||
AgroGuard
[edit]Real-Time Human and Animal Intrusion Detection System for Agricultural Farms with Adaptive Alarm and Notification Mechanisms Evangelistra (talk) 04:34, 26 July 2026 (UTC)
طلبوا منا تقرير بخصوص هذا الكود مع حل الشيفرة والسرك
[edit]import numpy as np import matplotlib.pyplot as plt import time
rng = np.random.default_rng(42)
x1 = np.linspace(-1, 1, 25) y1 = 2 * x1 + 1 + rng.normal(0, 0.15, len(x1))
x2 = rng.uniform(-1, 1, 5000) y2 = 2 * x2 + 1 + rng.normal(0, 1.0, len(x2))
results = []
for name, x, y in [('Small', x1, y1), ('Large', x2, y2)]: A = np.c_[np.ones(len(x)), x]
t = time.perf_counter()
theta_ne = np.linalg.solve(A.T @ A, A.T @ y)
time_ne = time.perf_counter() - t
theta = np.zeros(2)
epochs = 15
learning_rate = 0.001
t = time.perf_counter()
for epoch in range(epochs):
for a, actual in zip(A, y):
error = actual - a @ theta
theta += learning_rate * error * a
time_lms = time.perf_counter() - t
mse_ne = np.mean((y - A @ theta_ne) ** 2)
mse_lms = np.mean((y - A @ theta) ** 2)
print(name, 'NE MSE/time:', mse_ne, time_ne)
print(name, 'LMS MSE/time:', mse_lms, time_lms)
if name == 'Large':
results = [x, y, A, theta_ne, theta.copy()]
x, y, A, theta_ne, theta_lms = results order = np.argsort(x)
plt.figure(figsize=(8, 5)) plt.scatter(x, y, s=10, label='Data', alpha=0.5) plt.plot(x[order], (A @ theta_ne)[order], color='red', label='Normal Equation') plt.plot(x[order], (A @ theta_lms)[order], '--', color='green', label='LMS')
plt.xlabel('Input x') plt.ylabel('Output y') plt.title('LMS and Normal Equation (Modified)') plt.legend() plt.grid(True) plt.show() ~2026-57088-98 (talk) 20:40, 26 October 2026 (UTC)
- ضعه في ملف pdf مع خط مرتب ورسم جيد لان استنسخه ~2026-57088-98 (talk) 20:41, 26 October 2026 (UTC)