kshri 0.3.2__tar.gz → 0.4.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kshri
3
- Version: 0.3.2
3
+ Version: 0.4.0
4
4
  Summary: Kshri: A fun, lightweight array and dataframe library with personality.
5
5
  Author-email: Rishabh <rishabh@example.com>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "kshri"
7
- version = "0.3.2"
7
+ version = "0.4.0"
8
8
  authors = [
9
9
  { name="Rishabh", email="rishabh@example.com" },
10
10
  ]
@@ -15,8 +15,9 @@ from .modern import (
15
15
  )
16
16
  from .eda import dashboard
17
17
  from . import datasets
18
+ from .nn import NeuralNet
18
19
 
19
- __version__ = "0.3.2"
20
+ __version__ = "0.4.0"
20
21
  __all__ = [
21
22
  "Array",
22
23
  "DataFrame",
@@ -32,4 +33,5 @@ __all__ = [
32
33
  "to_llm_prompt",
33
34
  "dashboard",
34
35
  "datasets",
36
+ "NeuralNet",
35
37
  ]
@@ -13,9 +13,9 @@ def load_ipl():
13
13
  "MI", "MI", "LSG", "GT",
14
14
  "DC", "GT"
15
15
  ],
16
- "runs":,
17
- "strike_rate": [154.7, 150.0, 220.5, 95.0, 143.1, 167.5, 136.1, 145.7, 155.4, 147.4],
18
- "auction_price_cr": [15.0, 16.0, 12.0, 12.0, 15.0, 8.0, 17.0, 15.0, 16.0, 8.0]
16
+ "runs": list((741, 417, 161, 15, 216, 345, 520, 102, 446, 426)),
17
+ "strike_rate": list((154.7, 150.0, 220.5, 95.0, 143.1, 167.5, 136.1, 145.7, 155.4, 147.4)),
18
+ "auction_price_cr": list((15.0, 16.0, 12.0, 12.0, 15.0, 8.0, 17.0, 15.0, 16.0, 8.0))
19
19
  })
20
20
 
21
21
  def load_startups():
@@ -31,8 +31,8 @@ def load_startups():
31
31
  "Bengaluru", "Gurugram", "Bengaluru", "Bengaluru",
32
32
  "Gurugram", "Bengaluru"
33
33
  ],
34
- "revenue_cr":,
35
- "valuation_cr":,
34
+ "revenue_cr": list((8320, 2500, 4450, 2473, 11247, 12114, 3145, 5064, 5427, 1250)),
35
+ "valuation_cr": list((64000, 62000, 41500, 53000, 89000, 185000, 25000, 100000, 41000, 46000)),
36
36
  "profitable": ["Yes", "Yes", "No", "No", "No", "Yes", "Yes", "No", "Yes", "No"]
37
37
  })
38
38
 
@@ -41,5 +41,5 @@ def load_messy():
41
41
  return DataFrame({
42
42
  "name": ["Rishabh", "Aman", "Riya", "Kabir"],
43
43
  "age": ["22", "25", None, "29"],
44
- "salary": [65000, None, 82000, 950000]
44
+ "salary": list((65000, None, 82000, 950000))
45
45
  })
@@ -109,7 +109,7 @@ def dashboard(df, filename="kshri_dashboard.html", open_browser=True):
109
109
  <body>
110
110
  <div class="header">
111
111
  <div><h1 style="margin:0;">Kshri EDA Dashboard</h1><small style="color:#94a3b8;">Auto-generated Exploratory Data Analysis</small></div>
112
- <span class="badge">kshri v0.3.2</span>
112
+ <span class="badge">kshri v0.4.0</span>
113
113
  </div>
114
114
  <div class="kpi-row">
115
115
  <div class="kpi"><span>Total Rows</span><h2>{num_rows}</h2></div>
@@ -0,0 +1,51 @@
1
+ import math
2
+ import random
3
+
4
+ class NeuralNet:
5
+ """A lightweight, zero-dependency 2-layer Neural Network (MLP) in pure Python."""
6
+ def __init__(self, input_size, hidden_size=6, lr=0.1):
7
+ self.lr = lr
8
+ self.w1 = [[random.uniform(-0.5, 0.5) for _ in range(input_size)] for _ in range(hidden_size)]
9
+ self.b1 = [0.0 for _ in range(hidden_size)]
10
+ self.w2 = [random.uniform(-0.5, 0.5) for _ in range(hidden_size)]
11
+ self.b2 = 0.0
12
+
13
+ @staticmethod
14
+ def _sigmoid(x):
15
+ x = max(-20.0, min(20.0, x))
16
+ return 1.0 / (1.0 + math.exp(-x))
17
+
18
+ def predict_one(self, x):
19
+ hidden = [
20
+ self._sigmoid(sum(w * xi for w, xi in zip(weights, x)) + b)
21
+ for weights, b in zip(self.w1, self.b1)
22
+ ]
23
+ out = self._sigmoid(sum(w * h for w, h in zip(self.w2, hidden)) + self.b2)
24
+ return out, hidden
25
+
26
+ def fit(self, X, y, epochs=500):
27
+ """Train the neural network on features X and binary targets y (0 or 1)."""
28
+ for _ in range(epochs):
29
+ for xi, target in zip(X, y):
30
+ out, hidden = self.predict_one(xi)
31
+ error = target - out
32
+ d_out = error * out * (1.0 - out)
33
+
34
+ d_hidden = [
35
+ d_out * self.w2[j] * hidden[j] * (1.0 - hidden[j])
36
+ for j in range(len(hidden))
37
+ ]
38
+
39
+ for j in range(len(self.w2)):
40
+ self.w2[j] += self.lr * d_out * hidden[j]
41
+ self.b2 += self.lr * d_out
42
+
43
+ for j in range(len(self.w1)):
44
+ for i in range(len(xi)):
45
+ self.w1[j][i] += self.lr * d_hidden[j] * xi[i]
46
+ self.b1[j] += self.lr * d_hidden[j]
47
+ return self
48
+
49
+ def predict(self, X):
50
+ """Predict probabilities for a list of feature rows."""
51
+ return [round(self.predict_one(xi)[0], 4) for xi in X]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kshri
3
- Version: 0.3.2
3
+ Version: 0.4.0
4
4
  Summary: Kshri: A fun, lightweight array and dataframe library with personality.
5
5
  Author-email: Rishabh <rishabh@example.com>
6
6
  License-Expression: MIT
@@ -7,6 +7,7 @@ src/kshri/crazy.py
7
7
  src/kshri/datasets.py
8
8
  src/kshri/eda.py
9
9
  src/kshri/modern.py
10
+ src/kshri/nn.py
10
11
  src/kshri.egg-info/PKG-INFO
11
12
  src/kshri.egg-info/SOURCES.txt
12
13
  src/kshri.egg-info/dependency_links.txt
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes