Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python MinMaxScaler()

from sklearn.preprocessing import MinMaxScaler

#Normal minmaxscaler function to standarise data.
data = [[-1, 2], [-0.5, 6], [0, 10], [1, 18]]
scaler = MinMaxScaler()
scaler.fit(data)    

#get data for Max and Min from scaler functions, 
#best to store it in a dictionary and use it later make data normal again
print(scaler.transform([[2, 2]]))
Out>>> [[ 1.5  0. ]]

# Inverse transform the the 0-1 dataframe.
print(scaler.inverse_transform([[ 1.5  0. ]]))
Out>>> [[ 2.0  2.0]]
Comment

minmaxscaler python

from numpy import asarray
from sklearn.preprocessing import MinMaxScaler
# define data
data = asarray([[100, 0.001],
				[8, 0.05],
				[50, 0.005],
				[88, 0.07],
				[4, 0.1]])
print(data)
# define min max scaler
scaler = MinMaxScaler()
# transform data
scaled = scaler.fit_transform(data)
print(scaled)
Comment

minmax python

# Were you looking for min max python?
# if this is the case (works also with sets and numpy array)

>>> l = [1,2,8,4,7,9,6,3]
>>> min(l)
1
>>> max(l)
9
Comment

PREVIOUS NEXT
Code Example
Python :: create qr code in python 
Python :: python merge nested dictionaries 
Python :: creating empty set and append python 
Python :: discord python tts 
Python :: how to reverse array in python 
Python :: python optional arguments 
Python :: python sort the values in a dictionaryi 
Python :: python copy to clipboard command 
Python :: matplotlib pyplot comment on plot 
Python :: flask decoding base 64 image 
Python :: display prime numbers between two intervals in python 
Python :: deep copy a dataframe 
Python :: PhoneNumberField django forms 
Python :: how to install tkinter in pycharm 
Python :: how to convert adjacency list to adjacency matrix 
Python :: python json web request 
Python :: python insert list 
Python :: How to Merge train and Test dataset in python 
Python :: print in python 
Python :: geopandas stack or concatenate dataframe together 
Python :: add new row to numpy array 
Python :: python dictionary append 
Python :: pil.jpegimageplugin.jpegimagefile to image 
Python :: pandas return row 
Python :: compile python folder 
Python :: loop through words in a string python 
Python :: how to write a code for anagram in python 
Python :: python return using if 
Python :: use django taggit in template 
Python :: how to read files in python with 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =