在使用随机森林和SVM时,使用DataPreparer对数据进行标准化后,为什么我的数据值会变为负面?

发布于 2025-02-06 08:42:13 字数 403 浏览 4 评论 0原文

我正在研究预测建模,我需要在网站上预测在线客户是否最终在网站上购买产品,并且由于这是一个分类问题,我正在使用随机森林分类器和SVM。

在创建用于培训,测试和验证集的拟合拆分之后,我对数据进行伪造,标准化和标准化。但是,在我将集合归一化之后,它们的值都变为负面。有没有办法改变这一点,为什么会发生这种情况?

我用来将拟合集正常化的代码如下:

data_preparer = DataPreparer(one_hot_encoder, standard_scaler)
data_preparer.prepare_data(fitting_splits.train_set).head()
data_preparer.prepare_data(fitting_splits.validation_set).head()

I am working on predictive modeling where I need to predict whether an online customer ends up purchasing a product on a website or not, and I am using Random Forest Classifier and SVM since it's a classification problem.

After creating the fitting splits for training, testing, and validation sets, I dummify, standardize and normalize my data. However, after I normalize the sets, their values become all negative. Is there a way to change that and why does it happen?

The code that I am using to normalize my fitting sets is as below:

data_preparer = DataPreparer(one_hot_encoder, standard_scaler)
data_preparer.prepare_data(fitting_splits.train_set).head()
data_preparer.prepare_data(fitting_splits.validation_set).head()

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

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

发布评论

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

评论(1

雄赳赳气昂昂 2025-02-13 08:42:13

我认为Sklearn.preprocessing.standardscaler的文档可以在这里提供帮助:

样品x的标准分数计算为:

z =(x -u) / s < / p>

u是训练样本的平均值或零
with_mean = false,S是训练的标准偏差
样本或一个如果with_std = false。

基于此方程,如果x(当前缩放的个体值)小于变量的均值,则您的缩放值将为负。

I think the documentation from sklearn.preprocessing.StandardScaler can help here:

The standard score of a sample x is calculated as:

z = (x - u) / s

where u is the mean of the training samples or zero if
with_mean=False, and s is the standard deviation of the training
samples or one if with_std=False.

Based on this equation, if x (the individual value currently being scaled) is less than the mean of the variable, then your scaled value will be negative.

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