ppandass 0.1.1__tar.gz

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.
ppandass-0.1.1/LICENSE ADDED
@@ -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,90 @@
1
+ Metadata-Version: 2.1
2
+ Name: ppandass
3
+ Version: 0.1.1
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
+
21
+ # ppandass
22
+
23
+ `ppandass` 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.
24
+
25
+ ## Installation
26
+
27
+ Install the latest release directly via `pip`:
28
+
29
+ ```bash
30
+ pip install ppandass
31
+ ```
32
+
33
+ ## Quick Start (Python)
34
+
35
+ After installation, import the module as `pandaas`:
36
+
37
+ ```python
38
+ import pandaas
39
+
40
+ # 1. View available template and utility scripts
41
+ pandaas.list_files()
42
+
43
+ # 2. Inspect the source code of any included script directly in your terminal
44
+ pandaas.show_code("1.py")
45
+
46
+ # 3. Extract the scripts into a local folder for viewing and editing
47
+ pandaas.extract(folder_name="temp_files")
48
+
49
+ # 4. Open the installed package directory in your system file explorer
50
+ pandaas.open_folder()
51
+ ```
52
+
53
+ ## Command Line Interface (CLI)
54
+
55
+ `ppandass` also installs console commands that can be executed directly from your terminal (CMD, PowerShell, or Bash):
56
+
57
+ - **`list-temp`**: Displays all utility scripts bundled within the package.
58
+ - **`get-temp`**: Recursively copies package scripts into a local `temp_files/` folder in your current directory.
59
+ - **`open-temp`**: Opens the installed package folder in Windows Explorer or Linux file manager (`xdg-open`).
60
+
61
+ ### Example CLI Usage:
62
+
63
+ ```bash
64
+ # List all files
65
+ list-temp
66
+
67
+ # Extract files into the working directory
68
+ get-temp
69
+
70
+ # Open the site-packages location
71
+ open-temp
72
+ ```
73
+
74
+ ## Included Modules
75
+
76
+ The package contains data utility scripts and starter templates:
77
+ - `1.py`
78
+ - `2.py`
79
+ - `3.py`
80
+ - `4.py`
81
+ - `5.py`
82
+ - `6.py`
83
+ - `7.py`
84
+ - `8.py`
85
+
86
+ Use `pandaas.extract()` or `get-temp` to extract them into your working directory for editing and execution.
87
+
88
+ ## License
89
+
90
+ This project is licensed under the MIT License. See [LICENSE](LICENSE) for details.
@@ -0,0 +1,70 @@
1
+ # ppandass
2
+
3
+ `ppandass` 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.
4
+
5
+ ## Installation
6
+
7
+ Install the latest release directly via `pip`:
8
+
9
+ ```bash
10
+ pip install ppandass
11
+ ```
12
+
13
+ ## Quick Start (Python)
14
+
15
+ After installation, import the module as `pandaas`:
16
+
17
+ ```python
18
+ import pandaas
19
+
20
+ # 1. View available template and utility scripts
21
+ pandaas.list_files()
22
+
23
+ # 2. Inspect the source code of any included script directly in your terminal
24
+ pandaas.show_code("1.py")
25
+
26
+ # 3. Extract the scripts into a local folder for viewing and editing
27
+ pandaas.extract(folder_name="temp_files")
28
+
29
+ # 4. Open the installed package directory in your system file explorer
30
+ pandaas.open_folder()
31
+ ```
32
+
33
+ ## Command Line Interface (CLI)
34
+
35
+ `ppandass` also installs console commands that can be executed directly from your terminal (CMD, PowerShell, or Bash):
36
+
37
+ - **`list-temp`**: Displays all utility scripts bundled within the package.
38
+ - **`get-temp`**: Recursively copies package scripts into a local `temp_files/` folder in your current directory.
39
+ - **`open-temp`**: Opens the installed package folder in Windows Explorer or Linux file manager (`xdg-open`).
40
+
41
+ ### Example CLI Usage:
42
+
43
+ ```bash
44
+ # List all files
45
+ list-temp
46
+
47
+ # Extract files into the working directory
48
+ get-temp
49
+
50
+ # Open the site-packages location
51
+ open-temp
52
+ ```
53
+
54
+ ## Included Modules
55
+
56
+ The package contains data utility scripts and starter templates:
57
+ - `1.py`
58
+ - `2.py`
59
+ - `3.py`
60
+ - `4.py`
61
+ - `5.py`
62
+ - `6.py`
63
+ - `7.py`
64
+ - `8.py`
65
+
66
+ Use `pandaas.extract()` or `get-temp` to extract them into your working directory for editing and execution.
67
+
68
+ ## License
69
+
70
+ This project is licensed under the MIT License. See [LICENSE](LICENSE) for details.
@@ -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()
@@ -0,0 +1,53 @@
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/FashionMNIST/"
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
+ # Reshape images
14
+ X_train = X_train.reshape(60000, 28, 28)
15
+ X_test = X_test.reshape(10000, 28, 28)
16
+
17
+ # 2. Normalize data
18
+ X_train = X_train / 255.0
19
+ X_test = X_test / 255.0
20
+
21
+ # 3. Build neural network
22
+ model = tf.keras.Sequential([
23
+ tf.keras.layers.Flatten(input_shape=(28, 28)),
24
+ tf.keras.layers.Dense(128, activation='relu'),
25
+ tf.keras.layers.Dense(64, activation='relu'),
26
+ tf.keras.layers.Dense(10, activation='softmax')
27
+ ])
28
+
29
+ # 4. Compile model
30
+ model.compile(optimizer='adam',
31
+ loss='sparse_categorical_crossentropy',
32
+ metrics=['accuracy'])
33
+
34
+ # 5. Train model
35
+ history = model.fit(X_train, y_train,
36
+ epochs=5,
37
+ batch_size=64,
38
+ validation_split=0.1)
39
+
40
+ # 6. Test model
41
+ loss, accuracy = model.evaluate(X_test, y_test)
42
+
43
+ print("Test Loss:", loss)
44
+ print("Test Accuracy:", accuracy * 100, "%")
45
+
46
+ # 7. Plot accuracy and loss
47
+ plt.plot(history.history['accuracy'], label='Accuracy')
48
+ plt.plot(history.history['loss'], label='Loss')
49
+ plt.xlabel("Epochs")
50
+ plt.ylabel("Value")
51
+ plt.title("Accuracy and Loss")
52
+ plt.legend()
53
+ plt.show()
@@ -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()
@@ -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 = "DATASET DL Lab-20261113T174144Z-1-001/DATASET DL Lab/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()
@@ -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 = "DATASET DL Lab-20261113T174144Z-1-001/DATASET DL Lab/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()
@@ -0,0 +1,82 @@
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("DATASET DL Lab-20261113T174144Z-1-001/DATASET DL Lab/IMDB_Dataset.csv")
9
+
10
+ X = data['review'].fillna('').astype(str).values
11
+ y = data['sentiment'].map({'positive': 1, 'negative': 0}).values.astype('int32')
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
+ # Convert data types
21
+ X_train = tf.constant(X_train, dtype=tf.string)
22
+ X_test = tf.constant(X_test, dtype=tf.string)
23
+
24
+ # 3. Convert text into numbers
25
+ vectorizer = tf.keras.layers.TextVectorization(
26
+ max_tokens=10000,
27
+ output_sequence_length=200
28
+ )
29
+
30
+ vectorizer.adapt(X_train)
31
+
32
+ # 4. Build LSTM model
33
+ model = tf.keras.Sequential([
34
+ tf.keras.layers.Input(shape=(), dtype=tf.string),
35
+ vectorizer,
36
+ tf.keras.layers.Embedding(10000, 64, mask_zero=True),
37
+ tf.keras.layers.LSTM(64),
38
+ tf.keras.layers.Dense(1, activation='sigmoid')
39
+ ])
40
+
41
+ # 5. Compile model
42
+ model.compile(optimizer='adam',
43
+ loss='binary_crossentropy',
44
+ metrics=['accuracy'])
45
+
46
+ # 6. Train model
47
+ history = model.fit(
48
+ X_train, y_train,
49
+ epochs=3,
50
+ batch_size=64,
51
+ validation_split=0.1
52
+ )
53
+
54
+ # 7. Evaluate model
55
+ loss, accuracy = model.evaluate(X_test, y_test)
56
+
57
+ print("Test Loss:", loss)
58
+ print("Test Accuracy:", accuracy * 100, "%")
59
+
60
+ # 8. Plot accuracy
61
+ plt.plot(history.history['accuracy'], label='Training Accuracy')
62
+ plt.plot(history.history['val_accuracy'], label='Validation Accuracy')
63
+
64
+ plt.title("LSTM Accuracy")
65
+ plt.xlabel("Epochs")
66
+ plt.ylabel("Accuracy")
67
+ plt.legend()
68
+ plt.show()
69
+
70
+ # 9. Example predictions
71
+ reviews = tf.constant([
72
+ "This movie was amazing and I loved it",
73
+ "This movie was boring and very disappointing"
74
+ ], dtype=tf.string)
75
+
76
+ predictions = model.predict(reviews)
77
+
78
+ for i in range(len(reviews)):
79
+ if predictions[i][0] >= 0.5:
80
+ print(reviews[i], "-> Positive")
81
+ else:
82
+ print(reviews[i], "-> Negative")
@@ -0,0 +1,98 @@
1
+ # # Step I : Import libraries
2
+ import tensorflow as tf
3
+ import matplotlib.pyplot as plt
4
+ from tensorflow.keras.applications import VGG16
5
+ from tensorflow.keras.applications.vgg16 import preprocess_input
6
+
7
+ # Step II : Load Dataset
8
+
9
+ train_dir = "DATASET DL Lab-20261113T174144Z-1-001/DATASET DL Lab/cats_and_dogs_filtered/train"
10
+ test_dir = "DATASET DL Lab-20261113T174144Z-1-001/DATASET DL Lab/cats_and_dogs_filtered/validation"
11
+
12
+ # Step III : Load Images
13
+ train_data = tf.keras.utils.image_dataset_from_directory(
14
+ train_dir,
15
+ image_size=(224,224),
16
+ batch_size=32,
17
+ label_mode='binary'
18
+ )
19
+
20
+ test_data = tf.keras.utils.image_dataset_from_directory(
21
+ test_dir,
22
+ image_size=(224,224),
23
+ batch_size=32,
24
+ label_mode='binary'
25
+ )
26
+
27
+ # Step IV : Preprocessing
28
+ train_data = train_data.map(lambda x,y: (preprocess_input(x),y))
29
+ test_data = test_data.map(lambda x,y: (preprocess_input(x),y))
30
+
31
+ # Step V : Load Pretrained Model
32
+ base_model = VGG16(
33
+ weights='imagenet',
34
+ include_top=False,
35
+ input_shape=(224,224,3)
36
+ )
37
+
38
+ # Freeze layers
39
+ base_model.trainable = False
40
+
41
+ # Step VI : Build Model
42
+ model = tf.keras.Sequential([
43
+ base_model,
44
+ tf.keras.layers.GlobalAveragePooling2D(),
45
+ tf.keras.layers.Dense(128, activation='relu'),
46
+ tf.keras.layers.Dense(1, activation='sigmoid')
47
+ ])
48
+
49
+ # Step VII : Compile Model
50
+ model.compile(
51
+ optimizer='adam',
52
+ loss='binary_crossentropy',
53
+ metrics=['accuracy']
54
+ )
55
+
56
+ # Step VIII : Train Model
57
+ history = model.fit(
58
+ train_data,
59
+ epochs=2,
60
+ validation_data=test_data
61
+ )
62
+
63
+ # Step IX : Evaluate Model
64
+ loss, accuracy = model.evaluate(test_data)
65
+ print("Feature Extraction Accuracy:", accuracy)
66
+
67
+ # Step X : Fine Tuning
68
+ base_model.trainable = True
69
+
70
+ # Freeze all except last 4 layers
71
+ for layer in base_model.layers[:-4]:
72
+ layer.trainable = False
73
+
74
+ # Compile again
75
+ model.compile(
76
+ optimizer=tf.keras.optimizers.Adam(learning_rate=0.0001),
77
+ loss='binary_crossentropy',
78
+ metrics=['accuracy']
79
+ )
80
+
81
+ # Train again
82
+ history2 = model.fit(
83
+ train_data,
84
+ epochs=2,
85
+ validation_data=test_data
86
+ )
87
+
88
+ # Step XI : Final Evaluation
89
+ loss, accuracy = model.evaluate(test_data)
90
+ print("Fine Tuning Accuracy:", accuracy)
91
+
92
+ # Step XII : Compare Accuracy
93
+ plt.plot(history.history['accuracy'], label='Feature Extraction')
94
+ plt.plot(history2.history['accuracy'], label='Fine Tuning')
95
+ plt.xlabel('Epochs')
96
+ plt.ylabel('Accuracy')
97
+ plt.legend()
98
+ plt.show()
@@ -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 = "DATASET DL Lab-20261113T174144Z-1-001/DATASET DL Lab/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()
@@ -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.1"
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,90 @@
1
+ Metadata-Version: 2.1
2
+ Name: ppandass
3
+ Version: 0.1.1
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
+
21
+ # ppandass
22
+
23
+ `ppandass` 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.
24
+
25
+ ## Installation
26
+
27
+ Install the latest release directly via `pip`:
28
+
29
+ ```bash
30
+ pip install ppandass
31
+ ```
32
+
33
+ ## Quick Start (Python)
34
+
35
+ After installation, import the module as `pandaas`:
36
+
37
+ ```python
38
+ import pandaas
39
+
40
+ # 1. View available template and utility scripts
41
+ pandaas.list_files()
42
+
43
+ # 2. Inspect the source code of any included script directly in your terminal
44
+ pandaas.show_code("1.py")
45
+
46
+ # 3. Extract the scripts into a local folder for viewing and editing
47
+ pandaas.extract(folder_name="temp_files")
48
+
49
+ # 4. Open the installed package directory in your system file explorer
50
+ pandaas.open_folder()
51
+ ```
52
+
53
+ ## Command Line Interface (CLI)
54
+
55
+ `ppandass` also installs console commands that can be executed directly from your terminal (CMD, PowerShell, or Bash):
56
+
57
+ - **`list-temp`**: Displays all utility scripts bundled within the package.
58
+ - **`get-temp`**: Recursively copies package scripts into a local `temp_files/` folder in your current directory.
59
+ - **`open-temp`**: Opens the installed package folder in Windows Explorer or Linux file manager (`xdg-open`).
60
+
61
+ ### Example CLI Usage:
62
+
63
+ ```bash
64
+ # List all files
65
+ list-temp
66
+
67
+ # Extract files into the working directory
68
+ get-temp
69
+
70
+ # Open the site-packages location
71
+ open-temp
72
+ ```
73
+
74
+ ## Included Modules
75
+
76
+ The package contains data utility scripts and starter templates:
77
+ - `1.py`
78
+ - `2.py`
79
+ - `3.py`
80
+ - `4.py`
81
+ - `5.py`
82
+ - `6.py`
83
+ - `7.py`
84
+ - `8.py`
85
+
86
+ Use `pandaas.extract()` or `get-temp` to extract them into your working directory for editing and execution.
87
+
88
+ ## License
89
+
90
+ This project is licensed under the MIT License. See [LICENSE](LICENSE) for details.
@@ -0,0 +1,18 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ pandaas/1.py
5
+ pandaas/2.py
6
+ pandaas/3.py
7
+ pandaas/4.py
8
+ pandaas/5.py
9
+ pandaas/6.py
10
+ pandaas/7.py
11
+ pandaas/8.py
12
+ pandaas/__init__.py
13
+ ppandass.egg-info/PKG-INFO
14
+ ppandass.egg-info/SOURCES.txt
15
+ ppandass.egg-info/dependency_links.txt
16
+ ppandass.egg-info/entry_points.txt
17
+ ppandass.egg-info/requires.txt
18
+ ppandass.egg-info/top_level.txt
@@ -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,4 @@
1
+ numpy
2
+ matplotlib
3
+ pandas
4
+ scikit-learn
@@ -0,0 +1 @@
1
+ pandaas
@@ -0,0 +1,44 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ppandass"
7
+ version = "0.1.1"
8
+ description = "Lightweight helper utilities for data processing"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "Pandaas Developers" }
14
+ ]
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.8",
18
+ "Programming Language :: Python :: 3.9",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "License :: OSI Approved :: MIT License",
23
+ "Operating System :: OS Independent",
24
+ "Topic :: Scientific/Engineering",
25
+ "Topic :: Utilities"
26
+ ]
27
+ dependencies = [
28
+ "numpy",
29
+ "matplotlib",
30
+ "pandas",
31
+ "scikit-learn"
32
+ ]
33
+
34
+ [project.scripts]
35
+ get-temp = "pandaas:extract"
36
+ open-temp = "pandaas:open_folder"
37
+ list-temp = "pandaas:list_files"
38
+
39
+ [tool.setuptools.packages.find]
40
+ where = ["."]
41
+ include = ["pandaas*"]
42
+
43
+ [tool.setuptools.package-data]
44
+ pandaas = ["*.py", "**/*.py"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+