Got cluster not defined when trying to run cluster.vq.vq() in Scipy lib - scipy

I am trying to learn anomaly detection by following :
https://github.com/sayakpaul/FloydHub-Anomaly-Detection-Blog/blob/master/FloydHub%20Anomaly%20Detection%20Blog.ipynb
I installed necessary libraries using:
python -m pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose
cluster.vq.vq() is included in these libraries. However i am getting name error :
NameError: name 'cluster' is not defined
Any help is appreciated.

Now i solved my own question,
You just need to import:
from scipy.cluster.vq import vq
and instead of cluster.vq.vq(), vq() is enough

Related

Pytorch error on multi-GPU setup: cannot import name 'invoke_remote_python_udf' from 'torch.distributed'

I'm getting this below error when importing Pytorch.
"cannot import name 'invoke_remote_python_udf' from 'torch.distributed'"
I faced the similar problem. For me , the problem was occuring due to mismatch in cuda version. I am using conda environment.
In my system the nvcc --version showed the result as 10.0' , while I had mistakenly install the pytorch for cuda version10.1`
I removed the torch and torchvision and re-installed them using the following command:
conda install pytorch torchvision cuda100 -c pytorch.
Installing the package cuda100 solved the problem.

Import local module to the Jupyter Notebook

I've a local function to transform my data on a local.
For example, when I tried to import:
import com.company.area.project.area.functions
I've received the error:
console: 49: error: object company is not a member of package com
import com.company.area.project.area.functions
I'm using Anaconda and the pip. Reading trough the web I've found this question: Is there a pip / easy_install for Scala?
So, I noticed that there is no a equivalent to "Pip install ." we have in python.
So, the question is. How can I import a custom function in my Jupyter Notebook?
First you have to ensure that you have Scala environment enabled for your jupyter notebook.
pixiedust can help you with installing scala packages in your jupyter notebook.
A specific example in your case will be to deploy your project as a jar file to a repository or an address where you can then pass to the pixiedust package
Code example should look like this:
import pixiedust
pixiedust.installPackage("https://github.com/companyrepo/jars/raw/master/dist/functions-assembly-1.0.jar")

No module named 'scipy', although installed with Anaconda. Python 3 on Windows 10

I did conda install for numpy, pandas, scipy, and scikit-learn apparently all successful. I also tried to change the path in the Windows 10 registry. I only have 1 version of Python, 3.6 installed. I also installed Visual Studio. If I run the script, I get "scipy module not found". Can you explain me what's the problem, and how to fix this?
My imports look like this:
import pandas as pd
import quandl, math
import numpy as np
from sklearn import preprocessing, cross_validation, svm
from sklearn.linear_model import LinearRegression
I'm following this tutorial by Sentdex:
https://www.youtube.com/watch?v=r4mwkS2T9aI&index=4&list=PLQVvvaa0QuDfKTOs3Keq_kaG2P55YRn5v

how to import h5py on datalab?

Does anybody know how to install h5py on datalab? pip install h5py doesn't work. apt-get install python-h5py is working in the shell but it doesn't recognize the package in datalab notebook!
Thnaks
It is true that !pip install h5py wil allow you to install the library but unfortunately, even after a successful installation, the import will fail:
The issue is rooted on an ongoing python-future issue ("surrogateescape handler broken when encountering UnicodeEncodeError") that is experienced in datalab because the underlying OS uses an 'ANSI_X3.4-1968' file system encoding.
As a hacky workaround, you may remove line 60 from h5py's __init__.py by running the following command from within a notebook cell:
!sed -i.bak '/run_tests/d' /usr/local/lib/python2.7/dist-packages/h5py/__init__.py
Just make sure you run it using bash syntax: !pip install h5py in any notebook cell.

Install BeautifulSoup, mrjob, pattern, and seaborn on python 2.7 on Jupyter

I am learning how to use the new Jupyter. I want to install packages:BeautifulSoup, mrjob, pattern, and seaborn on python 2.7. I first tried to do so by running pip install BeautifulSoup mrjob pattern seaborn That all returns: SyntaxError: invalid syntax
I also tried from bs4 import BeautifulSoup, it did work for Beautifulsoup. But I still don't know how to install other packages.
Wondering anyone know why there was syntax error for using pip install? Is that because I haven't installed pip on python 2.7?
I was also able to install these packages from iphython notebook window by running
import pip
def install(package):
pip.main(['install', package])
install('BeautifulSoup4')
Have you tried installing one package at a time. This helps you find which installation command not working.
You can find Julia packages here.
The problem was I was running pip from inside Jupyter. However, Jupyter is a command line program. Thanks to Mwaskom, the solution is run it from a terminal using:
pip install BeautifulSoup mrjob pattern seaborn
You could try:
!pip install BeautifulSoup mrjob pattern seaborn