- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
对 Sci-kit 来说有点新,但注意到最小最大归一化和反转的一些行为似乎有点奇怪(但也许这是预期的行为??)。我以为在反转时我会重新生成原始数据点 - 但相反,反转生成的数字“接近”但不完全相等......这是应该发生的,还是我搞砸了?
#previously imported data is in a 3 column df
scaler = sklearn.preprocessing.MinMaxScaler()
df_norm = df.copy()
(df_norm == df).all()
#RETURNS TRUE
df_norm = scaler.fit_transform(df_norm)
df_norm = scaler.inverse_transform(df_norm)
(df_norm == df.values).all()
#RETURNS FALSE
所以我有点困惑为什么我有 2 个相同的数据帧,但在缩放和反转后数据集不再相等?许多数字是相等的,但也有不少是不相等的。奇怪的是,如下所示,有些甚至看起来相同,但在使用 df_norm == df 进行测试时却没有以这种方式显示
df:
array([[17.21 , 17.21 , 17.23 , 17.16 ],
[17.21 , 17.19 , 17.25 , 17.19 ],
[17.185, 17.21 , 17.23 , 17.18 ],
...,
[12.78 , 12.78 , 12.78 , 12.78 ],
[12.78 , 12.78 , 12.78 , 12.78 ],
[12.78 , 12.78 , 12.78 , 12.78 ]])
df_norm
array([[17.21 , 17.21 , 17.23 , 17.16 ],
[17.21 , 17.19 , 17.25 , 17.19 ],
[17.185, 17.21 , 17.23 , 17.18 ],
...,
[12.78 , 12.78 , 12.78 , 12.78 ],
[12.78 , 12.78 , 12.78 , 12.78 ],
[12.78 , 12.78 , 12.78 , 12.78 ]])
df == df_norm
array([[ True, True, True, True],
[ True, True, True, True],
[ True, True, True, True],
...,
[ True, True, False, True],
[ True, True, False, True],
[ True, True, False, True]])
最佳答案
这个问题很可能是由 float 的性质引起的,导致如下影响:
In [17]: 0.1 + 0.2 == 0.3
Out[17]: False
In [18]: 0.1 + 0.2 - 0.3
Out[18]: 5.551115123125783e-17
尝试使用 np.allclose()
比较您的数组:
np.allclose(df_norm, df.values)
关于python - Scikit Scaler 和 Inversion 不会产生相同的数字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49840087/
我正在阅读有关依赖倒置和解耦的理论,但我看不出两者之间的区别。 依赖倒置谈论解耦功能组件,以便较高级别的组件不依赖于较低级别的组件。 解耦谈论同样的事情以及如何实现它。但随后我们的 IoC 容器让事情
我仍在学习网页设计的诀窍,并且我无法理解一些事情是如何工作的...... 我创建了一个函数来切换导航栏标题背景颜色,我发现以下内容是正确的,但不确定原因: 作品: $(".navbar.navbar-
我正在使用 Autofac。我想根据应用于构造函数参数的属性注入(inject)不同的依赖项实现。例如: class CustomerRepository { public CustomerR
我试图绘制生存函数的倒数,因为我得到的数据实际上是随着时间的推移事件比例的增加。我可以生成 Kaplan-Meier 生存图,但我想生成这些的“相反”图。我可以使用以下 fun="cloglog" 获
我只是在阅读控制反转 (IOC) 并且让我烦恼的是它似乎使内存管理变得痛苦。当然,似乎 ioc 主要用于垃圾收集环境(Net、Java、Scripting),而我担心的是非 gc 设置。 我在这里担心
我正在创建一对多的关系。所以,我有一个 parent 和一个 child 。级联属性设置为全部。 我想知道,如果我们考虑以下代码: Parent p = (Parent) session.load(P
我最近读了Ayende's blog post关于使用 XML 配置的自动注册。我想做他所做的,但他的代码片段对我不起作用。我的容器对象上不存在 Register 方法。 这是他的代码: var co
我正在尝试删除一些日志记录依赖项,并偶然发现了 CaSTLe Windsor 的日志记录工具。但是,我对是否应该使用它持怀疑态度。 public class MyClass { public
我想在给定的 Windsor 容器中重新定义一个(默认)实现。这是 OverWrite 的用途吗?不过没用。 container.Register( Compo
似乎每个人都在转向 IoC 容器。我已经尝试“摸索”了一段时间,尽管我不想成为一个在高速公路上走错路的司机,但它仍然没有通过常识对我的考验。让我解释一下,如果我的论点有缺陷,请纠正/启发我: 我的理解
组件驱动开发术语开始得到广泛使用,尤其是。与控制反转有关。 这是什么? 它解决了什么问题? 什么时候合适,什么时候不合适? 最佳答案 What is it? 我认为您答案中的定义很好地涵盖了这个问题。
一个?? b 如果 a 不是 null => 返回 a。 否则(a 为null)=> 返回b。 我想模拟类似它的逆的东西(据我所知,没有运算符可以做到这一点): 如果 a 为 null => 返回 a
一个?? b 如果 a 不是 null => 返回 a。 否则(a 为null)=> 返回b。 我想模拟类似它的逆的东西(据我所知,没有运算符可以做到这一点): 如果 a 为 null => 返回 a
最近我正在查看社区领导者在他们的开源实现中提供的一些源代码。其中一个项目利用了 IOC。这是示例假设代码: public class Class1 { private ISomeInterfa
我熟悉许多代码覆盖工具,它们告诉我测试覆盖了多少行/分支/等的百分比,甚至告诉我代码的哪些部分覆盖率较差。 是否有任何工具可以做相反的事情——也就是说,给定一段代码,它能告诉我哪些测试触及它吗?通
我正在使用 MySQL 来存储财务资料,并使用这些数据来构建每个帐户的所有交易记录等。出于性能原因 - 并防止用户被庞大的表格所淹没 - 我对结果进行了分页。 现在,作为收银机的一部分,我显示帐户的运
我正在尝试用 Swift 编写一个算法来计算三角形的角度。引用检查 https://www.mathsisfun.com/algebra/trig-solving-sss-triangles.html
在 STL 中或一般情况下是否存在一种“反向”关联容器?例如,我想要一个容器,其中同一元素由一组键共享。 假设我的 key 是 int , 那么我会有例如: container.at(3) -> so
一些 IOC 容器具有基于约定的所谓自动连接,例如,IProductRepository 映射到 ProductRepository,而无需您进行任何手动连接。 Ninject 有这种东西吗? 最佳答
我正在处理遗留代码。 我有同一个类的不同方法,它们将不同的参数传递给依赖项的构造函数。我正在尝试介绍一些基本的 IoC 用法。现在我有 StructureMap 像这样传递我的参数: var thin
我是一名优秀的程序员,十分优秀!