Python Forum
Supervised learning, tree based model - problems splitting data
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Supervised learning, tree based model - problems splitting data
#1
I am currently using a tree based model for self training purposes and there is one area of code I get stuck. I used One-hot code to extract additional columns from my original data. Viewing the dataframe the new columns are visible, but trying to split the data into new features (X) and response (y), I continually get the KeyError that the new columns are not in the index.

My code:

X = df.loc[:, ["Mileage", "AgeP", "Category_SAV", "Category_SUV", "Category_Sedan", "Category_Small", "Category_Super"]]
y = df.loc[:, "Claim"]
The error however is only on the Category_ index columns even though I see these in the dataframe.
buran write May-16-2023, 05:26 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Problems with ploting data vermor 4 1,372 Jun-10-2024, 05:05 PM
Last Post: vermor
  Grouping Data based on 30% bracket purnima1 0 1,385 Feb-16-2023, 07:14 PM
Last Post: purnima1
  Make unique id in vectorized way based on text data column with similarity scoring ill8 0 1,434 Dec-12-2022, 03:22 AM
Last Post: ill8
  Training a model to identify specific SMS types and extract relevant data? lord_of_cinder 0 1,553 Oct-10-2022, 04:35 AM
Last Post: lord_of_cinder
  Fitting transfer function model to FRF data ymohammadi 0 2,447 Feb-10-2022, 10:02 AM
Last Post: ymohammadi
  Pandas Data frame column condition check based on length of the value aditi06 1 3,707 Jul-28-2021, 11:08 AM
Last Post: jefsummers
  Python Machine Learning: For Data Extraction JaneTan 0 2,402 Nov-24-2020, 06:45 AM
Last Post: JaneTan
  Ordered Learning Model (OLM) FranciscoPL 1 2,261 Oct-05-2020, 04:20 PM
Last Post: Larz60+
  Problems feeding live input from my microphone into a keras model (SegFault: 11) zeptozetta 1 3,345 Sep-14-2020, 03:08 AM
Last Post: zeptozetta
  Dropping Rows From A Data Frame Based On A Variable JoeDainton123 1 2,858 Aug-03-2020, 02:05 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020