Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue while installing mlrose #42

Closed
WajeehAlamoudi opened this issue May 16, 2024 · 1 comment
Closed

issue while installing mlrose #42

WajeehAlamoudi opened this issue May 16, 2024 · 1 comment

Comments

@WajeehAlamoudi
Copy link

i am encountering a problem while installing mlrose to run code below, in poth python 3.12 and 3.10.10. i am using pycharm as an editor.
code:

import lib

import mlrose
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, recall_score, roc_auc_score
from sklearn.preprocessing import StandardScaler

Load the dataset

data = pd.read_csv('heart_statlog_cleveland_hungary_final.csv')
X = data.iloc[:, :-1].values
y = data.iloc[:, -1].values

Split the dataset into training and test sets

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

Feature scaling

scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)

Define a fitness function based on the neural network

nn_model1 = mlrose.NeuralNetwork(hidden_nodes=[10], activation='relu',
algorithm='gradient_descent', max_iters=1000,
bias=True, is_classifier=True, learning_rate=0.0001,
early_stopping=True, clip_max=5, max_attempts=100,
random_state=3)

here is the command output:
Collecting mlrose==1.1.0
Using cached mlrose-1.1.0-py3-none-any.whl.metadata (4.4 kB)
Requirement already satisfied: numpy in c:\users\wajee\pycharmprojects\pythonproject3.venv\lib\site-packages (from mlrose==1.1.0) (1.26.4)
Requirement already satisfied: scipy in c:\users\wajee\pycharmprojects\pythonproject3.venv\lib\site-packages (from mlrose==1.1.0) (1.13.0)
Collecting sklearn (from mlrose==1.1.0)
Using cached sklearn-0.0.post12.tar.gz (2.6 kB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'error'

error: subprocess-exited-with-error

python setup.py egg_info did not run successfully.
exit code: 1

[15 lines of output]
The 'sklearn' PyPI package is deprecated, use 'scikit-learn'
rather than 'sklearn' for pip commands.

Here is how to fix this error in the main use cases:

  • use 'pip install scikit-learn' rather than 'pip install sklearn'
  • replace 'sklearn' by 'scikit-learn' in your pip requirements files
    (requirements.txt, setup.py, setup.cfg, Pipfile, etc ...)
  • if the 'sklearn' package is used by one of your dependencies,
    it would be great if you take some time to track which package uses
    'sklearn' instead of 'scikit-learn' and report it to their issue tracker
  • as a last resort, set the environment variable
    SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL=True to avoid this error

More information is available at
https://github.com/scikit-learn/sklearn-pypi-package
[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.

@lesteve
Copy link
Member

lesteve commented May 27, 2024

This is an issue with mlrose, look at gkhayes/mlrose#69 (comment) for some work-arounds.

The last resort work-around is to set the SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL as indicated in the error message.

Inside a terminal this works fine for me:

SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL=True pip install mlrose

If you do %pip install (or variations) inside a notebook, you need to set the environment variable via os.environ, i.e. something like this should work:

os.environ['SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL'] = 'True'

%pip install mlrose

@lesteve lesteve closed this as not planned Won't fix, can't repro, duplicate, stale May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants