Giter Club home page Giter Club logo

sklearn-nature-inspired-algorithms's Introduction

Nature-Inspired Algorithms for scikit-learn

CI Maintainability PyPI - Python Version PyPI version PyPI downloads Fedora package

Nature-inspired algorithms for hyper-parameter tuning of scikit-learn models. This package uses algorithms implementation from NiaPy.

Installation

$ pip install sklearn-nature-inspired-algorithms

To install this package on Fedora, run:

$ dnf install python3-sklearn-nature-inspired-algorithms

Usage

The usage is similar to using sklearn's GridSearchCV. Refer to the documentation for more detailed guides and more examples.

from sklearn_nature_inspired_algorithms.model_selection import NatureInspiredSearchCV
from sklearn.ensemble import RandomForestClassifier

param_grid = { 
    'n_estimators': range(20, 100, 20), 
    'max_depth': range(2, 40, 2),
    'min_samples_split': range(2, 20, 2), 
    'max_features': ["auto", "sqrt", "log2"],
}

clf = RandomForestClassifier(random_state=42)

nia_search = NatureInspiredSearchCV(
    clf,
    param_grid,
    algorithm='hba', # hybrid bat algorithm
    population_size=50,
    max_n_gen=100,
    max_stagnating_gen=10,
    runs=3,
    random_state=None, # or any number if you want same results on each run
)

nia_search.fit(X_train, y_train)

# the best params are stored in nia_search.best_params_
# finally you can train your model with best params from nia search
new_clf = RandomForestClassifier(**nia_search.best_params_, random_state=42)

Also you plot the search process with line plot or violin plot.

from sklearn_nature_inspired_algorithms.helpers import score_by_generation_lineplot, score_by_generation_violinplot

# line plot will plot all of the runs, you can specify the metric to be plotted ('min', 'max', 'median', 'mean')
score_by_generation_lineplot(nia_search, metric='max')

# in violin plot you need to specify the run to be plotted
score_by_generation_violinplot(nia_search, run=0)

Jupyter notebooks with full examples are available in here.

Using a Custom Nature-Inspired Algorithm

If you do not want to use any of the pre-defined algorithm configurations, you can use any algorithm from the NiaPy collection. This will allow you to have more control of the algorithm behavior. Refer to their documentation and examples for the usage.

Note: Use version >2.x.x of NiaPy package

from niapy.algorithms.basic import GeneticAlgorithm

algorithm = GeneticAlgorithm() # when custom algorithm is provided random_state is ignored
algorithm.set_parameters(NP=50, Ts=5, Mr=0.25)

nia_search = NatureInspiredSearchCV(
    clf,
    param_grid,
    algorithm=algorithm,
    population_size=50,
    max_n_gen=100,
    max_stagnating_gen=20,
    runs=3,
)

nia_search.fit(X_train, y_train)

Contributing

Detailed information on the contribution guidelines are in the CONTRIBUTING.md.

sklearn-nature-inspired-algorithms's People

Contributors

firefly-cpp avatar penguinpee avatar sanjayankur31 avatar timzatko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sklearn-nature-inspired-algorithms's Issues

Add support for dict-like parameters

Complete Description of the Issue

As a software developer, I want to tune dict-like parameters of ML model to improve its ability to generalize. This is a default behavior of parameter searching algorithms in sklearn (e.g., GridSearchCV ). Though able to use same API, NatureInspiredSearchCV raises an TypeError.

Simplest Possible Self-Contained Example Showing the Bug

from sklearn.datasets import make_classification
from sklearn.tree import DecisionTreeClassifier as DTC
from sklearn_nature_inspired_algorithms.model_selection import\
    NatureInspiredSearchCV as NIS_CV

X, y = make_classification()

tree = DTC(random_state=0)

param_grid = {'class_weight':
              [{False: 1, True: 2},
               {False: 1, True: 1}]}

sh = NIS_CV(tree, param_grid, scoring='f1_macro').fit(X, y)

Full Backtrace of Exception

Exception has occurred: TypeError Exception has occurred: TypeError unhashable type: 'dict' File "./Sklearn-Nature-Inspired-Search/sklearn_nature_inspired_algorithms/model_selection/_parameter_search.py", line 23, in get_cached_score if cache_key in self.cache: File "./Sklearn-Nature-Inspired-Search/sklearn_nature_inspired_algorithms/model_selection/_parameter_search.py", line 35, in _evaluate score = self.get_cached_score(params) File "./Sklearn-Nature-Inspired-Search/sklearn_nature_inspired_algorithms/model_selection/_stagnation_stopping_task.py", line 40, in eval x_f = super().eval(A) File "./Sklearn-Nature-Inspired-Search/sklearn_nature_inspired_algorithms/model_selection/nature_inspired_search_cv.py", line 47, in _run_search self.__algorithm.run(task=task) File "./Sklearn-Nature-Inspired-Search/sklearn_nature_inspired_algorithms/model_selection/nature_inspired_search_cv.py", line 19, in fit return super().fit(X, y, groups=groups, **fit_params) File "./RnD/Similarity/bug_nia.py", line 15, in sh = NIS_CV(tree, param_grid, scoring='f1_macro').fit(X, y) TypeError: unhashable type: 'dict'

sklearn-nature-inspired-algorithms is compatible with scikit-learn 0.23.2

Hi,
Initially I have scikit-learn version

Name: scikit-learn
Version: 0.23.2

While install "pip install sklearn-nature-inspired-algorithms"
we get scikit-learn version downgraded to

Name: scikit-learn
Version: 0.22.2.post1

then i am upgrading scikit-learn back "pip install -U scikit-learn" we get this

ERROR: sklearn-nature-inspired-algorithms 0.4.5 has requirement scikit-learn<0.23.0,>=0.22.2, but you'll have scikit-learn 0.23.2 which is incompatible.

sklearn-nature-inspired-algorithms works fine with scikit-learn 0.23.2,
Is it possible for updating the module please.

I am having problem inside docker, with my packages requirements file, scikit-learn got installed first, then sklearn-nature-inspired-algorithms getting installed and this downgrading the scikit-learn which is causing other module issues,

As "sklearn-nature-inspired-algorithms is compatible with scikit-learn 0.23.2" is it possible for updating the module pip please.
Thanks

"Add support for dict of scores in 'scoring' attribute"

Complete Description of the Issue

As a software developer, I want to track the improvement of ML model over iterations using multiple scoring metrics. This is a default behavior of parameter searching algorithms in sklearn (e.g., GridSearchCV ). Though able to use same API, NatureInspiredSearchCV raises a KeyError.

This seems to be due to default cv_results key used for evaluation, that changes from 'mean_test_score' to f'mean_test_{self.refit}'. However, method refit is not passed to ParameterSearch.

Simplest Possible Self-Contained Example Showing the Bug

from sklearn.datasets import make_classification
from sklearn.tree import DecisionTreeClassifier as DTC
from sklearn_nature_inspired_algorithms.model_selection import\
    NatureInspiredSearchCV as NIS_CV

X, y = make_classification()

tree = DTC(random_state=0)

param_grid = {'max_depth': [1, 2]}

scoring = {'AUC': 'roc_auc', 'F1': 'f1_macro'}

sh = NIS_CV(tree, param_grid,
            scoring=scoring, refit=False).fit(X, y)

Full Backtrace of Exception

Exception has occurred: KeyError Exception has occurred: KeyError 'mean_test_score' File "./Sklearn-Nature-Inspired-Search/sklearn_nature_inspired_algorithms/model_selection/_parameter_search.py", line 39, in _evaluate mean_test_score = cv_results['mean_test_score'] File "./Sklearn-Nature-Inspired-Search/sklearn_nature_inspired_algorithms/model_selection/_stagnation_stopping_task.py", line 40, in eval x_f = super().eval(A) File "./Sklearn-Nature-Inspired-Search/sklearn_nature_inspired_algorithms/model_selection/nature_inspired_search_cv.py", line 47, in _run_search self.__algorithm.run(task=task) File "./Sklearn-Nature-Inspired-Search/sklearn_nature_inspired_algorithms/model_selection/nature_inspired_search_cv.py", line 19, in fit return super().fit(X, y, groups=groups, **fit_params) File "./RnD/Similarity/bug_nia.py", line 15, in scoring=scoring, refit=False).fit(X, y) KeyError: 'mean_test_score'

k-fold cross-validation error

Hi timzatko, i am currently working on a optimization project. I am using your tutorial as a start point but i am getting this error. I am new to ML , i looked web for a solution but i failed.

`clf = RandomForestClassifier(random_state=42)

nia_search = NatureInspiredSearchCV(

clf,
param_grid,
cv=5,
verbose=0,
algorithm='ba',
population_size=25,
max_n_gen=100,
max_stagnating_gen=10,    
runs=5,
scoring='f1_macro',
random_state=42,

)

nia_search.fit(X_train, y_train)`

when i run this piece of code i got this error.

`/opt/anaconda3/envs/data-mining/lib/python3.8/site-packages/sklearn/utils/validation.py:70: FutureWarning: Pass scoring=f1_macro, n_jobs=None, refit=deprecated, cv=True, verbose=5, pre_dispatch=0, error_score=2*n_jobs, return_train_score=nan as keyword args. From version 1.0 (renaming of 0.25) passing these as positional arguments will result in an error
warnings.warn(f"Pass {args_msg} as keyword args. From version "

Any idea or comment how to solve this?

Versions of lib
sklearn-nature-inspired-algorithm 0.5.1
sklearn 0.24.2

Screenshots

Ekran Resmi 2021-05-03 15 17 30

Ekran Resmi 2021-05-03 15 17 38

New NiaPy release

A new version of niapy has recently been released. Please use the 2.0.2 version of niapy.

How to select optimum parameters?

Hi,
How should we select the optimum parameters on

algorithm : 'ba','hba','fa','hsaba','gwo'
population_size: int, default=50. 
max_n_gen: int, default=100. 
runs: int, default=3. 
max_stagnating_gen: int, default=20. 

That's is what is the effect of
population_size high value and low value
max_n_gen high value and low value
runs high value and low value
max_stagnating_gen high value and low value
Thanks

GPU usage is not full?

Hi,
Having tf 2.3.0 and keras 2.4.3
NatureInspiredSearchCV not using full GPU

from tensorflow.keras.wrappers.scikit_learn import KerasClassifier
from sklearn.model_selection import GridSearchCV
BatchSize = [100,200,300,400,500,600,700,800,900,1000]
Epochs = [100,200,300,400,500,600,700,800,900,1000]

    def create_model():
    	model = Sequential()
    	model.add(Dense(int(num_cols/2), input_dim=num_cols, activation='relu'))
    	model.add(Dense(1, activation='sigmoid'))
    	model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
    	return model
    model = KerasClassifier(build_fn=create_model, verbose=0)
    param_grid = dict(batch_size=BatchSize , epochs=Epochs )
    grid = NatureInspiredSearchCV(model, cv = 3, param_grid=param_grid, verbose=0,  algorithm='ba',  population_size=25,  max_n_gen=100,  max_stagnating_gen=10, runs=5, scoring='accuracy', random_state=42)
    grid_result = grid.fit(X_train, y_train)         
    best_hyperparameters = grid_result.best_params_

GPU usage is nearly 1-2% all time
image

i have set

from tensorflow.python.client import device_lib
assert 'GPU' in str(device_lib.list_local_devices())

Does NatureInspiredSearchCV use n_jobs parameter like GridSearchCV?

Having issues when used with KerasClassifier

Hi,
Thanks for this library, working very well,
I tried with KerasClassifier from

from tensorflow.keras.wrappers.scikit_learn import KerasClassifier

my Spyder ide getting hanged in half way of epoch tuning
Is this not supposed to work with keras, still a scikit learn wrapper?
Thanks

OSError : [Errno 22] Invalid argument

Hi,
Can I have a help here please
I am using this NatureInspiredSearchCV as

    grid = NatureInspiredSearchCV(model,
                                  cv=3,
                                  param_grid=model_parameters_space,
                                  verbose=0,
                                  algorithm='hba',
                                  population_size=50,
                                  max_n_gen=100,
                                  max_stagnating_gen=20,
                                  runs=5,
                                  scoring='accuracy',
                                #   n_jobs=-1,
                                  random_state=42)

If I comment n_jobs, it is working fine
If I use n_jobs, I am getting below error,
It looks like n_jobs is not working, not sure,

"""Exception occured: OSError : [Errno 22] Invalid argument (  File "C:\Python\Lib\site-packages\joblib\externals\loky\backend\resource_tracker.py", line 209, in _send
    nbytes = os.write(self._fd, msg)
  File "C:\Python\Lib\site-packages\joblib\externals\loky\backend\resource_tracker.py", line 182, in _check_alive
    self._send('PROBE', '', '')
  File "C:\Python\Lib\site-packages\joblib\externals\loky\backend\resource_tracker.py", line 102, in ensure_running
    if self._check_alive():
  File "C:\Python\Lib\site-packages\joblib\externals\loky\backend\spawn.py", line 86, in get_preparation_data
    _resource_tracker.ensure_running()
  File "C:\Python\Lib\site-packages\joblib\externals\loky\backend\popen_loky_win32.py", line 54, in __init__
    prep_data = spawn.get_preparation_data(
  File "C:\Python\Lib\site-packages\joblib\externals\loky\backend\process.py", line 39, in _Popen
    return Popen(process_obj)
  File "C:\Python\Lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
  File "C:\Python\Lib\site-packages\joblib\externals\loky\process_executor.py", line 1087, in _adjust_process_count
    p.start()
  File "C:\Python\Lib\site-packages\joblib\externals\loky\process_executor.py", line 1096, in _ensure_executor_running
    self._adjust_process_count()
  File "C:\Python\Lib\site-packages\joblib\externals\loky\process_executor.py", line 1122, in submit
    self._ensure_executor_running()
  File "C:\Python\Lib\site-packages\joblib\externals\loky\reusable_executor.py", line 177, in submit
    return super(_ReusablePoolExecutor, self).submit(
  File "C:\Python\Lib\site-packages\joblib\_parallel_backends.py", line 531, in apply_async
    future = self._workers.submit(SafeFunction(func))
  File "C:\Python\Lib\site-packages\joblib\parallel.py", line 777, in _dispatch
    job = self._backend.apply_async(batch, callback=cb)
  File "C:\Python\Lib\site-packages\joblib\parallel.py", line 859, in dispatch_one_batch
    self._dispatch(tasks)
  File "C:\Python\Lib\site-packages\joblib\parallel.py", line 1041, in __call__
    if self.dispatch_one_batch(iterator):
  File "C:\Python\Lib\site-packages\sklearn\model_selection\_search.py", line 795, in evaluate_candidates
    out = parallel(delayed(_fit_and_score)(clone(base_estimator),
  File "C:\Python\Lib\site-packages\sklearn_nature_inspired_algorithms\model_selection\_parameter_search.py", line 38, in _evaluate
    cv_results = self.evaluate_candidates([params])
  File "C:\Python\Lib\site-packages\niapy\problems\problem.py", line 57, in evaluate
    return self._evaluate(x)
  File "C:\Python\Lib\site-packages\niapy\task.py", line 144, in eval
    x_f = self.problem.evaluate(x) * self.optimization_type.value
  File "C:\Python\Lib\site-packages\sklearn_nature_inspired_algorithms\model_selection\_stagnation_stopping_task.py", line 40, in eval
    x_f = super().eval(A)
  File "C:\Python\Lib\site-packages\numpy\lib\shape_base.py", line 379, in apply_along_axis
    res = asanyarray(func1d(inarr_view[ind0], *args, **kwargs))
  File "<__array_function__ internals>", line 5, in apply_along_axis
  File "C:\Python\Lib\site-packages\niapy\algorithms\algorithm.py", line 38, in default_numpy_init
    fpop = np.apply_along_axis(task.eval, 1, pop)
  File "C:\Python\Lib\site-packages\niapy\algorithms\algorithm.py", line 258, in init_population
    pop, fpop = self.initialization_function(task=task, population_size=self.population_size, rng=self.rng,
  File "C:\Python\Lib\site-packages\niapy\algorithms\basic\ba.py", line 135, in init_population
    population, fitness, d = super().init_population(task)
  File "C:\Python\Lib\site-packages\niapy\algorithms\algorithm.py", line 308, in iteration_generator
    pop, fpop, params = self.init_population(task)
  File "C:\Python\Lib\site-packages\niapy\algorithms\algorithm.py", line 333, in run_task
    xb, fxb = next(algo)
  File "C:\Python\Lib\site-packages\niapy\algorithms\algorithm.py", line 353, in run
    r = self.run_task(task)
  File "C:\Python\Lib\site-packages\niapy\algorithms\algorithm.py", line 357, in run
    raise e
  File "C:\Python\Lib\site-packages\sklearn_nature_inspired_algorithms\model_selection\nature_inspired_search_cv.py", line 43, in _run_search
    self.__algorithm.run(task=task)
  File "C:\Python\Lib\site-packages\sklearn\model_selection\_search.py", line 841, in fit
    self._run_search(evaluate_candidates)
  File "C:\Python\Lib\site-packages\sklearn\utils\validation.py", line 63, in inner_f
    return f(*args, **kwargs)
  File "C:\src\scripts\AutoMLUtils.py", line 775, in feHPTuning
    lgbmgrid_result = lgbmgrid.fit(X_train,
  File "C:\src\scripts\AutoMLUtils.py", line 865, in feHyperParameterSelection
    febest_hyperparameters = feHPTuning(X_train,
  File "C:\src\scripts\AutoMLUtils.py", line 1050, in featureEnggData
    FE_HParams = feHyperParameterSelection(X_train_stomek,
  File "C:\src\scripts\AutoMLTrainer.py", line 537, in train
    to_drop, FE_HParams, balancer_algo, balancer = featureEnggData(cleaned_df,
===
   at Python.Runtime.PyObject.Invoke(PyTuple args, PyDict kw)
   at Python.Runtime.PyObject.InvokeMethod(String name, PyTuple args, PyDict kw)
   at Python.Runtime.PyObject.TryInvokeMember(InvokeMemberBinder binder, Object[] args, Object& result)
   at CallSite.Target(Closure , CallSite , Object , String , Object )
   at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
   at Intuition.AutoML.Trainer.Run(Guid tenantId, TrainingRunParameter parameter) in C:\src\src\Intuition.AutoML\Implementation\Trainer.cs:line 109)

Error Installing in python 3.10.0

Hi,
I am upgrading my python to 3.10.0, currently using 3.9.5 where sklearn-nature-inspired-algorithms 0.6.0 working good with scikit-learn==0.24.2.

for py3.10.0, I installed scikit-learn==1.0.2 and sklearn-nature-inspired-algorithms==0.6.1 also tired 0.7.1, I am getting following error while installing
May I have some help please

For now, python 3.10.0 requires scikit-learn > 1.0 but sklearn-nature-inspired-algorithms requires scikit-learn<1.0.0, am I correct?

Collecting sklearn-nature-inspired-algorithms==0.6.1
  Using cached sklearn_nature_inspired_algorithms-0.6.1-py3-none-any.whl (9.9 kB)
Collecting niapy==2.0.0rc18
  Using cached niapy-2.0.0rc18-py3-none-any.whl (202 kB)
Collecting toml<1.0.0,>=0.9
  Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
Requirement already satisfied: pandas<2.0.0,>=1.0 in c:\users\pg\anaconda3\envs\py3100\lib\site-packages (from sklearn-nature-inspired-algorithms==0.6.1) (1.3.5)
Requirement already satisfied: numpy<2.0.0,>=1.18 in c:\users\pg\anaconda3\envs\py3100\lib\site-packages (from sklearn-nature-inspired-algorithms==0.6.1) (1.22.3)
Collecting seaborn<1.0.0,>=0.10
  Using cached seaborn-0.11.2-py3-none-any.whl (292 kB)
Collecting matplotlib<4.0.0,>=3.2
  Using cached matplotlib-3.5.1-cp310-cp310-win_amd64.whl (7.2 MB)
Collecting scikit-learn<1.0.0,>=0.22
  Using cached scikit-learn-0.24.2.tar.gz (7.5 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... error
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\pg\anaconda3\envs\py3100\python.exe' 'C:\Users\pg\anaconda3\envs\autoMLpy3100\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\pg~1\AppData\Local\Temp\tmpalz9u3b0'
         cwd: C:\Users\pg\AppData\Local\Temp\pip-install-ue3it4ax\scikit-learn_6cde19b09c4e4340ac1e1890ee40a83c
    Complete output (46 lines):
    Partial import of sklearn during the build process.
    INFO: No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
    Traceback (most recent call last):
      File "C:\Users\pg\anaconda3\envs\py3100\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 349, in <module>
        main()
      File "C:\Users\pg\anaconda3\envs\py3100\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 331, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "C:\Users\pg\anaconda3\envs\py3100\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 151, in prepare_metadata_for_build_wheel
        return hook(metadata_directory, config_settings)
      File "C:\Users\pg\AppData\Local\Temp\pip-build-env-ydl3gzk9\overlay\Lib\site-packages\setuptools\build_meta.py", line 188, in prepare_metadata_for_build_wheel
        self.run_setup()
      File "C:\Users\pg\AppData\Local\Temp\pip-build-env-ydl3gzk9\overlay\Lib\site-packages\setuptools\build_meta.py", line 281, in run_setup
        super(_BuildMetaLegacyBackend,
      File "C:\Users\pg\AppData\Local\Temp\pip-build-env-ydl3gzk9\overlay\Lib\site-packages\setuptools\build_meta.py", line 174, in run_setup
        exec(compile(code, __file__, 'exec'), locals())
      File "setup.py", line 301, in <module>
        setup_package()
      File "setup.py", line 297, in setup_package
        setup(**metadata)
      File "C:\Users\pg\AppData\Local\Temp\pip-build-env-ydl3gzk9\overlay\Lib\site-packages\numpy\distutils\core.py", line 135, in setup
        config = configuration()
      File "setup.py", line 188, in configuration
        config.add_subpackage('sklearn')
      File "C:\Users\pg\AppData\Local\Temp\pip-build-env-ydl3gzk9\overlay\Lib\site-packages\numpy\distutils\misc_util.py", line 1054, in add_subpackage
        config_list = self.get_subpackage(subpackage_name, subpackage_path,
      File "C:\Users\pg\AppData\Local\Temp\pip-build-env-ydl3gzk9\overlay\Lib\site-packages\numpy\distutils\misc_util.py", line 1020, in get_subpackage
        config = self._get_configuration_from_setup_py(
      File "C:\Users\pg\AppData\Local\Temp\pip-build-env-ydl3gzk9\overlay\Lib\site-packages\numpy\distutils\misc_util.py", line 962, in _get_configuration_from_setup_py
        config = setup_module.configuration(*args)
      File "C:\Users\pg\AppData\Local\Temp\pip-install-ue3it4ax\scikit-learn_6cde19b09c4e4340ac1e1890ee40a83c\sklearn\setup.py", line 83, in configuration
        cythonize_extensions(top_path, config)
      File "C:\Users\pg\AppData\Local\Temp\pip-install-ue3it4ax\scikit-learn_6cde19b09c4e4340ac1e1890ee40a83c\sklearn\_build_utils\__init__.py", line 45, in cythonize_extensions
        basic_check_build()
      File "C:\Users\pg\AppData\Local\Temp\pip-install-ue3it4ax\scikit-learn_6cde19b09c4e4340ac1e1890ee40a83c\sklearn\_build_utils\pre_build_helpers.py", line 106, in basic_check_build
        compile_test_program(code)
      File "C:\Users\pg\AppData\Local\Temp\pip-install-ue3it4ax\scikit-learn_6cde19b09c4e4340ac1e1890ee40a83c\sklearn\_build_utils\pre_build_helpers.py", line 66, in compile_test_program
        ccompiler.compile(['test_program.c'], output_dir='objects',
      File "C:\Users\pg\AppData\Local\Temp\pip-build-env-ydl3gzk9\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 327, in compile
        self.initialize()
      File "C:\Users\pg\AppData\Local\Temp\pip-build-env-ydl3gzk9\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 224, in initialize
        vc_env = _get_vc_env(plat_spec)
      File "C:\Users\pg\AppData\Local\Temp\pip-build-env-ydl3gzk9\overlay\Lib\site-packages\setuptools\msvc.py", line 316, in msvc14_get_vc_env
        return _msvc14_get_vc_env(plat_spec)
      File "C:\Users\pg\AppData\Local\Temp\pip-build-env-ydl3gzk9\overlay\Lib\site-packages\setuptools\msvc.py", line 270, in _msvc14_get_vc_env
        raise distutils.errors.DistutilsPlatformError(
    distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/05/04/507280f20fafc8bc94b41e0592938c6f4a910d0e066be7c8ff1299628f5d/scikit-learn-0.24.2.tar.gz#sha256=d14701a12417930392cd3898e9646cf5670c190b933625ebe7511b1f7d7b8736 (from https://pypi.org/simple/scikit-learn/) (requires-python:>=3.6). Command errored out with exit status 1: 'C:\Users\pg\anaconda3\envs\py3100\python.exe' 'C:\Users\pg\anaconda3\envs\py3100\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\pg~1\AppData\Local\Temp\tmpalz9u3b0' Check the logs for full command output.
  Using cached scikit-learn-0.24.1.tar.gz (7.4 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting openpyxl>=3.0.3
  Using cached openpyxl-3.0.9-py2.py3-none-any.whl (242 kB)
Collecting kiwisolver>=1.0.1
  Using cached kiwisolver-1.4.2-cp310-cp310-win_amd64.whl (55 kB)
Collecting pyparsing>=2.2.1
  Using cached pyparsing-3.0.7-py3-none-any.whl (98 kB)
Collecting fonttools>=4.22.0
  Using cached fonttools-4.31.2-py3-none-any.whl (899 kB)
Collecting pillow>=6.2.0
  Using cached Pillow-9.0.1-cp310-cp310-win_amd64.whl (3.2 MB)
Collecting packaging>=20.0
  Using cached packaging-21.3-py3-none-any.whl (40 kB)
Collecting cycler>=0.10
  Using cached cycler-0.11.0-py3-none-any.whl (6.4 kB)
Requirement already satisfied: python-dateutil>=2.7 in c:\users\pg\anaconda3\envs\py3100\lib\site-packages (from matplotlib<4.0.0,>=3.2->sklearn-nature-inspired-algorithms==0.6.1) (2.8.2)
Collecting et-xmlfile
  Using cached et_xmlfile-1.1.0-py3-none-any.whl (4.7 kB)
Requirement already satisfied: pytz>=2017.3 in c:\users\pg\anaconda3\envs\py3100\lib\site-packages (from pandas<2.0.0,>=1.0->sklearn-nature-inspired-algorithms==0.6.1) (2022.1)
Requirement already satisfied: six>=1.5 in c:\users\pg\anaconda3\envs\py3100\lib\site-packages (from python-dateutil>=2.7->matplotlib<4.0.0,>=3.2->sklearn-nature-inspired-algorithms==0.6.1) (1.16.0)
Requirement already satisfied: threadpoolctl>=2.0.0 in c:\users\pg\anaconda3\envs\py3100\lib\site-packages (from scikit-learn<1.0.0,>=0.22->sklearn-nature-inspired-algorithms==0.6.1) (3.1.0)
Requirement already satisfied: joblib>=0.11 in c:\users\pg\anaconda3\envs\py3100\lib\site-packages (from scikit-learn<1.0.0,>=0.22->sklearn-nature-inspired-algorithms==0.6.1) (1.1.0)
Requirement already satisfied: scipy>=0.19.1 in c:\users\pg\anaconda3\envs\py3100\lib\site-packages (from scikit-learn<1.0.0,>=0.22->sklearn-nature-inspired-algorithms==0.6.1) (1.8.0)
Building wheels for collected packages: scikit-learn
  Building wheel for scikit-learn (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\pg\anaconda3\envs\py3100\python.exe' 'C:\Users\pg\anaconda3\envs\py3100\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' build_wheel 'C:\Users\pg~1\AppData\Local\Temp\tmpo71jfmah'
       cwd: C:\Users\pg\AppData\Local\Temp\pip-install-ue3it4ax\scikit-learn_b8c3a6aeefb843379cf942a042ae963b
  Complete output (48 lines):
  Partial import of sklearn during the build process.
  INFO: No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  Traceback (most recent call last):
    File "C:\Users\pg\anaconda3\envs\py3100\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 349, in <module>
      main()
    File "C:\Users\pg\anaconda3\envs\py3100\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 331, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "C:\Users\pg\anaconda3\envs\py3100\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 248, in build_wheel
      return _build_backend().build_wheel(wheel_directory, config_settings,
    File "C:\Users\pg\AppData\Local\Temp\pip-build-env-p6h1bo8u\overlay\Lib\site-packages\setuptools\build_meta.py", line 244, in build_wheel
      return self._build_with_temp_dir(['bdist_wheel'], '.whl',
    File "C:\Users\pg\AppData\Local\Temp\pip-build-env-p6h1bo8u\overlay\Lib\site-packages\setuptools\build_meta.py", line 229, in _build_with_temp_dir
      self.run_setup()
    File "C:\Users\pg\AppData\Local\Temp\pip-build-env-p6h1bo8u\overlay\Lib\site-packages\setuptools\build_meta.py", line 281, in run_setup
      super(_BuildMetaLegacyBackend,
    File "C:\Users\pg\AppData\Local\Temp\pip-build-env-p6h1bo8u\overlay\Lib\site-packages\setuptools\build_meta.py", line 174, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 306, in <module>
      setup_package()
    File "setup.py", line 302, in setup_package
      setup(**metadata)
    File "C:\Users\pg\AppData\Local\Temp\pip-build-env-p6h1bo8u\overlay\Lib\site-packages\numpy\distutils\core.py", line 135, in setup
      config = configuration()
    File "setup.py", line 188, in configuration
      config.add_subpackage('sklearn')
    File "C:\Users\pg\AppData\Local\Temp\pip-build-env-p6h1bo8u\overlay\Lib\site-packages\numpy\distutils\misc_util.py", line 1054, in add_subpackage
      config_list = self.get_subpackage(subpackage_name, subpackage_path,
    File "C:\Users\pg\AppData\Local\Temp\pip-build-env-p6h1bo8u\overlay\Lib\site-packages\numpy\distutils\misc_util.py", line 1020, in get_subpackage
      config = self._get_configuration_from_setup_py(
    File "C:\Users\pg\AppData\Local\Temp\pip-build-env-p6h1bo8u\overlay\Lib\site-packages\numpy\distutils\misc_util.py", line 962, in _get_configuration_from_setup_py
      config = setup_module.configuration(*args)
    File "C:\Users\pg\AppData\Local\Temp\pip-install-ue3it4ax\scikit-learn_b8c3a6aeefb843379cf942a042ae963b\sklearn\setup.py", line 83, in configuration
      cythonize_extensions(top_path, config)
    File "C:\Users\pg\AppData\Local\Temp\pip-install-ue3it4ax\scikit-learn_b8c3a6aeefb843379cf942a042ae963b\sklearn\_build_utils\__init__.py", line 45, in cythonize_extensions
      basic_check_build()
    File "C:\Users\pg\AppData\Local\Temp\pip-install-ue3it4ax\scikit-learn_b8c3a6aeefb843379cf942a042ae963b\sklearn\_build_utils\pre_build_helpers.py", line 106, in basic_check_build
      compile_test_program(code)
    File "C:\Users\pg\AppData\Local\Temp\pip-install-ue3it4ax\scikit-learn_b8c3a6aeefb843379cf942a042ae963b\sklearn\_build_utils\pre_build_helpers.py", line 66, in compile_test_program
      ccompiler.compile(['test_program.c'], output_dir='objects',
    File "C:\Users\pg\AppData\Local\Temp\pip-build-env-p6h1bo8u\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 327, in compile
      self.initialize()
    File "C:\Users\pg\AppData\Local\Temp\pip-build-env-p6h1bo8u\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 224, in initialize
      vc_env = _get_vc_env(plat_spec)
    File "C:\Users\pg\AppData\Local\Temp\pip-build-env-p6h1bo8u\overlay\Lib\site-packages\setuptools\msvc.py", line 316, in msvc14_get_vc_env
      return _msvc14_get_vc_env(plat_spec)
    File "C:\Users\pg\AppData\Local\Temp\pip-build-env-p6h1bo8u\overlay\Lib\site-packages\setuptools\msvc.py", line 270, in _msvc14_get_vc_env
      raise distutils.errors.DistutilsPlatformError(
  distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
  ----------------------------------------
  ERROR: Failed building wheel for scikit-learn
Failed to build scikit-learn
ERROR: Could not build wheels for scikit-learn which use PEP 517 and cannot be installed directly

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.