#๐Ÿ”’ Need help with a machine learning model I trained

47 messages ยท Page 1 of 1 (latest)

twilit bobcatBOT
#

@pale oracle

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

pale oracle
#

I'm not sure why my message got deleted so posting it here again

#

Hey all, I'm sort of new to this entire Machine learning, AI concept. using some YouTube videos, few resources from Kaggle, blogs , etc, I got to know about quite a few models. now I've actually started implementing them. I was referring to a YouTube video for a car price prediction model .

At 22:45 he has used oneHotEnocder for encoding a few columns ( I've used LabelEncoder )
and at 22:27 he has got the r2_score somewhere around 0.6267 later he uses multiple random_state values, trains models and calculates r2_score for different datasets ( gets r2_score around 0.89)
On the other hand when I also calculated r2_score for different random_state values, the maximum r2_score I got was 0.29

I'm seeing a huge difference here.

So, I've got **2 questions **

  1. just because the encoding method was changed does it really make this much of difference ?
  2. is it really feasible just to change the random_state value for getting better r2_score ?

for reference I'm attaching

  • .csv file for dataset
  • Jupyter notebook .ipynb file
  • model_execution.py file ( had created this to reduce the redundancy for model run and getting outputs )

YouTube video link : https://www.youtube.com/watch?v=iRCaMnR_bpA&list=PLKnIA16_RmvY5eP91BGPa0vXUYmIdtfPQ&index=3&t=1684s

I'm also open to any suggestions for accuracy improvement.

In this project we will build a car price predictor using Linear Regression. We will also convert it into a full-fledged website using the flask framework.

Link to dataset:
https://github.com/rajtilakls2510/car_price_predictor/blob/master/quikr_car.csv

Link to Notebook:
https://github.com/rajtilakls2510/car_price_predictor/blob/master/quikr_ca...

โ–ถ Play video
hidden summit
#
  1. The random state is not a hyperparamater
#
  1. I don't understand what you mean by using a LabelEncoder to encode columns, if you are doing it, that's simply wrong
#

The LabelEncoder is used to encode labels, that is ground truth

#

The Y column

#

The one hot encoding is used to encode categorical column in X

#

Basically, imagine a column of categorical values : red, blue and green. A LabelEncoder will turn red into 0, blue into 1 and green into 2.

#

However, there is no reason why green should be twice blue etc.

#

The one hot encoding will encode red as (1,0,0) blue as (0,1,0) and green as (0,0,1)

#

Which makes much more sense

#

So each component of the colors can be used accordingly

pale oracle
hidden summit
#

Yes, bc random state will have an influence on the performance

#

But not in a predictable, steady way

#

This is just random and you usually want to find an algorithm working well for all random states

pale oracle
#

about the encoder,
what if the column has about 200-300 different values ?

in the dataset I'm using the company , fuel_type have less number of values so one hot encoding would actually makes sense
but name column has about 254 unique values so using one hot encoder will actually make the dataset a lot messy

am I on the right track here, or I'm still missing something

#

I'm not able to upload my .pynb , .csv & .py files here otherwise I would have shown you

hidden summit
#

Either the name column is not relevant and should be removed from the X, or you still one-hot-encode it

#

Same, why would "Matthew" be worth 3 and "John" be worth 139 ? Doesn't make any sense

pale oracle
#

right but ig the name column will be useful later somewhere

#

may be to map the predictions

hidden summit
#

Ok but is there a reason why the name would have an influence on the output ?

pale oracle
#

not sure

twilit bobcatBOT
# pale oracle

Please react with โœ… to upload your file(s) to our paste bin, which is more accessible for some users.

pale oracle
#

this is my dataset file

#

I think it'll have some influence as it contains the model name as well

#

any thoughts ?

mortal venture
#

check feature importance

#

which feature gives bias to model or on which feature model is more dedicated or dependent

#

i dont feel name should be in it

pale oracle
#

okay this sounds familiar
must've read about it somewhere. will do some searching around it

pale oracle
#

I don't think name column matters that much

#

I tried with name column - one hot encoded
I got the r2_score as 0.6627

and without name column - dropped the column all together
I got the same r2_score

#

and yes now I agree the categorical columns from x has to be encoded using one-hot encoder

tall mauve
#

I doubt you would get still the same r2_score after dropping the name column so make sure to print number of features before starting training to make sure you actually dropped the name column

pale oracle
#

right lemme check the code once

#

ahh right
mistakenly I was using the same data for both the usecases

#

without name column the r2_score was 0.6032

#

not much difference though

#

uploading python file ( converted from jupyter notebook )
I'm open to suggestion for any improvements

twilit bobcatBOT
twilit bobcatBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.