Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Challenge: Classifying Penguins | Neural Networks
PyTorch Essentials
course content

Conteúdo do Curso

PyTorch Essentials

PyTorch Essentials

1. PyTorch Basics
2. Preparing for Neural Networks
3. Neural Networks

book
Challenge: Classifying Penguins

Tarefa
test

Swipe to begin your solution

Your goal is to train and evaluate a simple neural network using the palmer penguins dataset, which contains information about penguin species and various physical measurements.

  1. Load the Dataset:

    • Read the penguins.csv file into a Pandas DataFrame.
    • Handle missing values by dropping rows with any NaN values.
    • Encode the species column as integers (target variable).
  2. Prepare Features and Target:

    • Select bill_length_mm, bill_depth_mm, flipper_length_mm, and body_mass_g as features.
    • Encode the species column as the target.
  3. Split the Data:

    • Use an 80-20 split for train-test data.
  4. Create PyTorch Tensors:

    • Convert the features into FloatTensor and the target into LongTensor.
  5. Define a Neural Network:

    • Create a model class with one hidden layer using PyTorch’s nn.Module.
  6. Train the Model:

    • Use the CrossEntropyLoss function and the Adam optimizer.
    • Train for 100 epochs and print the loss every 10 epochs.
  7. Evaluate the Model:

    • Calculate test accuracy.
    • Display the confusion matrix to analyze the predictions.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 4
toggle bottom row

book
Challenge: Classifying Penguins

Tarefa
test

Swipe to begin your solution

Your goal is to train and evaluate a simple neural network using the palmer penguins dataset, which contains information about penguin species and various physical measurements.

  1. Load the Dataset:

    • Read the penguins.csv file into a Pandas DataFrame.
    • Handle missing values by dropping rows with any NaN values.
    • Encode the species column as integers (target variable).
  2. Prepare Features and Target:

    • Select bill_length_mm, bill_depth_mm, flipper_length_mm, and body_mass_g as features.
    • Encode the species column as the target.
  3. Split the Data:

    • Use an 80-20 split for train-test data.
  4. Create PyTorch Tensors:

    • Convert the features into FloatTensor and the target into LongTensor.
  5. Define a Neural Network:

    • Create a model class with one hidden layer using PyTorch’s nn.Module.
  6. Train the Model:

    • Use the CrossEntropyLoss function and the Adam optimizer.
    • Train for 100 epochs and print the loss every 10 epochs.
  7. Evaluate the Model:

    • Calculate test accuracy.
    • Display the confusion matrix to analyze the predictions.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 4
Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
We're sorry to hear that something went wrong. What happened?
some-alt