scikit-learn / sklearn-pypi-package

27 stars 11 forks source link

issue while installing mlrose #42

Closed WajeehAlamoudi closed 5 months ago

WajeehAlamoudi commented 6 months ago

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:

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 commented 5 months ago

This is an issue with mlrose, look at https://github.com/gkhayes/mlrose/issues/69#issuecomment-1641918488 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