<jupyter_start><jupyter_text>Feature scaling: output이 바뀌지 않으며, 처리속도가 좀 더 빨라진다.- feature(변수)간의 min-max를 맞춰준다.    - Min-Max Normalization- Standardization(정규분포화, Z-score Normalization)<jupyter_code>import pandas as pd
import numpy as np

df = pd.DataFrame({'A':[14.00,90.20,90.95,96.27,91.21],'B':[103.02,107.26,110.35,114.23,114.68], 'C':['big','small','big','small','small']})
df<jupyter_output><empty_output><jupyter_text>Min-Max Normalization<jupyter_code># A를 1~5사이의 값으로 바꿔준다.
df['A'] = (df['A'] - df['A'].min()) / (df['A'].max() - df['A'].min()) * (5 - 1) + 1
df<jupyter_output><empty_output><jupyter_text>Z-Score Normalization<jupyter_code>df['B'] = (df['B'] - df['B'].mean()) / df['B'].std()
df<jupyter_output><empty_output><jupyter_text>Feature scaling with sklearn<jupyter_code>df = pd.io.parsers.read_csv(
    'https://raw.githubusercontent.com/rasbt/pattern_classification/master/data/wine_data.csv',
     header=None,
     usecols=[0,1,2]
    )

df.columns=['Class label', 'Alcohol', 'Malic acid']

df.head()
from sklearn import preprocessing
std_scale = preprocessing.StandardScaler().fit(df[['Alcohol','Malic acid']])
df_std = std_scale.transform(df[['Alcohol','Malic acid']])

minmax_scale = preprocessing.MinMaxScaler(feature_range=(1,5)).fit(df[['Alcohol','Malic acid']])
df_minmax = minmax_scale.transform(df[['Alcohol','Malic acid']])<jupyter_output><empty_output><jupyter_text>fit() -> transform() 형태 : labelencoder와 동일<jupyter_code>df_std
df_minmax<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19826435246995994, 'fraction_numerical': 0.036715620827770364, 'mean_word_length': 7.281767955801105, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 22, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '379170', 'license': 'MIT', 'n_tokens_mistral': 668, 'n_tokens_neox': 667, 'n_words': 81, 'path': 'inflearn_machine_learning/matplotlib/Feature_Scaling.ipynb', 'repo_name': 'Junhojuno/TIL', 'size': '1498'}