Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Challenge: Evaluating the Perceptron | Neural Network from Scratch
/
Introduction to Neural Networks with Python
セクション 2.  12
single

single

bookChallenge: Evaluating the Perceptron

メニューを表示するにはスワイプしてください

To evaluate the previously created perceptron, you will use a dataset containing two input features and two distinct classes (0 and 1):

This dataset is balanced, with 500 samples from class 1 and 500 samples from class 0. Therefore, accuracy is a sufficient metric for evaluation in this case, which can be calculated using the accuracy_score() function:

accuracy_score(y_true, y_pred)

y_true represents the actual labels, while y_pred represents the predicted labels.

The dataset is stored in perceptron.py as two NumPy arrays: X (input features) and y (corresponding labels), so they will be simply imported. This file also contains model, which is the instance of the Perceptron class you previously created.

タスク

スワイプしてコーディングを開始

Your goal is to evaluate how well the trained perceptron model performs on unseen data. Follow the steps below to split the dataset, train the model, generate predictions, and measure its accuracy.

  1. Split the dataset into training (80%) and testing (20%) sets using the train_test_split() function.
    • Use test_size=0.2 and random_state=10 to ensure reproducibility.
  2. Train the perceptron model for 10 epochs with a learning rate of 0.01 by calling the fit() method.
  3. Obtain predictions for all examples in the test set by calling the model’s forward() method for each input example.
  4. Round the predictions using np.round() so that probabilities greater than or equal to 0.5 are treated as class 1, and those below 0.5 as class 0.
  5. Evaluate accuracy by comparing the predicted labels with the actual test labels using the accuracy_score() function from sklearn.metrics.

解答

Switch to desktop実践的な練習のためにデスクトップに切り替える下記のオプションのいずれかを利用して、現在の場所から続行する
すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 2.  12
single

single

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

some-alt