SJ001 / AI-Feynman

MIT License
607 stars 186 forks source link

pip installation guide needs to be updated #85

Open filip-frisk opened 3 months ago

filip-frisk commented 3 months ago

The following commands are needed:

Create a new virtual environment / venv does not work use virtualenv

virtualenv -p python3 feyn

Activate the virtual environment

source feyn/bin/activate

Install numpy

pip install numpy

Install aifeynman without its dependencies

pip install aifeynman --no-deps

Install additional Python packages

pip install sortedcontainers scikit-learn torch seaborn torchvision openpyxl

In order to use units in the dimensional analysis, the following changes are required:

1. Download first from https://space.mit.edu/home/tegmark/aifeynman.html) and convert csv to xlsx (There are three inconsistencies between equation names in units.csv and feynman_with_units/)

2. Add units.xlsx in the current folder

3. change line 36 in feyn/lib/python3.11/site-packages/aifeynman/dimensionalAnalysis.py

from:val = [file["m"][i],file["s"][i],file["kg"][i],file["T"][i],file["V"][i], file["cd"][I]] to: val = [file["m"][i],file["s"][i],file["kg"][i],file["T"][i],file["V"][I]]

4. change in 31 different lines for ex. 49 + 50 in feyn/lib/python3.11/site-packages/aifeynman/dimensionalS_symmetry.py

from: pathdir+"/%s" %filename to: pathdir+filename

5. also change line 44 in same file

from: file_sym = open(filename + "_dim_red_variables.txt" ,"w") to: file_sym = open(pathdir + filename + "_dim_red_variables.txt" ,"w")

6 change line 255 feyn/lib/python3.11/site-packages/aifeynman/S_run_aifeynman.py

from: DR_file = filename + "_dim_red_variables.txt" to: DR_file = pathdir + filename + "_dim_red_variables.txt"

7. Use pathdir = "example_data/" + filename = "example1.txt" as hyperparameters in .run_aifeynman(....)

DONE interact with import aifeynman + aifeynman.run_aifeynman(....) for example

import aifeynman

pathdir = "example_data/"
filename = "example1.txt"
BF_try_time = 60
BF_ops_file_type = "14ops.txt"
polyfit_deg = 3
NN_epochs = 500
vars_name = ['x1', 'x2', 'y1', 'y2', 'd']
test_percentage = 20

aifeynman.run_aifeynman(pathdir, filename, BF_try_time= BF_try_time, BF_ops_file_type=BF_ops_file_type, polyfit_deg=polyfit_deg, NN_epochs=NN_epochs, vars_name=vars_name, test_percentage=test_percentage)

See https://github.com/cavalab/srbench/issues/161 a/the maintained Symbolic Regression benchmark with origins from a NEURIPS 2021 paper (https://arxiv.org/abs/2107.14351). They considered AI Feynman to be depreciated/broken and I agree, that the method needs a maintainer to be kept relevant.

See https://github.com/filip-frisk/AI_Feynman_2024_tools if you want to run AI-feynman in 2024 and reproduce the main results.

EySword commented 1 month ago

Hi, I got error when I tried pip install aifeynman --no-deps in my conda virtual environment :

pip install aifeynman --no-deps

Collecting aifeynman
  Using cached aifeynman-2.0.7.tar.gz (219 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\yche1\AppData\Local\Temp\pip-install-vp9pesn7\aifeynman_5bac27eddf7e4154b9b3b2a350e862ab\setup.py", line 2, in <module>
          from numpy.distutils.core import Extension, setup
      ModuleNotFoundError: No module named 'numpy.distutils'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

It seems that numpy doesn't use 'numpy.distutils' now.

Do you know how to fix it?

filip-frisk commented 1 month ago

Hi, I got error when I tried pip install aifeynman --no-deps in my conda virtual environment :

pip install aifeynman --no-deps

Collecting aifeynman
  Using cached aifeynman-2.0.7.tar.gz (219 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\yche1\AppData\Local\Temp\pip-install-vp9pesn7\aifeynman_5bac27eddf7e4154b9b3b2a350e862ab\setup.py", line 2, in <module>
          from numpy.distutils.core import Extension, setup
      ModuleNotFoundError: No module named 'numpy.distutils'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

It seems that numpy doesn't use 'numpy.distutils' now.

Do you know how to fix it?

No sorry but it must be a anaconda problem, use virtualenv instead as written above since it works.