problem with importing SGDOneClassSVM from sklearn.linear_model - python

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

Related

Scikit-learn error dataset "load_breast_cancer"

Trying to run a code using sklearn (in windows, pycharm). Although import data load_breast_cancer is not working. Below is the complete code:
from sklearn.datasets import load_breast_cancer
data = load_breast_cancer()
label_names = data['target_names']
labels = data['target']
feature_names = data['feature_names']
features = data['data']
print(label_names)
print(labels[0])
print(feature_names[0])
print(features[0])
The error says
ModuleNotFoundError: No module named 'sklearn.datasets'; 'sklearn'
I have already installed scikit and its datasets using
pip install -U scikit-learn and pip install -U scikit-datasets.
I also tried installing it in pycharm interpreter...
Here are some images from my pycharm:
[1]https://i.stack.imgur.com/a1f7G.png [I already installed scikit-learn in the interpreter]
[2]https://i.stack.imgur.com/S2FFX.png [The error]
Try pip install sklearn, that should work.

ModuleNotFoundError: Pyramid

I'm trying to import these libraries:
from math import sqrt
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from statsmodels.tsa.arima_model import ARIMA
from sklearn.metrics import mean_absolute_error, mean_squared_error
from pyramid.arima import auto_arima
from statsmodels.tsa.stattools import adfuller
But this error is coming again and again
ModuleNotFoundError: No module named 'pyramid'
I have tried pip install pyramid-arima but it's also throwing me so many errors in cmd.
Can anyone suggest to me what I can do to resolve this problem?
try
pip install pmdarima
pmdarima is the official new name for pyramid.arima.
Try to install pmdarima by using pip:
pip install pmdarima
I also needed to modify my python script to use:
from pmdarima.arima import auto_arima

ModuleNotFoundError: No module named 'sksurv' in python

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

sklearn module not found in anaconda

I've been trying to import sklearn but it says that the module is not found.
my python, numpy, scipy and scikit versions are as follows as show in the conda list:
numpy 1.14.3 py36h9fa60d3_1
python 3.6.5 h0c2934d_0
scipy 1.1.0 py36h672f292_0
scikit-learn 0.19.1 py36h53aea1b_0
the error while trying to import sklearn is:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-f2461ba6e1e9> in <module>()
----> 1 from sklearn.family import model
ModuleNotFoundError: No module named 'sklearn.family'
I tried using
conda update scikit-learn
conda install scikit-learn
but I get the following results
All requested packages already installed.
how do I import sklearn then?
Although there is not skleran module, from sklearn import ... works well in PyCharm:
from sklearn.utils import resample
Try doing
conda install -c anaconda pip
pip install sklearn
AFAIK, there's no sklearn.family module. Have you tried importing other modules?
Say,
from sklearn.model_selection import TimeSeriesSplit
Does that work for you?

ImportError: cannot import name __check_build

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.

Categories

Resources