<jupyter_start><jupyter_text>Functions of DataFrame 5 **정규화 : X-min/max-min**<jupyter_code>import numpy as np
import pandas as pd
from sklearn.preprocessing import MinMaxScaler, minmax_scale, Binarizer, binarize
X=np.array([[10.,-10., 1.],
             [2., 3., 1.7],
             [0., 10., 3.]])
print((X-X.mean(axis=0))/(X.max(axis=0)-X.min(axis=0)))
mms=MinMaxScaler()
xmms=mms.fit_transform(X)
print(xmms)
xmms2=minmax_scale(X,axis=0,copy=True)
print(xmms2)<jupyter_output>[[1.   0.   0.  ]
 [0.2  0.65 0.35]
 [0.   1.   1.  ]]<jupyter_text>**이진화**<jupyter_code>X=np.array([[10.,-10., 1.],
             [2., 3., 1.7],
             [0., 10., 3.]])
binarizer=Binarizer().fit(X)
print(binarizer)
print(binarizer.transform(X))
binarizer=Binarizer(threshold=2.0)
print(binarizer)
print(binarizer.transform(X))
print(binarize(X,threshold=2.0, copy=False))
print(X)<jupyter_output>[[1. 0. 0.]
 [0. 1. 0.]
 [0. 1. 1.]]
[[1. 0. 0.]
 [0. 1. 0.]
 [0. 1. 1.]]<jupyter_text>**OneHotEncoding**<jupyter_code>from sklearn.preprocessing import OneHotEncoder
data_train=np.array([[0,0,0],
                     [0, 1, 1],
                     [0, 2, 2],
                     [1, 0, 3],
                     [1, 1, 4]])
enc=OneHotEncoder()
print(enc.fit(data_train))
print(enc.active_features_)
print(enc.n_values_)
print(enc.feature_indices_)
data_new=np.array([[1,2,3]])
print(enc.transform(data_new).toarray())<jupyter_output>[[0. 1. 0. 0. 1. 0. 0. 0. 1. 0.]]
{'fraction_non_alphanumeric': 0.21161825726141079, 'fraction_numerical': 0.06708160442600276, 'mean_word_length': 3.170028818443804, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '78197', 'license': 'MIT', 'n_tokens_mistral': 690, 'n_tokens_neox': 642, 'n_words': 108, 'path': 'DataFrame_5.ipynb', 'repo_name': 'heejinADP/TIL', 'size': '1446'}