learningmachine 2.7.0__tar.gz → 2.10.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. {learningmachine-2.7.0 → learningmachine-2.10.0}/PKG-INFO +13 -2
  2. {learningmachine-2.7.0 → learningmachine-2.10.0}/learningmachine.egg-info/PKG-INFO +13 -2
  3. learningmachine-2.10.0/setup.py +223 -0
  4. learningmachine-2.7.0/setup.py +0 -174
  5. {learningmachine-2.7.0 → learningmachine-2.10.0}/CONTRIBUTING.rst +0 -0
  6. {learningmachine-2.7.0 → learningmachine-2.10.0}/HISTORY.rst +0 -0
  7. {learningmachine-2.7.0 → learningmachine-2.10.0}/LICENSE +0 -0
  8. {learningmachine-2.7.0 → learningmachine-2.10.0}/MANIFEST.in +0 -0
  9. {learningmachine-2.7.0 → learningmachine-2.10.0}/README.md +0 -0
  10. {learningmachine-2.7.0 → learningmachine-2.10.0}/learningmachine/__init__.py +0 -0
  11. {learningmachine-2.7.0 → learningmachine-2.10.0}/learningmachine/base.py +0 -0
  12. {learningmachine-2.7.0 → learningmachine-2.10.0}/learningmachine/classifier.py +0 -0
  13. {learningmachine-2.7.0 → learningmachine-2.10.0}/learningmachine/regression.py +0 -0
  14. {learningmachine-2.7.0 → learningmachine-2.10.0}/learningmachine/utils.py +0 -0
  15. {learningmachine-2.7.0 → learningmachine-2.10.0}/learningmachine.egg-info/SOURCES.txt +0 -0
  16. {learningmachine-2.7.0 → learningmachine-2.10.0}/learningmachine.egg-info/dependency_links.txt +0 -0
  17. {learningmachine-2.7.0 → learningmachine-2.10.0}/learningmachine.egg-info/not-zip-safe +0 -0
  18. {learningmachine-2.7.0 → learningmachine-2.10.0}/learningmachine.egg-info/requires.txt +0 -0
  19. {learningmachine-2.7.0 → learningmachine-2.10.0}/learningmachine.egg-info/top_level.txt +0 -0
  20. {learningmachine-2.7.0 → learningmachine-2.10.0}/setup.cfg +0 -0
  21. {learningmachine-2.7.0 → learningmachine-2.10.0}/tests/__init__.py +0 -0
  22. {learningmachine-2.7.0 → learningmachine-2.10.0}/tests/test_learningmachine.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: learningmachine
3
- Version: 2.7.0
3
+ Version: 2.10.0
4
4
  Summary: Machine Learning with uncertainty quantification and interpretability
5
5
  Home-page: https://github.com/Techtonique/learningmachine_python
6
6
  Author: T. Moudiki
@@ -22,5 +22,16 @@ Requires-Dist: pandas
22
22
  Requires-Dist: rpy2>=3.4.5
23
23
  Requires-Dist: scikit-learn
24
24
  Requires-Dist: scipy
25
+ Dynamic: author
26
+ Dynamic: author-email
27
+ Dynamic: classifier
28
+ Dynamic: description
29
+ Dynamic: home-page
30
+ Dynamic: keywords
31
+ Dynamic: license
32
+ Dynamic: license-file
33
+ Dynamic: requires-dist
34
+ Dynamic: requires-python
35
+ Dynamic: summary
25
36
 
26
37
  Machine Learning with uncertainty quantification and interpretability.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: learningmachine
3
- Version: 2.7.0
3
+ Version: 2.10.0
4
4
  Summary: Machine Learning with uncertainty quantification and interpretability
5
5
  Home-page: https://github.com/Techtonique/learningmachine_python
6
6
  Author: T. Moudiki
@@ -22,5 +22,16 @@ Requires-Dist: pandas
22
22
  Requires-Dist: rpy2>=3.4.5
23
23
  Requires-Dist: scikit-learn
24
24
  Requires-Dist: scipy
25
+ Dynamic: author
26
+ Dynamic: author-email
27
+ Dynamic: classifier
28
+ Dynamic: description
29
+ Dynamic: home-page
30
+ Dynamic: keywords
31
+ Dynamic: license
32
+ Dynamic: license-file
33
+ Dynamic: requires-dist
34
+ Dynamic: requires-python
35
+ Dynamic: summary
25
36
 
26
37
  Machine Learning with uncertainty quantification and interpretability.
@@ -0,0 +1,223 @@
1
+ import os
2
+ import platform
3
+ import subprocess
4
+ import sys
5
+
6
+
7
+ def _running_noninteractively():
8
+ """True when there is no human at a terminal to answer a prompt.
9
+
10
+ This covers CI systems (GitHub Actions sets CI=true), any environment
11
+ where CI/PIP_NO_INPUT is set, and plain non-tty stdin.
12
+ """
13
+ if os.environ.get("CI") or os.environ.get("PIP_NO_INPUT"):
14
+ return True
15
+ try:
16
+ return not sys.stdin.isatty()
17
+ except Exception:
18
+ return True
19
+
20
+
21
+ def _is_packaging_only_invocation():
22
+ """True when setup.py is only being asked to build metadata/artifacts
23
+ (sdist, bdist_wheel, egg_info, ...), not to actually install the
24
+ package. These commands run on build machines (e.g. CI building a
25
+ release) that don't need R/rpy2 present at all -- R is a *runtime*
26
+ dependency of the installed package, not a build-time one.
27
+ """
28
+ packaging_commands = {
29
+ "sdist", "bdist_wheel", "bdist", "egg_info", "dist_info",
30
+ "check", "--version", "--help", "--help-commands",
31
+ }
32
+ return any(arg in packaging_commands for arg in sys.argv[1:])
33
+
34
+
35
+ def check_r_installed():
36
+ current_platform = platform.system()
37
+
38
+ if current_platform == "Windows":
39
+ try:
40
+ subprocess.run(
41
+ ["reg", "query", "HKLM\\Software\\R-core\\R"], check=True
42
+ )
43
+ print("R is already installed on Windows.")
44
+ return True
45
+ except (subprocess.CalledProcessError, FileNotFoundError):
46
+ print("R is not installed on Windows.")
47
+ return False
48
+
49
+ elif current_platform in ("Linux", "Darwin"):
50
+ try:
51
+ subprocess.run(["which", "R"], check=True)
52
+ print(f"R is already installed on {current_platform}.")
53
+ return True
54
+ except (subprocess.CalledProcessError, FileNotFoundError):
55
+ print(f"R is not installed on {current_platform}.")
56
+ return False
57
+
58
+ else:
59
+ print("Unsupported platform. Unable to check for R installation.")
60
+ return False
61
+
62
+
63
+ def install_r():
64
+ current_platform = platform.system()
65
+
66
+ if current_platform == "Windows":
67
+ install_command = (
68
+ "Start-Process powershell -Verb runAs -ArgumentList "
69
+ "'-Command \"& {Invoke-WebRequest "
70
+ "https://cran.r-project.org/bin/windows/base/R-4.1.2-win.exe "
71
+ "-OutFile R.exe}; Start-Process R.exe -ArgumentList "
72
+ "'/SILENT' -Wait}'"
73
+ )
74
+ subprocess.run(install_command, shell=True)
75
+
76
+ elif current_platform == "Linux":
77
+ install_command = (
78
+ "sudo apt update -qq && "
79
+ "sudo apt-key adv --keyserver keyserver.ubuntu.com "
80
+ "--recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 && "
81
+ "sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/' && "
82
+ "sudo apt update && "
83
+ "sudo apt -y install r-base"
84
+ )
85
+ subprocess.run(install_command, shell=True)
86
+
87
+ elif current_platform == "Darwin":
88
+ subprocess.run("brew install r", shell=True)
89
+
90
+ else:
91
+ print("Unsupported platform. Unable to install R.")
92
+
93
+
94
+ def install_packages():
95
+ """Install the R-side dependencies, retrying into a local library
96
+ ('r-learningmachine') if the default library isn't writable."""
97
+ attempts = [
98
+ {"lib": None},
99
+ {"lib": "r-learningmachine"},
100
+ ]
101
+
102
+ for attempt in attempts:
103
+ lib = attempt["lib"]
104
+ lib_arg = f", lib='{lib}'" if lib else ""
105
+ try:
106
+ if lib:
107
+ subprocess.run(["mkdir", "-p", lib], check=True)
108
+ subprocess.run(
109
+ ["Rscript", "-e",
110
+ f"utils::install.packages('remotes', dependencies=TRUE{lib_arg})"],
111
+ check=True,
112
+ )
113
+ subprocess.run(
114
+ ["Rscript", "-e",
115
+ f"utils::install.packages(c('R6', 'Rcpp', 'skimr'), dependencies=TRUE{lib_arg})"],
116
+ check=True,
117
+ )
118
+ subprocess.run(
119
+ ["Rscript", "-e",
120
+ f"remotes::install_github('Techtonique/learningmachine'{lib_arg})"],
121
+ check=True,
122
+ )
123
+ print(f"R package installation succeeded (lib={lib!r}).")
124
+ return True
125
+ except subprocess.CalledProcessError as e:
126
+ print(f"Error occurred while installing R packages (lib={lib!r}): {e}")
127
+ print(f"Return code: {e.returncode}")
128
+
129
+ print(
130
+ "Warning: could not install the R 'learningmachine' package "
131
+ "automatically. Install it manually, e.g.:\n"
132
+ " Rscript -e \"remotes::install_github('Techtonique/learningmachine')\""
133
+ )
134
+ return False
135
+
136
+
137
+ def ensure_r_available():
138
+ """Make sure R is present, installing it (or asking to) only when it
139
+ actually makes sense to do so."""
140
+ if check_r_installed():
141
+ print("No R installation needed.")
142
+ return
143
+
144
+ if _running_noninteractively():
145
+ if os.environ.get("LEARNINGMACHINE_AUTO_INSTALL_R") == "1":
146
+ print("Non-interactive environment: auto-installing R "
147
+ "(LEARNINGMACHINE_AUTO_INSTALL_R=1 was set).")
148
+ install_r()
149
+ else:
150
+ print(
151
+ "R is not installed and this looks like a non-interactive "
152
+ "environment (CI or no TTY), so setup.py will NOT prompt "
153
+ "for input and will NOT attempt to install R automatically.\n"
154
+ "Set the environment variable LEARNINGMACHINE_AUTO_INSTALL_R=1 "
155
+ "before running setup.py if you want it to try installing R, "
156
+ "or install R yourself first: https://cloud.r-project.org/"
157
+ )
158
+ return
159
+
160
+ # Interactive session with a real human at a terminal.
161
+ try:
162
+ install_r_prompt = int(input("Try installing R? 1-yes, 2-no: "))
163
+ except (EOFError, ValueError):
164
+ install_r_prompt = 2
165
+
166
+ if install_r_prompt == 1:
167
+ print("Installing R...")
168
+ install_r()
169
+ else:
170
+ print(
171
+ "Skipping R installation. Install R manually first: "
172
+ "https://cloud.r-project.org/"
173
+ )
174
+
175
+
176
+ # Building an sdist/wheel (e.g. in CI to publish a release) never needs R
177
+ # or rpy2 on the build machine -- those are runtime dependencies for
178
+ # whoever installs the package. Only run the R setup dance for actual
179
+ # install-type invocations.
180
+ if not _is_packaging_only_invocation():
181
+ ensure_r_available()
182
+ if check_r_installed():
183
+ install_packages()
184
+ subprocess.run([sys.executable, "-m", "pip", "install", "rpy2"])
185
+ else:
186
+ print(f"Packaging-only invocation ({' '.join(sys.argv[1:])}); "
187
+ "skipping R/rpy2 setup.")
188
+
189
+ from setuptools import setup, find_packages
190
+ from codecs import open
191
+ from os import path
192
+
193
+ # 4 - Package setup -----------------------------------------------
194
+
195
+ """The setup script."""
196
+
197
+ setup(
198
+ author="T. Moudiki",
199
+ author_email="thierry.moudiki@gmail.com",
200
+ python_requires=">=3.6",
201
+ classifiers=[
202
+ "Development Status :: 2 - Pre-Alpha",
203
+ "Intended Audience :: Developers",
204
+ "License :: OSI Approved :: BSD License",
205
+ "Natural Language :: English",
206
+ "Programming Language :: Python :: 3",
207
+ "Programming Language :: Python :: 3.6",
208
+ "Programming Language :: Python :: 3.7",
209
+ "Programming Language :: Python :: 3.8",
210
+ ],
211
+ description="Machine Learning with uncertainty quantification and interpretability",
212
+ install_requires=['numpy', 'pandas', 'rpy2>=3.4.5', 'scikit-learn', 'scipy'],
213
+ license="BSD Clause Clear license",
214
+ long_description="Machine Learning with uncertainty quantification and interpretability.",
215
+ include_package_data=True,
216
+ keywords="learningmachine",
217
+ name="learningmachine",
218
+ packages=find_packages(include=["learningmachine", "learningmachine.*"]),
219
+ test_suite="tests",
220
+ url="https://github.com/Techtonique/learningmachine_python",
221
+ version="2.10.0",
222
+ zip_safe=False,
223
+ )
@@ -1,174 +0,0 @@
1
- import platform
2
- import subprocess
3
-
4
- def check_r_installed():
5
- current_platform = platform.system()
6
-
7
- if current_platform == "Windows":
8
- # Check if R is installed on Windows by checking the registry
9
- try:
10
- subprocess.run(
11
- ["reg", "query", "HKLM\\Software\\R-core\\R"], check=True
12
- )
13
- print("R is already installed on Windows.")
14
- return True
15
- except subprocess.CalledProcessError:
16
- print("R is not installed on Windows.")
17
- return False
18
-
19
- elif current_platform == "Linux":
20
- # Check if R is installed on Linux by checking if the 'R' executable is available
21
- try:
22
- subprocess.run(["which", "R"], check=True)
23
- print("R is already installed on Linux.")
24
- return True
25
- except subprocess.CalledProcessError:
26
- print("R is not installed on Linux.")
27
- return False
28
-
29
- elif current_platform == "Darwin": # macOS
30
- # Check if R is installed on macOS by checking if the 'R' executable is available
31
- try:
32
- subprocess.run(["which", "R"], check=True)
33
- print("R is already installed on macOS.")
34
- return True
35
- except subprocess.CalledProcessError:
36
- print("R is not installed on macOS.")
37
- return False
38
-
39
- else:
40
- print("Unsupported platform. Unable to check for R installation.")
41
- return False
42
-
43
- def install_r():
44
-
45
- current_platform = platform.system()
46
-
47
- if current_platform == "Windows":
48
- # Install R on Windows using PowerShell
49
- install_command = "Start-Process powershell -Verb subprocess.runAs -ArgumentList '-Command \"& {Invoke-WebRequest https://cran.r-project.org/bin/windows/base/R-4.1.2-win.exe -OutFile R.exe}; Start-Process R.exe -ArgumentList '/SILENT' -Wait}'"
50
- subprocess.run(install_command, shell=True)
51
-
52
- elif current_platform == "Linux":
53
- # Install R on Linux using the appropriate package manager (e.g., apt-get)
54
- install_command = (
55
- "sudo apt update -qq && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9"
56
- + "&& sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/'"
57
- + "&& sudo apt update"
58
- + "&& sudo apt -y install r-base"
59
- )
60
- subprocess.run(install_command, shell=True)
61
-
62
- elif current_platform == "Darwin": # macOS
63
- # Install R on macOS using Homebrew
64
- install_command = "brew install r"
65
- subprocess.run(install_command, shell=True)
66
-
67
- else:
68
-
69
- print("Unsupported platform. Unable to install R.")
70
-
71
- def install_packages():
72
- try:
73
- subprocess.run(["Rscript", "-e", "utils::install.packages('remotes', dependencies=TRUE)"])
74
- subprocess.run(["Rscript", "-e", "utils::install.packages(c('R6', 'Rcpp', 'skimr'), dependencies=TRUE)"])
75
- subprocess.run(["Rscript", "-e", "remotes::install_github('Techtonique/learningmachine')"])
76
- except subprocess.CalledProcessError as e:
77
- print(f"Error occurred: {e}")
78
- print(f"Return code: {e.returncode}")
79
- print(f"Output: {e.output}")
80
- print(f"Stderr: {e.stderr}")
81
- try:
82
- subprocess.run(["mkdir", "-p", "r-learningmachine"])
83
- subprocess.run(["Rscript", "-e", "utils::install.packages('remotes', lib='r-learningmachine', dependencies=TRUE)"])
84
- subprocess.run(["Rscript", "-e", "utils::install.packages(c('R6', 'Rcpp', 'skimr'), lib='r-learningmachine', dependencies=TRUE)"])
85
- subprocess.run(["Rscript", "-e", "remotes::install_github('Techtonique/learningmachine', lib='r-learningmachine')"])
86
- except subprocess.CalledProcessError as e:
87
- print(f"Error occurred: {e}")
88
- print(f"Return code: {e.returncode}")
89
- print(f"Output: {e.output}")
90
- print(f"Stderr: {e.stderr}")
91
- try:
92
- subprocess.run(["Rscript", "-e", "utils::install.packages('remotes', dependencies=TRUE)"])
93
- subprocess.run(["Rscript", "-e", "utils::install.packages(c('R6', 'Rcpp', 'skimr'), dependencies=TRUE)"])
94
- subprocess.run(["Rscript", "-e", "remotes::install_github('Techtonique/learningmachine')"])
95
- except subprocess.CalledProcessError as e:
96
- print(f"Error occurred: {e}")
97
- print(f"Return code: {e.returncode}")
98
- print(f"Output: {e.output}")
99
- print(f"Stderr: {e.stderr}")
100
- try:
101
- subprocess.run(["mkdir", "-p", "r-learningmachine"])
102
- subprocess.run(["Rscript", "-e", "utils::install.packages('remotes', lib='r-learningmachine', dependencies=TRUE)"])
103
- subprocess.run(["Rscript", "-e", "utils::install.packages(c('R6', 'Rcpp', 'skimr'), lib='r-learningmachine', dependencies=TRUE)"])
104
- subprocess.run(["Rscript", "-e", "remotes::install_github('Techtonique/learningmachine', lib='r-learningmachine')"])
105
- except subprocess.CalledProcessError as e:
106
- print(f"Error occurred: {e}")
107
- print(f"Return code: {e.returncode}")
108
- print(f"Output: {e.output}")
109
- print(f"Stderr: {e.stderr}")
110
- try:
111
- subprocess.run(["Rscript", "-e", "utils::install.packages('remotes', dependencies=TRUE)"])
112
- subprocess.run(["Rscript", "-e", "utils::install.packages(c('R6', 'Rcpp', 'skimr'), dependencies=TRUE)"])
113
- subprocess.run(["Rscript", "-e", "remotes::install_github('Techtonique/learningmachine')"])
114
- except subprocess.CalledProcessError as e:
115
- print(f"Error occurred: {e}")
116
- print(f"Return code: {e.returncode}")
117
- print(f"Output: {e.output}")
118
- print(f"Stderr: {e.stderr}")
119
- subprocess.run(["mkdir", "-p", "r-learningmachine"])
120
- subprocess.run(["Rscript", "-e", "utils::install.packages('remotes', lib='r-learningmachine', dependencies=TRUE)"])
121
- subprocess.run(["Rscript", "-e", "utils::install.packages(c('R6', 'Rcpp', 'skimr'), lib='r-learningmachine', dependencies=TRUE)"])
122
- subprocess.run(["Rscript", "-e", "remotes::install_github('Techtonique/learningmachine', lib='r-learningmachine')"])
123
-
124
-
125
- # Check if R is installed; if not, install it
126
- if not check_r_installed():
127
- install_r_prompt = int(input("Try installing R? 1-yes, 2-no"))
128
- if install_r_prompt == 1:
129
- print("Installing R...")
130
- install_r()
131
- else:
132
- raise ValueError('Try installing R manually first.')
133
- else:
134
- print("No R installation needed.")
135
-
136
- install_packages()
137
-
138
- subprocess.run(["pip", "install", "rpy2"])
139
-
140
- from setuptools import setup, find_packages
141
- from codecs import open
142
- from os import path
143
-
144
- # 4 - Package setup -----------------------------------------------
145
-
146
- """The setup script."""
147
-
148
- setup(
149
- author="T. Moudiki",
150
- author_email="thierry.moudiki@gmail.com",
151
- python_requires=">=3.6",
152
- classifiers=[
153
- "Development Status :: 2 - Pre-Alpha",
154
- "Intended Audience :: Developers",
155
- "License :: OSI Approved :: BSD License",
156
- "Natural Language :: English",
157
- "Programming Language :: Python :: 3",
158
- "Programming Language :: Python :: 3.6",
159
- "Programming Language :: Python :: 3.7",
160
- "Programming Language :: Python :: 3.8",
161
- ],
162
- description="Machine Learning with uncertainty quantification and interpretability",
163
- install_requires=['numpy', 'pandas', 'rpy2>=3.4.5', 'scikit-learn', 'scipy'],
164
- license="BSD Clause Clear license",
165
- long_description="Machine Learning with uncertainty quantification and interpretability.",
166
- include_package_data=True,
167
- keywords="learningmachine",
168
- name="learningmachine",
169
- packages=find_packages(include=["learningmachine", "learningmachine.*"]),
170
- test_suite="tests",
171
- url="https://github.com/Techtonique/learningmachine_python",
172
- version="2.7.0",
173
- zip_safe=False,
174
- )