Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Challenge: Apply Oversampling | Sampling Techniques for Large Data
Large Data Handling
Osio 2. Luku 3
single

single

Challenge: Apply Oversampling

Pyyhkäise näyttääksesi valikon

In this challenge, you will practice handling class imbalance in a large dataset by applying oversampling. You are provided with a pandas DataFrame that contains a target column with imbalanced classes. Your goal is to create a new DataFrame in which the minority class is oversampled so that both classes have the same number of rows. This technique is useful in scenarios where you want to prevent models from being biased toward the majority class.

Tehtävä

Pyyhkäise aloittaaksesi koodauksen

Given a pandas DataFrame with a class imbalance in the target column, create a new DataFrame where the minority class is oversampled so that each class has the same number of rows as the majority class.

  • Identify the class counts in the target column.
  • Determine the class with the maximum count.
  • For each class, sample with replacement to reach the maximum count.
  • Concatenate the balanced subsets into a new DataFrame.
  • Return the balanced DataFrame.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 2. Luku 3
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

some-alt