-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinRegFile.py
More file actions
113 lines (73 loc) · 3.6 KB
/
Copy pathLinRegFile.py
File metadata and controls
113 lines (73 loc) · 3.6 KB
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
import tkinter as tk
from tkinter import filedialog
from tkinter import PhotoImage
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from tkinter import ttk
import customtkinter as ctk
from PIL import ImageTk, Image
ctk.set_appearance_mode("dark")
class LinReg:
def __init__(self, win, df):
self.win = win
self.df = df
def __call__(self):
def makeLine():
# errorLabel2.configure(text="")
chosen_val = selection5.index(lin_clicked.get())
chosen_val2 = selection6.index(lin_clicked2.get())
numPoints = int(linInput.get())
data_selection = self.df.iloc[:numPoints, chosen_val]
data_selection2 = self.df.iloc[:numPoints, chosen_val2]
linInput.delete(0, tk.END)
newData = []
newData2 = []
for o in data_selection:
newData.append(o)
for i in data_selection2:
newData2.append(i)
plt.plot(newData, newData2)
plt.show()
# Start of Linear Regression Setup (Universal Color: "#399adb")
icon_image = PhotoImage(file="DatafyLogo.png")
lr_page = ctk.CTkToplevel(self.win)
lr_page.title("Linear Regression Page")
lr_page.geometry("400x400")
lr_page.iconphoto(False, icon_image)
lr_title = ctk.CTkLabel(master=lr_page,
text="\nLinear Regression",
font=('Comic Sans Bold', 25), text_color="#399adb")
lr_title.pack(padx=10, pady=2)
scatter_prompt = 'How many data points would you like to have? The maximum points you can have are: ' + str(
len(self.df))
lin_question = ctk.CTkLabel(master=lr_page, text=scatter_prompt, text_color="#399adb", font=("Comic Sans", 15))
lin_question.pack(padx=10, pady=4)
linInput = ctk.CTkEntry(master=lr_page,fg_color="#399adb", placeholder_text_color='white', placeholder_text="Number of Data Points")
linInput.pack(padx=10, pady=5)
selection5 = list(self.df.columns.values)
selection6 = list(self.df.columns.values)
#---------------------------------------------------------------------
lin_label1 = ctk.CTkLabel(
master=lr_page, text="What selection of data would you like for the x-axis?", text_color="#399adb", font=("Comic Sans", 15))
lin_label1.pack(padx=10, pady=7)
lin_clicked = tk.StringVar()
lin_clicked.set(selection5[0])
xAxisDropdown3 = ctk.CTkOptionMenu(master=lr_page, variable=lin_clicked, values=selection5, fg_color="#399adb", dropdown_fg_color="#399adb")
xAxisDropdown3.pack(padx=10, pady=8)
#---------------------------------------------------------------------
lin_label2 = ctk.CTkLabel(
master=lr_page, text="What selection of data would you like for the y-axis?", font=("Comic Sans", 15), text_color="#399adb")
lin_label2.pack(padx=10, pady=10)
lin_clicked2 = tk.StringVar()
lin_clicked2.set(selection6[1])
yAxisDropdown3 = ctk.CTkOptionMenu(master=lr_page, variable=lin_clicked2, values=selection6, fg_color="#399adb", dropdown_fg_color="#399adb")
yAxisDropdown3.pack(padx=10, pady=11)
#---------------------------------------------------------------------
lr_question = ctk.CTkLabel(
master=lr_page,
text="Click the button below to plot a Linear Regression plot!", font=('Comic Sans', 15), text_color="#399adb")
lr_question.pack(padx=10, pady=13)
lr_button = ctk.CTkButton(master=lr_page,
text="Plot Linear Regression", fg_color="#399adb", height=25, font=("Arial", 15), command=makeLine)
lr_button.pack(padx=10, pady=13)