#🔒 Help with filtering dataset, random forest prediction

27 messages · Page 1 of 1 (latest)

lean olive
#

Hello im taking my first steps in DS, and here I have an exercise I cannot continue.

The provided starter Colab removes all non-numeric columns from both datasets. it is intended by the exercise itself. Nothing should be done with other columns (yet). The rule is that I can only make filters. Nothing else can be changed. The ultimate goal is to keep only sale prices for CABA. I also cannot touch the model or its parameters. The objetive is to predict prices with all those filters.

Things I do not understand yet:
Training and learning dataset should have the same filters?
I'm having trouble imputing missing values, and I feel that's the key for a good prediction.

Here is the most important db info:

Data columns (total 17 columns):
 #   Column            Non-Null Count    Dtype  
---  ------            --------------    -----  
 2   lat               422620 non-null   float64
 3   lon               422604 non-null   float64
 5   publisher_id      663922 non-null   object 
 7   location_0        982787 non-null   object 
 8   location_1        982769 non-null   object 
 12  operation_type    982487 non-null   object 
 13  property_type     982784 non-null   object 
 14  source            1283423 non-null  object 
 15  price             984477 non-null   float64 ```

Here are the important columns info: 

```df_ent["currency_type"].unique()
array(['dolares', 'Otro', 'pesos'], dtype=object)```

```df_ent["location_1"].unique()
array(['Ciudad Autónoma de Buenos Aires', 'Capital Federal', 'CABA'], dtype=object)```

Here is the model: 
```RandomForestRegressor(max_depth=5, n_estimators=50, n_jobs=-1, random_state=42)```

Filters for training and learning are in the images.
The `df_ap = df_ap.select_dtypes('number')` it is intended by the exercise itself.

You can also find in the images an histogram with the not so good final predictions

Thank you in advance!
olive templeBOT
#

@lean olive

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.

harsh monolith
#

also, can you tell me which features are numeric, and why it would be an issue to use only those features?

lean olive
harsh monolith
lean olive
# harsh monolith also, can you tell me which features are numeric, and why it would be an issue t...

As numeric features I have: id, lat, lon, price, publisher id

In lat, lon I have like 75% of missing values. I have only 422620 values out of 1283423.

But it will be an issue because I wont filter by the categorical features that I want: CABA, selling prices... The goal is not to predict the prices from every city, just that one in particular

df_ent["location_1"].unique()
array(['Ciudad Autónoma de Buenos Aires', 'Capital Federal', 'CABA'], dtype=object)

I've already cleaned it but it had other cities

df_ent["currency_type"].unique()
array(['dolares', 'Otro', 'pesos'], dtype=object)

I have different currencies, and I want to all be the same

Maybe I'm mistaking myself and i'm not quite understanding how filtering and imputating missing values is

harsh monolith
lean olive
#

What about imputating missing values in lat and lon?
I've used the median, but I end up with like 80% of my predicted data with just one number... that makes sense since im telling the model "ok all of these houses are in the exact same place"

harsh monolith
harsh monolith
lean olive
harsh monolith
lean olive
#

Got it, thank you

lean olive
#

yet I still have missing values... so every long lat is relatively similar at the beginning. Then when I fill missing values with the median the model is not predicting right

#

This is what I'm trying to say, taht im doing:

df_ent['lat'] = df_ent['lat'].fillna(df_ent['lat'].median())
df_ent['lon'] = df_ent['lon'].fillna(df_ent['lon'].median())
df_ent = df_ent.fillna(df_ent.median(numeric_only=True))

harsh monolith
#

you have to use different imputation methods for different kinds of data. can you see why imputing lat and long with the overall median is a bad idea?

lean olive
#

Yes, because every single value will be the median (over 70% of my data will be the median)... That's the reason why my prediction has a big spike in the middle

#

What other ways of imputing lat and long can I look for?

harsh monolith
lean olive
#

So using another variable to predict a (lat, long) data point? or to use something like nearest neighbors imputation?

harsh monolith
lean olive
#

Ok I will try that. Thank you very much for the help! I appreciate it

olive templeBOT
#
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.