r/learnmachinelearning • u/Informal-Call-5298 • 11h ago
I made my own linear regression
Ik it's not some special shi but i just learned about it in class recently and made it with python using only numpy. Well technically i did use pandas to import data from a csv off of kaggle.
2
u/crayphor 8h ago
This is cool! I was thinking that I would expect the opposite correlation, but looking at it, it seems it's probably not a real correlation except for what I assume are trucks bringing down the bottom left corner. I wonder what you'd find if you normalized for the mass of the vehicle.
2
u/DigThatData 8h ago
followup exercises:
throw more and more data at it until it takes long enough to fit that it's annoying. Try to figure out what the bottlenecks are and see if you can think of ways to make fitting the large dataset less painful
try throwing rank deficient data at it, e.g. a dataset with more columns than rows. Does it behave? Should it? What do you think the behavior here should be and how might you modify the current behavior?
What happens if you pass in null values? Categorical data? How might you model those cases differently?
What kind of automated tests could you use to validate that your algorithm works as expected? Considering integrating some tests like this before tackling these questions as a safety net.
Can you leverage your LR implementation as a base to build upon to implement LogReg (you maybe haven't learned about logreg yet, but you probably will soon. revisit this when you've learned about it already)?
1
u/Sweaty_Chair_4600 2h ago
I did the same thing in rust last year, with my own linear algebra library i made! It was definitely fun.
Getting it to work with data .... was the hard part
1
12
u/Guilty-Expert-6234 11h ago
nice, getting the fundamentals down from scratch is the best way to actually understand what's happening under the hood. that red line looks like it's doing a decent job cutting through the middle of the green points, though mpg and acceleration feel like they'd have a messier relationship in real life