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

Hello,

I have added an open source node in model studio and i have written the following pyhton script. It seem that the system does not recognize the dm_model.fit part of the script and returns an error. Any suggestions?
 
Thanks,

Andreas
 

from sklearn import decisiontreeclassifier
import sklearn as sk
from sklearn.metrics import accuracy_score
from pandas.api.types import is_object_dtype
import pandas as pd
import numpy as np
import pickle

# because of transformation/imputation process, some columns are converted into objects
# the lines below will convert all the objects into a string type

Y_full = dm_inputdf[dm_dec_target]
X_full = dm_inputdf[dm_interval_input]

Y_train = dm_traindf[dm_dec_target]
X_train = dm_traindf[dm_interval_input]


dm_model=DecisionTreeClassifier()
dm_model=dm_model.fit(X_train, Y_train)

andreas_zaras_0-1623138043028.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
andreas_zaras
Pyrite | Level 9

Hello!

 

I found the error.

 

I had to import the python tree library at the beggining of the script i.e.

 

from sklearn import tree

Thanks,

 

Andreas

View solution in original post

2 REPLIES 2
ballardw
Super User

Please,

ANY time you ask about an error, show the log with the entire procedure code and all the messages, errors, warnings and notes.

 

Copy from the log and paste into a text box opened on the forum with the </> icon to preserve formatting of text as SAS often supplies diagnostic information that is column specific and the message windows will reformat the text making the messages less useful or readable.

 

With "returns an error" we don't have any clue what the error is. You might just have misspelled a variable, data set name or option.

 

andreas_zaras
Pyrite | Level 9

Hello!

 

I found the error.

 

I had to import the python tree library at the beggining of the script i.e.

 

from sklearn import tree

Thanks,

 

Andreas

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 614 views
  • 1 like
  • 2 in conversation