nampy-ml 0.0.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.
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: nampy-ml
3
+ Version: 0.0.1
4
+ Summary: ML Lab programs library showing code
5
+ Author: Vamshi
6
+ License: MIT
7
+ Project-URL: Homepage, https://pypi.org/project/nampy-ml/
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
File without changes
@@ -0,0 +1,10 @@
1
+ from .programs import (
2
+ program1,
3
+ program2,
4
+ program3,
5
+ program4,
6
+ program5,
7
+ program6,
8
+ program7,
9
+ program8,
10
+ )
@@ -0,0 +1,283 @@
1
+ def program1():
2
+ code = """\
3
+ import pandas as pd
4
+ import seaborn as sns
5
+ import matplotlib.pyplot as plt
6
+ from sklearn.datasets import load_iris
7
+
8
+ # 1. Load the Iris dataset
9
+ iris = load_iris()
10
+ df_iris = pd.DataFrame(data=iris.data, columns=iris.feature_names)
11
+ df_iris['species'] = iris.target_names[iris.target]
12
+
13
+ print("Dataset loaded successfully.")
14
+
15
+ # 2. Perform basic data exploration
16
+ print("\\n--- Basic Data Exploration ---")
17
+ print("\\nMissing values:")
18
+ print(df_iris.isnull().sum())
19
+
20
+ print("\\nData types:")
21
+ print(df_iris.dtypes)
22
+
23
+ print("\\nSummary statistics:")
24
+ print(df_iris.describe())
25
+
26
+ # 3. Create visualizations
27
+ print("\\n--- Visualizations ---")
28
+
29
+ # Histograms
30
+ plt.figure(figsize=(12, 8))
31
+ for i, feature in enumerate(iris.feature_names):
32
+ plt.subplot(2, 2, i + 1)
33
+ sns.histplot(df_iris[feature], kde=True)
34
+ plt.title(f'Histogram of {feature}')
35
+ plt.tight_layout()
36
+ plt.show()
37
+
38
+ # Scatter plot
39
+ plt.figure(figsize=(8, 6))
40
+ sns.scatterplot(
41
+ x='sepal length (cm)',
42
+ y='sepal width (cm)',
43
+ hue='species',
44
+ data=df_iris
45
+ )
46
+ plt.title('Scatter Plot of Sepal Length vs. Sepal Width')
47
+ plt.show()
48
+
49
+ # Box plots
50
+ plt.figure(figsize=(12, 8))
51
+ for i, feature in enumerate(iris.feature_names):
52
+ plt.subplot(2, 2, i + 1)
53
+ sns.boxplot(x='species', y=feature, data=df_iris)
54
+ plt.title(f'Box Plot of {feature} by Species')
55
+ plt.tight_layout()
56
+ plt.show()
57
+ """
58
+ print(code)
59
+
60
+
61
+ def program2():
62
+ code = """\
63
+ import pandas as pd
64
+ import numpy as np
65
+ import matplotlib.pyplot as plt
66
+ from sklearn.linear_model import LinearRegression
67
+ from sklearn.metrics import mean_squared_error, r2_score
68
+
69
+ url = "https://raw.githubusercontent.com/selva86/datasets/master/BostonHousing.csv"
70
+ df = pd.read_csv(url)
71
+
72
+ print(df.head())
73
+ print(df.info())
74
+ print(df.describe())
75
+
76
+ X = df[['rm']]
77
+ y = df['medv']
78
+
79
+ model = LinearRegression()
80
+ model.fit(X, y)
81
+
82
+ print(model.intercept_)
83
+ print(model.coef_[0])
84
+
85
+ y_pred = model.predict(X)
86
+
87
+ print(mean_squared_error(y, y_pred))
88
+ print(r2_score(y, y_pred))
89
+
90
+ plt.scatter(X, y)
91
+ plt.plot(X, y_pred)
92
+ plt.show()
93
+ """
94
+ print(code)
95
+
96
+
97
+ def program3():
98
+ code = """\
99
+ import numpy as np
100
+ import pandas as pd
101
+ import matplotlib.pyplot as plt
102
+ import seaborn as sns
103
+ from sklearn.datasets import load_breast_cancer
104
+ from sklearn.model_selection import train_test_split
105
+ from sklearn.linear_model import LogisticRegression
106
+ from sklearn.metrics import accuracy_score, precision_score, recall_score, confusion_matrix, classification_report
107
+
108
+ data = load_breast_cancer()
109
+ X = data.data
110
+ y = data.target
111
+
112
+ X_train, X_test, y_train, y_test = train_test_split(
113
+ X, y, test_size=0.2, random_state=42, stratify=y
114
+ )
115
+
116
+ model = LogisticRegression(max_iter=10000)
117
+ model.fit(X_train, y_train)
118
+
119
+ y_pred = model.predict(X_test)
120
+
121
+ print(accuracy_score(y_test, y_pred))
122
+ print(precision_score(y_test, y_pred))
123
+ print(recall_score(y_test, y_pred))
124
+ print(confusion_matrix(y_test, y_pred))
125
+ print(classification_report(y_test, y_pred, target_names=data.target_names))
126
+ """
127
+ print(code)
128
+
129
+
130
+ def program4():
131
+ code = """\
132
+ import numpy as np
133
+ import matplotlib.pyplot as plt
134
+ from matplotlib.colors import ListedColormap
135
+ from sklearn import datasets
136
+ from sklearn.model_selection import train_test_split
137
+ from sklearn.preprocessing import StandardScaler
138
+ from sklearn.neighbors import KNeighborsClassifier
139
+ from sklearn.metrics import accuracy_score
140
+
141
+ iris = datasets.load_iris()
142
+ X = iris.data[:, :2]
143
+ y = iris.target
144
+
145
+ X_train, X_test, y_train, y_test = train_test_split(
146
+ X, y, test_size=0.3, random_state=42, stratify=y
147
+ )
148
+
149
+ sc = StandardScaler()
150
+ X_train = sc.fit_transform(X_train)
151
+ X_test = sc.transform(X_test)
152
+
153
+ print("k-NN program for Iris dataset")
154
+ """
155
+ print(code)
156
+
157
+
158
+ def program5():
159
+ code = """\
160
+ from sklearn.datasets import load_iris
161
+ from sklearn.tree import DecisionTreeClassifier, plot_tree, export_text
162
+ from sklearn.model_selection import train_test_split
163
+ from sklearn.metrics import accuracy_score, classification_report
164
+ import matplotlib.pyplot as plt
165
+ import pandas as pd
166
+
167
+ iris = load_iris()
168
+ X = pd.DataFrame(iris.data, columns=iris.feature_names)
169
+ y = pd.Series(iris.target)
170
+
171
+ X_train, X_test, y_train, y_test = train_test_split(
172
+ X, y, test_size=0.3, random_state=42
173
+ )
174
+
175
+ model = DecisionTreeClassifier(criterion="entropy", max_depth=3)
176
+ model.fit(X_train, y_train)
177
+
178
+ y_pred = model.predict(X_test)
179
+
180
+ print(accuracy_score(y_test, y_pred))
181
+ print(classification_report(y_test, y_pred))
182
+ """
183
+ print(code)
184
+
185
+
186
+ def program6():
187
+ code = """\
188
+ from sklearn import datasets
189
+ from sklearn.cluster import KMeans
190
+ from sklearn.preprocessing import StandardScaler
191
+ import matplotlib.pyplot as plt
192
+
193
+ iris = datasets.load_iris()
194
+ X = iris.data
195
+
196
+ scaler = StandardScaler()
197
+ X_scaled = scaler.fit_transform(X)
198
+
199
+ kmeans = KMeans(n_clusters=3, random_state=42)
200
+ kmeans.fit(X_scaled)
201
+
202
+ print(kmeans.cluster_centers_)
203
+ """
204
+ print(code)
205
+
206
+
207
+ def program7():
208
+ code = """\
209
+ from sklearn import datasets
210
+ from sklearn.model_selection import train_test_split
211
+ from sklearn.preprocessing import StandardScaler
212
+ from sklearn.svm import SVC
213
+ from sklearn.metrics import accuracy_score
214
+
215
+ digits = datasets.load_digits()
216
+
217
+ X_train, X_test, y_train, y_test = train_test_split(
218
+ digits.data, digits.target, test_size=0.3, random_state=42
219
+ )
220
+
221
+ sc = StandardScaler()
222
+ X_train = sc.fit_transform(X_train)
223
+ X_test = sc.transform(X_test)
224
+
225
+ svm = SVC(kernel="rbf", gamma=0.05, C=10)
226
+ svm.fit(X_train, y_train)
227
+
228
+ print("SVM program")
229
+ """
230
+ print(code)
231
+
232
+
233
+ def program8():
234
+ code = """\
235
+ from sklearn.datasets import fetch_openml
236
+ from sklearn.decomposition import PCA
237
+ from sklearn.preprocessing import StandardScaler
238
+ import matplotlib.pyplot as plt
239
+ import numpy as np
240
+
241
+ mnist = fetch_openml("mnist_784", version=1)
242
+ X = mnist.data
243
+ y = mnist.target.astype(int)
244
+
245
+ scaler = StandardScaler()
246
+ X_scaled = scaler.fit_transform(X)
247
+
248
+ pca = PCA(n_components=50)
249
+ X_pca = pca.fit_transform(X_scaled)
250
+
251
+ print("PCA on MNIST")
252
+ """
253
+ print(code)
254
+
255
+
256
+ def main():
257
+ print("Choose program:")
258
+ print("1 - Program 1")
259
+ print("2 - Program 2")
260
+ print("3 - Program 3")
261
+ print("4 - Program 4")
262
+ print("5 - Program 5")
263
+ print("6 - Program 6")
264
+ print("7 - Program 7")
265
+ print("8 - Program 8")
266
+
267
+ choice = input("Enter number: ")
268
+
269
+ programs = {
270
+ "1": program1,
271
+ "2": program2,
272
+ "3": program3,
273
+ "4": program4,
274
+ "5": program5,
275
+ "6": program6,
276
+ "7": program7,
277
+ "8": program8,
278
+ }
279
+
280
+ if choice in programs:
281
+ programs[choice]()
282
+ else:
283
+ print("Invalid choice")
File without changes
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: nampy-ml
3
+ Version: 0.0.1
4
+ Summary: ML Lab programs library showing code
5
+ Author: Vamshi
6
+ License: MIT
7
+ Project-URL: Homepage, https://pypi.org/project/nampy-ml/
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ nampy/__init__.py
4
+ nampy/programs.py
5
+ nampy/programs_old.py
6
+ nampy_ml.egg-info/PKG-INFO
7
+ nampy_ml.egg-info/SOURCES.txt
8
+ nampy_ml.egg-info/dependency_links.txt
9
+ nampy_ml.egg-info/entry_points.txt
10
+ nampy_ml.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ nampy-cli = nampy.programs:main
@@ -0,0 +1 @@
1
+ nampy
@@ -0,0 +1,18 @@
1
+ [build-system]
2
+ requires = ["setuptools", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "nampy-ml"
7
+ version = "0.0.1"
8
+ description = "ML Lab programs library showing code"
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ authors = [{ name = "Vamshi" }]
12
+ requires-python = ">=3.8"
13
+
14
+ [project.urls]
15
+ Homepage = "https://pypi.org/project/nampy-ml/"
16
+
17
+ [project.scripts]
18
+ nampy-cli = "nampy.programs:main"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+