Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • error occurred while loading r_ml_stata_cv.ado

    Hello,
    when I run r_ml_ stata_cv for example 1 which is in the help of this command, it always appear the following words:

    File "<stdin>", line 1
    ################################################## ##############################
    SyntaxError: invalid syntax
    (1041 lines skipped)
    (error occurred while loading r_ml_stata_cv.ado)
    r(7102);


    Can someone tell me how to do this?
    Best regards,
    Jalali

  • #2
    I have the same issue. Looks like python code in the r_ml_stata_cv.ado went wrong? I used Stata 16.1 SE. Not sure if the Stata version causes to it, because r_ml_stata_cv.ado is just release on 2023?
    Someone else can help to get out? Thank you.

    Comment


    • #3
      I am using Stata 17 MP version. I installed Python and the specific packages, but I am also getting the same error message.

      File "<stdin>", line 1
      ################################################## ##############################
      SyntaxError: invalid syntax
      (1041 lines skipped)
      (error occurred while loading r_ml_stata_cv.ado)
      r(7102); Therefore, it appears a problem in both Stata 16 and 17. It would be helpful to know if others were able to overcome this error.

      Comment


      • #4
        I emailed Giovanni Cerulli, and he sent back a response that worked. To share and help others, here is his suggestion:

        I suggest to use ANACONDA to install Python.

        To get this setting, follow this:

        * Python installation in Stata

        * Look at how many installation of python you have
        . python search

        * Look at which one is the current one
        . python query

        * Change the python executable
        . python set exec "/Users/XXXXX/opt/anaconda3/bin/python" , permanently


        Comment


        • #5
          after using anaconda, I still have errors with this package. I could not use it.

          Comment


          • #6
            i used these commands in STATA to replace ANACONDA to python:
            python search
            --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            Python environments found:
            C:\Users\Hp\AppData\Local\Programs\Python\Python31 2\python.exe
            C:\Users\Hp\anaconda3\python.exe
            --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

            set python_exec C:\Users\Hp\AppData\Local\Programs\Python\Python31 2\python.exe set python_userpath C:\ Python system information initialized yes version 3.12.3 architecture 64-bit library path C:\Users\Hp\AppData\Local\Programs\Python\Python31 2\python312.dll but the package did not work.

            Comment


            • #7
              Can only say: I experience the same errror message (followed the instruction in detail)

              Comment


              • #8
                Hi, if it is of any help, output/error:

                . r_ml_stata_cv $y $x, mlmodel($learner) data_test("data\data_test.dta") prediction("pred") seed(10)
                File "<stdin>", line 1
                ################################################## ##############################
                SyntaxError: invalid syntax
                (1041 lines skipped)
                (error occurred while loading r_ml_stata_cv.ado)
                r(7102);

                And r(7102): "
                [P] error . . . . . . . . . . . . . . . . . . . . . . . . Return code 7102
                a general error occurred while executing Python code
                This indicates a Python exception occurred while executing
                Python code in the interactive environment. Check the Python
                error message for additional information.
                "

                It seems related to the Python code. It would be great if somehow knows what the solution to this problem is, Many thanks

                Comment


                • #9
                  Hi Adriaan, I am getting a similar error to you when I am using StataMP version18. When I use either r_ml_stata_cv or c_ml_stata_cv. I have tried all of the above suggestions and I think I have Python installed correctly ? I even tried Anaconda and still same error occurs.
                  Is it possibly an issue now that an updated version of Python is not able to read the Stata code used in the older: c_ml_stata_cv.ado and r_ml_stata_cv.ado versions ???

                  r_ml_stata_cv $y $X , mlmodel($learner) in_prediction("in_pred") cross_validation("CV") out_sample("data_test") out_prediction("out_pred") see
                  > d(10) save_graphcv("graph_cv")
                  File "<stdin>", line 1
                  ################################################## ##############################
                  SyntaxError: invalid syntax
                  (1035 lines skipped)
                  (error occurred while loading r_ml_stata_cv.ado)


                  * Run tree classification
                  . *capture rm cv.dta
                  . use iris_train, clear
                  (Iris data)

                  .
                  .
                  .
                  .
                  . c_ml_stata_cv $y $X, mlmodel(tree) data_test("iris") prediction("pred") tree_depth(1 2 3 4 5 6 7 8 9) cross_validation("cv") n_folds(5) seed(10)
                  File "<stdin>", line 1
                  # ************************************************** ****************************
                  SyntaxError: invalid syntax
                  (1290 lines skipped)
                  (error occurred while loading c_ml_stata_cv.ado)



                  Comment


                  • #10
                    One important thing that should be noticed: which version of Python are you using? Run the following code in your Stata command window:
                    Code:
                    python query
                    -----------------------------------------------------------------------------------------------------------------
                        Python Settings
                          set python_exec      ......\Python3.6\python.exe
                          set python_userpath  
                    
                        Python system information
                          initialized          yes
                          version              3.6.2
                          architecture         64-bit
                          library path         ......\Python3.6\python36.dll
                    To run this program, you need to have both Stata 16 (or later) and Python (from version 2.7 onward) installed. You can find information about how to install Python on your machine here: https://www.python.org/downloads. In addition, the Python Scikit-learn (and related dependencies) and Stata Function Interface (sfi) APIs must be uploaded before running the command. You can find information about how to install and use them at, respectively, https://scikit-learn.org/stable/install.html and https://www.stata.com/python/api17. Note that the sfi API is already installed in Stata 16 and later versions.

                    Comment

                    Working...
                    X