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

Contenido del Curso

Neural Networks with PyTorch

Neural Networks with PyTorch

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

book
Challenge: Classifying Penguins

Tarea
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.

Solución

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 4
toggle bottom row

book
Challenge: Classifying Penguins

Tarea
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.

Solución

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 4
Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
We're sorry to hear that something went wrong. What happened?
some-alt