Learn practical skills, build real-world projects, and advance your career

Machine Learning Techniques

In this notebook we perform some of the techniques that helps us to make our workflow more efficient. We starts out with the simple one and move on with some advance techniques related to Hyperparameter Tuning or Encoding. We divide this notebook into sub-section with the heading at the top followed by the description and some sort of sample code.

Agenda:

  • Use of Lambda Function for performing single line operation
  • Understand the pandas.DataFrame.groupby aggregate function
  • Learn how to perform Target Encoding
  • Learn the Optimization Technique other than RandomizedSearchCV and GridSearchCV
  • Learn how to fill missing values using the Machine Learning Model

0. Use of Lambda Function for performing single line operation

In this section, we perform some mathematical operation on the dataset using the Lambda Function. We Perform the operation, create new columns using the map and the apply function.

Lets prepare some data over which we are going to perform the Lambda Function operation. For this we are using the Sklearn Dataset library and import the california housing dataset.

# import the library
import pandas as pd
import numpy as np
from sklearn.datasets import fetch_california_housing

import matplotlib.pyplot as plt
%matplotlib inline
dataset = fetch_california_housing()
df = pd.DataFrame(dataset.data, columns=dataset.feature_names)
df['MedHouseVal'] = dataset.target
df.head()

We prepare our dataset on which we gonna work with. Now we perfrom:

  • Apply the min-max normalization on population column.
  • Multiply the AveRooms with 100.
  • Create the bins for the Housege column.