Optimized recursive_bubble_sort (#2410)

* optimized recursive_bubble_sort

* Fixed doctest error due whitespace

* reduce loop times for optimization

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
Du Yuanchao
2020-09-10 16:31:26 +08:00
committed by GitHub
parent 25946e4570
commit 4d0a8f2355
60 changed files with 900 additions and 859 deletions

View File

@ -135,8 +135,7 @@ class Decision_Tree:
class Test_Decision_Tree:
"""Decision Tres test class
"""
"""Decision Tres test class"""
@staticmethod
def helper_mean_squared_error_test(labels, prediction):

View File

@ -132,12 +132,12 @@ def kmeans(
data, k, initial_centroids, maxiter=500, record_heterogeneity=None, verbose=False
):
"""This function runs k-means on given data and initial set of centroids.
maxiter: maximum number of iterations to run.(default=500)
record_heterogeneity: (optional) a list, to store the history of heterogeneity
as function of iterations
if None, do not store the history.
verbose: if True, print how many data points changed their cluster labels in
each iteration"""
maxiter: maximum number of iterations to run.(default=500)
record_heterogeneity: (optional) a list, to store the history of heterogeneity
as function of iterations
if None, do not store the history.
verbose: if True, print how many data points changed their cluster labels in
each iteration"""
centroids = initial_centroids[:]
prev_cluster_assignment = None

View File

@ -153,7 +153,7 @@ def calculate_variance(items: list, means: list, total_count: int) -> float:
def predict_y_values(
x_items: list, means: list, variance: float, probabilities: list
) -> list:
""" This function predicts new indexes(groups for our data)
"""This function predicts new indexes(groups for our data)
:param x_items: a list containing all items(gaussian distribution of all classes)
:param means: a list containing real mean values of each class
:param variance: calculated value of variance by calculate_variance function

View File

@ -12,7 +12,7 @@ import requests
def collect_dataset():
""" Collect dataset of CSGO
"""Collect dataset of CSGO
The dataset contains ADR vs Rating of a Player
:return : dataset obtained from the link, as matrix
"""
@ -32,7 +32,7 @@ def collect_dataset():
def run_steep_gradient_descent(data_x, data_y, len_data, alpha, theta):
""" Run steep gradient descent and updates the Feature vector accordingly_
"""Run steep gradient descent and updates the Feature vector accordingly_
:param data_x : contains the dataset
:param data_y : contains the output associated with each data-entry
:param len_data : length of the data_
@ -51,7 +51,7 @@ def run_steep_gradient_descent(data_x, data_y, len_data, alpha, theta):
def sum_of_square_error(data_x, data_y, len_data, theta):
""" Return sum of square error for error calculation
"""Return sum of square error for error calculation
:param data_x : contains our dataset
:param data_y : contains the output (result vector)
:param len_data : len of the dataset
@ -66,7 +66,7 @@ def sum_of_square_error(data_x, data_y, len_data, theta):
def run_linear_regression(data_x, data_y):
""" Implement Linear regression over the dataset
"""Implement Linear regression over the dataset
:param data_x : contains our dataset
:param data_y : contains the output (result vector)
:return : feature for line of best fit (Feature vector)