learningmachine 1.1.0__tar.gz → 1.1.2__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 (31) hide show
  1. {learningmachine-1.1.0 → learningmachine-1.1.2}/PKG-INFO +1 -1
  2. {learningmachine-1.1.0 → learningmachine-1.1.2}/learningmachine/base.py +5 -9
  3. {learningmachine-1.1.0 → learningmachine-1.1.2}/learningmachine.egg-info/PKG-INFO +1 -1
  4. learningmachine-1.1.2/setup.py +139 -0
  5. learningmachine-1.1.0/setup.py +0 -220
  6. {learningmachine-1.1.0 → learningmachine-1.1.2}/CONTRIBUTING.rst +0 -0
  7. {learningmachine-1.1.0 → learningmachine-1.1.2}/HISTORY.rst +0 -0
  8. {learningmachine-1.1.0 → learningmachine-1.1.2}/LICENSE +0 -0
  9. {learningmachine-1.1.0 → learningmachine-1.1.2}/MANIFEST.in +0 -0
  10. {learningmachine-1.1.0 → learningmachine-1.1.2}/README.rst +0 -0
  11. {learningmachine-1.1.0 → learningmachine-1.1.2}/docs/Makefile +0 -0
  12. {learningmachine-1.1.0 → learningmachine-1.1.2}/docs/conf.py +0 -0
  13. {learningmachine-1.1.0 → learningmachine-1.1.2}/docs/contributing.rst +0 -0
  14. {learningmachine-1.1.0 → learningmachine-1.1.2}/docs/history.rst +0 -0
  15. {learningmachine-1.1.0 → learningmachine-1.1.2}/docs/index.rst +0 -0
  16. {learningmachine-1.1.0 → learningmachine-1.1.2}/docs/installation.rst +0 -0
  17. {learningmachine-1.1.0 → learningmachine-1.1.2}/docs/make.bat +0 -0
  18. {learningmachine-1.1.0 → learningmachine-1.1.2}/docs/readme.rst +0 -0
  19. {learningmachine-1.1.0 → learningmachine-1.1.2}/docs/usage.rst +0 -0
  20. {learningmachine-1.1.0 → learningmachine-1.1.2}/learningmachine/__init__.py +0 -0
  21. {learningmachine-1.1.0 → learningmachine-1.1.2}/learningmachine/classifier.py +0 -0
  22. {learningmachine-1.1.0 → learningmachine-1.1.2}/learningmachine/regression.py +0 -0
  23. {learningmachine-1.1.0 → learningmachine-1.1.2}/learningmachine/utils.py +0 -0
  24. {learningmachine-1.1.0 → learningmachine-1.1.2}/learningmachine.egg-info/SOURCES.txt +0 -0
  25. {learningmachine-1.1.0 → learningmachine-1.1.2}/learningmachine.egg-info/dependency_links.txt +0 -0
  26. {learningmachine-1.1.0 → learningmachine-1.1.2}/learningmachine.egg-info/not-zip-safe +0 -0
  27. {learningmachine-1.1.0 → learningmachine-1.1.2}/learningmachine.egg-info/requires.txt +0 -0
  28. {learningmachine-1.1.0 → learningmachine-1.1.2}/learningmachine.egg-info/top_level.txt +0 -0
  29. {learningmachine-1.1.0 → learningmachine-1.1.2}/setup.cfg +0 -0
  30. {learningmachine-1.1.0 → learningmachine-1.1.2}/tests/__init__.py +0 -0
  31. {learningmachine-1.1.0 → learningmachine-1.1.2}/tests/test_learningmachine.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: learningmachine
3
- Version: 1.1.0
3
+ Version: 1.1.2
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
@@ -88,22 +88,18 @@ class Base(BaseEstimator):
88
88
 
89
89
  try:
90
90
  base.library(StrVector(["learningmachine"]))
91
- except (
92
- NotImplementedError
93
- ) as e1: # can't load the package from the global environment
91
+ except: # can't load the package from the global environment
94
92
  try:
95
93
  base.library(
96
94
  StrVector(["learningmachine"]),
97
95
  lib_loc="learningmachine_r",
98
96
  )
99
- except NotImplementedError as e2: # well, we tried
97
+ except: # well, we tried
100
98
  try:
101
- r("try(library('learningmachine'), silence=FALSE)")
102
- except (
103
- NotImplementedError
104
- ) as e3: # well, we tried everything at this point
99
+ r("try(library('learningmachine'), silence=TRUE)")
100
+ except: # well, we tried everything at this point
105
101
  r(
106
- "try(library('learningmachine', lib.loc='learningmachine_r'), silence=FALSE)"
102
+ "try(library('learningmachine', lib.loc='learningmachine_r'), silence=TRUE)"
107
103
  )
108
104
 
109
105
  def score(self, X, y, scoring=None, **kwargs):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: learningmachine
3
- Version: 1.1.0
3
+ Version: 1.1.2
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
@@ -0,0 +1,139 @@
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(["sudo", "Rscript", "-e", "utils::install.packages(devtools, dependencies=TRUE)"])
74
+ subprocess.run(["sudo", "Rscript", "-e", "utils::install.packages(c('R6', 'Rcpp', 'skimr'), dependencies=TRUE)"])
75
+ subprocess.run(["sudo", "Rscript", "-e", "utils::install.packages('learningmachine', repos='https://techtonique.r-universe.dev', dependencies=TRUE)"])
76
+ except:
77
+ try:
78
+ subprocess.run(["mkdir", "-p", "r-learningmachine"])
79
+ subprocess.run(["sudo", "Rscript", "-e", "utils::install.packages(devtools, lib='r-learningmachine', dependencies=TRUE)"])
80
+ subprocess.run(["sudo", "Rscript", "-e", "utils::install.packages(c('R6', 'Rcpp', 'skimr'), lib='r-learningmachine', dependencies=TRUE)"])
81
+ subprocess.run(["sudo", "Rscript", "-e", "utils::install.packages('learningmachine', repos='https://techtonique.r-universe.dev', lib='r-learningmachine', dependencies=TRUE)"])
82
+ except:
83
+ try:
84
+ subprocess.run(["sudo", "Rscript", "-e", "utils::install.packages(devtools, dependencies=TRUE)"])
85
+ subprocess.run(["sudo", "Rscript", "-e", "utils::install.packages(c('R6', 'Rcpp', 'skimr'), dependencies=TRUE)"])
86
+ subprocess.run(["sudo", "Rscript", "-e", "devtools::install_github('Techtonique/learningmachine')"])
87
+ except:
88
+ subprocess.run(["mkdir", "-p", "r-learningmachine"])
89
+ subprocess.run(["sudo", "Rscript", "-e", "utils::install.packages(devtools, lib='r-learningmachine', dependencies=TRUE)"])
90
+ subprocess.run(["sudo", "Rscript", "-e", "utils::install.packages(c('R6', 'Rcpp', 'skimr'), lib='r-learningmachine', dependencies=TRUE)"])
91
+ subprocess.run(["sudo", "Rscript", "-e", "devtools::install_github('Techtonique/learningmachine', lib='r-learningmachine')"])
92
+
93
+
94
+ # Check if R is installed; if not, install it
95
+ if not check_r_installed():
96
+ print("Installing R...")
97
+ install_r()
98
+ else:
99
+ print("No installation needed.")
100
+
101
+ install_packages()
102
+
103
+ subprocess.run(["pip", "install", "rpy2"])
104
+
105
+ from setuptools import setup, find_packages
106
+ from codecs import open
107
+ from os import path
108
+
109
+ # 4 - Package setup -----------------------------------------------
110
+
111
+ """The setup script."""
112
+
113
+ setup(
114
+ author="T. Moudiki",
115
+ author_email="thierry.moudiki@gmail.com",
116
+ python_requires=">=3.6",
117
+ classifiers=[
118
+ "Development Status :: 2 - Pre-Alpha",
119
+ "Intended Audience :: Developers",
120
+ "License :: OSI Approved :: BSD License",
121
+ "Natural Language :: English",
122
+ "Programming Language :: Python :: 3",
123
+ "Programming Language :: Python :: 3.6",
124
+ "Programming Language :: Python :: 3.7",
125
+ "Programming Language :: Python :: 3.8",
126
+ ],
127
+ description="Machine Learning with uncertainty quantification and interpretability",
128
+ install_requires=['numpy', 'pandas', 'rpy2>=3.4.5', 'scikit-learn', 'scipy'],
129
+ license="BSD Clause Clear license",
130
+ long_description="Machine Learning with uncertainty quantification and interpretability.",
131
+ include_package_data=True,
132
+ keywords="learningmachine",
133
+ name="learningmachine",
134
+ packages=find_packages(include=["learningmachine", "learningmachine.*"]),
135
+ test_suite="tests",
136
+ url="https://github.com/Techtonique/learningmachine_python",
137
+ version="1.1.2",
138
+ zip_safe=False,
139
+ )
@@ -1,220 +0,0 @@
1
- #!/usr/bin/env python
2
-
3
- import platform
4
- import subprocess
5
- from os import path
6
- from setuptools import setup, find_packages
7
-
8
- # 0 - utility functions -----------------------------------------------
9
-
10
- def check_r_installed():
11
- current_platform = platform.system()
12
-
13
- if current_platform == "Windows":
14
- # Check if R is installed on Windows by checking the registry
15
- try:
16
- subprocess.run(
17
- ["reg", "query", "HKLM\\Software\\R-core\\R"], check=True
18
- )
19
- print("R is already installed on Windows.")
20
- return True
21
- except subprocess.CalledProcessError as e:
22
- install_r(prompt=True)
23
- return True
24
-
25
- elif current_platform in ("Darwin", "Linux"):
26
- # Check if R is installed on Linux by checking if the 'R' executable is available
27
-
28
- try:
29
- # Try to find the 'R' executable using 'which' (if available)
30
- subprocess.check_call(['which', 'R'])
31
- print(f"R is already installed on {current_platform}.")
32
- return True
33
- except subprocess.CalledProcessError:
34
- # 'which' might not be available, or R is not installed
35
- print('R may not be installed.')
36
- install_r(prompt=True)
37
- return True
38
-
39
- else:
40
-
41
- print("Unsupported platform (check manually: https://cloud.r-project.org/)")
42
- return False
43
-
44
- def install_r(prompt=False):
45
-
46
- current_platform = platform.system()
47
-
48
- if prompt == True:
49
- print("Installing R...")
50
- # choice = input("Would you like to install R? (yes/no): ").strip().lower()
51
- # if choice == 'yes':
52
- # print("Installing R...")
53
- # elif choice == 'no':
54
- # print("No problem. R will not be installed.")
55
- # return
56
- # else:
57
- # print("Invalid input. Please enter 'yes' or 'no'.")
58
- # return
59
-
60
- if current_platform == "Windows":
61
- # Install R on Windows using PowerShell
62
- install_command = "Start-Process powershell -Verb 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}'"
63
- subprocess.run(install_command, shell=True)
64
-
65
- elif current_platform == "Linux":
66
- # Install R on Linux using the appropriate package manager (e.g., apt-get)
67
- install_command = (
68
- "sudo apt update -qq && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9"
69
- + "&& sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/'"
70
- + "&& sudo apt update"
71
- + "&& sudo apt install r-base"
72
- )
73
- try:
74
- subprocess.run(install_command, shell=True)
75
- except NotImplementedError as e:
76
- print("Error installing R on this Linux distribution. Please check manually: https://cloud.r-project.org/")
77
-
78
- elif current_platform == "Darwin": # macOS
79
- # Install R on macOS using Homebrew
80
- install_command = "brew install r"
81
- try:
82
- subprocess.run(install_command, shell=True)
83
- except NotImplementedError as e:
84
- print("Error installing R on macOS. Please check manually: https://cloud.r-project.org/")
85
-
86
- else:
87
- print("Unsupported platform. Unable to install R.")
88
-
89
- def load_learningmachine():
90
- # Install R packages
91
- commands1_lm = 'base::system.file(package = "learningmachine")' # check "learningmachine" is installed
92
- commands2_lm = 'base::system.file("learningmachine_r", package = "learningmachine")' # check "learningmachine" is installed locally
93
- exec_commands1_lm = subprocess.run(
94
- ["Rscript", "-e", commands1_lm], capture_output=True, text=True
95
- )
96
- exec_commands2_lm = subprocess.run(
97
- ["Rscript", "-e", commands2_lm], capture_output=True, text=True
98
- )
99
- if (
100
- len(exec_commands1_lm.stdout) == 7
101
- and len(exec_commands2_lm.stdout) == 7
102
- ): # kind of convoluted, but works
103
- print("Installing R packages along with 'learningmachine'...")
104
- commands1 = [
105
- 'try(utils::install.packages(c("R6", "Rcpp", "skimr"), repos="https://cloud.r-project.org", dependencies = TRUE), silent=TRUE)',
106
- 'try(utils::install.packages("learningmachine", repos="https://techtonique.r-universe.dev", dependencies = TRUE), silent=TRUE)',
107
- ]
108
- commands2 = [
109
- 'try(utils::install.packages(c("R6", "Rcpp", "skimr"), lib="./learningmachine_r", repos="https://cloud.r-project.org", dependencies = TRUE), silent=TRUE)',
110
- 'try(utils::install.packages("learningmachine", lib="./learningmachine_r", repos="https://techtonique.r-universe.dev", dependencies = TRUE), silent=TRUE)',
111
- ]
112
- commands3 = [
113
- 'try(utils::install.packages(c("R6", "Rcpp", "remotes", "skimr"), repos="https://cloud.r-project.org", dependencies = TRUE), silent=TRUE)',
114
- 'try(remotes::install_github("Techtonique/learningmachine"), silent=TRUE)',
115
- ]
116
- commands4 = [
117
- 'try(utils::install.packages(c("R6", "Rcpp", "remotes", "skimr"), lib="./learningmachine_r", repos="https://cloud.r-project.org", dependencies = TRUE), silent=TRUE)',
118
- 'try(remotes::install_github("Techtonique/learningmachine", lib="./learningmachine_r", dependencies = TRUE), silent=TRUE)',
119
- ]
120
-
121
- try:
122
- for cmd in commands3:
123
- try:
124
- subprocess.run(["Rscript", "-e", cmd])
125
- except:
126
- pass
127
- except NotImplementedError as e: # can't install packages globally
128
- try:
129
- subprocess.run(["mkdir", "learningmachine_r"])
130
- for cmd in commands4:
131
- try:
132
- subprocess.run(["Rscript", "-e", cmd])
133
- except:
134
- pass
135
- except NotImplementedError as e:
136
- try:
137
- for cmd in commands1:
138
- try:
139
- subprocess.run(["Rscript", "-e", cmd])
140
- except:
141
- pass
142
- except NotImplementedError as e:
143
- subprocess.run(["mkdir", "learningmachine_r"])
144
- for cmd in commands2:
145
- try:
146
- subprocess.run(["Rscript", "-e", cmd])
147
- except:
148
- pass
149
-
150
- # try:
151
- # base.library(StrVector(["learningmachine"]))
152
- # except (
153
- # NotImplementedError
154
- # ) as e1: # can't load the package from the global environment
155
- # try:
156
- # base.library(
157
- # StrVector(["learningmachine"]), lib_loc="learningmachine_r"
158
- # )
159
- # except NotImplementedError as e2: # well, we tried
160
- # try:
161
- # r("try(library('learningmachine'), silence=TRUE)")
162
- # except (
163
- # NotImplementedError
164
- # ) as e3: # well, we tried everything at this point
165
- # r(
166
- # "try(library('learningmachine', lib.loc='learningmachine_r'), silence=TRUE)"
167
- # )
168
-
169
- # 1 - import Python packages -----------------------------------------------
170
-
171
- subprocess.run(["pip", "install", "rpy2"])
172
- try:
173
- subprocess.run(["pip", "install", "setuptools"])
174
- except ModuleNotFoundError as e:
175
- print("Error installing setuptools. Please install setuptools manually.")
176
-
177
- from rpy2.robjects.packages import importr
178
- from rpy2.robjects.vectors import StrVector
179
- from rpy2.robjects import r
180
-
181
- base = importr("base")
182
-
183
- if not check_r_installed():
184
- install_r()
185
- else:
186
- print("R is already installed.")
187
-
188
- load_learningmachine()
189
-
190
- # 4 - Package setup -----------------------------------------------
191
-
192
- """The setup script."""
193
-
194
- setup(
195
- author="T. Moudiki",
196
- author_email="thierry.moudiki@gmail.com",
197
- python_requires=">=3.6",
198
- classifiers=[
199
- "Development Status :: 2 - Pre-Alpha",
200
- "Intended Audience :: Developers",
201
- "License :: OSI Approved :: BSD License",
202
- "Natural Language :: English",
203
- "Programming Language :: Python :: 3",
204
- "Programming Language :: Python :: 3.6",
205
- "Programming Language :: Python :: 3.7",
206
- "Programming Language :: Python :: 3.8",
207
- ],
208
- description="Machine Learning with uncertainty quantification and interpretability",
209
- install_requires=['numpy', 'pandas', 'rpy2>=3.4.5', 'scikit-learn', 'scipy'],
210
- license="BSD Clause Clear license",
211
- long_description="Machine Learning with uncertainty quantification and interpretability.",
212
- include_package_data=True,
213
- keywords="learningmachine",
214
- name="learningmachine",
215
- packages=find_packages(include=["learningmachine", "learningmachine.*"]),
216
- test_suite="tests",
217
- url="https://github.com/Techtonique/learningmachine_python",
218
- version="1.1.0",
219
- zip_safe=False,
220
- )
File without changes