BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DaisyQL
Fluorite | Level 6

Hi, 

 

I follow this repo to create my open source code node. My target is character, so I need to add label encoder (from sklearn) to transform it to numeric. Here is my code:

le = LabelEncoder()
y = le.fit_transform(dm_traindf[dm_dec_target])

X = dm_traindf.loc[:, dm_input]

params = {'n_estimators': 100}
dm_model = RandomForestClassifier(**params)
dm_model.fit(X, y)

fullX = dm_inputdf.loc[:, dm_input]
dm_inputdf.predict(fullX)

I was able to run the fit, but when I tried to get the predict value the program failed. I guess the label or the level is not lined up with input, but I don't know how to fix. 

TIA for all the help or comments, thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
RadhikhaMyneni
SAS Employee
Hi,
When you say it failed, can you tell if the failure was in Python or afterwards in the Open Source Code node?. Did you place the node in the Supervised Lane?

Also, can you post back the failure messages from the log - When an error occurs in the Open Source Code node, the generic message Encountered error code 1 when executing Python program is highlighted in the log. The detailed error messages that help pinpoint the problem are displayed above this generic message and you can scroll up to view them. You can also search for the first occurrence of executeProcess string in the log to see the start of these detailed error messages.

I would think your use case should work as the only two columns needed in dm_scoreddf dataframe that the node expects you to create (if it is in Supervised Lane) are posterior probabilities. I am assuming here that you have a binary or nominal target. It should not matter that you label encoded the target and used it in the Python code.

Radhikha

View solution in original post

2 REPLIES 2
RadhikhaMyneni
SAS Employee
Hi,
When you say it failed, can you tell if the failure was in Python or afterwards in the Open Source Code node?. Did you place the node in the Supervised Lane?

Also, can you post back the failure messages from the log - When an error occurs in the Open Source Code node, the generic message Encountered error code 1 when executing Python program is highlighted in the log. The detailed error messages that help pinpoint the problem are displayed above this generic message and you can scroll up to view them. You can also search for the first occurrence of executeProcess string in the log to see the start of these detailed error messages.

I would think your use case should work as the only two columns needed in dm_scoreddf dataframe that the node expects you to create (if it is in Supervised Lane) are posterior probabilities. I am assuming here that you have a binary or nominal target. It should not matter that you label encoded the target and used it in the Python code.

Radhikha
DaisyQL
Fluorite | Level 6

Thank you so much! It is so helpful and you save my life!

 

I checked my log and found the issue, because I had missing data in fullX, once I remove the missing data, the node can produce the result.

 

Thanks again for helping me locate the error message. I was very struggling with finding out the error in the log, maybe the team could consider highlight the python error message in the future that would be easier for users like me know very little about SAS code.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 576 views
  • 1 like
  • 2 in conversation