Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
1.9 kB
1
Indexable
Never
import numpy as np

# Load the data from the file
data = np.loadtxt("australian.txt")

# Decision class symbols (assuming the last column represents the decision class)
decision_classes = np.unique(data[:, -1])
print("Available Decision Classes:", decision_classes)

# Size of decision classes
class_sizes = {cls: np.sum(data[:, -1] == cls) for cls in decision_classes}
print("Size of Decision Classes:")
for cls, size in class_sizes.items():
    print(f"Class {cls}: {size} objects")

# Minimum and maximum values for numerical attributes
min_values = np.min(data[:, :-1], axis=0)  # Assuming the last column is the decision class
max_values = np.max(data[:, :-1], axis=0)
print("Minimum Values for Numerical Attributes:", min_values)
print("Maximum Values for Numerical Attributes:", max_values)

# Number of different available values for each attribute
num_unique_values = [np.unique(data[:, i]).size for i in range(data.shape[1] - 1)]
print("Number of Different Available Values for Each Attribute:", num_unique_values)

# List of different available values for each attribute
unique_values = [np.unique(data[:, i]) for i in range(data.shape[1] - 1)]
print("List of Different Available Values for Each Attribute:")
for i, values in enumerate(unique_values):
    print(f"Attribute {i+1}: {values}")

# Standard deviation for numerical attributes in the whole system
std_dev_whole_system = np.std(data[:, :-1], axis=0)
print("Standard Deviation for Numerical Attributes in the Whole System:", std_dev_whole_system)

# Standard deviation for numerical attributes in each decision class
std_dev_per_class = {cls: np.std(data[data[:, -1] == cls, :-1], axis=0) for cls in decision_classes}
print("Standard Deviation for Numerical Attributes in Each Decision Class:")
for cls, std_dev in std_dev_per_class.items():
    print(f"Class {cls}: {std_dev}")
Leave a Comment