- 功能介绍
- 参数说明
- 脚本示例
- 脚本
- 结果
功能介绍
标准化是对数据进行按正态化处理的组件
参数说明
| 名称 | 中文名称 | 描述 | 类型 | 是否必须? | 默认值 | |
|---|---|---|---|---|---|---|
| selectedCols | 选择的列名 | 计算列对应的列名列表 | String[] | ✓ | ||
| withMean | 是否使用均值 | 是否使用均值,默认使用 | Boolean | true | ||
| withStd | 是否使用标准差 | 是否使用标准差,默认使用 | Boolean | true |
脚本示例
脚本
data = np.array([["a", 10.0, 100],["b", -2.5, 9],["c", 100.2, 1],["d", -99.9, 100],["a", 1.4, 1],["b", -2.2, 9],["c", 100.9, 1]])colnames = ["col1", "col2", "col3"]selectedColNames = ["col2", "col3"]df = pd.DataFrame({"col1": data[:, 0], "col2": data[:, 1], "col3": data[:, 2]})inOp = dataframeToOperator(df, schemaStr='col1 string, col2 double, col3 long', op_type='batch')# traintrainOp = StandardScalerTrainBatchOp()\.setSelectedCols(selectedColNames)trainOp.linkFrom(inOp)# batch predictpredictOp = StandardScalerPredictBatchOp()predictOp.linkFrom(trainOp, inOp).print()# stream predictsinOp = dataframeToOperator(df, schemaStr='col1 string, col2 double, col3 long', op_type='stream')predictStreamOp = StandardScalerPredictStreamOp(trainOp)predictStreamOp.linkFrom(sinOp).print()StreamOperator.execute()
结果
col1 col2 col30 a -0.078352 1.4595811 b -0.259243 -0.4814492 c 1.226961 -0.6520893 d -1.668749 1.4595814 a -0.202805 -0.6520895 b -0.254902 -0.4814496 c 1.237091 -0.652089
