Classify Handwritten Digits
Train and evaluate an SVC that classifies handwritten digits in Google Colab.
Introduction
ملخص في 30 ثانية
يمكنك تمييز رقم مكتوب بسرعة حتى لو اختلف الخط أو سمك القلم. بالنسبة إلى الحاسوب، تبدأ الصورة كمربعات من درجات السطوع تحتاج إلى معنى.
في هذا المشروع، ستبني مصنفًا للأرقام المكتوبة يدويًا داخل دفتر Google Colab باستخدام التعلم الآلي الخاضع للإشراف. ستقارن نتائجه مع خط أساس محدود لترى أثر التعلم من البكسلات.
ما الذي ستبنيه
ستشغّل الدفتر أمام أي شخص لترى تنبؤات النموذج فوق صور اختبار لم يستخدمها أثناء التدريب.
بنهاية هذا المشروع، سيكون لديك:
- دفتر تفاعلي قابل للتشغيل يحمّل صور الأرقام الجاهزة ويعرض تنبؤات النموذج عليها.
- مقارنة مرئية تكشف الفرق بين تخمينات خط الأساس وتنبؤات مصنف SVC المتعلم.
- تقرير تقييم ومصفوفة التباس يوضحان الأرقام التي يصنفها النموذج بنجاح والأرقام التي يخلط بينها.
- المهمة السرية: استخدام GridSearchCV لاختيار إعدادات أفضل لمصنف SVC بطريقة قابلة للتكرار.
هل توجد متطلبات مسبقة؟
تحتاج إلى حساب Google ومتصفح حديث واتصال بالإنترنت. لا يلزم تثبيت Python محليًا لأن الدفتر يعمل مجانًا في Google Colab.
Before We Start
هذه الخطوة تثبت هدف مشروعك قبل بدء العمل العملي: نموذج يصنف صور الأرقام المكتوبة يدويًا من 0 إلى 9. تحتفظ ببيانات اختبار منفصلة لقياس قدرة النموذج على التعميم على صور جديدة دون الاعتماد على حفظ بيانات التدريب.
Set Up Your Colab Notebook
Your classifier needs a stable workspace before it can learn from digit images. Google Colab gives you a hosted notebook without a local Python setup.
Colab runtimes can change between sessions. In this step, you will pin scikit-learn to version 1.9.1 plus Matplotlib to version 3.11.2 so every later result comes from the same environment.
In this step, get ready to:
- Create the digits_classifier.ipynb notebook in Google Colab.
- Install the pinned project dependencies.
- Verify that the required imports load with the pinned versions.
Create your notebook
A Colab notebook keeps your code in the .ipynb format. Your notebook is saved in Google Drive so you can return to it later.
Google handles your sign-in on its own account page. The notebook never contains your Google password.
- Visit Google Colab in your browser.
- Complete Google sign-in with the account that should store this notebook.
- Click File in the top menu.
- Select New notebook.
- Click the current notebook title at the top of the page.
- Enter digits_classifier.ipynb as the new title.
- Press Enter to apply the title.
You should see digits_classifier.ipynb at the top of the page. Good progress. That named notebook is now the home for every model cell you build.
Why Colab Instead of Local Python?
A local Python environment would add installation work before you could begin the machine learning cycle. Colab provides a hosted runtime through your browser.
This keeps the project focused on training plus evaluating the classifier. The pinned cells preserve the environment details that matter for reproducibility.
Pin the project dependencies
The first cell records the exact library versions required by this project. Running this cell rebuilds the same dependency setup when a fresh Colab runtime starts.
- Paste the dependency commands into the first code cell:
# Cell 1: Pin the project dependencies
!pip install scikit-learn==1.9.1
!pip install matplotlib==3.11.2
What Does This Cell Do?
- The !pip prefix runs each package installation command through the notebook runtime.
- The scikit-learn==1.9.1 requirement pins the library used to build plus evaluate the classifier.
- The matplotlib==3.11.2 requirement pins the library used to display digit images plus evaluation plots.
- Run the installation cell by clicking its play icon.
You should see both installation commands finish without a dependency installation error. Colab saves the completed cell in digits_classifier.ipynb.
Installation Cell Failed?
- Confirm that the installation cell matches the two pinned commands exactly.
- Reconnect your browser session if the Colab runtime disconnected during installation.
- Run the installation cell again after the runtime reconnects.
Help me diagnose the dependency installation in my Colab notebook.
Verify the notebook environment
A successful installation still needs a runtime check. The next cell imports every library required by the later model cells before displaying the active environment versions.
- Click + Code in the notebook toolbar to create a second code cell.
- Paste the environment-verification cell below:
# Cell 2: Import and verify the environment
import sklearn
import matplotlib
import matplotlib.pyplot as plt
from sklearn import datasets, metrics, svm
from sklearn.dummy import DummyClassifier
from sklearn.model_selection import train_test_split
sklearn.show_versions()
print("matplotlib:", matplotlib.__version__)
What Does This Cell Check?
- The import group loads the plotting tools plus every scikit-learn module used in later cells.
- The sklearn.show_versions() call displays the installed scikit-learn version plus its environment details.
- The matplotlib.__version__ value confirms which Matplotlib release the runtime loaded.
Before you run this cell, which two pinned version numbers do you expect the environment check to display?
- Run the environment-verification cell by clicking its play icon.
You should see scikit-learn 1.9.1 in the environment details. You should also see matplotlib: 3.11.2 below those details.
No import error should appear. That is the foundation locked in. Your notebook can now load every tool required by the classifier.
Versions Missing or Incorrect?
- Confirm that you ran the installation cell before the environment-verification cell.
- Rerun the installation cell if either displayed version differs from the pinned version.
- Rerun the environment-verification cell after both installations finish.
Help me fix the version check in my Colab notebook.
✔️ Awesome, I've got everything!
Your installation plus verification cells are complete. Make sure digits_classifier.ipynb remains open for the next step.
ⓧ I'd like to double check the full code
- Compare the first two cells in digits_classifier.ipynb with this complete reference:
# Cell 1: Pin the project dependencies
!pip install scikit-learn==1.9.1
!pip install matplotlib==3.11.2
# Cell 2: Import and verify the environment
import sklearn
import matplotlib
import matplotlib.pyplot as plt
from sklearn import datasets, metrics, svm
from sklearn.dummy import DummyClassifier
from sklearn.model_selection import train_test_split
sklearn.show_versions()
print("matplotlib:", matplotlib.__version__)
How Is This Notebook Organized?
- Cell 1 installs the two pinned project dependencies.
- Cell 2 imports the required modules plus displays the active environment versions.
Your Colab notebook now runs with the exact libraries this project expects. Next, you will load the handwritten digits plus build a baseline that exposes what prediction without learning looks like.
Build a Baseline Classifier
Your Google Colab notebook now has its scikit-learn tools ready. The verified environment gives each experiment a consistent starting point.
Producing a prediction does not prove that a classifier learned from the images. You will test that idea with a deliberately limited baseline that provides a reference score.
In this step, get ready to:
- Prepare each digit image as 64 pixel features.
- Separate the examples into training data and test data.
- Train a most-frequent baseline and inspect its predictions.
Prepare the digits data
Each image in the built-in digits dataset is an 8 by 8 grid. Flattening that grid gives the classifier 64 pixel features for each image.
- Add a new code cell below the environment-verification cell in the open digits_classifier.ipynb notebook.
- Paste the data preparation code into the new cell:
# Cell 3: Load and split the digits dataset
digits = datasets.load_digits()
n_samples = len(digits.images)
data = digits.images.reshape((n_samples, -1))
X_train, X_test, y_train, y_test = train_test_split(
data, digits.target, test_size=0.5, shuffle=False
)
print(f"Training samples: {len(X_train)}")
print(f"Test samples: {len(X_test)}")
What does this code do?
- The digits variable holds the built-in images and their correct number labels.
- The data variable stores each image as a row of 64 pixel features.
- The train_test_split call reserves half of the examples for training. The other half remains separate for testing.
- The two print statements expose the size of each group before model training begins.
- Run Cell 3 by clicking the run control on its left.
- Confirm that the output lists separate training and test sample counts.
You should see two sample counts. The test group contains one more example because the complete dataset has an odd number of images.
Data cell not running?
- Confirm that Cell 2 ran successfully in the current Colab session so the earlier imports remain available.
- Check that the indentation inside train_test_split matches the reference code.
- Check that digits.images uses a period between the variable name and the attribute.
Ask for help with the data preparation cell.
Train the deliberately limited baseline
A baseline sets the minimum result that a useful model should beat. This one uses DummyClassifier(strategy="most_frequent") to ignore the pixel features and repeat the most common training label.
- Add a new code cell below Cell 3.
- Paste the baseline training code into the new cell:
# Cell 4: Build the deliberately limited baseline
baseline = DummyClassifier(strategy="most_frequent")
baseline.fit(X_train, y_train)
baseline_predictions = baseline.predict(X_test)
baseline_accuracy = metrics.accuracy_score(y_test, baseline_predictions)
print(f"Baseline accuracy: {baseline_accuracy:.3f}")
How does the baseline work?
- The baseline variable holds a classifier that selects the most frequent training label.
- Training records which label occurs most often. The pixel patterns do not influence that choice.
- The baseline_accuracy value measures the share of test labels that match those repeated predictions.
Before you run the cell, consider how accurate a classifier can be when it ignores every pixel.
- Run Cell 4 by clicking the run control on its left.
You should see a line beginning with Baseline accuracy. The low score exposes the limit of predicting without learning from the image features.
Baseline cell failing?
- Run Cell 3 again if the training or test variables are unavailable in the current Colab session.
- Confirm that the strategy value is spelled exactly as most_frequent.
- Check that baseline_predictions appears before the accuracy calculation.
Ask for help with the baseline training cell.
Visualize the baseline predictions
A score summarizes performance across the test set. A Matplotlib figure makes the baseline's behavior visible on four real test images.
- Place the cursor below the accuracy print statement in Cell 4.
- Paste the visualization code at the bottom of the same cell:
_, axes = plt.subplots(nrows=1, ncols=4, figsize=(10, 3))
for ax, image, prediction in zip(axes, X_test, baseline_predictions):
ax.set_axis_off()
ax.imshow(image.reshape(8, 8), cmap=plt.cm.gray_r, interpolation="nearest")
ax.set_title(f"Baseline: {prediction}")
plt.show()
What does the visualization show?
- The figure creates four spaces for the first four test examples.
- Each flattened row returns to an 8 by 8 image for display.
- Each title uses the corresponding value from baseline_predictions.
Before you run the completed cell, picture whether four different images will receive varied labels or the same label.
- Run Cell 4 again by clicking the run control on its left.
- Wait for Colab to finish saving digits_classifier.ipynb to Google Drive.
You should see four different digit images with matching Baseline prediction titles. You should also see the Baseline accuracy line above the figure.
You have now caught the baseline's weakness in plain sight. Different images receive the same prediction because the classifier never uses their pixels.
Plot missing or incomplete?
- Confirm that the visualization code remains inside Cell 4 below the baseline accuracy print statement.
- Run Cell 3 before Cell 4 if the Colab runtime restarted.
- Check that the final plt.show() line remains at the bottom of Cell 4.
Ask for help with the four-image baseline plot.
✔️ Awesome, I've got everything!
Your notebook now contains the complete data preparation and baseline sections.
ⓧ I'd like to double check the full code
- Compare your digits_classifier.ipynb notebook with this complete reference:
# Cell 1: Pin the project dependencies
!pip install scikit-learn==1.9.1
!pip install matplotlib==3.11.2
# Cell 2: Import and verify the environment
import sklearn
import matplotlib
import matplotlib.pyplot as plt
from sklearn import datasets, metrics, svm
from sklearn.dummy import DummyClassifier
from sklearn.model_selection import train_test_split
sklearn.show_versions()
print("matplotlib:", matplotlib.__version__)
# Cell 3: Load and split the digits dataset
digits = datasets.load_digits()
n_samples = len(digits.images)
data = digits.images.reshape((n_samples, -1))
X_train, X_test, y_train, y_test = train_test_split(
data, digits.target, test_size=0.5, shuffle=False
)
print(f"Training samples: {len(X_train)}")
print(f"Test samples: {len(X_test)}")
# Cell 4: Build the deliberately limited baseline
baseline = DummyClassifier(strategy="most_frequent")
baseline.fit(X_train, y_train)
baseline_predictions = baseline.predict(X_test)
baseline_accuracy = metrics.accuracy_score(y_test, baseline_predictions)
print(f"Baseline accuracy: {baseline_accuracy:.3f}")
_, axes = plt.subplots(nrows=1, ncols=4, figsize=(10, 3))
for ax, image, prediction in zip(axes, X_test, baseline_predictions):
ax.set_axis_off()
ax.imshow(image.reshape(8, 8), cmap=plt.cm.gray_r, interpolation="nearest")
ax.set_title(f"Baseline: {prediction}")
plt.show()
Your baseline now gives the project a concrete score to beat. Next up, you will train a classifier that learns from the pixel patterns.
Train Your SVC Model
Your Google Colab notebook now contains a baseline that makes repeated guesses without reading the pixel patterns.
An SVC uses the 64 pixel features to learn decision boundaries between digit classes. This step trains that classifier on the training split.
In this step, get ready to:
- Fit an SVC on the training split.
- Measure the classifier's accuracy against the saved baseline.
- Display four predictions on test images.
Train and measure the classifier
The baseline establishes the minimum performance your learned model should beat. The SVC can improve on it because its training process uses the pixel features.
Why SVC after the baseline?
The baseline provides a reference score without learning from the images. That score gives your SVC result a useful comparison point.
The SVC learns boundaries between digit classes from the training examples. Its test accuracy shows how well those boundaries generalize to unseen images.
- Add a code cell directly below Cell 4.
- Paste the following code into the new cell:
# Cell 5: Train and test the SVC model
classifier = svm.SVC(gamma=0.001)
classifier.fit(X_train, y_train)
predicted = classifier.predict(X_test)
model_accuracy = metrics.accuracy_score(y_test, predicted)
print(f"SVC accuracy: {model_accuracy:.3f}")
print(f"Improvement: {model_accuracy - baseline_accuracy:.3f}")
What does this code do?
- The classifier variable holds an svm.SVC(gamma=0.001) classifier.
- The training split teaches the classifier how pixel patterns relate to digit labels.
- The predicted variable stores one prediction for each image in X_test.
- The model_accuracy variable stores the share of correct test predictions.
- The second printed value measures the improvement over baseline_accuracy.
Before you run Cell 5, do you expect a classifier that reads the pixels to beat the repeated baseline guesses?
- Run Cell 5 using the play control beside the cell.
- Save digits_classifier.ipynb after the output appears.
You should see one line labelled SVC accuracy. A second line should report a positive Improvement value.
Good progress. Your classifier now produces test predictions from learned pixel patterns.
Cell does not run?
- Run Cells 2 through 4 again if the Colab runtime no longer contains the imported tools or training variables.
- Check that X_train uses a capital X.
- Confirm that the accuracy calculation uses predicted.
Ask for help with the failed training cell.
Visualize the SVC predictions
Numerical accuracy summarizes the full test split. A Matplotlib visualization connects several predictions to the images that produced them.
- Place your cursor below the second print line in Cell 5.
- Paste this visualization code at the bottom of the cell:
_, axes = plt.subplots(nrows=1, ncols=4, figsize=(10, 3))
for ax, image, prediction in zip(axes, X_test, predicted):
ax.set_axis_off()
ax.imshow(image.reshape(8, 8), cmap=plt.cm.gray_r, interpolation="nearest")
ax.set_title(f"SVC prediction: {prediction}")
plt.show()
What does this visualization show?
- The subplot creates four positions for test images.
- The loop pairs each position with an image from X_test.
- The reshape operation restores each flattened image to its 8 by 8 layout.
- Each title displays the corresponding value from predicted.
- Save the completed Cell 5 in digits_classifier.ipynb.
Before you rerun Cell 5, do you expect the four SVC titles to repeat one label or vary across the images?
- Run Cell 5 again using the play control beside the cell.
You should see four test images with varied SVC prediction titles. The printed SVC accuracy value should be higher than Baseline accuracy.
You have now shown that a classifier using pixel patterns beats the feature-blind baseline.
Predictions not appearing?
- Confirm that the visualization code sits below the accuracy print lines in Cell 5.
- Check that the loop uses predicted instead of baseline_predictions.
- Rerun the complete cell if you added the visualization after its previous execution.
Help me troubleshoot the missing SVC visualization.
✔️ Awesome, I've got everything!
Great. Double check that digits_classifier.ipynb is saved with the completed Cell 5.
ⓧ I'd like to double check the full code
This is the complete notebook through Cell 5.
# Cell 1: Pin the project dependencies
!pip install scikit-learn==1.9.1
!pip install matplotlib==3.11.2
# Cell 2: Import and verify the environment
import sklearn
import matplotlib
import matplotlib.pyplot as plt
from sklearn import datasets, metrics, svm
from sklearn.dummy import DummyClassifier
from sklearn.model_selection import train_test_split
sklearn.show_versions()
print("matplotlib:", matplotlib.__version__)
# Cell 3: Load and split the digits dataset
digits = datasets.load_digits()
n_samples = len(digits.images)
data = digits.images.reshape((n_samples, -1))
X_train, X_test, y_train, y_test = train_test_split(
data, digits.target, test_size=0.5, shuffle=False
)
print(f"Training samples: {len(X_train)}")
print(f"Test samples: {len(X_test)}")
# Cell 4: Build the deliberately limited baseline
baseline = DummyClassifier(strategy="most_frequent")
baseline.fit(X_train, y_train)
baseline_predictions = baseline.predict(X_test)
baseline_accuracy = metrics.accuracy_score(y_test, baseline_predictions)
print(f"Baseline accuracy: {baseline_accuracy:.3f}")
_, axes = plt.subplots(nrows=1, ncols=4, figsize=(10, 3))
for ax, image, prediction in zip(axes, X_test, baseline_predictions):
ax.set_axis_off()
ax.imshow(image.reshape(8, 8), cmap=plt.cm.gray_r, interpolation="nearest")
ax.set_title(f"Baseline: {prediction}")
plt.show()
# Cell 5: Train and test the SVC model
classifier = svm.SVC(gamma=0.001)
classifier.fit(X_train, y_train)
predicted = classifier.predict(X_test)
model_accuracy = metrics.accuracy_score(y_test, predicted)
print(f"SVC accuracy: {model_accuracy:.3f}")
print(f"Improvement: {model_accuracy - baseline_accuracy:.3f}")
_, axes = plt.subplots(nrows=1, ncols=4, figsize=(10, 3))
for ax, image, prediction in zip(axes, X_test, predicted):
ax.set_axis_off()
ax.imshow(image.reshape(8, 8), cmap=plt.cm.gray_r, interpolation="nearest")
ax.set_title(f"SVC prediction: {prediction}")
plt.show()
Your SVC now recognizes patterns in unseen digit images. Next up, you will analyze which digit classes still confuse it.
Analyze Classification Errors
Your SVC model now predicts unseen digits more accurately than the baseline. That gives you a working classifier whose mistakes are worth investigating.
One accuracy score hides which digits cause those mistakes. In this step, you will generate a classification report plus a confusion matrix to expose the error patterns.
In this step, get ready to:
- Generate a classification report for each digit.
- Plot a confusion matrix to locate misclassified digit pairs.
Generate the evaluation outputs
- Return to the bottom of digits_classifier.ipynb in the notebook from earlier.
- Use the add-cell control beneath Cell 5 to insert a new code cell.
- Paste this evaluation code into the new cell:
# Cell 6: Analyze the errors
print(metrics.classification_report(y_test, predicted))
display = metrics.ConfusionMatrixDisplay.from_predictions(y_test, predicted)
display.figure_.suptitle("Confusion Matrix")
print(f"Confusion matrix:\n{display.confusion_matrix}")
plt.show()
What Does This Evaluation Do?
- The metrics.classification_report(y_test, predicted) call separates model performance into one row for each digit.
- The metrics.ConfusionMatrixDisplay.from_predictions(y_test, predicted) call turns the actual labels plus predictions into a grid of counts.
- The printed matrix exposes the same counts as text. The plt.show() call renders those counts as a plot.
Interpret the confusion matrix
Before you run the cell, consider whether most counts will appear on the main diagonal or away from it.
- Run Cell 6 using the play button on the left side of the cell.
You will see a report containing precision, recall, plus f1-score values for digits 0 through 9.
You will also see a plot titled Confusion Matrix. The printed Confusion matrix: output contains the underlying counts.
How Do I Read the Matrix?
The main diagonal collects predictions where the actual digit matches the predicted digit. Larger values on this diagonal show where the model succeeds most often.
Every count outside the main diagonal represents a classification error. These cells reveal the digit pairs that look similar to the model.
- Find the largest count outside the main diagonal.
- Use the plot axis labels to identify the actual digit for that cell.
- Use the same cell to identify the predicted digit.
Missing the Report or Plot?
- Rerun Cell 5 if Colab reports that predicted is unavailable. A restarted runtime clears variables from earlier cells.
- Confirm that plt.show() remains on the final line if the report appears without the matrix plot.
- Check that the new cell sits beneath Cell 5 so the notebook keeps its evaluation sequence clear.
Help me diagnose my missing classification report or confusion matrix.
✔️ Awesome, I've got everything!
Your final notebook now contains the classification report plus the confusion matrix. Make sure Cell 6 has finished running successfully.
ⓧ I'd like to double check the full code
# Cell 1: Pin the project dependencies
!pip install scikit-learn==1.9.1
!pip install matplotlib==3.11.2
# Cell 2: Import and verify the environment
import sklearn
import matplotlib
import matplotlib.pyplot as plt
from sklearn import datasets, metrics, svm
from sklearn.dummy import DummyClassifier
from sklearn.model_selection import train_test_split
sklearn.show_versions()
print("matplotlib:", matplotlib.__version__)
# Cell 3: Load and split the digits dataset
digits = datasets.load_digits()
n_samples = len(digits.images)
data = digits.images.reshape((n_samples, -1))
X_train, X_test, y_train, y_test = train_test_split(
data, digits.target, test_size=0.5, shuffle=False
)
print(f"Training samples: {len(X_train)}")
print(f"Test samples: {len(X_test)}")
# Cell 4: Build the deliberately limited baseline
baseline = DummyClassifier(strategy="most_frequent")
baseline.fit(X_train, y_train)
baseline_predictions = baseline.predict(X_test)
baseline_accuracy = metrics.accuracy_score(y_test, baseline_predictions)
print(f"Baseline accuracy: {baseline_accuracy:.3f}")
_, axes = plt.subplots(nrows=1, ncols=4, figsize=(10, 3))
for ax, image, prediction in zip(axes, X_test, baseline_predictions):
ax.set_axis_off()
ax.imshow(image.reshape(8, 8), cmap=plt.cm.gray_r, interpolation="nearest")
ax.set_title(f"Baseline: {prediction}")
plt.show()
# Cell 5: Train and test the SVC model
classifier = svm.SVC(gamma=0.001)
classifier.fit(X_train, y_train)
predicted = classifier.predict(X_test)
model_accuracy = metrics.accuracy_score(y_test, predicted)
print(f"SVC accuracy: {model_accuracy:.3f}")
print(f"Improvement: {model_accuracy - baseline_accuracy:.3f}")
_, axes = plt.subplots(nrows=1, ncols=4, figsize=(10, 3))
for ax, image, prediction in zip(axes, X_test, predicted):
ax.set_axis_off()
ax.imshow(image.reshape(8, 8), cmap=plt.cm.gray_r, interpolation="nearest")
ax.set_title(f"SVC prediction: {prediction}")
plt.show()
# Cell 6: Analyze the errors
print(metrics.classification_report(y_test, predicted))
display = metrics.ConfusionMatrixDisplay.from_predictions(y_test, predicted)
display.figure_.suptitle("Confusion Matrix")
print(f"Confusion matrix:\n{display.confusion_matrix}")
plt.show()
Well done. Your notebook now reveals which digits the SVC confuses.
Secret mission
المهمة السرية: تحسين النموذج باستخدام GridSearchCV
اختيار معاملات النموذج يدويًا قد يحصره في إعداد واحد. في هذه المهمة، ستستخدم GridSearchCV لمقارنة عدة إعدادات على بيانات التدريب، ثم ستقيس دقة أفضل نموذج باستخدام بيانات الاختبار المنفصلة.
Clean Up Your Resources
Clean Up Your Resources
اختر بين الاحتفاظ بدفتر Google Colab أو إيقاف جلسته مؤقتًا أو حذفه نهائيًا. المشروع مجاني، لذلك لا توجد موارد مدفوعة تظل قيد التشغيل.
الموارد التي استخدمتها:
- دفتر digits_classifier.ipynb المحفوظ في Google Drive.
- جلسة تشغيل Colab المؤقتة التي تحتوي على الحزم والمتغيرات ونتائج التنفيذ الحالية.
Keep everything running
لا يلزم أي إجراء. اختر هذا الخيار إذا كنت تريد متابعة تجربة المصنف أو مشاركة الدفتر لاحقًا.
- اترك دفتر digits_classifier.ipynb محفوظًا في Google Drive.
- استمر في استخدام تبويب Colab المفتوح لتجربة معاملات أخرى.
- شغّل الخلايا من الأعلى إلى الأسفل إذا أنشأ Colab جلسة تشغيل جديدة.
Pause - I'll come back to this later
إغلاق تبويب Colab يوقف عملك الحالي مع بقاء الدفتر محفوظًا. قد يحذف Colab الآلة الافتراضية بعد الخمول.
- أغلق تبويب Colab في متصفحك.
- احتفظ بدفتر digits_classifier.ipynb في Google Drive.
- ارجع إلى دفتر digits_classifier.ipynb من Google Drive عند متابعة المشروع.
- شغّل الخلايا من الأعلى إلى الأسفل لاستعادة الحزم والمتغيرات والنتائج.
Delete - I don't want to use this again
هذا الخيار يزيل الدفتر نهائيًا. لا توجد خدمة مدفوعة تحتاج إلى الإيقاف.
- أغلق تبويب Colab لإنهاء استخدام جلسة التشغيل الحالية.
- ارجع إلى قائمة الملفات في Google Drive.
- ابحث عن digits_classifier.ipynb.
- حدّد digits_classifier.ipynb.
- اختر حذف الملف من قائمة إجراءاته.
- انتقل إلى مهملات Google Drive.
- احذف digits_classifier.ipynb نهائيًا.
- ابحث عن digits_classifier.ipynb في Google Drive للتأكد من أنه لم يعد ظاهرًا.
Nice Work!
Nice Work!
لقد أنجزتها! يعرض دفترك القابل لإعادة التشغيل في Google Colab دورة تعلم الآلة كاملة لتصنيف صور الأرقام المكتوبة يدويًا.
ما تعلمته:
- بنيت خط أساس باستخدام DummyClassifier لكشف محدودية التنبؤات التي تتجاهل سمات البكسلات.
- درّبت مصنف SVC على 64 سمة بكسل لكل صورة. اختبرت قدرته على صور محفوظة خارج بيانات التدريب.
- قست دقة النموذج. قرأت تقرير التصنيف لكل رقم. استخدمت مصفوفة الالتباس لتحديد الأرقام التي يخلط بينها المصنف.
- المهمة السرية: استخدمت GridSearchCV لاختيار معاملات SVC عبر التحقق المتقاطع. حافظت على بيانات الاختبار للتقييم النهائي.
أصبحت مستعدًا لاختبار نفسك.