How to impute missing class labels in Python?
DATA MUNGING

How to impute missing class labels in Python?

How to impute missing class labels in Python?

This recipe helps you impute missing class labels in Python

0
This python source code does the following : 1. Creates a numpy array with missing values 2. Builds up imputer along with parameter for imputing the values 3. Uses imputer "fit_transform" for filling out NaN values
In [2]:
## How to impute missing class labels in Python 
def Kickstarter_Example_27():
    print()
    print(format('How to impute missing class labels in Python', '*^82'))
    import warnings
    warnings.filterwarnings("ignore")

    # Load libraries
    import numpy as np
    from sklearn.preprocessing import Imputer

    # Create Feature Matrix With Missing Values
    X = np.array([[2,       2.10, 1.45],
                  [1,       1.18, 1.33],
                  [2,       1.22, 1.27],
                  [0,       -0.21, -1.19],
                  [np.nan,  0.87, 1.31],
                  [np.nan, -0.67, -0.22]])

    # Create Imputer object
    imputer = Imputer(strategy='most_frequent', axis=0)

    # Fill missing values with most frequent class
    print(); print(X)
    print(); print(imputer.fit_transform(X))

Kickstarter_Example_27()
*******************How to impute missing class labels in Python*******************

[[ 2.    2.1   1.45]
 [ 1.    1.18  1.33]
 [ 2.    1.22  1.27]
 [ 0.   -0.21 -1.19]
 [  nan  0.87  1.31]
 [  nan -0.67 -0.22]]

[[ 2.    2.1   1.45]
 [ 1.    1.18  1.33]
 [ 2.    1.22  1.27]
 [ 0.   -0.21 -1.19]
 [ 2.    0.87  1.31]
 [ 2.   -0.67 -0.22]]

Relevant Projects

Predict Census Income using Deep Learning Models
In this project, we are going to work on Deep Learning using H2O to predict Census income.

Build an Image Classifier for Plant Species Identification
In this machine learning project, we will use binary leaf images and extracted features, including shape, margin, and texture to accurately identify plant species using different benchmark classification techniques.

Music Recommendation System Project using Python and R
Machine Learning Project - Work with KKBOX's Music Recommendation System dataset to build the best music recommendation engine.

PySpark Tutorial - Learn to use Apache Spark with Python
PySpark Project-Get a handle on using Python with Spark through this hands-on data processing spark python tutorial.

Anomaly Detection Using Deep Learning and Autoencoders
Deep Learning Project- Learn about implementation of a machine learning algorithm using autoencoders for anomaly detection.

Ecommerce product reviews - Pairwise ranking and sentiment analysis
This project analyzes a dataset containing ecommerce product reviews. The goal is to use machine learning models to perform sentiment analysis on product reviews and rank them based on relevance. Reviews play a key role in product recommendation systems.

Solving Multiple Classification use cases Using H2O
In this project, we are going to talk about H2O and functionality in terms of building Machine Learning models.

Human Activity Recognition Using Smartphones Data Set
In this deep learning project, you will build a classification system where to precisely identify human fitness activities.

Data Science Project-All State Insurance Claims Severity Prediction
Data science project in R to develop automated methods for predicting the cost and severity of insurance claims.

Deep Learning with Keras in R to Predict Customer Churn
In this deep learning project, we will predict customer churn using Artificial Neural Networks and learn how to model an ANN in R with the keras deep learning package.