Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
  • Loading branch information
cclauss authored Oct 22, 2022
commit 375fa3f4357041792eb6a15b5f105eb5b4af4039
4 changes: 4 additions & 0 deletions divide_and_conquer/strassen_matrix_multiplication.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ def matrix_dimensions(matrix: list) -> tuple[int, int]:
return len(matrix), len(matrix[0])


def print_matrix(matrix: list) -> None:
print("\n".join(str(line) for line in matrix))


def actual_strassen(matrix_a: list, matrix_b: list) -> list:
"""
Recursive function to calculate the product of two matrices, using the Strassen
Expand Down
2 changes: 1 addition & 1 deletion dynamic_programming/subset_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def print_combination(arr, n, r):


if __name__ == "__main__":
# Driver function to check for above function
# Driver code to check the function above
arr = [10, 20, 30, 40, 50]
print_combination(arr, len(arr), 3)
# This code is contributed by Ambuj sahu
2 changes: 1 addition & 1 deletion dynamic_programming/sum_of_subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def is_sum_subset(arr: list[int], required_sum: int) -> bool:
# a subset value says 1 if that subset sum can be formed else 0
# initially no subsets can be formed hence False/0
arr_len = len(arr)
subset = [[False for _ in range(required_sum + 1)] for _ in range(arr_len + 1)]
subset = [[False] * (required_sum + 1) for _ in range(arr_len + 1)]

# for each arr value, a sum of zero(0) can be formed by not taking any element
# hence True/1
Expand Down
17 changes: 7 additions & 10 deletions machine_learning/forecasting/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,12 @@ def data_safety_checker(list_vote: list, actual_result: float) -> bool:
tst_match = total_match[len(total_match) - 1 :]

# voting system with forecasting
res_vote = []
res_vote.append(
linear_regression_prediction(trn_date, trn_user, trn_match, tst_date, tst_match)
)
res_vote.append(sarimax_predictor(trn_user, trn_match, tst_match))
res_vote.append(support_vector_regressor(x_train, x_test, trn_user))
res_vote = [
linear_regression_prediction(trn_date, trn_user, trn_match, tst_date, tst_match),
sarimax_predictor(trn_user, trn_match, tst_match),
support_vector_regressor(x_train, x_test, trn_user),
]

# check the safety of today's data
if data_safety_checker(res_vote, tst_user):
print("Today's data is safe.")
else:
print("Today's data is not safe.")
not_str = "" if data_safety_checker(res_vote, tst_user) else "not "
print("Today's data is {not_str}safe.")
Copy link
Contributor Author

@tianyizheng02 tianyizheng02 Oct 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cclauss This string needs to be an f-string for not_str to print correctly