Practical - 1

 Aim: Data Preprocessing using scikitLearn python library

Theory:

what is data pre-processing?

Data Preprocessing is a method used to transform raw data to a clean data package. In other words, whenever data is obtained from various sources, it is obtained in a raw medium that can not be analysed.

Any steps are then taken to transform the data to a limited collection of clean data. This technique is performed prior to the completion of the Iterative Analysis. The set of steps is known as Preprocessing Data. Includes –
  • Data Cleaning
  • Data Integration
  • Data Transformation
  • Data Reduction
Why it is needed?
A bunch of data collected from different sources in which some of them may not be in proper format which will generate difficulty to analyse so before using that un-formatted data there is need to make the data proper and for that we use the term data processing. 

Describe various data pre-processing techniques:
Standardization:
Used to transform data so that it has 0 mean and 1 variance. Uses "sklearn.preprocessing.scale()" function.

Normalization:
Used to transform data so that it is scaled to the [0,1] range. Uses "sklearn.preprocessing.normalize()" function.

One-hot Encoding:
It helps us to turn nominal data categorical data into features with numerical values.

Discretization:
Discretization refers to the method of converting or partitioning discretized or nominal attributes / features / variables / intervals from continuous attributes, features or variables.

What is Scikit Learn?
Scikit Learn is built on top of many Python libraries of common data and math. Such a design makes the integration between them all super simple. You can transfer numpy arrays and pandas data frames straight to Scikit's ML algorithms. It uses the following libraries
  • NumPy For any work with matrices, especially math operations
  • SciPy Scientific and technical computing
  • Matplotlib Data visualization
  • IPython Interactive console for Python
  • Sympy Symbolic mathematics
  • Pandas Data handling, manipulation, and analysis
Importing required packages and Dataset


Data Exploration

Data Cleaning and Creating training and test dataset Applying, KNN model before pre-processing.

Now applying feature scaling and then Applying KNN model 

Applying Feature Standardization

Applying One-Hot Encoding


Question and Answers

1. How to decide variance threshold in data reduction?
ans: The variance threshold calculation depends on the probability density function of a particular distribution.

2. Does the output result same even after applying model on encoded data v\s original data?
ans: No, as performing above practical after applying several methods and process the data the output changes even by small percentage value..

Python file:


No comments:

Post a Comment