diff --git a/03Handing Numrical data/00Problem.py b/03Handing Numrical data/00Problem.py new file mode 100644 index 0000000..6bc229f --- /dev/null +++ b/03Handing Numrical data/00Problem.py @@ -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) \ No newline at end of file diff --git a/03Handing Numrical data/01Problem.py b/03Handing Numrical data/01Problem.py new file mode 100644 index 0000000..c94665a --- /dev/null +++ b/03Handing Numrical data/01Problem.py @@ -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) diff --git a/03Handing Numrical data/02Problem.py b/03Handing Numrical data/02Problem.py new file mode 100644 index 0000000..70976da --- /dev/null +++ b/03Handing Numrical data/02Problem.py @@ -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) \ No newline at end of file diff --git a/03Handing Numrical data/03Problem.py b/03Handing Numrical data/03Problem.py new file mode 100644 index 0000000..e69de29 diff --git a/03Handing Numrical data/04Problem.py b/03Handing Numrical data/04Problem.py new file mode 100644 index 0000000..e69de29 diff --git a/03Handing Numrical data/05Problem.py b/03Handing Numrical data/05Problem.py new file mode 100644 index 0000000..e69de29 diff --git a/03Handing Numrical data/06Problem.py b/03Handing Numrical data/06Problem.py new file mode 100644 index 0000000..e69de29 diff --git a/03Handing Numrical data/07Problem.py b/03Handing Numrical data/07Problem.py new file mode 100644 index 0000000..e69de29 diff --git a/03Handing Numrical data/08Problem.py b/03Handing Numrical data/08Problem.py new file mode 100644 index 0000000..e69de29 diff --git a/03Handing Numrical data/09Problem.py b/03Handing Numrical data/09Problem.py new file mode 100644 index 0000000..e69de29 diff --git a/03Handing Numrical data/10Problem.py b/03Handing Numrical data/10Problem.py new file mode 100644 index 0000000..e69de29 diff --git a/03Handing Numrical data/11Problem.py b/03Handing Numrical data/11Problem.py new file mode 100644 index 0000000..e69de29 diff --git a/03Handing Numrical data/Images/Normalizer.png b/03Handing Numrical data/Images/Normalizer.png new file mode 100644 index 0000000..a80f389 Binary files /dev/null and b/03Handing Numrical data/Images/Normalizer.png differ diff --git a/03Handing Numrical data/Images/NormalizerL1.png b/03Handing Numrical data/Images/NormalizerL1.png new file mode 100644 index 0000000..af13de5 Binary files /dev/null and b/03Handing Numrical data/Images/NormalizerL1.png differ diff --git a/03Handing Numrical data/Images/NormalizerL2.png b/03Handing Numrical data/Images/NormalizerL2.png new file mode 100644 index 0000000..a80f389 Binary files /dev/null and b/03Handing Numrical data/Images/NormalizerL2.png differ diff --git a/03Handing Numrical data/Images/Screenshot 2024-07-29 193529.png b/03Handing Numrical data/Images/Screenshot 2024-07-29 193529.png new file mode 100644 index 0000000..e18b0f2 Binary files /dev/null and b/03Handing Numrical data/Images/Screenshot 2024-07-29 193529.png differ diff --git a/03Handing Numrical data/Images/Standardization.png b/03Handing Numrical data/Images/Standardization.png new file mode 100644 index 0000000..50078f6 Binary files /dev/null and b/03Handing Numrical data/Images/Standardization.png differ