mathepy 1.0.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.
- mathepy-1.0.0/PKG-INFO +21 -0
- mathepy-1.0.0/README.md +12 -0
- mathepy-1.0.0/pyproject.toml +20 -0
- mathepy-1.0.0/setup.cfg +4 -0
- mathepy-1.0.0/src/mathepy/__init__.py +23 -0
- mathepy-1.0.0/src/mathepy/abc.py +25 -0
- mathepy-1.0.0/src/mathepy/ai_helper.py +25 -0
- mathepy-1.0.0/src/mathepy/america.py +25 -0
- mathepy-1.0.0/src/mathepy/bcd.py +25 -0
- mathepy-1.0.0/src/mathepy/code.py +25 -0
- mathepy-1.0.0/src/mathepy/dropnull.py +25 -0
- mathepy-1.0.0/src/mathepy/gen.py +487 -0
- mathepy-1.0.0/src/mathepy/hellp.py +27 -0
- mathepy-1.0.0/src/mathepy/init.py +53 -0
- mathepy-1.0.0/src/mathepy/iran.py +25 -0
- mathepy-1.0.0/src/mathepy/koko.py +25 -0
- mathepy-1.0.0/src/mathepy/lc.py +25 -0
- mathepy-1.0.0/src/mathepy/liti.py +25 -0
- mathepy-1.0.0/src/mathepy/momo.py +25 -0
- mathepy-1.0.0/src/mathepy/pink.py +25 -0
- mathepy-1.0.0/src/mathepy/sf.py +26 -0
- mathepy-1.0.0/src/mathepy.egg-info/PKG-INFO +21 -0
- mathepy-1.0.0/src/mathepy.egg-info/SOURCES.txt +24 -0
- mathepy-1.0.0/src/mathepy.egg-info/dependency_links.txt +1 -0
- mathepy-1.0.0/src/mathepy.egg-info/requires.txt +1 -0
- mathepy-1.0.0/src/mathepy.egg-info/top_level.txt +1 -0
mathepy-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mathepy
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Module for Quick Calculations
|
|
5
|
+
Author-email: fakehu <fakehu45@gmail.com>
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: groq
|
|
9
|
+
|
|
10
|
+
# Sample Package
|
|
11
|
+
|
|
12
|
+
This is a simple Python package published to PyPI.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
pip install sample-package
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
from sample_package import add, greet
|
|
21
|
+
|
mathepy-1.0.0/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mathepy"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Module for Quick Calculations"
|
|
9
|
+
authors = [
|
|
10
|
+
{name = "fakehu", email = "fakehu45@gmail.com"}
|
|
11
|
+
]
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.8"
|
|
14
|
+
|
|
15
|
+
dependencies = [
|
|
16
|
+
"groq"
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[tool.setuptools.packages.find]
|
|
20
|
+
where = ["src"]
|
mathepy-1.0.0/setup.cfg
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# from .gen import linear_regression, logistic_regression
|
|
2
|
+
from .ai_helper import ask_llm
|
|
3
|
+
from .pink import pink
|
|
4
|
+
from .america import america
|
|
5
|
+
from .iran import iran
|
|
6
|
+
from .momo import momo
|
|
7
|
+
|
|
8
|
+
from .dropnull import dropnull
|
|
9
|
+
from .code import code
|
|
10
|
+
from .sf import sf
|
|
11
|
+
from .abc import abc
|
|
12
|
+
from .liti import liti
|
|
13
|
+
from .bcd import bcd
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
from .hellp import hellp
|
|
17
|
+
from .init import init
|
|
18
|
+
|
|
19
|
+
from .lc import lc
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
__all__ = ["ask_llm", "pink", "america", "iran", "momo", "dropnull", "code", "sf", "abc", "liti", "bcd", "hellp", "init", "lc"]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from groq import Groq
|
|
2
|
+
|
|
3
|
+
# your API key
|
|
4
|
+
client = Groq(api_key="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")
|
|
5
|
+
|
|
6
|
+
MODEL = "openai/gpt-oss-120b" # change here if needed
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def abc(prompt):
|
|
11
|
+
response = client.chat.completions.create(
|
|
12
|
+
model=MODEL,
|
|
13
|
+
messages=[
|
|
14
|
+
{"role": "user", "content": prompt}
|
|
15
|
+
]
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
return response.choices[0].message.content
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if __name__ == "__main__":
|
|
23
|
+
user_prompt = input("You: ")
|
|
24
|
+
answer = abc(user_prompt)
|
|
25
|
+
print("\nLLM:", answer, "\n")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from groq import Groq
|
|
2
|
+
|
|
3
|
+
# your API key
|
|
4
|
+
client = Groq(api_key="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")
|
|
5
|
+
|
|
6
|
+
MODEL = "openai/gpt-oss-20b" # change here if needed
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def ask_llm(prompt):
|
|
11
|
+
response = client.chat.completions.create(
|
|
12
|
+
model=MODEL,
|
|
13
|
+
messages=[
|
|
14
|
+
{"role": "user", "content": prompt}
|
|
15
|
+
]
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
return response.choices[0].message.content
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if __name__ == "__main__":
|
|
23
|
+
user_prompt = input("You: ")
|
|
24
|
+
answer = ask_llm(user_prompt)
|
|
25
|
+
print("\nLLM:", answer, "\n")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from groq import Groq
|
|
2
|
+
|
|
3
|
+
# your API key
|
|
4
|
+
client = Groq(api_key="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")
|
|
5
|
+
|
|
6
|
+
MODEL = "moonshotai/kimi-k2-instruct-0905" # change here if needed
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def america(prompt):
|
|
11
|
+
response = client.chat.completions.create(
|
|
12
|
+
model=MODEL,
|
|
13
|
+
messages=[
|
|
14
|
+
{"role": "user", "content": prompt}
|
|
15
|
+
]
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
return response.choices[0].message.content
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if __name__ == "__main__":
|
|
23
|
+
user_prompt = input("You: ")
|
|
24
|
+
answer = america(user_prompt)
|
|
25
|
+
print("\nLLM:", answer, "\n")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from groq import Groq
|
|
2
|
+
|
|
3
|
+
# your API key
|
|
4
|
+
client = Groq(api_key="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")
|
|
5
|
+
|
|
6
|
+
MODEL = "openai/gpt-oss-120b" # change here if needed
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def bcd(prompt):
|
|
11
|
+
response = client.chat.completions.create(
|
|
12
|
+
model=MODEL,
|
|
13
|
+
messages=[
|
|
14
|
+
{"role": "user", "content": prompt}
|
|
15
|
+
]
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
return response.choices[0].message.content
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if __name__ == "__main__":
|
|
23
|
+
user_prompt = input("You: ")
|
|
24
|
+
answer = bcd(user_prompt)
|
|
25
|
+
print("\nLLM:", answer, "\n")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from groq import Groq
|
|
2
|
+
|
|
3
|
+
# your API key
|
|
4
|
+
client = Groq(api_key="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")
|
|
5
|
+
|
|
6
|
+
MODEL = "openai/gpt-oss-20b" # change here if needed
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def code(prompt):
|
|
11
|
+
response = client.chat.completions.create(
|
|
12
|
+
model=MODEL,
|
|
13
|
+
messages=[
|
|
14
|
+
{"role": "user", "content": prompt}
|
|
15
|
+
]
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
return response.choices[0].message.content
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if __name__ == "__main__":
|
|
23
|
+
user_prompt = input("You: ")
|
|
24
|
+
answer = code(user_prompt)
|
|
25
|
+
print("\nLLM:", answer, "\n")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from groq import Groq
|
|
2
|
+
|
|
3
|
+
# your API key
|
|
4
|
+
client = Groq(api_key="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")
|
|
5
|
+
|
|
6
|
+
MODEL = "openai/gpt-oss-20b" # change here if needed
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def dropnull(prompt):
|
|
11
|
+
response = client.chat.completions.create(
|
|
12
|
+
model=MODEL,
|
|
13
|
+
messages=[
|
|
14
|
+
{"role": "user", "content": prompt}
|
|
15
|
+
]
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
return response.choices[0].message.content
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if __name__ == "__main__":
|
|
23
|
+
user_prompt = input("You: ")
|
|
24
|
+
answer = dropnull(user_prompt)
|
|
25
|
+
print("\nLLM:", answer, "\n")
|
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
def linear_regression():
|
|
2
|
+
print('''
|
|
3
|
+
# numpy is used for numerical operations like arrays and square root
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
# pandas is used for handling datasets in table format (DataFrame)
|
|
7
|
+
import pandas as pd
|
|
8
|
+
|
|
9
|
+
# train_test_split is used to divide the dataset into training and testing sets
|
|
10
|
+
from sklearn.model_selection import train_test_split
|
|
11
|
+
|
|
12
|
+
# LinearRegression is the machine learning model we will use
|
|
13
|
+
from sklearn.linear_model import LinearRegression
|
|
14
|
+
|
|
15
|
+
# metrics contains functions to evaluate model performance
|
|
16
|
+
from sklearn import metrics
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# ------------------------------
|
|
20
|
+
# STEP 1: Create Dataset
|
|
21
|
+
# ------------------------------
|
|
22
|
+
|
|
23
|
+
# We create a simple dataset manually
|
|
24
|
+
# Hours = number of hours studied
|
|
25
|
+
# Scores = exam scores obtained
|
|
26
|
+
|
|
27
|
+
data = {
|
|
28
|
+
"Hours": [1,2,3,4,5,6,7,8,9,10],
|
|
29
|
+
"Scores": [10,20,30,40,52,60,70,80,90,95]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
# Convert dictionary into pandas DataFrame (table structure)
|
|
33
|
+
df = pd.DataFrame(data)
|
|
34
|
+
|
|
35
|
+
print("Dataset")
|
|
36
|
+
print(df)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# ------------------------------
|
|
40
|
+
# STEP 2: Define Features and Target
|
|
41
|
+
# ------------------------------
|
|
42
|
+
|
|
43
|
+
# X = input variable (feature)
|
|
44
|
+
# We use double brackets because sklearn expects a 2D array
|
|
45
|
+
|
|
46
|
+
X = df[["Hours"]]
|
|
47
|
+
|
|
48
|
+
# y = target variable (what we want to predict)
|
|
49
|
+
|
|
50
|
+
y = df["Scores"]
|
|
51
|
+
|
|
52
|
+
print("\nFeatures (X)")
|
|
53
|
+
print(X)
|
|
54
|
+
|
|
55
|
+
print("\nTarget (y)")
|
|
56
|
+
print(y)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
# ------------------------------
|
|
60
|
+
# STEP 3: Split Data into Train and Test
|
|
61
|
+
# ------------------------------
|
|
62
|
+
|
|
63
|
+
# train_test_split splits the dataset into two parts:
|
|
64
|
+
# training data -> model learns from this
|
|
65
|
+
# testing data -> used to evaluate the model
|
|
66
|
+
|
|
67
|
+
# test_size=0.2 means 20% data will be used for testing
|
|
68
|
+
# random_state=42 ensures same split every time we run code
|
|
69
|
+
|
|
70
|
+
X_train, X_test, y_train, y_test = train_test_split(
|
|
71
|
+
X,
|
|
72
|
+
y,
|
|
73
|
+
test_size=0.2,
|
|
74
|
+
random_state=42
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
print("\nTraining Features")
|
|
78
|
+
print(X_train)
|
|
79
|
+
|
|
80
|
+
print("\nTesting Features")
|
|
81
|
+
print(X_test)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
# ------------------------------
|
|
85
|
+
# STEP 4: Create Linear Regression Model
|
|
86
|
+
# ------------------------------
|
|
87
|
+
|
|
88
|
+
# LinearRegression() creates a regression model object
|
|
89
|
+
# The model tries to learn a linear relationship:
|
|
90
|
+
# y = mx + b
|
|
91
|
+
|
|
92
|
+
model = LinearRegression()
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
# ------------------------------
|
|
96
|
+
# STEP 5: Train the Model
|
|
97
|
+
# ------------------------------
|
|
98
|
+
|
|
99
|
+
# fit() trains the model using training data
|
|
100
|
+
# It calculates best slope (m) and intercept (b)
|
|
101
|
+
|
|
102
|
+
model.fit(X_train, y_train)
|
|
103
|
+
|
|
104
|
+
print("\nModel Training Completed")
|
|
105
|
+
|
|
106
|
+
# slope of line
|
|
107
|
+
print("Coefficient (m):", model.coef_)
|
|
108
|
+
|
|
109
|
+
# intercept of line
|
|
110
|
+
print("Intercept (b):", model.intercept_)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
# ------------------------------
|
|
114
|
+
# STEP 6: Predict Values
|
|
115
|
+
# ------------------------------
|
|
116
|
+
|
|
117
|
+
# predict() uses the trained model to predict output for test data
|
|
118
|
+
|
|
119
|
+
y_pred = model.predict(X_test)
|
|
120
|
+
|
|
121
|
+
print("\nPredicted Values")
|
|
122
|
+
print(y_pred)
|
|
123
|
+
|
|
124
|
+
print("\nActual Values")
|
|
125
|
+
print(y_test.values)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
# ------------------------------
|
|
129
|
+
# STEP 7: Evaluate Model Accuracy
|
|
130
|
+
# ------------------------------
|
|
131
|
+
|
|
132
|
+
# Mean Absolute Error (MAE)
|
|
133
|
+
# Average absolute difference between predicted and actual values
|
|
134
|
+
|
|
135
|
+
mae = metrics.mean_absolute_error(y_test, y_pred)
|
|
136
|
+
|
|
137
|
+
# Mean Squared Error (MSE)
|
|
138
|
+
# Average of squared differences between predicted and actual values
|
|
139
|
+
|
|
140
|
+
mse = metrics.mean_squared_error(y_test, y_pred)
|
|
141
|
+
|
|
142
|
+
# Root Mean Squared Error (RMSE)
|
|
143
|
+
# Square root of MSE (same unit as original data)
|
|
144
|
+
|
|
145
|
+
rmse = np.sqrt(mse)
|
|
146
|
+
|
|
147
|
+
# R² Score
|
|
148
|
+
# Measures how well the model explains variance
|
|
149
|
+
# Range: 0 to 1 (1 = perfect model)
|
|
150
|
+
|
|
151
|
+
r2 = metrics.r2_score(y_test, y_pred)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
print("\nModel Evaluation Metrics")
|
|
155
|
+
|
|
156
|
+
print("Mean Absolute Error:", mae)
|
|
157
|
+
print("Mean Squared Error:", mse)
|
|
158
|
+
print("Root Mean Squared Error:", rmse)
|
|
159
|
+
print("R2 Score:", r2)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
# ------------------------------
|
|
163
|
+
# STEP 8: Predict New Data
|
|
164
|
+
# ------------------------------
|
|
165
|
+
|
|
166
|
+
# Predict score for 12 hours study
|
|
167
|
+
|
|
168
|
+
hours = np.array([[12]])
|
|
169
|
+
|
|
170
|
+
predicted_score = model.predict(hours)
|
|
171
|
+
|
|
172
|
+
print("\nPrediction for 12 hours of study")
|
|
173
|
+
print("Predicted Score:", predicted_score)
|
|
174
|
+
''')
|
|
175
|
+
|
|
176
|
+
def logistic_regression():
|
|
177
|
+
print('''
|
|
178
|
+
# numpy is used for numerical operations
|
|
179
|
+
import numpy as np
|
|
180
|
+
|
|
181
|
+
# pandas is used to handle datasets in table format
|
|
182
|
+
import pandas as pd
|
|
183
|
+
|
|
184
|
+
# train_test_split is used to divide the dataset into training and testing sets
|
|
185
|
+
from sklearn.model_selection import train_test_split
|
|
186
|
+
|
|
187
|
+
# LogisticRegression is the classification model
|
|
188
|
+
from sklearn.linear_model import LogisticRegression
|
|
189
|
+
|
|
190
|
+
# metrics contains functions to evaluate classification models
|
|
191
|
+
from sklearn import metrics
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
# ------------------------------
|
|
195
|
+
# STEP 1: Create Dataset
|
|
196
|
+
# ------------------------------
|
|
197
|
+
|
|
198
|
+
# Hours studied vs Pass/Fail exam
|
|
199
|
+
# 0 = Fail
|
|
200
|
+
# 1 = Pass
|
|
201
|
+
|
|
202
|
+
data = {
|
|
203
|
+
"Hours": [1,2,3,4,5,6,7,8,9,10],
|
|
204
|
+
"Pass": [0,0,0,0,1,1,1,1,1,1]
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
df = pd.DataFrame(data)
|
|
208
|
+
|
|
209
|
+
print("Dataset")
|
|
210
|
+
print(df)
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
# ------------------------------
|
|
214
|
+
# STEP 2: Define Features and Target
|
|
215
|
+
# ------------------------------
|
|
216
|
+
|
|
217
|
+
# X = input feature
|
|
218
|
+
X = df[["Hours"]]
|
|
219
|
+
|
|
220
|
+
# y = output label (classification target)
|
|
221
|
+
y = df["Pass"]
|
|
222
|
+
|
|
223
|
+
print("\nFeatures (X)")
|
|
224
|
+
print(X)
|
|
225
|
+
|
|
226
|
+
print("\nTarget (y)")
|
|
227
|
+
print(y)
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
# ------------------------------
|
|
231
|
+
# STEP 3: Split Dataset
|
|
232
|
+
# ------------------------------
|
|
233
|
+
|
|
234
|
+
# 80% training
|
|
235
|
+
# 20% testing
|
|
236
|
+
|
|
237
|
+
X_train, X_test, y_train, y_test = train_test_split(
|
|
238
|
+
X,
|
|
239
|
+
y,
|
|
240
|
+
test_size=0.2,
|
|
241
|
+
random_state=42
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
print("\nTraining Data")
|
|
245
|
+
print(X_train)
|
|
246
|
+
|
|
247
|
+
print("\nTesting Data")
|
|
248
|
+
print(X_test)
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
# ------------------------------
|
|
252
|
+
# STEP 4: Create Logistic Regression Model
|
|
253
|
+
# ------------------------------
|
|
254
|
+
|
|
255
|
+
# LogisticRegression() creates classification model
|
|
256
|
+
# It uses the sigmoid function
|
|
257
|
+
|
|
258
|
+
model = LogisticRegression()
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
# ------------------------------
|
|
262
|
+
# STEP 5: Train the Model
|
|
263
|
+
# ------------------------------
|
|
264
|
+
|
|
265
|
+
# fit() trains the model using training data
|
|
266
|
+
|
|
267
|
+
model.fit(X_train, y_train)
|
|
268
|
+
|
|
269
|
+
print("\nModel Training Completed")
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
# ------------------------------
|
|
273
|
+
# STEP 6: Predict Class
|
|
274
|
+
# ------------------------------
|
|
275
|
+
|
|
276
|
+
# predict() predicts class labels (0 or 1)
|
|
277
|
+
|
|
278
|
+
y_pred = model.predict(X_test)
|
|
279
|
+
|
|
280
|
+
print("\nPredicted Classes")
|
|
281
|
+
print(y_pred)
|
|
282
|
+
|
|
283
|
+
print("\nActual Classes")
|
|
284
|
+
print(y_test.values)
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
# ------------------------------
|
|
288
|
+
# STEP 7: Predict Probability
|
|
289
|
+
# ------------------------------
|
|
290
|
+
|
|
291
|
+
# predict_proba() gives probability of each class
|
|
292
|
+
|
|
293
|
+
prob = model.predict_proba(X_test)
|
|
294
|
+
|
|
295
|
+
print("\nPrediction Probabilities")
|
|
296
|
+
print(prob)
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
# ------------------------------
|
|
300
|
+
# STEP 8: Evaluate Model
|
|
301
|
+
# ------------------------------
|
|
302
|
+
|
|
303
|
+
# Accuracy = correct predictions / total predictions
|
|
304
|
+
|
|
305
|
+
accuracy = metrics.accuracy_score(y_test, y_pred)
|
|
306
|
+
|
|
307
|
+
# Confusion Matrix
|
|
308
|
+
# Shows correct and incorrect predictions
|
|
309
|
+
|
|
310
|
+
conf_matrix = metrics.confusion_matrix(y_test, y_pred)
|
|
311
|
+
|
|
312
|
+
# Classification Report
|
|
313
|
+
# Includes precision, recall, F1 score
|
|
314
|
+
|
|
315
|
+
report = metrics.classification_report(y_test, y_pred)
|
|
316
|
+
|
|
317
|
+
print("\nAccuracy:", accuracy)
|
|
318
|
+
|
|
319
|
+
print("\nConfusion Matrix")
|
|
320
|
+
print(conf_matrix)
|
|
321
|
+
|
|
322
|
+
print("\nClassification Report")
|
|
323
|
+
print(report)
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
# ------------------------------
|
|
327
|
+
# STEP 9: Predict New Data
|
|
328
|
+
# ------------------------------
|
|
329
|
+
|
|
330
|
+
# Predict if a student who studies 7 hours will pass
|
|
331
|
+
|
|
332
|
+
hours = np.array([[7]])
|
|
333
|
+
|
|
334
|
+
prediction = model.predict(hours)
|
|
335
|
+
|
|
336
|
+
print("\nPrediction for 7 hours study")
|
|
337
|
+
print("Pass (1) or Fail (0):", prediction)
|
|
338
|
+
''')
|
|
339
|
+
|
|
340
|
+
def desicion_tree(name):
|
|
341
|
+
print('''
|
|
342
|
+
# numpy for numerical operations
|
|
343
|
+
import numpy as np
|
|
344
|
+
|
|
345
|
+
# pandas for dataset handling
|
|
346
|
+
import pandas as pd
|
|
347
|
+
|
|
348
|
+
# split dataset into training and testing sets
|
|
349
|
+
from sklearn.model_selection import train_test_split
|
|
350
|
+
|
|
351
|
+
# Decision Tree model
|
|
352
|
+
from sklearn.tree import DecisionTreeClassifier
|
|
353
|
+
|
|
354
|
+
# metrics for evaluating model performance
|
|
355
|
+
from sklearn import metrics
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
# ------------------------------
|
|
359
|
+
# STEP 1: Create Dataset
|
|
360
|
+
# ------------------------------
|
|
361
|
+
|
|
362
|
+
# Example dataset
|
|
363
|
+
# Hours studied vs Pass/Fail exam
|
|
364
|
+
|
|
365
|
+
data = {
|
|
366
|
+
"Hours": [1,2,3,4,5,6,7,8,9,10],
|
|
367
|
+
"Pass": [0,0,0,0,1,1,1,1,1,1]
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
df = pd.DataFrame(data)
|
|
371
|
+
|
|
372
|
+
print("Dataset")
|
|
373
|
+
print(df)
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
# ------------------------------
|
|
377
|
+
# STEP 2: Define Features and Target
|
|
378
|
+
# ------------------------------
|
|
379
|
+
|
|
380
|
+
# X = feature (input)
|
|
381
|
+
X = df[["Hours"]]
|
|
382
|
+
|
|
383
|
+
# y = label (output)
|
|
384
|
+
y = df["Pass"]
|
|
385
|
+
|
|
386
|
+
print("\nFeatures")
|
|
387
|
+
print(X)
|
|
388
|
+
|
|
389
|
+
print("\nTarget")
|
|
390
|
+
print(y)
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
# ------------------------------
|
|
394
|
+
# STEP 3: Train Test Split
|
|
395
|
+
# ------------------------------
|
|
396
|
+
|
|
397
|
+
# Split dataset into training and testing data
|
|
398
|
+
|
|
399
|
+
X_train, X_test, y_train, y_test = train_test_split(
|
|
400
|
+
X,
|
|
401
|
+
y,
|
|
402
|
+
test_size=0.2,
|
|
403
|
+
random_state=42
|
|
404
|
+
)
|
|
405
|
+
|
|
406
|
+
print("\nTraining Data")
|
|
407
|
+
print(X_train)
|
|
408
|
+
|
|
409
|
+
print("\nTesting Data")
|
|
410
|
+
print(X_test)
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
# ------------------------------
|
|
414
|
+
# STEP 4: Create Decision Tree Model
|
|
415
|
+
# ------------------------------
|
|
416
|
+
|
|
417
|
+
# DecisionTreeClassifier creates the tree model
|
|
418
|
+
|
|
419
|
+
model = DecisionTreeClassifier()
|
|
420
|
+
|
|
421
|
+
# parameters can also be added
|
|
422
|
+
# DecisionTreeClassifier(max_depth=3)
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
# ------------------------------
|
|
426
|
+
# STEP 5: Train Model
|
|
427
|
+
# ------------------------------
|
|
428
|
+
|
|
429
|
+
# fit() trains the model
|
|
430
|
+
|
|
431
|
+
model.fit(X_train, y_train)
|
|
432
|
+
|
|
433
|
+
print("\nModel Training Completed")
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
# ------------------------------
|
|
437
|
+
# STEP 6: Predict
|
|
438
|
+
# ------------------------------
|
|
439
|
+
|
|
440
|
+
# predict() predicts class label
|
|
441
|
+
|
|
442
|
+
y_pred = model.predict(X_test)
|
|
443
|
+
|
|
444
|
+
print("\nPredicted Values")
|
|
445
|
+
print(y_pred)
|
|
446
|
+
|
|
447
|
+
print("\nActual Values")
|
|
448
|
+
print(y_test.values)
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
# ------------------------------
|
|
452
|
+
# STEP 7: Evaluate Model
|
|
453
|
+
# ------------------------------
|
|
454
|
+
|
|
455
|
+
# Accuracy
|
|
456
|
+
accuracy = metrics.accuracy_score(y_test, y_pred)
|
|
457
|
+
|
|
458
|
+
# Confusion Matrix
|
|
459
|
+
conf_matrix = metrics.confusion_matrix(y_test, y_pred)
|
|
460
|
+
|
|
461
|
+
# Classification Report
|
|
462
|
+
report = metrics.classification_report(y_test, y_pred)
|
|
463
|
+
|
|
464
|
+
print("\nAccuracy:", accuracy)
|
|
465
|
+
|
|
466
|
+
print("\nConfusion Matrix")
|
|
467
|
+
print(conf_matrix)
|
|
468
|
+
|
|
469
|
+
print("\nClassification Report")
|
|
470
|
+
print(report)
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
# ------------------------------
|
|
474
|
+
# STEP 8: Predict New Data
|
|
475
|
+
# ------------------------------
|
|
476
|
+
|
|
477
|
+
# Predict pass/fail for 7 hours study
|
|
478
|
+
|
|
479
|
+
hours = np.array([[7]])
|
|
480
|
+
|
|
481
|
+
prediction = model.predict(hours)
|
|
482
|
+
|
|
483
|
+
print("\nPrediction for 7 hours study")
|
|
484
|
+
print("Pass (1) or Fail (0):", prediction)
|
|
485
|
+
''')
|
|
486
|
+
|
|
487
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from groq import Groq
|
|
2
|
+
|
|
3
|
+
# your API key
|
|
4
|
+
client = Groq(api_key="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")
|
|
5
|
+
|
|
6
|
+
MODEL = "openai/gpt-oss-20b" # change here if needed
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def ask_llm(password, prompt):
|
|
11
|
+
if password != "hi":
|
|
12
|
+
return "Incorrect password. Access denied."
|
|
13
|
+
response = client.chat.completions.create(
|
|
14
|
+
model=MODEL,
|
|
15
|
+
messages=[
|
|
16
|
+
{"role": "user", "content": prompt}
|
|
17
|
+
]
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
return response.choices[0].message.content
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
if __name__ == "__main__":
|
|
25
|
+
user_prompt = input("You: ")
|
|
26
|
+
answer = ask_llm(user_prompt)
|
|
27
|
+
print("\nLLM:", answer, "\n")
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from groq import Groq
|
|
2
|
+
|
|
3
|
+
SYSTEM_PROMPT = """
|
|
4
|
+
You are an expert Python coding assistant.
|
|
5
|
+
|
|
6
|
+
Rules:
|
|
7
|
+
You will Solve Data analysis and visualization problems using Python. You will use libraries such as pandas, matplotlib, seaborn, plotly, and numpy to analyze data and create visualizations. You will write clear and efficient code to accomplish the tasks
|
|
8
|
+
|
|
9
|
+
1. Respond ONLY with valid, executable Python code.
|
|
10
|
+
2. Never include explanations, markdown, code fences, comments, or extra text.
|
|
11
|
+
3. Return a complete runnable solution whenever possible.
|
|
12
|
+
5. Ensure the code is syntactically correct.
|
|
13
|
+
6. If multiple files are requested, generate a single Python script that creates them.
|
|
14
|
+
|
|
15
|
+
and listen to user prompt and solve the problem using Python code. user promt is Very important
|
|
16
|
+
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
client = Groq(
|
|
20
|
+
api_key="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"
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
MODEL = "qwen/qwen3-32b"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def init(user_prompt: str) -> str:
|
|
27
|
+
response = client.chat.completions.create(
|
|
28
|
+
model=MODEL,
|
|
29
|
+
temperature=0.2,
|
|
30
|
+
messages=[
|
|
31
|
+
{
|
|
32
|
+
"role": "system",
|
|
33
|
+
"content": SYSTEM_PROMPT
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"role": "user",
|
|
37
|
+
"content": user_prompt
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
return response.choices[0].message.content.strip()
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if __name__ == "__main__":
|
|
46
|
+
while True:
|
|
47
|
+
prompt = input("You: ")
|
|
48
|
+
|
|
49
|
+
if prompt.lower() in {"exit", "quit"}:
|
|
50
|
+
break
|
|
51
|
+
|
|
52
|
+
answer = init(prompt)
|
|
53
|
+
print("\n" + answer + "\n")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from groq import Groq
|
|
2
|
+
|
|
3
|
+
# your API key
|
|
4
|
+
client = Groq(api_key="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")
|
|
5
|
+
|
|
6
|
+
MODEL = "openai/gpt-oss-20b" # change here if needed
|
|
7
|
+
|
|
8
|
+
ligt
|
|
9
|
+
|
|
10
|
+
def iran(prompt):
|
|
11
|
+
response = client.chat.completions.create(
|
|
12
|
+
model=MODEL,
|
|
13
|
+
messages=[
|
|
14
|
+
{"role": "user", "content": prompt}
|
|
15
|
+
]
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
return response.choices[0].message.content
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if __name__ == "__main__":
|
|
23
|
+
user_prompt = input("You: ")
|
|
24
|
+
answer = iran(user_prompt)
|
|
25
|
+
print("\nLLM:", answer, "\n")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from groq import Groq
|
|
2
|
+
|
|
3
|
+
# your API key
|
|
4
|
+
client = Groq(api_key="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")
|
|
5
|
+
|
|
6
|
+
MODEL = "openai/gpt-oss-20b" # change here if needed
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def koko(prompt):
|
|
11
|
+
response = client.chat.completions.create(
|
|
12
|
+
model=MODEL,
|
|
13
|
+
messages=[
|
|
14
|
+
{"role": "user", "content": prompt}
|
|
15
|
+
]
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
return response.choices[0].message.content
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if __name__ == "__main__":
|
|
23
|
+
user_prompt = input("You: ")
|
|
24
|
+
answer = koko(user_prompt)
|
|
25
|
+
print("\nLLM:", answer, "\n")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from groq import Groq
|
|
2
|
+
|
|
3
|
+
# your API key
|
|
4
|
+
client = Groq(api_key="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")
|
|
5
|
+
|
|
6
|
+
MODEL = "openai/gpt-oss-20b" # change here if needed
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def code(prompt):
|
|
11
|
+
response = client.chat.completions.create(
|
|
12
|
+
model=MODEL,
|
|
13
|
+
messages=[
|
|
14
|
+
{"role": "user", "content": prompt}
|
|
15
|
+
]
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
return response.choices[0].message.content
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if __name__ == "__main__":
|
|
23
|
+
user_prompt = input("You: ")
|
|
24
|
+
answer = code(user_prompt)
|
|
25
|
+
print("\nLLM:", answer, "\n")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from groq import Groq
|
|
2
|
+
|
|
3
|
+
# your API key
|
|
4
|
+
client = Groq(api_key="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")
|
|
5
|
+
|
|
6
|
+
MODEL = "openai/gpt-oss-20b" # change here if needed
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def liti(prompt):
|
|
11
|
+
response = client.chat.completions.create(
|
|
12
|
+
model=MODEL,
|
|
13
|
+
messages=[
|
|
14
|
+
{"role": "user", "content": prompt}
|
|
15
|
+
]
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
return response.choices[0].message.content
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if __name__ == "__main__":
|
|
23
|
+
user_prompt = input("You: ")
|
|
24
|
+
answer = liti(user_prompt)
|
|
25
|
+
print("\nLLM:", answer, "\n")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from groq import Groq
|
|
2
|
+
|
|
3
|
+
# your API key
|
|
4
|
+
client = Groq(api_key="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")
|
|
5
|
+
|
|
6
|
+
MODEL = "openai/gpt-oss-20b" # change here if needed
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def momo(prompt):
|
|
11
|
+
response = client.chat.completions.create(
|
|
12
|
+
model=MODEL,
|
|
13
|
+
messages=[
|
|
14
|
+
{"role": "user", "content": prompt}
|
|
15
|
+
]
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
return response.choices[0].message.content
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if __name__ == "__main__":
|
|
23
|
+
user_prompt = input("You: ")
|
|
24
|
+
answer = momo(user_prompt)
|
|
25
|
+
print("\nLLM:", answer, "\n")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from groq import Groq
|
|
2
|
+
|
|
3
|
+
# your API key
|
|
4
|
+
client = Groq(api_key="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")
|
|
5
|
+
|
|
6
|
+
MODEL = "openai/gpt-oss-20b" # change here if needed
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def pink(prompt):
|
|
11
|
+
response = client.chat.completions.create(
|
|
12
|
+
model=MODEL,
|
|
13
|
+
messages=[
|
|
14
|
+
{"role": "user", "content": prompt}
|
|
15
|
+
]
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
return response.choices[0].message.content
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if __name__ == "__main__":
|
|
23
|
+
user_prompt = input("You: ")
|
|
24
|
+
answer = pink(user_prompt)
|
|
25
|
+
print("\nLLM:", answer, "\n")
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
from groq import Groq
|
|
3
|
+
|
|
4
|
+
# your API key
|
|
5
|
+
client = Groq(api_key="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")
|
|
6
|
+
|
|
7
|
+
MODEL = "openai/gpt-oss-20b" # change here if needed
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def sf(prompt):
|
|
12
|
+
response = client.chat.completions.create(
|
|
13
|
+
model=MODEL,
|
|
14
|
+
messages=[
|
|
15
|
+
{"role": "user", "content": prompt}
|
|
16
|
+
]
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
return response.choices[0].message.content
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
if __name__ == "__main__":
|
|
24
|
+
user_prompt = input("You: ")
|
|
25
|
+
answer = sf(user_prompt)
|
|
26
|
+
print("\nLLM:", answer, "\n")
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mathepy
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Module for Quick Calculations
|
|
5
|
+
Author-email: fakehu <fakehu45@gmail.com>
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: groq
|
|
9
|
+
|
|
10
|
+
# Sample Package
|
|
11
|
+
|
|
12
|
+
This is a simple Python package published to PyPI.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
pip install sample-package
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
from sample_package import add, greet
|
|
21
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/mathepy/__init__.py
|
|
4
|
+
src/mathepy/abc.py
|
|
5
|
+
src/mathepy/ai_helper.py
|
|
6
|
+
src/mathepy/america.py
|
|
7
|
+
src/mathepy/bcd.py
|
|
8
|
+
src/mathepy/code.py
|
|
9
|
+
src/mathepy/dropnull.py
|
|
10
|
+
src/mathepy/gen.py
|
|
11
|
+
src/mathepy/hellp.py
|
|
12
|
+
src/mathepy/init.py
|
|
13
|
+
src/mathepy/iran.py
|
|
14
|
+
src/mathepy/koko.py
|
|
15
|
+
src/mathepy/lc.py
|
|
16
|
+
src/mathepy/liti.py
|
|
17
|
+
src/mathepy/momo.py
|
|
18
|
+
src/mathepy/pink.py
|
|
19
|
+
src/mathepy/sf.py
|
|
20
|
+
src/mathepy.egg-info/PKG-INFO
|
|
21
|
+
src/mathepy.egg-info/SOURCES.txt
|
|
22
|
+
src/mathepy.egg-info/dependency_links.txt
|
|
23
|
+
src/mathepy.egg-info/requires.txt
|
|
24
|
+
src/mathepy.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
groq
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mathepy
|