I am trying to run survival analysis in python (pycharm) in linux, here is a part of the code
import numpy as np
import matplotlib.pyplot as plt
#matplotlib inline
import pandas as pd
from sklearn.impute import SimpleImputer
from sklearn.pipeline import make_pipeline
from sklearn.model_selection import train_test_split
from sksurv.datasets import load_flchain
from sksurv.linear_model import CoxPHSurvivalAnalysis
I get the error "ModuleNotFoundError: No module named 'sksurv'", I tried everything, but nothing works.
The required dependencies for scikit-survival,
cvxpy
cvxopt
joblib
numexpr
numpy 1.12 or later
osqp
pandas 0.21 or later
scikit-learn 0.22
scipy 1.0 or later
...will be automatically installed by pip when you run:
pip install scikit-survival
However, one module in particular, osqp, has CMake as one of its dependencies. If you don't have CMake installed, pip install scikit-survival will throw an error and the installation will fail.
You can download CMake for your OS at cmake.org/download
After CMake has installed, you should be able to successfully run
pip install scikit-survival
Notes:
GCC needs to be installed also
scikit-survival works with Python 3.5 or higher
More information is available in the docs
Related
after importing and installing required packages and libraries I am encountering an import error on patch_sklearn().
from sklearnx import patch_sklearn()
patch_sklearn()
ImportError: cannot import name 'sparse_lsqr' from 'sklearn.utils.fixes' (C:\Users\yogis\AppData\Roaming\Python\Python38\site-packages\sklearn\utils\fixes.py)
Didn't know what you want to do here.
But you can try this:
from sklearn.feature_extraction.image import extract_patches_2d
You must install scikit learn version 1.0 and not 1.1
pip install scikit-learn==1.0
Then after this, restart kernel. If it doesn't work after this, I also had to force reinstall the other packages for conda.
conda install numpy scipy joblib scikit-learn --force-reinstall
and then restart kernel. It worked fine. This is a known bug and is fixed on pypi releases but not yet on conda.
I'm trying "from sklearn.linear_model import SGDOneClassSVM"
but it doesn't work and raises an import error "ImportError: cannot import name 'SGDOneClassSVM' from 'sklearn.linear_model"
Upgrade sklearn package using the command:
pip install --upgrade scikit-learn
I updated my spyder from 3.3.6 to 4.0.1 and since then my libraries are not getting compiled , like pandas library, sklearn , and few other .
I don't know why it's happening . Normal import statements show error . Even numpy did the same , so i just ran pip install numpy in the ipython console and then it got solved .
Is there no other alternative? Spyder 3.6 worked just fine without running the pip command in the ipython console .
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder,OneHotEncoder
for now i used ipython commands to install the entire library again (pip install sklearn).
Can someone help me out with a permanent fix?
I have installed the gensim module for MAC by passing the following command in my Terminal:
pip3 install gensim
I already have many other modules such as pandas and numpy that have been installed but I am able to import the same to my Jupyter Notebook without any issues.
This is how I am importing gensim:
from gensim.models import Word2Vec
from gensim.models import KeyedVectors
So I checked the path where the 2 modules have been installed through the terminal, these being the same for a module I am able to import such as pandas as well as for gensim.
pip3 show pandas
pip3 show gensim
In both the cases I get the same output:
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
Can anyone tell me what could be the issue in this case?
from sklearn import svm
ImportError: cannot import name __check_build
I've been able to install scikit-learn on a fresh virtualenv here but it seems you need to do some extra job to get it up-and-running:
By doing just pip install scikit-learn and then from sklearn import svm you'll get import errors, it seems the library requires numpy and scipy. So you need to do:
pip install numpy scipy
After that it should work fine.