Skip to content

add files #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions 03Handing Numrical data/00Problem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# ReScaling a feature

# Load the Library
import numpy as np
from sklearn import preprocessing

# Create Feature
feature = np.array([[-900.5],
[-300.1],
[0],
[300.1],
[900.9]])

# Create Scaler
minmax_Scale = preprocessing.MinMaxScaler(feature_range=(0, 1))
# Scale feature
scaled_feature = minmax_Scale.fit_transform(feature)

# show feature
print(scaled_feature)
40 changes: 40 additions & 0 deletions 03Handing Numrical data/01Problem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Standardizing a Feature

# Load the Libraries
import numpy as np
from sklearn.preprocessing import *

# Create feature
x = np.array([[-1000.1],
[-200.2],
[500.3],
[600.6],
[9000.9]])

# Create Feature
scaler = StandardScaler()

# Transform the feature
standardized = scaler.fit_transform(x)

# show the feature
print(standardized)

# print mean and std
print('mean :', round(standardized.mean()))
print('Std', standardized.std())


'''
If our data has significant outliers, it can negatively impact our standardization by
affecting the feature’s mean and variance. In this scenario, it is often helpful to instead
rescale the feature using the median and quartile range. In scikit-learn, we do this
using the RobustScaler method
'''
# Create scaler
robust_scaler = RobustScaler()

# Transform Feature
tf = robust_scaler.fit_transform(x)
# show the feature
print(tf)
34 changes: 34 additions & 0 deletions 03Handing Numrical data/02Problem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Normalizing Observation

# Load the libraries
import numpy as np
from sklearn.preprocessing import Normalizer

# Crate a featture matrix
features = np.array([[0.5, 0.5],
[1.1, 3.5],
[1.5, 20.2],
[1.64, 34.5],
[10.9, 3.3]])

# create normalizer
normalizer = Normalizer(norm='l2')

'''
s. Normalizer
rescales the values on individual observations to have unit norm (the sum of their
lengths is 1). This type of rescaling is often used when we have many equivalent fea‐
tures (e.g., text classification when every word or n-word group is a feature).
'''
# Transform feature matrix
print(normalizer.transform(features))

'''
Normalizer provides three norm options with
Euclidean norm (often called L2)

'''

# Transform feature matrix
f_l1_norm = Normalizer(norm='l1').transform(features)
print(f_l1_norm)
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Binary file added 03Handing Numrical data/Images/Normalizer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 03Handing Numrical data/Images/NormalizerL1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 03Handing Numrical data/Images/NormalizerL2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.