Skip to content

Standardize does not handle constant columns #1058

@Markopolo141

Description

@Markopolo141

Describe the bug

calling standardize() does not properly handle columns which are constant

Steps/Code to Reproduce

import numpy as np
Z = np.array([[0,1,2,5],[1,2,3,5],[3,1,2,5]])
print(standardize(Z))

outputs a column of -5.

Suggested Fix

Insert below line 130 in scaling.py

parameters["avgs"][c] = 0.0

Expected Results

should have column of zeros instead of -5.

Actual Results

has a column of -5s when it should have column of zero

Versions

MLxtend 0.22.0
Linux-5.19.0-46-generic-x86_64-with-glibc2.35
Python 3.9.17 (main, Jun 6 2023, 20:11:21)
[GCC 11.3.0]
Scikit-learn 1.2.2
NumPy 1.23.5
SciPy 1.10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions