pandaas-utils 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pandaas/1.1.py ADDED
@@ -0,0 +1,45 @@
1
+ import numpy as np
2
+ import matplotlib.pyplot as plt
3
+
4
+ X = np.array([[0,0], [0,1], [1,0], [1,1]])
5
+ y = np.array([0,0,0,1])
6
+
7
+ weights = np.zeros(2)
8
+ bias = 0
9
+ lr = 0.1
10
+ epochs = 10
11
+
12
+ def activation(z):
13
+ return 1 if z>=0 else 0
14
+
15
+ for epoch in range(epochs):
16
+ for i in range(len(X)):
17
+ z = np.dot(X[i], weights) + bias
18
+ prediction = activation(z)
19
+ error = y[i] - prediction
20
+ weights = weights + lr * error * X[i]
21
+ bias = bias + lr * error
22
+
23
+ print("Epoch: ",epoch + 1, "Weights: ", weights, "Bias: ", bias)
24
+
25
+ print("\nAND Gate Predictions: ")
26
+
27
+ for i in range(len(X)):
28
+ z = np.dot(X[i], weights) + bias
29
+ prediction = activation(z)
30
+
31
+ print(X[i], "Actual: ", y[i], "Predicted: ", prediction)
32
+
33
+ plt.plot(X[:,0], X[:,1], 'bo', label='Data Points')
34
+
35
+ x = np.linspace(-0.5, 1.5, 100)
36
+ y = -(weights[0] * x + bias)/weights[1]
37
+
38
+ plt.plot(x, y, 'r-', label='Decision Boundary')
39
+
40
+ plt.xlabel("X1")
41
+ plt.ylabel("X2")
42
+ plt.title("AND Gate Decision Boundary")
43
+ plt.legend()
44
+ plt.grid()
45
+ plt.show()
pandaas/1.2.py ADDED
@@ -0,0 +1,49 @@
1
+ import numpy as np
2
+ import matplotlib.pyplot as plt
3
+
4
+ # OR gate dataset
5
+ X = np.array([[0,0], [0,1], [1,0], [1,1]])
6
+ y = np.array([0,1,1,1])
7
+
8
+ # Initialize weights and bias
9
+ w = np.zeros(2)
10
+ b = 0
11
+ lr = 0.1
12
+
13
+ # Training
14
+ for epoch in range(10):
15
+ for i in range(4):
16
+ z = np.dot(X[i], w) + b
17
+
18
+ if z >= 0:
19
+ pred = 1
20
+ else:
21
+ pred = 0
22
+
23
+ error = y[i] - pred
24
+
25
+ w = w + lr * error * X[i]
26
+ b = b + lr * error
27
+
28
+ # Testing
29
+ for i in range(4):
30
+ z = np.dot(X[i], w) + b
31
+
32
+ if z >= 0:
33
+ pred = 1
34
+ else:
35
+ pred = 0
36
+
37
+ print(X[i], ":", pred)
38
+
39
+ # Plot graph
40
+ x = np.linspace(-0.5, 1.5, 100)
41
+ plt.scatter(X[:,0], X[:,1], c=y)
42
+
43
+ y_line = -(w[0]*x+b)/w[1]
44
+ plt.plot(x, y_line)
45
+
46
+ plt.title("OR Gate Perceptron")
47
+ plt.xlabel("Input 1")
48
+ plt.ylabel("Input 2")
49
+ plt.show()
pandaas/2.py ADDED
@@ -0,0 +1,37 @@
1
+ import numpy as np
2
+ import matplotlib.pyplot as plt
3
+ import tensorflow as tf
4
+
5
+ path = "DATASET DL Lab-20261113T174144Z-1-001/DATASET DL Lab/FashionMNIST/"
6
+
7
+ X_train = np.fromfile(path + "train-images-idx3-ubyte", dtype=np.unint8)[16:]
8
+ y_train = np.fromfile(path + "train-labels-idx1-ubyte", dtype=np.unint8)[8:]
9
+
10
+ X_test = np.fromfile(path + "t10k-images-idx3-ubyte", dtype=np.unint8)[16:]
11
+ y_test = np.fromfile(path + "t10k-labels-idx1-ubyte", dtype=np.unint8)[8:]
12
+
13
+ X_train = X_train.reshape(60000, 28, 28)
14
+ X_test = X_test.reshape(10000, 28, 28)
15
+
16
+ X_train = X_train / 255.0
17
+ X_test = X_test / 255.0
18
+
19
+ model = tf.keras.Sequential([
20
+ tf.keras.layers.Flatten(input_shape=(28,28)),
21
+ tf.keras.layers.Dense(128, activation='relu'),
22
+ tf.keras.layers.Dense(64, activation='relu'),
23
+ tf.keras.layers.Dense(10, activation='softmax'),
24
+ ])
25
+
26
+ model.compile(optimizer = 'adam',
27
+ loss = 'sparse_categorical_crossentropy',
28
+ metrics = ['accuracy'])
29
+
30
+ history = model.fit(X_train, y_train,
31
+ epochs = 5,
32
+ batch_size = 64,
33
+ validation_split = 0.1)
34
+
35
+ loss, accuracy = model.evaluate(X_test, y_test)
36
+
37
+ print("Test")
pandaas/3.py ADDED
@@ -0,0 +1,80 @@
1
+ import numpy as np
2
+ import tensorflow as tf
3
+ import matplotlib.pyplot as plt
4
+
5
+ path = "DATASET DL Lab-20261113T174144Z-1-001/DATASET DL Lab/MNIST/"
6
+
7
+ X_train = np.fromfile(path + "train-images-idx3-ubyte", dtype=np.uint8)[16:]
8
+ y_train = np.fromfile(path + "train-labels-idx1-ubyte", dtype=np.uint8)[8:]
9
+
10
+ X_test = np.fromfile(path + "t10k-images-idx3-ubyte", dtype=np.uint8)[16:]
11
+ y_test = np.fromfile(path + "t10k-labels-idx1-ubyte", dtype=np.uint8)[8:]
12
+
13
+ X_train = X_train.reshape(60000, 28, 28) / 255.0
14
+ X_test = X_test.reshape(10000, 28, 28) / 255.0
15
+
16
+ # 2. Model without regularization
17
+ model1 = tf.keras.Sequential([
18
+ tf.keras.layers.Flatten(input_shape=(28, 28)),
19
+ tf.keras.layers.Dense(128, activation='relu'),
20
+ tf.keras.layers.Dense(10, activation='softmax')
21
+ ])
22
+
23
+ # 3. Model with L2 regularization
24
+ model2 = tf.keras.Sequential([
25
+ tf.keras.layers.Flatten(input_shape=(28, 28)),
26
+ tf.keras.layers.Dense(128, activation='relu',
27
+ kernel_regularizer=tf.keras.regularizers.l2(0.01)),
28
+ tf.keras.layers.Dense(10, activation='softmax')
29
+ ])
30
+
31
+ # 4. Model with Dropout
32
+ model3 = tf.keras.Sequential([
33
+ tf.keras.layers.Flatten(input_shape=(28, 28)),
34
+ tf.keras.layers.Dense(128, activation='relu'),
35
+ tf.keras.layers.Dropout(0.5),
36
+ tf.keras.layers.Dense(10, activation='softmax')
37
+ ])
38
+
39
+ # 5. Train all models
40
+ models = [model1, model2, model3]
41
+ names = ['Without Regularization', 'L2 Regularization', 'Dropout']
42
+ histories = []
43
+
44
+ for model in models:
45
+
46
+ model.compile(optimizer='adam',
47
+ loss='sparse_categorical_crossentropy',
48
+ metrics=['accuracy'])
49
+
50
+ history = model.fit(X_train, y_train,
51
+ epochs=3,
52
+ batch_size=64,
53
+ validation_split=0.1)
54
+
55
+ histories.append(history)
56
+
57
+ loss, accuracy = model.evaluate(X_test, y_test)
58
+ print("Test Accuracy:", accuracy * 100, "%")
59
+
60
+ # 6. Plot training and validation loss
61
+ for i, h in enumerate(histories):
62
+ plt.plot(h.history['loss'], label=names[i] + ' Training')
63
+ plt.plot(h.history['val_loss'], label=names[i] + ' Validation')
64
+
65
+ plt.title("Loss Comparison")
66
+ plt.xlabel("Epochs")
67
+ plt.ylabel("Loss")
68
+ plt.legend()
69
+ plt.show()
70
+
71
+ # 7. Plot training and validation accuracy
72
+ for i, h in enumerate(histories):
73
+ plt.plot(h.history['accuracy'], label=names[i] + ' Training')
74
+ plt.plot(h.history['val_accuracy'], label=names[i] + ' Validation')
75
+
76
+ plt.title("Accuracy Comparison")
77
+ plt.xlabel("Epochs")
78
+ plt.ylabel("Accuracy")
79
+ plt.legend()
80
+ plt.show()
pandaas/4.py ADDED
@@ -0,0 +1,76 @@
1
+ import numpy as np
2
+ import tensorflow as tf
3
+ import matplotlib.pyplot as plt
4
+ import time
5
+
6
+ # 1. Load MNIST dataset from local folder
7
+ path = "MNIST/"
8
+
9
+ X_train = np.fromfile(path + "train-images-idx3-ubyte", dtype=np.uint8)[16:]
10
+ y_train = np.fromfile(path + "train-labels-idx1-ubyte", dtype=np.uint8)[8:]
11
+
12
+ X_test = np.fromfile(path + "t10k-images-idx3-ubyte", dtype=np.uint8)[16:]
13
+ y_test = np.fromfile(path + "t10k-labels-idx1-ubyte", dtype=np.uint8)[8:]
14
+
15
+ X_train = X_train.reshape(60000, 28, 28) / 255.0
16
+ X_test = X_test.reshape(10000, 28, 28) / 255.0
17
+
18
+ # 2. Activation functions
19
+ activations = ['sigmoid', 'tanh', 'relu']
20
+
21
+ accuracies = []
22
+ times = []
23
+
24
+ # 3. Train models
25
+ for act in activations:
26
+
27
+ model = tf.keras.Sequential([
28
+ tf.keras.layers.Flatten(input_shape=(28, 28)),
29
+ tf.keras.layers.Dense(128, activation=act),
30
+ tf.keras.layers.Dense(10, activation='softmax')
31
+ ])
32
+
33
+ model.compile(optimizer='adam',
34
+ loss='sparse_categorical_crossentropy',
35
+ metrics=['accuracy'])
36
+
37
+ start = time.time()
38
+
39
+ model.fit(X_train, y_train,
40
+ epochs=3, batch_size=64, verbose=0)
41
+
42
+ times.append(time.time() - start)
43
+
44
+ loss, acc = model.evaluate(X_test, y_test, verbose=0)
45
+ accuracies.append(acc)
46
+
47
+ print(act, "Accuracy:", acc, "Loss:", loss)
48
+
49
+ # 4. Accuracy graph
50
+ plt.bar(activations, accuracies)
51
+ plt.title("Activation Function Accuracy")
52
+ plt.ylabel("Accuracy")
53
+ plt.show()
54
+
55
+ # 5. Training time graph
56
+ plt.bar(activations, times)
57
+ plt.title("Training Time Comparison")
58
+ plt.ylabel("Time (seconds)")
59
+ plt.show()
60
+
61
+ # 6. Gradient flow graph
62
+ x = np.linspace(-5, 5, 100)
63
+
64
+ sigmoid = 1 / (1 + np.exp(-x))
65
+ tanh = np.tanh(x)
66
+
67
+ plt.plot(x, sigmoid * (1 - sigmoid), label='Sigmoid')
68
+ plt.plot(x, 1 - tanh**2, label='Tanh')
69
+ plt.plot(x, (x > 0).astype(float), label='ReLU')
70
+
71
+ plt.title("Gradient Flow Comparison")
72
+ plt.xlabel("Input")
73
+ plt.ylabel("Gradient")
74
+ plt.legend()
75
+ plt.grid()
76
+ plt.show()
pandaas/5.py ADDED
@@ -0,0 +1,76 @@
1
+
2
+ import numpy as np
3
+ import tensorflow as tf
4
+ import matplotlib.pyplot as plt
5
+
6
+ # 1. Load MNIST dataset
7
+ path = "MNIST/"
8
+
9
+ X_train = np.fromfile(path + "train-images-idx3-ubyte", dtype=np.uint8)[16:]
10
+ y_train = np.fromfile(path + "train-labels-idx1-ubyte", dtype=np.uint8)[8:]
11
+
12
+ X_test = np.fromfile(path + "t10k-images-idx3-ubyte", dtype=np.uint8)[16:]
13
+ y_test = np.fromfile(path + "t10k-labels-idx1-ubyte", dtype=np.uint8)[8:]
14
+
15
+ X_train = X_train.reshape(60000, 28, 28, 1) / 255.0
16
+ X_test = X_test.reshape(10000, 28, 28, 1) / 255.0
17
+
18
+ # 2. Build CNN model
19
+ cnn = tf.keras.Sequential([
20
+ tf.keras.layers.Conv2D(32, (3,3), activation='relu',
21
+ input_shape=(28,28,1)),
22
+ tf.keras.layers.MaxPooling2D((2,2)),
23
+
24
+ tf.keras.layers.Conv2D(64, (3,3), activation='relu'),
25
+ tf.keras.layers.MaxPooling2D((2,2)),
26
+
27
+ tf.keras.layers.Flatten(),
28
+ tf.keras.layers.Dense(128, activation='relu'),
29
+ tf.keras.layers.Dense(10, activation='softmax')
30
+ ])
31
+
32
+ # 3. Compile CNN
33
+ cnn.compile(optimizer='adam',
34
+ loss='sparse_categorical_crossentropy',
35
+ metrics=['accuracy'])
36
+
37
+ # 4. Data augmentation
38
+ augmentation = tf.keras.Sequential([
39
+ tf.keras.layers.RandomRotation(0.1),
40
+ tf.keras.layers.RandomZoom(0.1)
41
+ ])
42
+
43
+ # 5. Train CNN with augmentation
44
+ cnn.fit(augmentation(X_train, training=True), y_train,
45
+ epochs=3, batch_size=64,
46
+ validation_split=0.1)
47
+
48
+ # 6. Evaluate CNN
49
+ cnn_loss, cnn_acc = cnn.evaluate(X_test, y_test)
50
+
51
+ print("CNN Accuracy:", cnn_acc * 100, "%")
52
+
53
+ # 7. Build MLP model for comparison
54
+ mlp = tf.keras.Sequential([
55
+ tf.keras.layers.Flatten(input_shape=(28,28,1)),
56
+ tf.keras.layers.Dense(128, activation='relu'),
57
+ tf.keras.layers.Dense(10, activation='softmax')
58
+ ])
59
+
60
+ mlp.compile(optimizer='adam',
61
+ loss='sparse_categorical_crossentropy',
62
+ metrics=['accuracy'])
63
+
64
+ # 8. Train MLP
65
+ mlp.fit(X_train, y_train, epochs=3, batch_size=64)
66
+
67
+ # 9. Evaluate MLP
68
+ mlp_loss, mlp_acc = mlp.evaluate(X_test, y_test)
69
+
70
+ print("MLP Accuracy:", mlp_acc * 100, "%")
71
+
72
+ # 10. Compare accuracy
73
+ plt.bar(['MLP', 'CNN'], [mlp_acc, cnn_acc])
74
+ plt.title("MLP vs CNN Accuracy")
75
+ plt.ylabel("Accuracy")
76
+ plt.show()
pandaas/6.py ADDED
@@ -0,0 +1,78 @@
1
+
2
+ import numpy as np
3
+ import pandas as pd
4
+ import tensorflow as tf
5
+ import matplotlib.pyplot as plt
6
+
7
+ # 1. Load IMDB dataset
8
+ data = pd.read_csv("IMDB_Dataset.csv")
9
+
10
+ X = data['review'].values
11
+ y = data['sentiment'].map({'positive': 1, 'negative': 0}).values
12
+
13
+ # 2. Split dataset (80% training, 20% testing)
14
+ X_train = X[:40000]
15
+ y_train = y[:40000]
16
+
17
+ X_test = X[40000:]
18
+ y_test = y[40000:]
19
+
20
+ # 3. Convert text into numbers
21
+ vectorizer = tf.keras.layers.TextVectorization(
22
+ max_tokens=10000,
23
+ output_sequence_length=200
24
+ )
25
+
26
+ vectorizer.adapt(X_train)
27
+
28
+ # 4. Build LSTM model
29
+ model = tf.keras.Sequential([
30
+ tf.keras.layers.Input(shape=(), dtype=tf.string),
31
+ vectorizer,
32
+ tf.keras.layers.Embedding(10000, 64, mask_zero=True),
33
+ tf.keras.layers.LSTM(64),
34
+ tf.keras.layers.Dense(1, activation='sigmoid')
35
+ ])
36
+
37
+ # 5. Compile model
38
+ model.compile(optimizer='adam',
39
+ loss='binary_crossentropy',
40
+ metrics=['accuracy'])
41
+
42
+ # 6. Train model
43
+ history = model.fit(
44
+ X_train, y_train,
45
+ epochs=3,
46
+ batch_size=64,
47
+ validation_split=0.1
48
+ )
49
+
50
+ # 7. Evaluate model
51
+ loss, accuracy = model.evaluate(X_test, y_test)
52
+
53
+ print("Test Loss:", loss)
54
+ print("Test Accuracy:", accuracy * 100, "%")
55
+
56
+ # 8. Plot accuracy
57
+ plt.plot(history.history['accuracy'], label='Training Accuracy')
58
+ plt.plot(history.history['val_accuracy'], label='Validation Accuracy')
59
+
60
+ plt.title("LSTM Accuracy")
61
+ plt.xlabel("Epochs")
62
+ plt.ylabel("Accuracy")
63
+ plt.legend()
64
+ plt.show()
65
+
66
+ # 9. Example predictions
67
+ reviews = [
68
+ "This movie was amazing and I loved it",
69
+ "This movie was boring and very disappointing"
70
+ ]
71
+
72
+ predictions = model.predict(np.array(reviews))
73
+
74
+ for i in range(len(reviews)):
75
+ if predictions[i][0] >= 0.5:
76
+ print(reviews[i], "-> Positive")
77
+ else:
78
+ print(reviews[i], "-> Negative")
pandaas/7.py ADDED
@@ -0,0 +1,113 @@
1
+
2
+ import tensorflow as tf
3
+ import matplotlib.pyplot as plt
4
+
5
+ # 1. Load Cats vs Dogs dataset
6
+ path = "cats_vs_dogs/"
7
+
8
+ train_data = tf.keras.utils.image_dataset_from_directory(
9
+ path,
10
+ validation_split=0.2,
11
+ subset="training",
12
+ seed=123,
13
+ image_size=(224, 224),
14
+ batch_size=32,
15
+ label_mode='binary'
16
+ )
17
+
18
+ test_data = tf.keras.utils.image_dataset_from_directory(
19
+ path,
20
+ validation_split=0.2,
21
+ subset="validation",
22
+ seed=123,
23
+ image_size=(224, 224),
24
+ batch_size=32,
25
+ label_mode='binary'
26
+ )
27
+
28
+ # 2. Load pretrained ResNet50
29
+ base_model = tf.keras.applications.ResNet50(
30
+ weights="resnet50_weights_tf_dim_ordering_tf_kernels_notop.h5",
31
+ include_top=False,
32
+ input_shape=(224, 224, 3)
33
+ )
34
+
35
+ # 3. Freeze pretrained layers
36
+ base_model.trainable = False
37
+
38
+ # 4. Build model
39
+ model = tf.keras.Sequential([
40
+ tf.keras.layers.Input(shape=(224, 224, 3)),
41
+ tf.keras.layers.Lambda(
42
+ tf.keras.applications.resnet50.preprocess_input
43
+ ),
44
+ base_model,
45
+ tf.keras.layers.GlobalAveragePooling2D(),
46
+ tf.keras.layers.Dense(1, activation='sigmoid')
47
+ ])
48
+
49
+ # 5. Compile model
50
+ model.compile(
51
+ optimizer='adam',
52
+ loss='binary_crossentropy',
53
+ metrics=['accuracy']
54
+ )
55
+
56
+ # 6. Train with frozen layers
57
+ history1 = model.fit(
58
+ train_data,
59
+ epochs=3,
60
+ validation_data=test_data
61
+ )
62
+
63
+ # 7. Unfreeze last 10 layers
64
+ base_model.trainable = True
65
+
66
+ for layer in base_model.layers[:-10]:
67
+ layer.trainable = False
68
+
69
+ # 8. Fine-tune model
70
+ model.compile(
71
+ optimizer=tf.keras.optimizers.Adam(learning_rate=0.00001),
72
+ loss='binary_crossentropy',
73
+ metrics=['accuracy']
74
+ )
75
+
76
+ history2 = model.fit(
77
+ train_data,
78
+ epochs=3,
79
+ validation_data=test_data
80
+ )
81
+
82
+ # 9. Evaluate model
83
+ loss, accuracy = model.evaluate(test_data)
84
+
85
+ print("Test Accuracy:", accuracy * 100, "%")
86
+
87
+ # 10. Plot accuracy
88
+ plt.plot(history1.history['val_accuracy'], label='Frozen')
89
+ plt.plot(
90
+ [x + 3 for x in range(3)],
91
+ history2.history['val_accuracy'],
92
+ label='Fine Tuned'
93
+ )
94
+
95
+ plt.title("Transfer Learning Accuracy")
96
+ plt.xlabel("Epochs")
97
+ plt.ylabel("Accuracy")
98
+ plt.legend()
99
+ plt.show()
100
+
101
+ # 11. Plot loss
102
+ plt.plot(history1.history['val_loss'], label='Frozen')
103
+ plt.plot(
104
+ [x + 3 for x in range(3)],
105
+ history2.history['val_loss'],
106
+ label='Fine Tuned'
107
+ )
108
+
109
+ plt.title("Transfer Learning Loss")
110
+ plt.xlabel("Epochs")
111
+ plt.ylabel("Loss")
112
+ plt.legend()
113
+ plt.show()
pandaas/8.py ADDED
@@ -0,0 +1,76 @@
1
+
2
+ import numpy as np
3
+ import tensorflow as tf
4
+ import matplotlib.pyplot as plt
5
+ import time
6
+
7
+ # 1. Load MNIST dataset
8
+ path = "MNIST/"
9
+
10
+ X_train = np.fromfile(path + "train-images-idx3-ubyte", dtype=np.uint8)[16:]
11
+ y_train = np.fromfile(path + "train-labels-idx1-ubyte", dtype=np.uint8)[8:]
12
+
13
+ X_test = np.fromfile(path + "t10k-images-idx3-ubyte", dtype=np.uint8)[16:]
14
+ y_test = np.fromfile(path + "t10k-labels-idx1-ubyte", dtype=np.uint8)[8:]
15
+
16
+ X_train = X_train.reshape(60000, 28, 28) / 255.0
17
+ X_test = X_test.reshape(10000, 28, 28) / 255.0
18
+
19
+ # 2. Hyperparameter configurations
20
+ configs = [
21
+ (0.001, 32, [128]),
22
+ (0.01, 64, [128, 64]),
23
+ (0.1, 128, [128, 64])
24
+ ]
25
+
26
+ accuracies = []
27
+ times = []
28
+
29
+ # 3. Train models
30
+ for lr, bs, hidden in configs:
31
+
32
+ model = tf.keras.Sequential()
33
+ model.add(tf.keras.layers.Input(shape=(28, 28)))
34
+ model.add(tf.keras.layers.Flatten())
35
+
36
+ for neurons in hidden:
37
+ model.add(tf.keras.layers.Dense(neurons, activation='relu'))
38
+
39
+ model.add(tf.keras.layers.Dense(10, activation='softmax'))
40
+
41
+ model.compile(
42
+ optimizer=tf.keras.optimizers.Adam(learning_rate=lr),
43
+ loss='sparse_categorical_crossentropy',
44
+ metrics=['accuracy']
45
+ )
46
+
47
+ start = time.time()
48
+
49
+ model.fit(X_train, y_train,
50
+ epochs=3, batch_size=bs, verbose=0)
51
+
52
+ times.append(time.time() - start)
53
+
54
+ loss, acc = model.evaluate(X_test, y_test, verbose=0)
55
+ accuracies.append(acc)
56
+
57
+ print("Learning Rate:", lr)
58
+ print("Batch Size:", bs)
59
+ print("Hidden Layers:", hidden)
60
+ print("Accuracy:", acc)
61
+ print("Training Time:", times[-1])
62
+ print("----------------------")
63
+
64
+ # 4. Plot accuracy comparison
65
+ names = ['Experiment 1', 'Experiment 2', 'Experiment 3']
66
+
67
+ plt.bar(names, accuracies)
68
+ plt.title("Accuracy Comparison")
69
+ plt.ylabel("Accuracy")
70
+ plt.show()
71
+
72
+ # 5. Plot training time
73
+ plt.bar(names, times)
74
+ plt.title("Training Time Comparison")
75
+ plt.ylabel("Time (seconds)")
76
+ plt.show()
pandaas/__init__.py ADDED
@@ -0,0 +1,109 @@
1
+ """pandaas - Lightweight helper utilities for data workflows and quick-start scripts.
2
+ """
3
+
4
+ from __future__ import annotations
5
+
6
+ import os
7
+ import shutil
8
+ import subprocess
9
+ import sys
10
+ from pathlib import Path
11
+ from typing import List
12
+
13
+ __version__ = "0.1.0"
14
+ __all__ = ["extract", "open_folder", "list_files", "show_code", "get_package_dir"]
15
+
16
+
17
+ def get_package_dir() -> Path:
18
+ """Return the absolute path of the installed package directory."""
19
+ return Path(__file__).resolve().parent
20
+
21
+
22
+ def extract(folder_name: str = "temp_files") -> None:
23
+ """Recursively copies all .py files (excluding __init__.py) from the package
24
+
25
+ into a destination folder inside the current working directory.
26
+ """
27
+ # If invoked from CLI with an argument (e.g. `get-temp custom_dir`)
28
+ if len(sys.argv) > 1 and folder_name == "temp_files":
29
+ candidate = sys.argv[1].strip()
30
+ if candidate and not candidate.startswith("-"):
31
+ folder_name = candidate
32
+
33
+ pkg_root = get_package_dir()
34
+ dest_dir = Path.cwd() / folder_name
35
+ dest_dir.mkdir(parents=True, exist_ok=True)
36
+
37
+ copied: List[str] = []
38
+
39
+ for file_path in pkg_root.rglob("*.py"):
40
+ if file_path.name == "__init__.py":
41
+ continue
42
+
43
+ relative_path = file_path.relative_to(pkg_root)
44
+ target_path = dest_dir / relative_path
45
+ target_path.parent.mkdir(parents=True, exist_ok=True)
46
+ shutil.copy2(file_path, target_path)
47
+ copied.append(str(relative_path))
48
+
49
+ print(f"Extracted {len(copied)} file(s) into: {dest_dir.resolve()}")
50
+ for item in copied:
51
+ print(f" -> {item}")
52
+
53
+
54
+ def open_folder() -> None:
55
+ """Prints the installed package directory and opens it in the system file manager."""
56
+ pkg_dir = get_package_dir()
57
+ resolved_path = str(pkg_dir.resolve())
58
+ print(f"Package directory: {resolved_path}")
59
+
60
+ try:
61
+ if sys.platform == "win32":
62
+ os.startfile(resolved_path) # type: ignore[attr-defined]
63
+ elif sys.platform == "darwin":
64
+ subprocess.run(["open", resolved_path], check=False)
65
+ else:
66
+ subprocess.run(["xdg-open", resolved_path], check=False)
67
+ except Exception as exc:
68
+ print(f"Unable to launch system file browser automatically: {exc}")
69
+ print(f"You can open the path manually: {resolved_path}")
70
+
71
+
72
+ def list_files() -> None:
73
+ """Prints a clean list of all available temp*.py files inside the package."""
74
+ pkg_dir = get_package_dir()
75
+ py_files = sorted(
76
+ str(p.relative_to(pkg_dir))
77
+ for p in pkg_dir.rglob("*.py")
78
+ if p.name != "__init__.py"
79
+ )
80
+
81
+ print(f"Files available in package '{__name__}' ({pkg_dir.resolve()}):")
82
+ if not py_files:
83
+ print(" (No files found)")
84
+ else:
85
+ for idx, filename in enumerate(py_files, start=1):
86
+ print(f" {idx}. {filename}")
87
+
88
+
89
+ def show_code(filename: str) -> None:
90
+ """Prints the complete readable source code of a specified package file."""
91
+ pkg_dir = get_package_dir()
92
+ target_path = pkg_dir / filename
93
+
94
+ if not target_path.exists():
95
+ matches = list(pkg_dir.rglob(filename))
96
+ if matches:
97
+ target_path = matches[0]
98
+
99
+ if not target_path.exists() or not target_path.is_file():
100
+ print(f"Error: File '{filename}' not found inside package at {pkg_dir}")
101
+ return
102
+
103
+ print(f"--- Content of {filename} ({target_path}) ---")
104
+ try:
105
+ content = target_path.read_text(encoding="utf-8")
106
+ print(content)
107
+ except Exception as err:
108
+ print(f"Failed to read file: {err}")
109
+ print("--- End of file ---")
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pandaas Utils Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,95 @@
1
+ Metadata-Version: 2.1
2
+ Name: pandaas-utils
3
+ Version: 0.1.0
4
+ Summary: Lightweight helper utilities for data processing
5
+ Author: Pandaas Developers
6
+ License: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.8
9
+ Classifier: Programming Language :: Python :: 3.9
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Topic :: Scientific/Engineering
16
+ Classifier: Topic :: Utilities
17
+ Requires-Python: >=3.8
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: numpy
21
+ Requires-Dist: matplotlib
22
+ Requires-Dist: pandas
23
+ Requires-Dist: scikit-learn
24
+
25
+ # pandaas-utils
26
+
27
+ `pandaas-utils` is a lightweight Python utility package providing helper tools, templates, and starter scripts for data manipulation, quick experiments, and workflow prototyping across Windows, Linux, and macOS.
28
+
29
+ ## Installation
30
+
31
+ Install the latest release directly via `pip`:
32
+
33
+ ```bash
34
+ pip install pandaas-utils
35
+ ```
36
+
37
+ ## Quick Start (Python)
38
+
39
+ After installation, import the module as `pandaas`:
40
+
41
+ ```python
42
+ import pandaas
43
+
44
+ # 1. View available template and utility scripts
45
+ pandaas.list_files()
46
+
47
+ # 2. Inspect the source code of any included script directly in your terminal
48
+ pandaas.show_code("1.1.py")
49
+
50
+ # 3. Extract the scripts into a local folder for viewing and editing
51
+ pandaas.extract(folder_name="temp_files")
52
+
53
+ # 4. Open the installed package directory in your system file explorer
54
+ pandaas.open_folder()
55
+ ```
56
+
57
+ ## Command Line Interface (CLI)
58
+
59
+ `pandaas-utils` also installs console commands that can be executed directly from your terminal (CMD, PowerShell, or Bash):
60
+
61
+ - **`list-temp`**: Displays all utility scripts bundled within the package.
62
+ - **`get-temp`**: Recursively copies package scripts into a local `temp_files/` folder in your current directory.
63
+ - **`open-temp`**: Opens the installed package folder in Windows Explorer or Linux file manager (`xdg-open`).
64
+
65
+ ### Example CLI Usage:
66
+
67
+ ```bash
68
+ # List all files
69
+ list-temp
70
+
71
+ # Extract files into the working directory
72
+ get-temp
73
+
74
+ # Open the site-packages location
75
+ open-temp
76
+ ```
77
+
78
+ ## Included Modules
79
+
80
+ The package contains data utility scripts and starter templates:
81
+ - `1.1.py`
82
+ - `1.2.py`
83
+ - `2.py`
84
+ - `3.py`
85
+ - `4.py`
86
+ - `5.py`
87
+ - `6.py`
88
+ - `7.py`
89
+ - `8.py`
90
+
91
+ Use `pandaas.extract()` or `get-temp` to extract them into your working directory for editing and execution.
92
+
93
+ ## License
94
+
95
+ This project is licensed under the MIT License. See [LICENSE](LICENSE) for details.
@@ -0,0 +1,16 @@
1
+ pandaas/1.1.py,sha256=p8Y58DbutkW_eXyUKPJ0As5HP7BpKXmy8jvrH2VJ1mU,1054
2
+ pandaas/1.2.py,sha256=F32aJZ-HXLC9UR6llOsAoChi6yI6yLjWfmbqf76k2OI,864
3
+ pandaas/2.py,sha256=DoW4JhUWirfNF2iJK6U1hv_eiHiWSrud_h--UY4V-AQ,1210
4
+ pandaas/3.py,sha256=CqPEBSbTdCFlB5twDjgFKjSu0AjiaRTzeiF-wVqUHI0,2603
5
+ pandaas/4.py,sha256=SUjVgF-Ab-bsMlr9S1xcM4nmkYqvnscMK6kCXFPJjII,2011
6
+ pandaas/5.py,sha256=h-jBcxVdex3bwP-uItL7yNIjqqr_AUD3p5XI0PtEFJU,2230
7
+ pandaas/6.py,sha256=wQwV1PIgabuFE7qt5WyHNw98amPCM0IPD-tq5jMB5AI,1867
8
+ pandaas/7.py,sha256=g7xeyybdtG-sbV-kEUMOxk9zJSl2ruH85V62Ror_Qhk,2472
9
+ pandaas/8.py,sha256=L2y6rNSMbrVVlNt7ciJEZCL_3rjkgvOr15xWj7Pxz_8,2008
10
+ pandaas/__init__.py,sha256=7DuJcGt3zSgRpyubmBkaw2KCPp6YIRmHiUfNY-Aq24k,3589
11
+ pandaas_utils-0.1.0.dist-info/LICENSE,sha256=gHRszZWKe83eHKI9lBOm2q3HN524HAUk-qee1VR84bs,1083
12
+ pandaas_utils-0.1.0.dist-info/METADATA,sha256=yLiqIoTMVM_FJNM2uWVluKCqfUDs2xf7yYfNeAdwXE0,2732
13
+ pandaas_utils-0.1.0.dist-info/WHEEL,sha256=EWGgdj_eH-g9dwsWZOTG0kmGucEuKPxGzOKD-jAVUHs,92
14
+ pandaas_utils-0.1.0.dist-info/entry_points.txt,sha256=RPHvxLSsul5TzJyzYTt70Mx0KxsC_YBXB3UB79aJkv4,108
15
+ pandaas_utils-0.1.0.dist-info/top_level.txt,sha256=wnom2R7-ohJsaxnTcagtJQQZRleBj9S24loqQpZGBaA,8
16
+ pandaas_utils-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.48.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ get-temp = pandaas:extract
3
+ list-temp = pandaas:list_files
4
+ open-temp = pandaas:open_folder
@@ -0,0 +1 @@
1
+ pandaas