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
  Grouping Data based on 30% bracket purnima1 0 961 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 898 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 984 Oct-10-2022, 04:35 AM
Last Post: lord_of_cinder
  Fitting transfer function model to FRF data ymohammadi 0 1,697 Feb-10-2022, 10:02 AM
Last Post: ymohammadi
  Pandas Data frame column condition check based on length of the value aditi06 1 2,707 Jul-28-2021, 11:08 AM
Last Post: jefsummers
  Python Machine Learning: For Data Extraction JaneTan 0 1,861 Nov-24-2020, 06:45 AM
Last Post: JaneTan
  Ordered Learning Model (OLM) FranciscoPL 1 1,670 Oct-05-2020, 04:20 PM
Last Post: Larz60+
  Problems feeding live input from my microphone into a keras model (SegFault: 11) zeptozetta 1 2,604 Sep-14-2020, 03:08 AM
Last Post: zeptozetta
  Dropping Rows From A Data Frame Based On A Variable JoeDainton123 1 2,238 Aug-03-2020, 02:05 AM
Last Post: scidam
  How to extract data from paragraph using Machine Learning with python? bccsthilina 2 3,068 Jul-27-2020, 07:02 AM
Last Post: hussainmujtaba

Forum Jump:

User Panel Messages

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