tommy-lab 0.1.0__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jothi Sai M
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,112 @@
1
+ Metadata-Version: 2.4
2
+ Name: tommy-lab
3
+ Version: 0.1.0
4
+ Summary: Data Analytics Laboratory Practice Toolkit
5
+ Author: Jothi Sai M
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: numpy
11
+ Requires-Dist: matplotlib
12
+ Requires-Dist: scikit-learn
13
+ Requires-Dist: pandas
14
+ Requires-Dist: seaborn
15
+ Requires-Dist: torch
16
+ Requires-Dist: torchvision
17
+ Requires-Dist: pillow
18
+ Dynamic: license-file
19
+
20
+ # Tommy Lab
21
+
22
+ A Python toolkit for practising Data Analytics laboratory experiments.
23
+
24
+ This package is a renamed/repackaged continuation of the Gomma Lab project. Original project attribution is retained.
25
+
26
+ ## Experiments
27
+
28
+ 1. Gradient Descent
29
+ 2. Linear and Binary Search
30
+ 3. K-Means Clustering
31
+ 4. SVM Classification
32
+ 5. Image Classification using ResNet50
33
+ 6. LSTM Time Series Prediction
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ pip install tommy-lab
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ Display all six complete experiment programs:
44
+
45
+ ```bash
46
+ tommy-lab
47
+ ```
48
+
49
+ The command prints each experiment's source code, including its execution block. Copy the relevant experiment into a Google Colab code cell and run it.
50
+
51
+ ## Requirements
52
+
53
+ Python 3.9 or later. Dependencies are listed in `pyproject.toml`.
54
+
55
+ CNN and LSTM experiments require PyTorch. The CNN experiment downloads pretrained ResNet50 weights on first use and its upload example is designed for Google Colab.
56
+
57
+ ## Individual experiment usage
58
+
59
+ ### Gradient Descent
60
+
61
+ ```python
62
+ from gomma_lab.gradient import gradient_descent, plot_gradient
63
+
64
+ history = gradient_descent()
65
+ plot_gradient(history)
66
+ ```
67
+
68
+ ### Searching Techniques
69
+
70
+ ```python
71
+ from gomma_lab.searching import linear_search, binary_search
72
+
73
+ arr = [10, 20, 30, 40, 50]
74
+ print(linear_search(arr, 30))
75
+ print(binary_search(arr, 30))
76
+ ```
77
+
78
+ ### K-Means Clustering
79
+
80
+ ```python
81
+ from gomma_lab.clustering import kmeans_clustering
82
+
83
+ kmeans_clustering()
84
+ ```
85
+
86
+ ### SVM Classification
87
+
88
+ ```python
89
+ from gomma_lab.classification import svm_classification
90
+
91
+ svm_classification()
92
+ ```
93
+
94
+ ### Image Classification
95
+
96
+ ```python
97
+ from gomma_lab.cnn import classify_image
98
+
99
+ classify_image("image.jpg")
100
+ ```
101
+
102
+ ### LSTM Time Series Prediction
103
+
104
+ ```python
105
+ from gomma_lab.lstm import lstm_prediction
106
+
107
+ lstm_prediction()
108
+ ```
109
+
110
+ ## License
111
+
112
+ This project is distributed under the MIT License. See `LICENSE`.
@@ -0,0 +1,93 @@
1
+ # Tommy Lab
2
+
3
+ A Python toolkit for practising Data Analytics laboratory experiments.
4
+
5
+ This package is a renamed/repackaged continuation of the Gomma Lab project. Original project attribution is retained.
6
+
7
+ ## Experiments
8
+
9
+ 1. Gradient Descent
10
+ 2. Linear and Binary Search
11
+ 3. K-Means Clustering
12
+ 4. SVM Classification
13
+ 5. Image Classification using ResNet50
14
+ 6. LSTM Time Series Prediction
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ pip install tommy-lab
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ Display all six complete experiment programs:
25
+
26
+ ```bash
27
+ tommy-lab
28
+ ```
29
+
30
+ The command prints each experiment's source code, including its execution block. Copy the relevant experiment into a Google Colab code cell and run it.
31
+
32
+ ## Requirements
33
+
34
+ Python 3.9 or later. Dependencies are listed in `pyproject.toml`.
35
+
36
+ CNN and LSTM experiments require PyTorch. The CNN experiment downloads pretrained ResNet50 weights on first use and its upload example is designed for Google Colab.
37
+
38
+ ## Individual experiment usage
39
+
40
+ ### Gradient Descent
41
+
42
+ ```python
43
+ from gomma_lab.gradient import gradient_descent, plot_gradient
44
+
45
+ history = gradient_descent()
46
+ plot_gradient(history)
47
+ ```
48
+
49
+ ### Searching Techniques
50
+
51
+ ```python
52
+ from gomma_lab.searching import linear_search, binary_search
53
+
54
+ arr = [10, 20, 30, 40, 50]
55
+ print(linear_search(arr, 30))
56
+ print(binary_search(arr, 30))
57
+ ```
58
+
59
+ ### K-Means Clustering
60
+
61
+ ```python
62
+ from gomma_lab.clustering import kmeans_clustering
63
+
64
+ kmeans_clustering()
65
+ ```
66
+
67
+ ### SVM Classification
68
+
69
+ ```python
70
+ from gomma_lab.classification import svm_classification
71
+
72
+ svm_classification()
73
+ ```
74
+
75
+ ### Image Classification
76
+
77
+ ```python
78
+ from gomma_lab.cnn import classify_image
79
+
80
+ classify_image("image.jpg")
81
+ ```
82
+
83
+ ### LSTM Time Series Prediction
84
+
85
+ ```python
86
+ from gomma_lab.lstm import lstm_prediction
87
+
88
+ lstm_prediction()
89
+ ```
90
+
91
+ ## License
92
+
93
+ This project is distributed under the MIT License. See `LICENSE`.
@@ -0,0 +1 @@
1
+ """Data Analytics Laboratory Practice Toolkit."""
@@ -0,0 +1,45 @@
1
+ import matplotlib.pyplot as plt
2
+ import seaborn as sns
3
+
4
+ from sklearn.datasets import load_iris
5
+ from sklearn.model_selection import train_test_split
6
+ from sklearn.svm import SVC
7
+ from sklearn.metrics import accuracy_score, confusion_matrix
8
+
9
+
10
+ def svm_classification(test_size=0.3, kernel="linear"):
11
+ iris = load_iris()
12
+
13
+ X = iris.data
14
+ y = iris.target
15
+
16
+ X_train, X_test, y_train, y_test = train_test_split(
17
+ X, y, test_size=test_size, random_state=42
18
+ )
19
+
20
+ model = SVC(kernel=kernel)
21
+ model.fit(X_train, y_train)
22
+
23
+ y_pred = model.predict(X_test)
24
+
25
+ accuracy = accuracy_score(y_test, y_pred)
26
+ print("Accuracy:", accuracy)
27
+
28
+ cm = confusion_matrix(y_test, y_pred)
29
+
30
+ sns.heatmap(
31
+ cm, annot=True, fmt="d",
32
+ xticklabels=iris.target_names,
33
+ yticklabels=iris.target_names
34
+ )
35
+
36
+ plt.xlabel("Predicted")
37
+ plt.ylabel("Actual")
38
+ plt.title("SVM Classification")
39
+ plt.show()
40
+
41
+ return accuracy
42
+
43
+
44
+ if __name__ == "__main__":
45
+ svm_classification()
@@ -0,0 +1,27 @@
1
+ from importlib.resources import files
2
+
3
+ EXPERIMENTS = [
4
+ ("EXPERIMENT 1 - GRADIENT DESCENT", "gradient.py"),
5
+ ("EXPERIMENT 2 - SEARCHING TECHNIQUES", "searching.py"),
6
+ ("EXPERIMENT 3 - K-MEANS CLUSTERING", "clustering.py"),
7
+ ("EXPERIMENT 4 - SVM CLASSIFICATION", "classification.py"),
8
+ ("EXPERIMENT 5 - CNN IMAGE CLASSIFICATION", "cnn.py"),
9
+ ("EXPERIMENT 6 - LSTM TIME SERIES PREDICTION", "lstm.py"),
10
+ ]
11
+
12
+
13
+ def main():
14
+ package = files("gomma_lab")
15
+
16
+ for title, filename in EXPERIMENTS:
17
+ print("\\n" + "=" * 70)
18
+ print(title)
19
+ print("=" * 70 + "\\n")
20
+
21
+ code = package.joinpath(filename).read_text(encoding="utf-8")
22
+ print(code)
23
+ print("\\n" + "=" * 70)
24
+
25
+
26
+ if __name__ == "__main__":
27
+ main()
@@ -0,0 +1,45 @@
1
+ import numpy as np
2
+ import matplotlib.pyplot as plt
3
+ from sklearn.datasets import make_blobs
4
+
5
+ def kmeans_clustering(k=3, samples=500, iterations=10):
6
+ X, _ = make_blobs(
7
+ n_samples=samples,
8
+ centers=k,
9
+ n_features=2,
10
+ random_state=23
11
+ )
12
+
13
+ rng = np.random.default_rng(23)
14
+ centers = X[rng.choice(len(X), k, replace=False)].copy()
15
+
16
+ for i in range(iterations):
17
+ distances = np.linalg.norm(
18
+ X[:, None] - centers[None, :], axis=2
19
+ )
20
+ labels = np.argmin(distances, axis=1)
21
+
22
+ for j in range(k):
23
+ if np.any(labels == j):
24
+ centers[j] = X[labels == j].mean(axis=0)
25
+
26
+ distances = np.linalg.norm(
27
+ X[:, None] - centers[None, :], axis=2
28
+ )
29
+ labels = np.argmin(distances, axis=1)
30
+
31
+ plt.scatter(X[:, 0], X[:, 1], c=labels)
32
+ plt.scatter(
33
+ centers[:, 0], centers[:, 1],
34
+ marker="*", c="red", s=200
35
+ )
36
+ plt.title("K-Means Clustering")
37
+ plt.show()
38
+
39
+ return centers, labels
40
+
41
+
42
+ if __name__ == "__main__":
43
+ centers, labels = kmeans_clustering()
44
+ print("Cluster Centers:")
45
+ print(centers)
@@ -0,0 +1,34 @@
1
+ import torch
2
+ from torchvision import models
3
+ from PIL import Image
4
+
5
+
6
+ def classify_image(image_path):
7
+ # Load pretrained ResNet50 model
8
+ weights = models.ResNet50_Weights.DEFAULT
9
+ model = models.resnet50(weights=weights)
10
+ model.eval()
11
+
12
+ # Preprocess image
13
+ transform = weights.transforms()
14
+ image = Image.open(image_path).convert("RGB")
15
+ image_tensor = transform(image).unsqueeze(0)
16
+
17
+ # Predict image
18
+ with torch.no_grad():
19
+ output = model(image_tensor)
20
+
21
+ predicted = output.argmax(dim=1).item()
22
+ labels = weights.meta["categories"]
23
+
24
+ print("Predicted Label:", labels[predicted])
25
+
26
+ return labels[predicted]
27
+
28
+
29
+ if __name__ == "__main__":
30
+ from google.colab import files
31
+
32
+ uploaded = files.upload()
33
+ image_path = next(iter(uploaded.keys()))
34
+ classify_image(image_path)
@@ -0,0 +1,32 @@
1
+ import numpy as np
2
+ import matplotlib.pyplot as plt
3
+
4
+ def gradient_descent(x=8, y=8, lr=0.1, iterations=20):
5
+ history = []
6
+
7
+ for i in range(iterations):
8
+ x = x - lr * 2 * x
9
+ y = y - lr * 2 * y
10
+ history.append((x, y))
11
+
12
+ print("Minimum x:", x)
13
+ print("Minimum y:", y)
14
+ print("Minimum value:", x**2 + y**2)
15
+
16
+ return history
17
+
18
+
19
+ def plot_gradient(history):
20
+ points = np.array(history)
21
+ plt.plot(points[:, 0], label="X")
22
+ plt.plot(points[:, 1], label="Y")
23
+ plt.xlabel("Iterations")
24
+ plt.ylabel("Values")
25
+ plt.title("Gradient Descent")
26
+ plt.legend()
27
+ plt.show()
28
+
29
+
30
+ if __name__ == "__main__":
31
+ history = gradient_descent()
32
+ plot_gradient(history)
@@ -0,0 +1,55 @@
1
+ import numpy as np
2
+ import matplotlib.pyplot as plt
3
+ import torch
4
+ import torch.nn as nn
5
+
6
+
7
+ class LSTMModel(nn.Module):
8
+ def __init__(self):
9
+ super().__init__()
10
+ self.lstm = nn.LSTM(1, 64, 2, batch_first=True)
11
+ self.linear = nn.Linear(64, 1)
12
+
13
+ def forward(self, x):
14
+ out, _ = self.lstm(x)
15
+ return self.linear(out[:, -1, :])
16
+
17
+
18
+ def lstm_prediction(epochs=30):
19
+ data = np.sin(np.linspace(0, 100, 1000))
20
+
21
+ X, y = [], []
22
+ for i in range(len(data) - 50):
23
+ X.append(data[i:i+50])
24
+ y.append(data[i+50])
25
+
26
+ X = torch.tensor(np.array(X), dtype=torch.float32).unsqueeze(-1)
27
+ y = torch.tensor(np.array(y), dtype=torch.float32).unsqueeze(-1)
28
+
29
+ model = LSTMModel()
30
+ criterion = nn.MSELoss()
31
+ optimizer = torch.optim.Adam(model.parameters(), lr=0.001)
32
+
33
+ for epoch in range(epochs):
34
+ optimizer.zero_grad()
35
+ output = model(X)
36
+ loss = criterion(output, y)
37
+ loss.backward()
38
+ optimizer.step()
39
+ print("Epoch:", epoch+1, "Loss:", loss.item())
40
+
41
+ model.eval()
42
+ with torch.no_grad():
43
+ prediction = model(X[-1].unsqueeze(0))
44
+
45
+ print("Predicted value:", prediction.item())
46
+
47
+ plt.plot(data)
48
+ plt.title("LSTM Time Series Prediction")
49
+ plt.show()
50
+
51
+ return prediction.item()
52
+
53
+
54
+ if __name__ == "__main__":
55
+ lstm_prediction()
@@ -0,0 +1,33 @@
1
+ def linear_search(arr, target):
2
+ for i in range(len(arr)):
3
+ if arr[i] == target:
4
+ return i
5
+ return -1
6
+
7
+
8
+ def binary_search(arr, target):
9
+ arr = sorted(arr)
10
+ low = 0
11
+ high = len(arr) - 1
12
+
13
+ while low <= high:
14
+ mid = (low + high) // 2
15
+
16
+ if arr[mid] == target:
17
+ return mid
18
+ elif arr[mid] < target:
19
+ low = mid + 1
20
+ else:
21
+ high = mid - 1
22
+
23
+ return -1
24
+
25
+
26
+ if __name__ == "__main__":
27
+ arr = [10, 20, 30, 40, 50]
28
+ target = 30
29
+
30
+ print("Array:", arr)
31
+ print("Target:", target)
32
+ print("Linear Search Result:", linear_search(arr, target))
33
+ print("Binary Search Result:", binary_search(arr, target))
@@ -0,0 +1,30 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "tommy-lab"
7
+ version = "0.1.0"
8
+ description = "Data Analytics Laboratory Practice Toolkit"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "MIT"
12
+ authors = [
13
+ {name = "Jothi Sai M"}
14
+ ]
15
+ dependencies = [
16
+ "numpy",
17
+ "matplotlib",
18
+ "scikit-learn",
19
+ "pandas",
20
+ "seaborn",
21
+ "torch",
22
+ "torchvision",
23
+ "pillow"
24
+ ]
25
+
26
+ [tool.setuptools.packages.find]
27
+ include = ["gomma_lab*"]
28
+
29
+ [project.scripts]
30
+ tommy-lab = "gomma_lab.cli:main"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.4
2
+ Name: tommy-lab
3
+ Version: 0.1.0
4
+ Summary: Data Analytics Laboratory Practice Toolkit
5
+ Author: Jothi Sai M
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: numpy
11
+ Requires-Dist: matplotlib
12
+ Requires-Dist: scikit-learn
13
+ Requires-Dist: pandas
14
+ Requires-Dist: seaborn
15
+ Requires-Dist: torch
16
+ Requires-Dist: torchvision
17
+ Requires-Dist: pillow
18
+ Dynamic: license-file
19
+
20
+ # Tommy Lab
21
+
22
+ A Python toolkit for practising Data Analytics laboratory experiments.
23
+
24
+ This package is a renamed/repackaged continuation of the Gomma Lab project. Original project attribution is retained.
25
+
26
+ ## Experiments
27
+
28
+ 1. Gradient Descent
29
+ 2. Linear and Binary Search
30
+ 3. K-Means Clustering
31
+ 4. SVM Classification
32
+ 5. Image Classification using ResNet50
33
+ 6. LSTM Time Series Prediction
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ pip install tommy-lab
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ Display all six complete experiment programs:
44
+
45
+ ```bash
46
+ tommy-lab
47
+ ```
48
+
49
+ The command prints each experiment's source code, including its execution block. Copy the relevant experiment into a Google Colab code cell and run it.
50
+
51
+ ## Requirements
52
+
53
+ Python 3.9 or later. Dependencies are listed in `pyproject.toml`.
54
+
55
+ CNN and LSTM experiments require PyTorch. The CNN experiment downloads pretrained ResNet50 weights on first use and its upload example is designed for Google Colab.
56
+
57
+ ## Individual experiment usage
58
+
59
+ ### Gradient Descent
60
+
61
+ ```python
62
+ from gomma_lab.gradient import gradient_descent, plot_gradient
63
+
64
+ history = gradient_descent()
65
+ plot_gradient(history)
66
+ ```
67
+
68
+ ### Searching Techniques
69
+
70
+ ```python
71
+ from gomma_lab.searching import linear_search, binary_search
72
+
73
+ arr = [10, 20, 30, 40, 50]
74
+ print(linear_search(arr, 30))
75
+ print(binary_search(arr, 30))
76
+ ```
77
+
78
+ ### K-Means Clustering
79
+
80
+ ```python
81
+ from gomma_lab.clustering import kmeans_clustering
82
+
83
+ kmeans_clustering()
84
+ ```
85
+
86
+ ### SVM Classification
87
+
88
+ ```python
89
+ from gomma_lab.classification import svm_classification
90
+
91
+ svm_classification()
92
+ ```
93
+
94
+ ### Image Classification
95
+
96
+ ```python
97
+ from gomma_lab.cnn import classify_image
98
+
99
+ classify_image("image.jpg")
100
+ ```
101
+
102
+ ### LSTM Time Series Prediction
103
+
104
+ ```python
105
+ from gomma_lab.lstm import lstm_prediction
106
+
107
+ lstm_prediction()
108
+ ```
109
+
110
+ ## License
111
+
112
+ This project is distributed under the MIT License. See `LICENSE`.
@@ -0,0 +1,17 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ gomma_lab/__init__.py
5
+ gomma_lab/classification.py
6
+ gomma_lab/cli.py
7
+ gomma_lab/clustering.py
8
+ gomma_lab/cnn.py
9
+ gomma_lab/gradient.py
10
+ gomma_lab/lstm.py
11
+ gomma_lab/searching.py
12
+ tommy_lab.egg-info/PKG-INFO
13
+ tommy_lab.egg-info/SOURCES.txt
14
+ tommy_lab.egg-info/dependency_links.txt
15
+ tommy_lab.egg-info/entry_points.txt
16
+ tommy_lab.egg-info/requires.txt
17
+ tommy_lab.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ tommy-lab = gomma_lab.cli:main
@@ -0,0 +1,8 @@
1
+ numpy
2
+ matplotlib
3
+ scikit-learn
4
+ pandas
5
+ seaborn
6
+ torch
7
+ torchvision
8
+ pillow
@@ -0,0 +1 @@
1
+ gomma_lab