mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 17:34:49 +08:00
Add pep8-naming to pre-commit hooks and fixes incorrect naming conventions (#7062)
* ci(pre-commit): Add pep8-naming to `pre-commit` hooks (#7038) * refactor: Fix naming conventions (#7038) * Update arithmetic_analysis/lu_decomposition.py Co-authored-by: Christian Clauss <cclauss@me.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * refactor(lu_decomposition): Replace `NDArray` with `ArrayLike` (#7038) * chore: Fix naming conventions in doctests (#7038) * fix: Temporarily disable project euler problem 104 (#7069) * chore: Fix naming conventions in doctests (#7038) Co-authored-by: Christian Clauss <cclauss@me.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -69,8 +69,8 @@ def get_initial_centroids(data, k, seed=None):
|
||||
return centroids
|
||||
|
||||
|
||||
def centroid_pairwise_dist(X, centroids):
|
||||
return pairwise_distances(X, centroids, metric="euclidean")
|
||||
def centroid_pairwise_dist(x, centroids):
|
||||
return pairwise_distances(x, centroids, metric="euclidean")
|
||||
|
||||
|
||||
def assign_clusters(data, centroids):
|
||||
@ -197,8 +197,8 @@ if False: # change to true to run this test case.
|
||||
plot_heterogeneity(heterogeneity, k)
|
||||
|
||||
|
||||
def ReportGenerator(
|
||||
df: pd.DataFrame, ClusteringVariables: np.ndarray, FillMissingReport=None
|
||||
def report_generator(
|
||||
df: pd.DataFrame, clustering_variables: np.ndarray, fill_missing_report=None
|
||||
) -> pd.DataFrame:
|
||||
"""
|
||||
Function generates easy-erading clustering report. It takes 2 arguments as an input:
|
||||
@ -214,7 +214,7 @@ def ReportGenerator(
|
||||
>>> data['col2'] = [100, 200, 300]
|
||||
>>> data['col3'] = [10, 20, 30]
|
||||
>>> data['Cluster'] = [1, 1, 2]
|
||||
>>> ReportGenerator(data, ['col1', 'col2'], 0)
|
||||
>>> report_generator(data, ['col1', 'col2'], 0)
|
||||
Features Type Mark 1 2
|
||||
0 # of Customers ClusterSize False 2.000000 1.000000
|
||||
1 % of Customers ClusterProportion False 0.666667 0.333333
|
||||
@ -231,8 +231,8 @@ def ReportGenerator(
|
||||
[104 rows x 5 columns]
|
||||
"""
|
||||
# Fill missing values with given rules
|
||||
if FillMissingReport:
|
||||
df.fillna(value=FillMissingReport, inplace=True)
|
||||
if fill_missing_report:
|
||||
df.fillna(value=fill_missing_report, inplace=True)
|
||||
df["dummy"] = 1
|
||||
numeric_cols = df.select_dtypes(np.number).columns
|
||||
report = (
|
||||
@ -313,7 +313,7 @@ def ReportGenerator(
|
||||
report = pd.concat(
|
||||
[report, a, clustersize, clusterproportion], axis=0
|
||||
) # concat report with clustert size and nan values
|
||||
report["Mark"] = report["Features"].isin(ClusteringVariables)
|
||||
report["Mark"] = report["Features"].isin(clustering_variables)
|
||||
cols = report.columns.tolist()
|
||||
cols = cols[0:2] + cols[-1:] + cols[2:-1]
|
||||
report = report[cols]
|
||||
|
Reference in New Issue
Block a user