فيديو المحاضرة
فيديو المحاضرة ١: مقدمة في تعلّم الآلة
مدة الفيديو أربع دقائق تقريباً، وبعده الأمثلة والاختبار والتمارين تحت.
أمثلة Python
أمثلة صغيرة بالـ scikit-learn
الكود والنتيجة معروضين هنا كنص ثابت (النتائج اتجرّبت فعلاً). لتشغيل الكود بنفسك انسخه في Google Colab المجاني. تقدر كمان تفتح الدفتر الرسمي للكتاب (ترخيص Apache-2.0) من الرابط تحت.
المثال ١: التعلّم من أمثلة
Sample output (press Run to produce your own): score per extra hour: 6.46 predicted score for 7 hours: 90.6
المثال ٢: Supervised، تصنيف الزهور
Sample output (press Run to produce your own): accuracy on unseen flowers: 1.0
المثال ٣: Unsupervised، تجميع بدون labels
Sample output (press Run to produce your own): group sizes: [38, 50, 62]
اختبار قصير
اختبر فهمك
1. In traditional programming vs machine learning, what does the machine learning approach start from?
2. A spam filter trained on emails already marked 'spam' or 'not spam' is an example of:
3. Grouping customers into similar groups with no labels at all is:
4. Predicting a number (like an exam score) is called:
5. A robot that learns by getting rewards and penalties is using:
تمارين برمجة
جرّب بإيدك
التمرين 1
أضف طالب ذاكر ٠ ساعة وجابت درجته ٤٥ للداتا، وأعد التدريب، واطبع توقّع درجة ٧ ساعات.
Add a student with 0 hours and score 45, refit, and print the prediction for 7 hours.
(output appears here)
from sklearn.linear_model import LinearRegression hours = [[1], [2], [3], [4], [5], [6]] scores = [52, 58, 65, 71, 78, 84] hours.append([0]) scores.append(45) model = LinearRegression().fit(hours, scores) print(round(model.predict([[7]])[0], 1))
Output
90.7
التمرين 2
في مثال الزهور، جرّب n_neighbors = 1 ثم 50 ثم 100 واطبع دقة كل واحد. إيه اللي بيحصل عند 100؟
In the flower example, try n_neighbors = 1, 50 and 100 and print each accuracy. What happens at 100?
(output appears here)
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
X, y = load_iris(return_X_y=True)
X_tr, X_te, y_tr, y_te = train_test_split(X, y, test_size=0.3, random_state=42)
for k in (1, 50, 100):
clf = KNeighborsClassifier(n_neighbors=k).fit(X_tr, y_tr)
print('k =', k, 'accuracy:', round(clf.score(X_te, y_te), 3))
Output
k = 1 accuracy: 1.0 k = 50 accuracy: 0.956 k = 100 accuracy: 0.289
مشروع نهاية الفصل
ملف المشروع العملي للفصل 1
ملف PDF فيه مشروع صغير بأسئلة عملية تطبّق بيها كل اللي اتعلمته في الفصل، مع حل نموذجي في الآخر.
Credits: topic order follows the public chapter list of Aurélien Géron's book "Hands-On Machine Learning with Scikit-Learn, Keras and TensorFlow" (3rd ed.). All explanations and code here are original.