rescale

SKLearn MinMaxScaler - scale specific columns only

泪湿孤枕 提交于 2020-11-27 04:46:49
问题 I'd like to scale some (but not all) of the columns in a Pandas dataFrame using a MinMaxScaler. How can I do it? 回答1: Since sklearn >= 0.20 you can do it using Column Transformer standard_transformer = Pipeline(steps=[ ('standard', StandardScaler())]) minmax_transformer = Pipeline(steps=[ ('minmax', MinMaxScaler())]) preprocessor = ColumnTransformer( remainder='passthrough', #passthough features not listed transformers=[ ('std', standard_transformer , ['z']), ('mm', minmax_transformer , ['x',

SKLearn MinMaxScaler - scale specific columns only

≯℡__Kan透↙ 提交于 2020-11-27 04:36:11
问题 I'd like to scale some (but not all) of the columns in a Pandas dataFrame using a MinMaxScaler. How can I do it? 回答1: Since sklearn >= 0.20 you can do it using Column Transformer standard_transformer = Pipeline(steps=[ ('standard', StandardScaler())]) minmax_transformer = Pipeline(steps=[ ('minmax', MinMaxScaler())]) preprocessor = ColumnTransformer( remainder='passthrough', #passthough features not listed transformers=[ ('std', standard_transformer , ['z']), ('mm', minmax_transformer , ['x',

SKLearn MinMaxScaler - scale specific columns only

会有一股神秘感。 提交于 2020-11-27 04:36:07
问题 I'd like to scale some (but not all) of the columns in a Pandas dataFrame using a MinMaxScaler. How can I do it? 回答1: Since sklearn >= 0.20 you can do it using Column Transformer standard_transformer = Pipeline(steps=[ ('standard', StandardScaler())]) minmax_transformer = Pipeline(steps=[ ('minmax', MinMaxScaler())]) preprocessor = ColumnTransformer( remainder='passthrough', #passthough features not listed transformers=[ ('std', standard_transformer , ['z']), ('mm', minmax_transformer , ['x',

SKLearn MinMaxScaler - scale specific columns only

早过忘川 提交于 2020-11-27 04:36:06
问题 I'd like to scale some (but not all) of the columns in a Pandas dataFrame using a MinMaxScaler. How can I do it? 回答1: Since sklearn >= 0.20 you can do it using Column Transformer standard_transformer = Pipeline(steps=[ ('standard', StandardScaler())]) minmax_transformer = Pipeline(steps=[ ('minmax', MinMaxScaler())]) preprocessor = ColumnTransformer( remainder='passthrough', #passthough features not listed transformers=[ ('std', standard_transformer , ['z']), ('mm', minmax_transformer , ['x',

Reshape a pandas DataFrame of (720, 720) into (518400, ) 2D into 1D

走远了吗. 提交于 2020-06-23 08:48:07
问题 I have a DataFrame with shape: 720*720 2D. I wanna convert it to 1D dimension without changing its values. How can I do this using Pandas? 回答1: Use numpy.ravel with converted DataFrame to numpy array: np.random.seed(123) df = pd.DataFrame(np.random.randint(10, size=(3,3))) print (df) 0 1 2 0 2 2 6 1 1 3 9 2 6 1 0 out = df.values.ravel('F') #alternative for pandas 0.24+ #out = df.to_numpy().ravel('F') print (out) [2 1 6 2 3 1 6 9 0] s = pd.Series(df.values.ravel('F')) #alternative for pandas 0

Java: drawing scaled objects (buffered image and vector graphics)

和自甴很熟 提交于 2019-12-23 04:57:23
问题 I would like to draw scaled objects containing raster as well as vector data. Currently, I am drawing into a scaled Graphics2D object protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g.create(); //Get transformation, apply scale and shifts at = g2d.getTransform(); at.translate(x, y); at.scale(zoom, zoom); //Transform Graphics2D object g2d.setTransform(at); //Draw buffered image into the transformed object g2d.drawImage(img, 0, 0, this); //Draw

Normalize data in R data.frame column

流过昼夜 提交于 2019-12-23 03:48:11
问题 Suppose I have the following data: a <- data.frame(var1=letters,var2=runif(26)) Suppose I want to scale every value in var2 such that the sum of the var2 column is equal to 1 (basically turn the var2 column into a probability distribution) I have tried the following: a$var2 <- lapply(a$var2,function(x) (x-min(a$var2))/(max(a$var2)-min(a$var2))) this not only gives an overall sum greater than 1 but also turns the var2 column into a list on which I can't do operations like sum Is there any

Automatic rescaling of an application on high-dpi Windows platform?

血红的双手。 提交于 2019-12-17 06:09:19
问题 I'm writing a Qt application that needs to run on high-dpi Windows (192dpi instead of 96dpi). Unfortunately the Qt framework does not have support for high-dpi yet (at least on Windows), so my application and all its elements looks half the size it should. Is there any way to force/simulate automatic upscaling of such apps by Windows? 回答1: Applications that use fixed coordinates and sizes will look small on high-DPI resolutions. Although even if using layouts there are some issues regarding

How to apply a set of functions to each group of a grouping variable in R data.frame

无人久伴 提交于 2019-12-10 11:10:04
问题 I need to reshape data.frame in R in one step . In short, change of values of objects (x1 to x6) is visible row by row (from 1990 to 1995): > tab1[1:10, ] # raw data see plot for tab1 id value year 1 x1 7 1990 2 x1 10 1991 3 x1 11 1992 4 x1 7 1993 5 x1 3 1994 6 x1 1 1995 7 x2 6 1990 8 x2 7 1991 9 x2 9 1992 10 x2 5 1993 I am able to do reshaping step by step, does anybody know how do it in one step? Original data Table 1 - see that minimal value from all timeseries is "0" Step1: Table 2 -