smilo 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.
- smilo/__init__.py +7 -0
- smilo/clean.py +31 -0
- smilo/split.py +47 -0
- smilo/stats.py +75 -0
- smilo/utils.py +45 -0
- smilo/viz.py +43 -0
- smilo-0.1.0.dist-info/METADATA +51 -0
- smilo-0.1.0.dist-info/RECORD +11 -0
- smilo-0.1.0.dist-info/WHEEL +5 -0
- smilo-0.1.0.dist-info/licenses/LICENSE +0 -0
- smilo-0.1.0.dist-info/top_level.txt +1 -0
smilo/__init__.py
ADDED
smilo/clean.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Smilo Data Cleaning Module
|
|
3
|
+
Author: Fahad
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
def remove_nulls(data):
|
|
7
|
+
"""
|
|
8
|
+
Remove None values from a list.
|
|
9
|
+
"""
|
|
10
|
+
return [item for item in data if item is not None]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def fill_nulls(data, value=0):
|
|
14
|
+
"""
|
|
15
|
+
Replace None values with a specified value.
|
|
16
|
+
"""
|
|
17
|
+
return [value if item is None else item for item in data]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def remove_duplicates(data):
|
|
21
|
+
"""
|
|
22
|
+
Remove duplicate values while preserving order.
|
|
23
|
+
"""
|
|
24
|
+
return list(dict.fromkeys(data))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def remove_empty_strings(data):
|
|
28
|
+
"""
|
|
29
|
+
Remove empty strings from a list.
|
|
30
|
+
"""
|
|
31
|
+
return [item for item in data if item != ""]
|
smilo/split.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Smilo Data Splitting Module
|
|
3
|
+
Author: Fahad
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import random
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def train_test_split(data, test_size=0.2, seed=None):
|
|
10
|
+
"""
|
|
11
|
+
Split a list of data into train and test sets.
|
|
12
|
+
|
|
13
|
+
Parameters:
|
|
14
|
+
data (list): The dataset to split.
|
|
15
|
+
test_size (float): Proportion of data to use as test set (0-1).
|
|
16
|
+
seed (int): Optional random seed for reproducibility.
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
tuple: (train_data, test_data)
|
|
20
|
+
"""
|
|
21
|
+
if seed is not None:
|
|
22
|
+
random.seed(seed)
|
|
23
|
+
|
|
24
|
+
shuffled = data.copy()
|
|
25
|
+
random.shuffle(shuffled)
|
|
26
|
+
|
|
27
|
+
split_index = int(len(shuffled) * (1 - test_size))
|
|
28
|
+
train_data = shuffled[:split_index]
|
|
29
|
+
test_data = shuffled[split_index:]
|
|
30
|
+
|
|
31
|
+
return train_data, test_data
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def k_fold_split(data, k=5):
|
|
35
|
+
"""
|
|
36
|
+
Split data into k equal-sized folds for cross-validation.
|
|
37
|
+
|
|
38
|
+
Parameters:
|
|
39
|
+
data (list): The dataset to split.
|
|
40
|
+
k (int): Number of folds.
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
list of lists: k folds of data.
|
|
44
|
+
"""
|
|
45
|
+
fold_size = len(data) // k
|
|
46
|
+
folds = [data[i * fold_size:(i + 1) * fold_size] for i in range(k)]
|
|
47
|
+
return folds
|
smilo/stats.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Smilo Statistics Module
|
|
3
|
+
Author: Fahad
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from collections import Counter
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def mean(data):
|
|
10
|
+
"""Return the average of a list."""
|
|
11
|
+
if not data:
|
|
12
|
+
raise ValueError("Data cannot be empty.")
|
|
13
|
+
return sum(data) / len(data)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def median(data):
|
|
17
|
+
"""Return the median of a list."""
|
|
18
|
+
if not data:
|
|
19
|
+
raise ValueError("Data cannot be empty.")
|
|
20
|
+
|
|
21
|
+
data = sorted(data)
|
|
22
|
+
n = len(data)
|
|
23
|
+
mid = n // 2
|
|
24
|
+
|
|
25
|
+
if n % 2 == 0:
|
|
26
|
+
return (data[mid - 1] + data[mid]) / 2
|
|
27
|
+
return data[mid]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def mode(data):
|
|
31
|
+
"""Return the most frequent value."""
|
|
32
|
+
if not data:
|
|
33
|
+
raise ValueError("Data cannot be empty.")
|
|
34
|
+
|
|
35
|
+
count = Counter(data)
|
|
36
|
+
return count.most_common(1)[0][0]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def minimum(data):
|
|
40
|
+
"""Return the minimum value."""
|
|
41
|
+
return min(data)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def maximum(data):
|
|
45
|
+
"""Return the maximum value."""
|
|
46
|
+
return max(data)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def data_range(data):
|
|
50
|
+
"""Return the range (max - min)."""
|
|
51
|
+
return max(data) - min(data)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def total(data):
|
|
55
|
+
"""Return the sum of all values."""
|
|
56
|
+
return sum(data)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def count(data):
|
|
60
|
+
"""Return the number of values."""
|
|
61
|
+
return len(data)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def variance(data):
|
|
65
|
+
"""Return the population variance."""
|
|
66
|
+
if not data:
|
|
67
|
+
raise ValueError("Data cannot be empty.")
|
|
68
|
+
|
|
69
|
+
avg = mean(data)
|
|
70
|
+
return sum((x - avg) ** 2 for x in data) / len(data)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def standard_deviation(data):
|
|
74
|
+
"""Return the population standard deviation."""
|
|
75
|
+
return variance(data) ** 0.5
|
smilo/utils.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Smilo Utilities Module
|
|
3
|
+
Author: Fahad
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import pandas as pd
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def load_csv(filepath):
|
|
10
|
+
"""
|
|
11
|
+
Load a CSV file into a pandas DataFrame.
|
|
12
|
+
|
|
13
|
+
Parameters:
|
|
14
|
+
filepath (str): Path to the CSV file.
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
pd.DataFrame: Loaded data.
|
|
18
|
+
"""
|
|
19
|
+
return pd.read_csv(filepath)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def dataset_info(df):
|
|
23
|
+
"""
|
|
24
|
+
Print a quick summary of a DataFrame: shape, columns, missing values.
|
|
25
|
+
|
|
26
|
+
Parameters:
|
|
27
|
+
df (pd.DataFrame): The dataset to inspect.
|
|
28
|
+
"""
|
|
29
|
+
print(f"Shape: {df.shape}")
|
|
30
|
+
print(f"Columns: {list(df.columns)}")
|
|
31
|
+
print("Missing values per column:")
|
|
32
|
+
print(df.isnull().sum())
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def column_types(df):
|
|
36
|
+
"""
|
|
37
|
+
Return a dictionary of column names and their data types.
|
|
38
|
+
|
|
39
|
+
Parameters:
|
|
40
|
+
df (pd.DataFrame): The dataset to inspect.
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
dict: {column_name: dtype}
|
|
44
|
+
"""
|
|
45
|
+
return df.dtypes.astype(str).to_dict()
|
smilo/viz.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Smilo Visualization Module
|
|
3
|
+
Author: Fahad
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import matplotlib.pyplot as plt
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def quick_hist(data, column, bins=20, title=None):
|
|
10
|
+
"""
|
|
11
|
+
Plot a quick histogram for a DataFrame column.
|
|
12
|
+
|
|
13
|
+
Parameters:
|
|
14
|
+
data (pd.DataFrame): The dataset.
|
|
15
|
+
column (str): Column name to plot.
|
|
16
|
+
bins (int): Number of histogram bins.
|
|
17
|
+
title (str): Optional plot title.
|
|
18
|
+
"""
|
|
19
|
+
plt.figure(figsize=(8, 5))
|
|
20
|
+
plt.hist(data[column].dropna(), bins=bins, color="skyblue", edgecolor="black")
|
|
21
|
+
plt.title(title or f"Distribution of {column}")
|
|
22
|
+
plt.xlabel(column)
|
|
23
|
+
plt.ylabel("Frequency")
|
|
24
|
+
plt.show()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def quick_corr(data, title="Correlation Heatmap"):
|
|
28
|
+
"""
|
|
29
|
+
Plot a correlation heatmap for numeric columns in a DataFrame.
|
|
30
|
+
|
|
31
|
+
Parameters:
|
|
32
|
+
data (pd.DataFrame): The dataset.
|
|
33
|
+
title (str): Plot title.
|
|
34
|
+
"""
|
|
35
|
+
corr = data.corr(numeric_only=True)
|
|
36
|
+
plt.figure(figsize=(8, 6))
|
|
37
|
+
plt.imshow(corr, cmap="coolwarm", interpolation="none")
|
|
38
|
+
plt.colorbar()
|
|
39
|
+
plt.xticks(range(len(corr.columns)), corr.columns, rotation=90)
|
|
40
|
+
plt.yticks(range(len(corr.columns)), corr.columns)
|
|
41
|
+
plt.title(title)
|
|
42
|
+
plt.tight_layout()
|
|
43
|
+
plt.show()
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: smilo
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A beginner-friendly Python data analysis library.
|
|
5
|
+
Author-email: Fahad <dr.fahad1001@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/yourusername/smilo
|
|
8
|
+
Project-URL: Repository, https://github.com/yourusername/smilo
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: numpy>=1.24
|
|
13
|
+
Requires-Dist: pandas>=2.0
|
|
14
|
+
Requires-Dist: matplotlib>=3.7
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# smilo
|
|
18
|
+
|
|
19
|
+
A beginner-friendly Python data analysis library for cleaning, splitting, exploring, and visualizing data.
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
pip install smilo
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
from smilo.clean import remove_nulls
|
|
28
|
+
from smilo.split import train_test_split
|
|
29
|
+
from smilo.stats import mean, median, standard_deviation
|
|
30
|
+
from smilo.utils import load_csv, dataset_info
|
|
31
|
+
from smilo.viz import quick_hist
|
|
32
|
+
|
|
33
|
+
data = [1, None, 2, None, 3]
|
|
34
|
+
clean_data = remove_nulls(data)
|
|
35
|
+
print(clean_data) # [1, 2, 3]
|
|
36
|
+
|
|
37
|
+
train, test = train_test_split([1,2,3,4,5,6,7,8,9,10], test_size=0.2, seed=42)
|
|
38
|
+
|
|
39
|
+
print(mean([1, 2, 3, 4, 5])) # 3.0
|
|
40
|
+
|
|
41
|
+
## Modules
|
|
42
|
+
|
|
43
|
+
- **clean.py** — remove_nulls, fill_nulls, remove_duplicates, remove_empty_strings
|
|
44
|
+
- **split.py** — train_test_split, k_fold_split
|
|
45
|
+
- **stats.py** — mean, median, mode, minimum, maximum, data_range, total, count, variance, standard_deviation
|
|
46
|
+
- **utils.py** — load_csv, dataset_info, column_types
|
|
47
|
+
- **viz.py** — quick_hist, quick_corr
|
|
48
|
+
|
|
49
|
+
## License
|
|
50
|
+
|
|
51
|
+
MIT
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
smilo/__init__.py,sha256=3eWMZfta_LXGuxpKboNhAgUXLnwwazcAIO4dvdBN368,131
|
|
2
|
+
smilo/clean.py,sha256=J5mwecdpqBPMRY5G86laKz0WW60fFYIq-K1dCyL-2zY,642
|
|
3
|
+
smilo/split.py,sha256=9M7qorQzxtEk8qWcsvO9dfO79v8TYNmHGuynJGz4uZQ,1134
|
|
4
|
+
smilo/stats.py,sha256=eNbyHdsQ-QB-aGPuBYC5J5tzoxkHwwNGLxtjOsoid5M,1517
|
|
5
|
+
smilo/utils.py,sha256=4M7zx382iO_-G4DMTkjnQ9FoEIBCd5kY9js61HTsfrU,928
|
|
6
|
+
smilo/viz.py,sha256=m4oJD1wa08Q0e98rlWGmEyym6On-q_TkC16XMpgyNIg,1225
|
|
7
|
+
smilo-0.1.0.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
smilo-0.1.0.dist-info/METADATA,sha256=K9HtOd3FCgT9cxJ8_02Q627T4pP5miVanpesuec1YAU,1506
|
|
9
|
+
smilo-0.1.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
10
|
+
smilo-0.1.0.dist-info/top_level.txt,sha256=cmFzxOu8We3QKVZGpoQ5qjNUsByt4c7oKdl3UhVfYIw,6
|
|
11
|
+
smilo-0.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
smilo
|