Installing an old version of scikit-learn

2024/10/8 8:25:01

Problem Statment

I'm trying to run some old python code that requires scikit-learn 18.0 but the current version I have installed is 0.22 and so I'm getting a warning/invalid data when I run the code.


What I've Tried

I tried installing the specific version both in the terminal: python -m pip install scikit-learn==0.18 and in conda and none of that has worked. All I can install is v 0.22. Help? Thanks.


Error In Terminal

ERROR: Failed building wheel for scikit-learn
Running setup.py clean for scikit-learn
Failed to build scikit-learn
Installing collected packages: scikit-learn
Found existing installation: scikit-learn 0.22.1
Uninstalling scikit-learn-0.22.1:
Successfully uninstalled scikit-learn-0.22.1
Running setup.py install for scikit-learn ... error
ERROR: Command errored out with exit status 1:

Error through conda environment:

PackagesNotFoundError: The following packages are not available fromcurrent channels:
- scikit-learn==0.18 this was after creating and activating the new environment

Answer

Tackling your issues one at a time:

python -m pip install scikit-learn==0.18 fails

This is probably due to the fact that scikit-learn==0.18, if you check on pypi only has whl files for python 3.5 and 2.7 for windows, therefore pip downloads the source distribution and then fails in compiling it, probably because it doesn't work with newer python versions

The following packages are not available from current channels

This happens, because scikit-learn==18.0 simply does not exist in the default conda channels. On my win64 machine, the oldesst version that I can install is 19.0 (You can check by typing conda search scikit-learn in the cmd), so unfortunately no way to install using the default conda channels. There is a channel called free (found through the anaconda website) that has scikit-learn 18.0, so you could install with:

conda install -c free scikit-learn 

To also make sure that the python version is compatible, I would just create a fitting environment:

conda create -n py35 -c free scikit-learn=0.18.0
https://en.xdnf.cn/q/70144.html

Related Q&A

remove characters from pandas column

Im trying to simply remove the ( and ) from the beginning and end of the pandas column series. This is my best guess so far but it just returns empty strings with () intact. postings[location].replace(…

numerically stable inverse of a 2x2 matrix

In a numerical solver I am working on in C, I need to invert a 2x2 matrix and it then gets multiplied on the right side by another matrix:C = B . inv(A)I have been using the following definition of an …

Type annotating class variable: in init or body?

Lets consider the two following syntax variations:class Foo:x: intdef __init__(self, an_int: int):self.x = an_intAndclass Foo:def __init__(self, an_int: int):self.x = an_intApparently the following cod…

decoding shift-jis: illegal multibyte sequence

Im trying to decode a shift-jis encoded string, like this:string.decode(shift-jis).encode(utf-8)to be able to view it in my program.When I come across 2 shift-jis characters, in hex "0x87 0x54&quo…

Add columns in pandas dataframe dynamically

I have following code to load dataframe import pandas as pdufo = pd.read_csv(csv_path) print(ufo.loc[[0,1,2] , :])which gives following output, see the structure of the csvCity Colors Reported Shape Re…

How do you add input from user into list in Python [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.Want to improve this question? Add details and clarify the problem by editing this post.Closed 9 years ago.Improve…

How to suppress matplotlib inline for a single cell in Jupyter Notebooks/Lab?

I was looking at matplotlib python inline on/off and this kind of solves the problem but when I do plt.ion() all of the Figures pop up (100s of figures). I want to keep them suppressed in a single cel…

Using django-filer, can I chose the folder that images go into, from Unsorted Uploads

Im using django-filer for the first time, and it looks great, and work pretty well.But all my images are being uploaded to the Unsorted Uploads folder, and I cant figure out a way to put them in a spec…

how to use distutils to create executable .zip file?

Python 2.6 and beyond has the ability to directly execute a .zip file if the zip file contains a __main__.py file at the top of the zip archive. Im wanting to leverage this feature to provide preview r…

Pass nested dictionary location as parameter in Python

If I have a nested dictionary I can get a key by indexing like so: >>> d = {a:{b:c}} >>> d[a][b] cAm I able to pass that indexing as a function parameter? def get_nested_value(d, pat…