-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrainwave.py
271 lines (235 loc) · 8.05 KB
/
brainwave.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
"""
BrAiNwAvE is a tool that allows us to perform usual operations related to data analysis on the terminal
Author : jerrgems
Social-Links :
"""
#!/bin/python3
import os
import numpy as np
import pandas as pd
from sklearn.preprocessing import PolynomialFeatures
import matplotlib.pyplot as plt
from sklearn.linear_model import Lasso, Ridge, ElasticNet, LinearRegression
from operations import Opr
from models import Models
import warnings
warnings.filterwarnings('ignore')
print("""
hey welcome here
""")
def getPrompt():
prompt = "BrAiNwAvE🧠"
return prompt
def plotter(mode="simple"):
if mode == "simple":
print("hello")
else:
print("bye")
def grafty(data):
print("""
You're in grafty mode
_______ _______ _______ _______ _________
( ____ \( ____ )( ___ )( ____ \\\\__ __/|\ /|
| ( \/| ( )|| ( ) || ( \/ ) ( ( \ / )
| | | (____)|| (___) || (__ | | \ (_) /
| | ____ | __)| ___ || __) | | \ /
| | \_ )| (\ ( | ( ) || ( | | ) (
| (___) || ) \ \__| ) ( || ) | | | |
(_______)|/ \__/|/ \||/ )_( \_/
Note: you may need to hit exit to go back on previous mode
""")
##########################
## definations ##
##########################
def getInput():
colx = input("Enter X-axis column: ")
coly = input("Enter Y-axis column: ")
return colx, coly
def plotGraph(data):
colx, coly = getInput()
plt.ion()
plt.plot(data[colx], data[coly])
plt.show(block=False)
def barGraph(data):
colx, coly = getInput()
plt.ion()
plt.bar(range(len(data[colx])), data[coly])
plt.xticks(range(len(data[colx])), data[colx])
plt.xlabel(colx)
plt.ylabel(coly)
plt.show(block=False)
def pieGraph(data):
col = input("enter the column: ")
plt.ion()
plt.pie(data[col])
plt.show(block=False)
def boxGraph(data):
col = input("enter the column: ")
plt.ion()
plt.boxplot(data[col])
plt.show(block=False)
def histoGraph(data):
col = input("enter the column: ")
plt.ion()
plt.hist(data[col])
plt.show(block=False)
def scatterGraph(data):
colx, coly = getInput()
plt.ion()
plt.scatter(data[colx], data[coly])
plt.show(block=False)
##########################
## /definations ##
##########################
while True:
cmd = input(getPrompt() + " grafty>>")
if cmd == 'plot':
plotGraph(data)
elif cmd == 'bar':
barGraph(data)
elif cmd == 'pie':
pieGraph(data)
elif cmd == 'box':
boxGraph(data)
elif cmd == 'histogram':
histoGraph(data)
elif cmd == 'scatter':
scatterGraph(data)
elif cmd == 'clean':
plt.clf()
elif cmd == 'clear':
os.system("cls" if os.name == 'nt' else "clear")
elif cmd == 'help me' or cmd == 'help':
print("""\tFollowing commands are available for GRAFTY\n1. plot\n2. bar\n3. pie\n4. box\n5. histogram\n6. scatter\n7. help\n8. exit """)
elif cmd == 'leave' or cmd == 'exit':
break
# apply prediction stuff here
###################################
## predictions ##
###################################
def models(data):
print("""
following models you can use directly
1. Linear Regression
2. Polynomial Regression
3. Ridge Regression
4. Lasso Regression
5. ElasticNet Regression
6. Logistic Regression
7. Poisson Regression
8. Cox Regression
9. Support Vector Regression
10. Decision Tree Regression
11. Gradient Boosting Regression
12. Neural Network Regression
13. Bayesian Regression
14. K-Nearest Neighbour
15. Quantile Regression
16. Gaussian Regression
17. Robust Regression
18. Multi Task Regression
19. Multi-output Regression
20. Time-series Regression
21. Ordinal Regression
22. Quantative Regression
""")
choice = input("select the model by their assined int numbers : ")
try:
if choice == '1':
mods.linearReg()
elif choice == '2':
mods.polynomReg()
elif choice == '3':
mods.RidgeReg()
elif choice == '4':
mods.LassoReg()
elif choice == '5':
mods.ElasticNetReg()
elif choice == '6':
mods.LogisticReg()
else:
print('not valid')
except Exception as errr:
print(f"hey i didn't get what you want : {errr}")
###################################
## classification ##
###################################
def classify():
print("")
###################################
## /classification ##
###################################
# Print the ASCII art of the brain
# with open('assets/brain.txt', 'r') as file:
# print(file.read())
def getFile():
csv_path = input("Enter the path of the CSV file: ").replace("\"", "")
data = pd.read_csv(csv_path)
return data
data = getFile()
opr = Opr(data)
mods = Models(data)
while True:
try:
inp = input(getPrompt()+" >>")
if inp == 'mean':
opr.mean()
elif inp in ['head','top']:
opr.showHead()
elif inp in ['tail','last']:
opr.showTail()
elif inp in ['describe','des']:
opr.describeCsv()
elif inp == 'show columns':
opr.showColumns()
elif inp == 'models':
models(data)
elif inp == 'median':
opr.median()
elif inp == 'info':
opr.dataInfo()
elif inp == 'linearReg':
mods.linearReg()
elif inp == 'polynomReg':
mods.polynomReg()
elif inp == 'ridgeReg':
mods.RidgeReg(data)
elif inp == 'lassoReg':
mods.LassoReg(data)
elif inp == 'logisticReg':
mods.LogisticReg(data)
elif inp == 'learn':
mods.tutor()
elif inp == 'grafty':
grafty(data)
elif inp == 'changeFile':
data = getFile()
elif inp == 'classification':
classify()
elif inp == 'clear':
os.system('cls' if os.name == 'nt' else 'clear')
elif inp == 'ls' or inp == 'dir':
os.system('dir' if os.name == 'nt' else 'ls -al')
elif inp == 'brainwave' or inp == 'brain':
fl = open('./assets/brain.txt', 'r').read()
print(fl)
elif inp in ['showna','show na','showNA']:
opr.showNull()
elif inp == 'help' or inp == 'help me' or inp == 'please help' or inp == 'Help':
print("""
Usage: following commands can be executed from this script
\n\t1. mean\n\t2. head\n\t3. tail\n\t4. describe\n\t5. show na\n\t6. show columns\n\t7. models\n\t8. median\n\t9. info\n\t10. learn
11. linearReg\n\t12. polynomReg\n\t13. ridgeReg\n\t14. lassoReg\n\t15. logisticReg\n\t16. grafty\n\t17. changeFile
""")
elif inp == '':
print("huh how many times i told you that you must have to enter commands here don't you just understand")
elif inp == 'exit':
print('hey i see yah man next time i\'ll be more cool than now i am')
break
else:
print(f"No such command found: {inp}")
continue
except Exception as err:
print(f"Sorry, the following error occurred: {err}")
continue
# "C:\Users\shubh\Downloads\speed.csv"