mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-06 10:31:29 +08:00
Improved readability (#1615)
* improved readability * further readability improvements * removed csv file and added f
This commit is contained in:

committed by
Christian Clauss

parent
938dd0bbb5
commit
9eb50cc223
@ -7,8 +7,8 @@ iris = load_iris()
|
||||
iris.keys()
|
||||
|
||||
|
||||
print("Target names: \n {} ".format(iris.target_names))
|
||||
print("\n Features: \n {}".format(iris.feature_names))
|
||||
print(f"Target names: \n {iris.target_names} ")
|
||||
print(f"\n Features: \n {iris.feature_names}")
|
||||
|
||||
# Train set e Test set
|
||||
X_train, X_test, y_train, y_test = train_test_split(
|
||||
|
@ -174,8 +174,8 @@ def accuracy(actual_y: list, predicted_y: list) -> float:
|
||||
def main():
|
||||
""" This function starts execution phase """
|
||||
while True:
|
||||
print(" Linear Discriminant Analysis ".center(100, "*"))
|
||||
print("*" * 100, "\n")
|
||||
print(" Linear Discriminant Analysis ".center(50, "*"))
|
||||
print("*" * 50, "\n")
|
||||
print("First of all we should specify the number of classes that")
|
||||
print("we want to generate as training dataset")
|
||||
# Trying to get number of classes
|
||||
@ -239,7 +239,7 @@ def main():
|
||||
else:
|
||||
print(
|
||||
f"Your entered value is {user_count}, Number of "
|
||||
f"instances should be positive!"
|
||||
"instances should be positive!"
|
||||
)
|
||||
continue
|
||||
except ValueError:
|
||||
@ -302,7 +302,7 @@ def main():
|
||||
# for loop iterates over number of elements in 'probabilities' list and print
|
||||
# out them in separated line
|
||||
for i, probability in enumerate(probabilities, 1):
|
||||
print("Probability of class_{} is: {}".format(i, probability))
|
||||
print(f"Probability of class_{i} is: {probability}")
|
||||
print("-" * 100)
|
||||
|
||||
# Calculating the values of variance for each class
|
||||
|
@ -446,7 +446,7 @@ def count_time(func):
|
||||
start_time = time.time()
|
||||
func(*args, **kwargs)
|
||||
end_time = time.time()
|
||||
print("smo algorithm cost {} seconds".format(end_time - start_time))
|
||||
print(f"smo algorithm cost {end_time - start_time} seconds")
|
||||
|
||||
return call_func
|
||||
|
||||
@ -500,11 +500,9 @@ def test_cancel_data():
|
||||
if test_tags[i] == predict[i]:
|
||||
score += 1
|
||||
print(
|
||||
"\r\nall: {}\r\nright: {}\r\nfalse: {}".format(
|
||||
test_num, score, test_num - score
|
||||
)
|
||||
f"\r\nall: {test_num}\r\nright: {score}\r\nfalse: {test_num - score}"
|
||||
)
|
||||
print("Rough Accuracy: {}".format(score / test_tags.shape[0]))
|
||||
print(f"Rough Accuracy: {score / test_tags.shape[0]}")
|
||||
|
||||
|
||||
def test_demonstration():
|
||||
|
Reference in New Issue
Block a user