如何使用列车数据的分组最大最大最大最大限制组来按组MIN_MAX_SCALE测试数据?

发布于 2025-02-07 10:03:40 字数 484 浏览 0 评论 0原文

例如,数据集类似于:

ABC
10.10.10.2 0.3
10.70.70.34 0.67
20.30.3 0.10.5
20.52 0.540.60.6

我想使用训练数据集的每一列的最小值和最大值来扩展测试数据的测试数据,以使每个列分别具有相似的结构。谢谢你!

For example, the dataset is like:

GroupABC
10.10.20.3
10.70.340.67
20.30.10.5
20.540.60.2

I want to use the min and max values of every column of the training dataset to scale the test data for each column separately, which also have a similar structure. THANK YOU!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烛影斜 2025-02-14 10:03:40

您可以按以下方式使用此工作;

import tensorflow as tf 

import pandas as pd

from sklearn.preprocessing import MinMaxScaler as scaler

df = pd.DataFrame([[0.1,0.2,0.3],[0.7,0.34,0.67],[0.3,0.1,0.5],[0.54,0.6,0.2]],columns=['A','B','C'])

df

输出:

    A   B   C
0   0.10    0.20    0.30
1   0.70    0.34    0.67
2   0.30    0.10    0.50
3   0.54    0.60    0.20


def transform(df):
  scaler.fit(df)
  return scaler.transform(df)
df

输出:

    A   B   C
0   0.10    0.20    0.30
1   0.70    0.34    0.67
2   0.30    0.10    0.50
3   0.54    0.60    0.20

数据集已经在范围{0,1}之间。

MinMaxScaler将将每个值转换为0-1。

因此,使用不同的输入数据,值将相应地反映。

You can use this working as follows ;

import tensorflow as tf 

import pandas as pd

from sklearn.preprocessing import MinMaxScaler as scaler

df = pd.DataFrame([[0.1,0.2,0.3],[0.7,0.34,0.67],[0.3,0.1,0.5],[0.54,0.6,0.2]],columns=['A','B','C'])

df

Output:

    A   B   C
0   0.10    0.20    0.30
1   0.70    0.34    0.67
2   0.30    0.10    0.50
3   0.54    0.60    0.20


def transform(df):
  scaler.fit(df)
  return scaler.transform(df)
df

Output :

    A   B   C
0   0.10    0.20    0.30
1   0.70    0.34    0.67
2   0.30    0.10    0.50
3   0.54    0.60    0.20

The dataset is already between the range {0,1} .

MinMaxScaler will convert each value to the range 0-1 .

Hence with a different input data, the values will reflect accordingly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文