

He has used chatGPT but his college tutor told him it was all wrong! Not certain exactly what he needs to do but can find out. Is this something you could assist with if I get some details?Rick_Muller wrote: ↑Sun Mar 19, 2023 7:19 amUse chatGPT to ask specific tech questions- you’ll get answers you need. What exactly does he need to do?
By all means post some details, it’s not my specialism though but others may now more. So much of learning these days is knowing how to gather and use the right info from what is available, and I suspect the task in hand will test that process.Leyland Claret wrote: ↑Sun Mar 19, 2023 7:26 amHe has used chatGPT but his college tutor told him it was all wrong! Not certain exactly what he needs to do but can find out. Is this something you could assist with if I get some details?
I know a lot of colleges have banned Chat GPTRick_Muller wrote: ↑Sun Mar 19, 2023 7:19 amUse chatGPT to ask specific tech questions- you’ll get answers you need. What exactly does he need to do?
Thank you so much! You sound as though you are thoroughly clued up which is amazing. I have sent this through to my lad. What he needs to know is that he has to do it himself but just needs guiding. Would it at all be possible to get in touch through email if he has any queries? I appreciate you have said you are struggling time wise and understand if it’s not possible. Many thanks. LeeClaretPete001 wrote: ↑Sun Mar 19, 2023 11:01 amDepends what he is doing. This is a simple object oriented AI: Machine learning linear regression model using Pandas, matplotlib, sklearn etc.
He can have it but I'd struggle to help time wise.
It's starting off with the libraries, then opening a CSV and database, designing the model, fitting the model and finally allowing the model to learn from the data.
To be honest there are loads of sites for Python just nick some code and get it working.
import pyodbc
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error, r2_score
from sklearn.linear_model import LinearRegression
import seaborn as sns
import sys
import statistics
class Querydata:
def Connect_to_database():
conn = pyodbc.connect('DRIVER={SQL Server Native Client 11.0};Trusted_Connection=Yes;SERVER=IR- _____________;DATABASE=_________;TrustServerCertificate=Yes')
cursor = conn.cursor()
cursor.execute('SELECT * FROM D_DETAILS')
Records = cursor.fetchall()
return Records
#def Importdata():
# dfAchievement_data = pd.read_csv(r'C:\Users\________\project_data\_________.csv')
# print(dfAchievement_data)
# return dfAchievement_data
class Linear_regression:
#constructor
# Calling main function
# if __name__ == "__main__":
# main
def __init__(self):
# Data extraction
dfAchievement_data = Querydata.Connect_to_database()
#Data pre-processing
self.Check_for_nulls(dfAchievement_data)
self.Generatevisuals(dfAchievement_data)
dfAchievement_data = self.outlier_removal(dfAchievement_data)
print('dfAchievement_data', dfAchievement_data)
self.ReGeneratevisuals(dfAchievement_data)
# Identifiying the x and y variables
x, y = self.creatingxandyvariables(dfAchievement_data)
self.CheckforXandy(x, y)
# Training the data
x_train, x_test, y_train, y_test = self.splitdataset(x, y)
print('print before create', x_train, y_test)
Fitted_model = self.Createmodel(x_train, y_train)
# Creating the model
self.Prediction(Fitted_model,x_test, y_test)
coefficients, intercept = self.Assessment(Fitted_model)
# Implementing the model
Predicted_writing_score = self.calculate_charges(72, coefficients, intercept)
print("calculate_charges", Predicted_writing_score)
#Triangulaing the model
self.check_calculated_score(x,y)
sys.exit()
def Check_for_nulls(dfAchievement_data):
pd.isna(dfAchievement_data)
rpisnull = pd.isnull(dfAchievement_data)
print("Are there any nulls", rpisnull)
pd.DataFrame.isna(dfAchievement_data)
def Generatevisuals(dfAchievement_data):
dfAchievement_data.plot(x="gender", y="math score", kind="bar")
sns.relplot(data=dfAchievement_data, x='reading score', y='writing score', hue='gender')
plt.show()
sns.pairplot(dfAchievement_data, hue='gender')
plt.show()
def outlier_removal(dfAchievement_data):
Reading_upper_limit = dfAchievement_data['reading score'].mean() + 3 * dfAchievement_data['reading score'].std()
Reading_lower_limit = dfAchievement_data['reading score'].mean() - 3 * dfAchievement_data['reading score'].std()
Writing_upper_limit = dfAchievement_data['writing score'].mean() + 3 * dfAchievement_data['writing score'].std()
Writing_lower_limit = dfAchievement_data['writing score'].mean() - 3 * dfAchievement_data['writing score'].std()
print("Reading upper limit: ", Reading_upper_limit)
print("Reading Lower Limit: ", Reading_lower_limit)
print("Writing upper limit: ", Writing_upper_limit)
print("Writing Lower Limit: ", Writing_lower_limit)
dfAchievement_data = dfAchievement_data[(dfAchievement_data['reading score'] > Reading_lower_limit) & (dfAchievement_data['reading score'] < Reading_upper_limit)]
dfAchievement_data = dfAchievement_data[(dfAchievement_data['writing score'] > Writing_lower_limit) & (dfAchievement_data['writing score'] < Writing_upper_limit)]
Reading_upper_limit = dfAchievement_data['reading score'].mean() + 3 * dfAchievement_data['reading score'].std()
Reading_lower_limit = dfAchievement_data['reading score'].mean() - 3 * dfAchievement_data['reading score'].std()
Writing_upper_limit = dfAchievement_data['writing score'].mean() + 3 * dfAchievement_data['writing score'].std()
Writing_lower_limit = dfAchievement_data['writing score'].mean() - 3 * dfAchievement_data['writing score'].std()
print("New Reading upper limit: ", Reading_upper_limit)
print("New Reading Lower Limit: ", Reading_lower_limit)
print("New Writing upper limit: ", Writing_upper_limit)
print("New Writing Lower Limit: ", Writing_lower_limit)
return dfAchievement_data
def ReGeneratevisuals(dfAchievement_data):
dfAchievement_data.plot(x="reading score", y="writing score", kind="bar")
# Instantiating a LinearRegression Model
sns.relplot(data=dfAchievement_data, x='reading score', y='writing score', hue='gender')
plt.show()
sns.pairplot(dfAchievement_data, hue='gender')
plt.show()
def creatingxandyvariables(dfAchievement_data):
x = dfAchievement_data['reading score']
y = dfAchievement_data['writing score']
print(x, y)
return x, y
def CheckforXandy(x, y):
print('Returned variable x', x)
print('Returned variable y', y)
def splitdataset(x, y):
x_train, x_test, y_train, y_test = train_test_split(
x, y, shuffle=True, train_size=0.3)
return x_train, x_test, y_train, y_test
def Createmodel(x_train, y_train):
print('in creatmodel func',x_train, y_train)
x_train = x_train.array.reshape(-1,1)
model = LinearRegression()
Fitted_model= model.fit(x_train, y_train)
return Fitted_model
def Prediction(model, x_test, y_test):
predictions = model.predict(x_test.array.reshape(-1,1))
r2 = r2_score(y_test, predictions)
rmse = mean_squared_error(y_test, predictions, squared=False)
print('The r2 is: ', r2)
print('The rmse is: ', rmse)
def Assessment(model):
coefficients = model.coef_
intercept = model.intercept_
return coefficients, intercept
def calculate_charges(Rdscore, coefficients, intercept):
print('Reading score', Rdscore)
return (Rdscore * coefficients) + intercept
def check_calculated_score(x,y):
print('Statistics mean x',statistics.mean(x))
print('Statistic mean y', statistics.mean(y))
Good point, I don't know what he is studying. I think M'ch Learning is part of the Computer Science T Level and it usually forms some aspect of Undergraduate study at L4.brexit wrote: ↑Sun Mar 19, 2023 1:27 pmHi Leyland
I assume your son is at Runshaw so he will be doing the T Level - Design Engineering?
if so, building and designing a "something" may be more appropriate - check out
https://store.arduino.cc/products/ardui ... X0QAvD_BwE
don't take this the wrong way, but if your son needs his dad to come on a football message board asking for assistance in this matter then I'm not sure this is the career for him going forward.Leyland Claret wrote: ↑Sun Mar 19, 2023 7:00 amMy lad has a project to complete for his A level in Design and Engineering. He is currently struggling to complete it and his tutors, how can say this…, aren’t being very helpfulHe has all the physical items but is struggling with the programming and coding side of things. Can you help
Hints, tips or actually speak/email with someone who has the knowledge to help. As you can imagine I am not particularly happy with the college and also working through the pandemic slightly hindered things…a lot!!
Thank you for your reply. He didn’t ask or know that I had requested some assistance in this. Due to the pandemic and a rather lacklustre approach by the college and the revolving door of tutors it has had things haven’t gone particularly smoothly the last couple of years. This includes his current tutor who is also leaving shortly and told some of his students that he didn’t care how things went as he was also leaving. Again I appreciate your input on something that didn’t need that type of responsepushpinpussy wrote: ↑Sun Mar 19, 2023 2:20 pmdon't take this the wrong way, but if your son needs his dad to come on a football message board asking for assistance in this matter then I'm not sure this is the career for him going forward.
Thank you Rowls. More like the type of post I like to read…
Hiya pal. My lad has sent me this which obviously makes no sense to me! I have also been told it’s a Raspberry Pi Pico. Any help would be brilliant.ClaretPete001 wrote: ↑Sun Mar 19, 2023 2:14 pmGood point, I don't know what he is studying. I think M'ch Learning is part of the Computer Science T Level and it usually forms some aspect of Undergraduate study at L4.
If you find out what his project is supposed to be about and what tools he is using then might be able to help.
If he want some simple code to read a text file (CSV) and create a machine learning Python programme to make predictions then the above will help.
For example, if he wants to get Ashley Barnes goal scoring record then he could use the above to predict when he is next likely to score. Course, Ash might be so random you can't get any mathematic correlation but I guess you could mess with the data and make it work I doubt any examiner is going to check.
But it all depends what his project is on.
As I suspected, this is machine level programming not machine learningLeyland Claret wrote: ↑Sun Mar 19, 2023 3:46 pmHiya pal. My lad has sent me this which obviously makes no sense to me! I have also been told it’s a Raspberry Pi Pico. Any help would be brilliant.
# read the Adafruit NeoTrellis keypad
# connect to 4 digit seven segment LED display
# numbers inputted on Adafruit display on LED display
# countdown displayed, counts backwards in the form 00:00
# countdown ends, two red LEDs turn on
Cheers
Oh ok looks like you've got some good advice above.Leyland Claret wrote: ↑Sun Mar 19, 2023 3:46 pmHiya pal. My lad has sent me this which obviously makes no sense to me! I have also been told it’s a Raspberry Pi Pico. Any help would be brilliant.
# read the Adafruit NeoTrellis keypad
# connect to 4 digit seven segment LED display
# numbers inputted on Adafruit display on LED display
# countdown displayed, counts backwards in the form 00:00
# countdown ends, two red LEDs turn on
Cheers
Croydon Claret wrote: ↑Sun Mar 19, 2023 6:11 pmSome basic programming tips to help him along, in no particular order.
1) Take versioned backups. Don't just keep saving the same file over and over again. You can 100% guarantee that he'll change something then suddenly all his previous hard work has stopped executing. Best case you can spend hours figuring out what you broke, worst case you may never figure it out
Wherever he's storing his code then create subfolders and call them "version 1", "version 2" etc. When he's happy that he's made good progress then he can save the entire thing as a new version. If he screws up the code (ask me how I know) then he only has to go back to the last known working version
2) Add comments before each little section of code to describe what it's doing. When you're in the zone and it's all like "A Beautiful Mind" then the code all makes sense. Come back to it in the morning and often you have no clue what drugs you were on when you wrote that code the previous day
3) Leave a note at the end of the day re where you're at and what you need to do next. Often you come back in the morning then whilst the code might be commented nicely and understandable you can't remember what the hell the next steps are.
4) Don't write too much code at once without testing what you have done so far. Personally I might write half a dozen lines then give it a quick test before continuing. It's a lot easier to check you're going down the write track. If you change code all over the place and it all stops working it can be a nightmare figuring out which change broke the code.
5) Try to put distinct and/or repeatable blocks of code into functions that can be called from the main running code. You don't want a routine that's 1000 lines long, it's too hard to read and maintain. ClaretPete's earlier code is a good example of using functions. If he just wants to get the code written because he's still learning then maybe don't worry so much about this right now if it makes it too difficult, but it's definitely something he would want to look at later. Once he has a working version then he can refactor it later to make it neater![]()
Maybe he could fabricate a career in the legal professionpushpinpussy wrote: ↑Sun Mar 19, 2023 2:20 pmdon't take this the wrong way, but if your son needs his dad to come on a football message board asking for assistance in this matter then I'm not sure this is the career for him going forward.
And you complain about people picking on you ... Wow you really are a complete and utter ****pushpinpussy wrote: ↑Sun Mar 19, 2023 2:20 pmdon't take this the wrong way, but if your son needs his dad to come on a football message board asking for assistance in this matter then I'm not sure this is the career for him going forward.
Is that you LongTimeLurker?ClaretPete001 wrote: ↑Sun Mar 19, 2023 11:01 amDepends what he is doing. This is a simple object oriented AI: Machine learning linear regression model using Pandas, matplotlib, sklearn etc.
He can have it but I'd struggle to help time wise.
It's starting off with the libraries, then opening a CSV and database, designing the model, fitting the model and finally allowing the model to learn from the data.
To be honest there are loads of sites for Python just nick some code and get it working.
import pyodbc
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error, r2_score
from sklearn.linear_model import LinearRegression
import seaborn as sns
import sys
import statistics
class Querydata:
def Connect_to_database():
conn = pyodbc.connect('DRIVER={SQL Server Native Client 11.0};Trusted_Connection=Yes;SERVER=IR- _____________;DATABASE=_________;TrustServerCertificate=Yes')
cursor = conn.cursor()
cursor.execute('SELECT * FROM D_DETAILS')
Records = cursor.fetchall()
return Records
#def Importdata():
# dfAchievement_data = pd.read_csv(r'C:\Users\________\project_data\_________.csv')
# print(dfAchievement_data)
# return dfAchievement_data
class Linear_regression:
#constructor
# Calling main function
# if __name__ == "__main__":
# main
def __init__(self):
# Data extraction
dfAchievement_data = Querydata.Connect_to_database()
#Data pre-processing
self.Check_for_nulls(dfAchievement_data)
self.Generatevisuals(dfAchievement_data)
dfAchievement_data = self.outlier_removal(dfAchievement_data)
print('dfAchievement_data', dfAchievement_data)
self.ReGeneratevisuals(dfAchievement_data)
# Identifiying the x and y variables
x, y = self.creatingxandyvariables(dfAchievement_data)
self.CheckforXandy(x, y)
# Training the data
x_train, x_test, y_train, y_test = self.splitdataset(x, y)
print('print before create', x_train, y_test)
Fitted_model = self.Createmodel(x_train, y_train)
# Creating the model
self.Prediction(Fitted_model,x_test, y_test)
coefficients, intercept = self.Assessment(Fitted_model)
# Implementing the model
Predicted_writing_score = self.calculate_charges(72, coefficients, intercept)
print("calculate_charges", Predicted_writing_score)
#Triangulaing the model
self.check_calculated_score(x,y)
sys.exit()
def Check_for_nulls(dfAchievement_data):
pd.isna(dfAchievement_data)
rpisnull = pd.isnull(dfAchievement_data)
print("Are there any nulls", rpisnull)
pd.DataFrame.isna(dfAchievement_data)
def Generatevisuals(dfAchievement_data):
dfAchievement_data.plot(x="gender", y="math score", kind="bar")
sns.relplot(data=dfAchievement_data, x='reading score', y='writing score', hue='gender')
plt.show()
sns.pairplot(dfAchievement_data, hue='gender')
plt.show()
def outlier_removal(dfAchievement_data):
Reading_upper_limit = dfAchievement_data['reading score'].mean() + 3 * dfAchievement_data['reading score'].std()
Reading_lower_limit = dfAchievement_data['reading score'].mean() - 3 * dfAchievement_data['reading score'].std()
Writing_upper_limit = dfAchievement_data['writing score'].mean() + 3 * dfAchievement_data['writing score'].std()
Writing_lower_limit = dfAchievement_data['writing score'].mean() - 3 * dfAchievement_data['writing score'].std()
print("Reading upper limit: ", Reading_upper_limit)
print("Reading Lower Limit: ", Reading_lower_limit)
print("Writing upper limit: ", Writing_upper_limit)
print("Writing Lower Limit: ", Writing_lower_limit)
dfAchievement_data = dfAchievement_data[(dfAchievement_data['reading score'] > Reading_lower_limit) & (dfAchievement_data['reading score'] < Reading_upper_limit)]
dfAchievement_data = dfAchievement_data[(dfAchievement_data['writing score'] > Writing_lower_limit) & (dfAchievement_data['writing score'] < Writing_upper_limit)]
Reading_upper_limit = dfAchievement_data['reading score'].mean() + 3 * dfAchievement_data['reading score'].std()
Reading_lower_limit = dfAchievement_data['reading score'].mean() - 3 * dfAchievement_data['reading score'].std()
Writing_upper_limit = dfAchievement_data['writing score'].mean() + 3 * dfAchievement_data['writing score'].std()
Writing_lower_limit = dfAchievement_data['writing score'].mean() - 3 * dfAchievement_data['writing score'].std()
print("New Reading upper limit: ", Reading_upper_limit)
print("New Reading Lower Limit: ", Reading_lower_limit)
print("New Writing upper limit: ", Writing_upper_limit)
print("New Writing Lower Limit: ", Writing_lower_limit)
return dfAchievement_data
def ReGeneratevisuals(dfAchievement_data):
dfAchievement_data.plot(x="reading score", y="writing score", kind="bar")
# Instantiating a LinearRegression Model
sns.relplot(data=dfAchievement_data, x='reading score', y='writing score', hue='gender')
plt.show()
sns.pairplot(dfAchievement_data, hue='gender')
plt.show()
def creatingxandyvariables(dfAchievement_data):
x = dfAchievement_data['reading score']
y = dfAchievement_data['writing score']
print(x, y)
return x, y
def CheckforXandy(x, y):
print('Returned variable x', x)
print('Returned variable y', y)
def splitdataset(x, y):
x_train, x_test, y_train, y_test = train_test_split(
x, y, shuffle=True, train_size=0.3)
return x_train, x_test, y_train, y_test
def Createmodel(x_train, y_train):
print('in creatmodel func',x_train, y_train)
x_train = x_train.array.reshape(-1,1)
model = LinearRegression()
Fitted_model= model.fit(x_train, y_train)
return Fitted_model
def Prediction(model, x_test, y_test):
predictions = model.predict(x_test.array.reshape(-1,1))
r2 = r2_score(y_test, predictions)
rmse = mean_squared_error(y_test, predictions, squared=False)
print('The r2 is: ', r2)
print('The rmse is: ', rmse)
def Assessment(model):
coefficients = model.coef_
intercept = model.intercept_
return coefficients, intercept
def calculate_charges(Rdscore, coefficients, intercept):
print('Reading score', Rdscore)
return (Rdscore * coefficients) + intercept
def check_calculated_score(x,y):
print('Statistics mean x',statistics.mean(x))
print('Statistic mean y', statistics.mean(y))
Has he tried turning it off, then on again?Leyland Claret wrote: ↑Sun Mar 19, 2023 7:00 amMy lad has a project to complete for his A level in Design and Engineering. He is currently struggling to complete it and his tutors, how can say this…, aren’t being very helpfulHe has all the physical items but is struggling with the programming and coding side of things. Can you help
Hints, tips or actually speak/email with someone who has the knowledge to help. As you can imagine I am not particularly happy with the college and also working through the pandemic slightly hindered things…a lot!!
I don’t post on here much and I haven’t come across this person before but it was just a totally uncalled for response without knowing anything in depth about my sons situation with this. It is critical my lad gets this done and I thought I would try this media to seek assistance as he’s been utterly let down by his college tutors in my opinion. Thank you for taking the time to comment.
To get it to turn on in the 1st place would be progress
Thank you for your assistance in this.Croydon Claret wrote: ↑Mon Mar 20, 2023 8:02 pmI'll try to share a basic construct tomorrow re how I would approach the problem
I don't use Python, or have experience of Raspberry Pi but I do teach programming in various other languages and the constructs are exactly the same
He is a fantasist Leyland Claret with delusions of being a solicitor and multiple business owner ... His comment on here was well out of order as are his comments about people leaving football matches early ...Leyland Claret wrote: ↑Mon Mar 20, 2023 9:06 pmI don’t post on here much and I haven’t come across this person before but it was just a totally uncalled for response without knowing anything in depth about my sons situation with this. It is critical my lad gets this done and I thought I would try this media to seek assistance as he’s been utterly let down by his college tutors in my opinion. Thank you for taking the time to comment.
I've got a little experience setting up a Raspberry Pi (albeit, at OS level and running a Node.js server.) I've done a bit of work with Arduino - which is probably more suited to the task based on what I've read.Panthro wrote: ↑Sun Mar 19, 2023 8:56 amCodecademy is a good place to start learning the fundamentals of programming using various languages, here is the Python link: -https://www.codecademy.com/learn/learn-python-3
Thank you for your amazing help with this to you and all the other (minus 1 plank) people who have contributed. He has digested all the information given on here and from other sources and he has come up with a solution! He has scaled the project down a little as it was a little too in-depth for a complete novice. So now he has a countdown timer that concludes with an LED lighting up and an audible buzzer. He choose this project originally because he would have aced it using circuits but his ‘tutors’ decided it needed to be run through programming and coding which hadn’t been covered. When he questioned this his tutors gave him examples of coding on YouTube to watch and to crack on! He’s not had the best of times in his college years but fingers crossed he gets out with the grades that he requires. He loves his engineering and is hoping to bag himself an apprenticeship. Thank you all again for your fantastic input.Croydon Claret wrote: ↑Tue Mar 21, 2023 1:27 pmI came up with a basic template for him. It's just a starter and will no doubt need change as things become more known but it might give him an idea of how to break the challenge down into its constituent parts and not get bogged down trying to write all his code in one function.
Caveat - I don't program with Python so hope there's no syntax errors. Haven't fleshed out any of the logic, but given indicators for what each section should do.
I wasn't sure what the exact rules were for "read the keypad" so had to cut my template short as I'm not sure what the inputted data represented. I added some comments in the example template to show where I'm confused
I understand that the numbers later need to be displayed in hh:mm format but wasn't sure what the numbers coming in represent
- Do the inputted numbers represented an hh:mm time format e.g. "12:59" rather than an amount of seconds?
- Is he expected to wait until a set number of buttons have been pressed before processing the input? if so then that leaves you wide open to bugs if converting to hh:mm and the user pressed 4 large numbers e.g. "12", "11", "10" and "12", which you then can't convert to a time
If you're not waiting for a set number of button presses then at some point you have to tell the program that you're done listening for button presses so that the rest of the logic can flow. Wasn't sure if there was further info about what is deemed to be sufficient button presses to continue and whether the inputted numbers should be deemed as an amount of seconds or an exact time in hours and minutes?
back to the code...
At which point is he stuck at the moment? Has he managed to connect to the keyboard and convert the button presses into numbers(regardless of what those numbers actually mean as mentioned above)?
TEMPLATE
# Read the number from the keyboard
userInput = inputFromKeyboard()
# You might need a date/time formatting function here depending on how you're processing the inputted numbers. See questions in "inputFromKeyboard()" method
# userInput = formatToDataTime(userInput)
# Connect to the LED Panel and set the defaults
initialiseLEDPanel()
# Display the number on the LED panel
timeCountdown(userInput)
# Light up the LED dots
illuminateLEDDots())
def inputFromKeyboard():
# Add logic here to capture the keyboard numbers
# (Not sure what the requirements or expectations are here.)
# See questions in thread
def timeCountdown(timeToDisplay):
# Set up a "while" loop that counts down the time and calls the display function every second
# Start of "while" loop (while loop continues until time is at or equal to zero)
# Call the display function passing in the current time
displayOnLED(timeToDisplay)
# Add logic to subtract one second from the time
# End of "while" loop
def initialiseLEDPanel():
# Add logic to initialise the LED panel
# https://circuitdigest.com/microcontroll ... lay-module
def displayOnLED(timeToDisplay):
# format the timeToDisplay parameter into 4 numbers(preferably by calling a dedicated function) and illuminate the LEDs
# https://circuitdigest.com/microcontroll ... lay-module
def illuminateLEDDots():
# Add logic to illuminate the LED dots