scikit-tools 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,19 @@
1
+ Metadata-Version: 2.4
2
+ Name: scikit-tools
3
+ Version: 0.1.0
4
+ Summary: Clean, streamlined Data Science and Machine Learning toolkit with direct topic names
5
+ Author-email: Your Name <your.email@example.com>
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Operating System :: OS Independent
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: pandas
12
+ Requires-Dist: numpy
13
+ Requires-Dist: matplotlib
14
+ Requires-Dist: seaborn
15
+ Requires-Dist: scipy
16
+ Requires-Dist: scikit-learn
17
+
18
+ # scikit-tools
19
+ A clean, streamlined scientific data science toolkit with self-contained dataset fetching and direct topic interfaces.
@@ -0,0 +1,2 @@
1
+ # scikit-tools
2
+ A clean, streamlined scientific data science toolkit with self-contained dataset fetching and direct topic interfaces.
@@ -0,0 +1,29 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "scikit-tools"
7
+ version = "0.1.0"
8
+ description = "Clean, streamlined Data Science and Machine Learning toolkit with direct topic names"
9
+ authors = [
10
+ { name="Your Name", email="your.email@example.com" }
11
+ ]
12
+ readme = "README.md"
13
+ requires-python = ">=3.8"
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ ]
19
+ dependencies = [
20
+ "pandas",
21
+ "numpy",
22
+ "matplotlib",
23
+ "seaborn",
24
+ "scipy",
25
+ "scikit-learn"
26
+ ]
27
+
28
+ [tool.setuptools.packages.find]
29
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ from .solutions import *
@@ -0,0 +1,186 @@
1
+ import pandas as pd
2
+ import numpy as np
3
+ import matplotlib.pyplot as plt
4
+ import seaborn as sns
5
+ from scipy import stats
6
+ from sklearn.preprocessing import StandardScaler
7
+ from sklearn.decomposition import PCA
8
+ from sklearn.model_selection import train_test_split
9
+ from sklearn.linear_model import LinearRegression, LogisticRegression
10
+ from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, confusion_matrix
11
+ from sklearn.cluster import KMeans
12
+ import os
13
+
14
+ def ensure_dataset(filepath='iris.csv'):
15
+ """Ensures that the local dataset exists. If not, automatically downloads and formats it."""
16
+ if not os.path.exists(filepath):
17
+ url = 'https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv'
18
+ df = pd.read_csv(url)
19
+ df.columns = ['SepalLengthCm', 'SepalWidthCm', 'PetalLengthCm', 'PetalWidthCm', 'Species']
20
+ df['Species'] = df['Species'].map(lambda x: f"Iris-{x}")
21
+ df.to_csv(filepath, index=False)
22
+
23
+ def numpy_stats(filepath='iris.csv'):
24
+ """Topic 1: Basic numerical operations and statistics using NumPy."""
25
+ ensure_dataset(filepath)
26
+ df = pd.read_csv(filepath)
27
+ sepal_length = df['SepalLengthCm'].to_numpy()
28
+ return {
29
+ 'sum': np.sum(sepal_length),
30
+ 'mean': np.mean(sepal_length),
31
+ 'max': np.max(sepal_length),
32
+ 'min': np.min(sepal_length),
33
+ 'first_five': sepal_length[:5]
34
+ }
35
+
36
+ def inspect_dataset(filepath='iris.csv'):
37
+ """Topic 2: Load DataFrame and inspect its structure, columns, and shape."""
38
+ ensure_dataset(filepath)
39
+ df = pd.read_csv(filepath)
40
+ return {
41
+ 'head': df.head(),
42
+ 'shape': df.shape,
43
+ 'dtypes': df.dtypes,
44
+ 'description': df.describe()
45
+ }
46
+
47
+ def handle_missing_values(filepath='iris.csv'):
48
+ """Topic 3: Introduce mock missing values and handle them using median and mode."""
49
+ ensure_dataset(filepath)
50
+ df_copy = pd.read_csv(filepath).copy()
51
+ df_copy.loc[[5, 10, 15], 'SepalLengthCm'] = np.nan
52
+ df_copy.loc[[20, 25], 'Species'] = np.nan
53
+
54
+ median_sepal = df_copy['SepalLengthCm'].median()
55
+ df_copy['SepalLengthCm'] = df_copy['SepalLengthCm'].fillna(median_sepal)
56
+ mode_species = df_copy['Species'].mode()[0]
57
+ df_copy['Species'] = df_copy['Species'].fillna(mode_species)
58
+ return df_copy
59
+
60
+ def data_transformation(filepath='iris.csv'):
61
+ """Topic 4: Perform one-hot encoding and standardization (scaling)."""
62
+ ensure_dataset(filepath)
63
+ df = pd.read_csv(filepath)
64
+ df_encoded = pd.get_dummies(df, columns=['Species'])
65
+ num_cols = ['SepalLengthCm', 'SepalWidthCm', 'PetalLengthCm', 'PetalWidthCm']
66
+ scaler = StandardScaler()
67
+ df_encoded[num_cols] = scaler.fit_transform(df_encoded[num_cols])
68
+ return df_encoded
69
+
70
+ def eda_plots(filepath='iris.csv'):
71
+ """Topic 5: Generate and render Histogram and Scatter Plots for EDA."""
72
+ ensure_dataset(filepath)
73
+ df = pd.read_csv(filepath)
74
+ fig, axes = plt.subplots(1, 2, figsize=(14, 5))
75
+ sns.histplot(data=df, x='PetalLengthCm', kde=True, color='skyblue', ax=axes[0])
76
+ axes[0].set_title('Histogram of PetalLengthCm')
77
+ sns.scatterplot(data=df, x='SepalLengthCm', y='PetalLengthCm', hue='Species', palette='Set1', ax=axes[1])
78
+ axes[1].set_title('SepalLengthCm vs PetalLengthCm')
79
+ plt.tight_layout()
80
+ plt.show()
81
+
82
+ def outlier_detection(filepath='iris.csv'):
83
+ """Topic 6: Quantify outliers using Interquartile Range (IQR) bounds."""
84
+ ensure_dataset(filepath)
85
+ df = pd.read_csv(filepath)
86
+ Q1 = df['SepalWidthCm'].quantile(0.25)
87
+ Q3 = df['SepalWidthCm'].quantile(0.75)
88
+ IQR = Q3 - Q1
89
+ lower_bound = Q1 - 1.5 * IQR
90
+ upper_bound = Q3 + 1.5 * IQR
91
+ outliers = df[(df['SepalWidthCm'] < lower_bound) | (df['SepalWidthCm'] > upper_bound)]
92
+ return {
93
+ 'IQR': IQR,
94
+ 'limits': (lower_bound, upper_bound),
95
+ 'outliers': outliers
96
+ }
97
+
98
+ def descriptive_stats(filepath='iris.csv'):
99
+ """Topic 7: Calculate detailed descriptive metrics."""
100
+ ensure_dataset(filepath)
101
+ df = pd.read_csv(filepath)
102
+ attributes = ['SepalLengthCm', 'PetalLengthCm']
103
+ return pd.DataFrame({
104
+ 'Mean': df[attributes].mean(),
105
+ 'Median': df[attributes].median(),
106
+ 'Sample Variance': df[attributes].var(),
107
+ 'Standard Deviation': df[attributes].std()
108
+ })
109
+
110
+ def correlation_covariance(filepath='iris.csv'):
111
+ """Topic 8: Evaluate covariance and Pearson correlation coefficient."""
112
+ ensure_dataset(filepath)
113
+ df = pd.read_csv(filepath)
114
+ return {
115
+ 'covariance': df['PetalLengthCm'].cov(df['PetalWidthCm']),
116
+ 'correlation': df['PetalLengthCm'].corr(df['PetalWidthCm'])
117
+ }
118
+
119
+ def hypothesis_testing(filepath='iris.csv'):
120
+ """Topic 9: Run an independent T-test on SepalLengthCm between Setosa and Versicolor."""
121
+ ensure_dataset(filepath)
122
+ df = pd.read_csv(filepath)
123
+ setosa_sepal = df[df['Species'] == 'Iris-setosa']['SepalLengthCm']
124
+ versicolor_sepal = df[df['Species'] == 'Iris-versicolor']['SepalLengthCm']
125
+ t_stat, p_val = stats.ttest_ind(setosa_sepal, versicolor_sepal, equal_var=False)
126
+ return {'t_statistic': t_stat, 'p_value': p_val}
127
+
128
+ def linear_regression(filepath='iris.csv'):
129
+ """Topic 10: Linear Regression predicting PetalLengthCm."""
130
+ ensure_dataset(filepath)
131
+ df = pd.read_csv(filepath)
132
+ X = df[['SepalLengthCm', 'SepalWidthCm', 'PetalWidthCm']]
133
+ y = df['PetalLengthCm']
134
+ X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
135
+ model = LinearRegression()
136
+ model.fit(X_train, y_train)
137
+ predictions = model.predict(X_test)
138
+ return {
139
+ 'coefficients': {col: coef for col, coef in zip(X.columns, model.coef_)},
140
+ 'intercept': model.intercept_,
141
+ 'predictions': pd.DataFrame({'Actual': y_test, 'Predicted': predictions})
142
+ }
143
+
144
+ def logistic_regression(filepath='iris.csv'):
145
+ """Topic 11: Multi-class Logistic Regression for classification."""
146
+ ensure_dataset(filepath)
147
+ df = pd.read_csv(filepath)
148
+ X = df[['SepalLengthCm', 'SepalWidthCm', 'PetalLengthCm', 'PetalWidthCm']]
149
+ y = df['Species']
150
+ X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
151
+ clf = LogisticRegression(max_iter=200)
152
+ clf.fit(X_train, y_train)
153
+ y_pred = clf.predict(X_test)
154
+ return {
155
+ 'accuracy': accuracy_score(y_test, y_pred),
156
+ 'confusion_matrix': confusion_matrix(y_test, y_pred)
157
+ }
158
+
159
+ def kmeans_clustering(filepath='iris.csv'):
160
+ """Topic 12: Cluster attributes unsupervised using K-Means."""
161
+ ensure_dataset(filepath)
162
+ df = pd.read_csv(filepath)
163
+ X = df[['SepalLengthCm', 'SepalWidthCm', 'PetalLengthCm', 'PetalWidthCm']]
164
+ kmeans = KMeans(n_clusters=3, random_state=42, n_init='auto')
165
+ df['Cluster'] = kmeans.fit_predict(X)
166
+ return df
167
+
168
+ def pca_analysis(filepath='iris.csv'):
169
+ """Topic 13: Standardize, compress with 2-Component PCA, and classify."""
170
+ ensure_dataset(filepath)
171
+ df = pd.read_csv(filepath)
172
+ X = df[['SepalLengthCm', 'SepalWidthCm', 'PetalLengthCm', 'PetalWidthCm']]
173
+ y = df['Species']
174
+ X_scaled = StandardScaler().fit_transform(X)
175
+ pca = PCA(n_components=2)
176
+ X_pca = pca.fit_transform(X_scaled)
177
+ X_train, X_test, y_train, y_test = train_test_split(X_pca, y, test_size=0.2, random_state=42)
178
+ clf = LogisticRegression()
179
+ clf.fit(X_train, y_train)
180
+ y_pred = clf.predict(X_test)
181
+ return {
182
+ 'accuracy': accuracy_score(y_test, y_pred),
183
+ 'precision': precision_score(y_test, y_pred, average='macro'),
184
+ 'recall': recall_score(y_test, y_pred, average='macro'),
185
+ 'f1_score': f1_score(y_test, y_pred, average='macro')
186
+ }
@@ -0,0 +1,19 @@
1
+ Metadata-Version: 2.4
2
+ Name: scikit-tools
3
+ Version: 0.1.0
4
+ Summary: Clean, streamlined Data Science and Machine Learning toolkit with direct topic names
5
+ Author-email: Your Name <your.email@example.com>
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Operating System :: OS Independent
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: pandas
12
+ Requires-Dist: numpy
13
+ Requires-Dist: matplotlib
14
+ Requires-Dist: seaborn
15
+ Requires-Dist: scipy
16
+ Requires-Dist: scikit-learn
17
+
18
+ # scikit-tools
19
+ A clean, streamlined scientific data science toolkit with self-contained dataset fetching and direct topic interfaces.
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/scikit_tools/__init__.py
4
+ src/scikit_tools/solutions.py
5
+ src/scikit_tools.egg-info/PKG-INFO
6
+ src/scikit_tools.egg-info/SOURCES.txt
7
+ src/scikit_tools.egg-info/dependency_links.txt
8
+ src/scikit_tools.egg-info/requires.txt
9
+ src/scikit_tools.egg-info/top_level.txt
@@ -0,0 +1,6 @@
1
+ pandas
2
+ numpy
3
+ matplotlib
4
+ seaborn
5
+ scipy
6
+ scikit-learn
@@ -0,0 +1 @@
1
+ scikit_tools