I am just trying to use the MICE function from fancyimpute.
Simple line of code from fancyimpute import MICE gives an error cannot import name 'MICE'
I did try to consult https://github.com/iskandr/fancyimpute (i find it strange that MICE is nowhere to be found there but then people are implementing it https://medium.com/logicai/5-useful-python-packages-from-kaggles-kernels-you-didn-t-know-existed-part-2-4b35ba2d812)
as well as similiar problems on stack concerning MICE and importing problems but without of luck
The below steps worked for me on MAC OSX.
Use easy_install fancyimpute in your terminal instead of pip install fancyimpute
Unable to install fancyimpute for use in Jupyter
Use 'from fancyimpute import IterativeImputer as MICE' in your jupyter notebook. Looks like MICE is now called IterativeImputer.
https://github.com/iskandr/fancyimpute/issues/81
Use 'df1 = MICE().fit_transform(df)' on your dataframe. Looks like IterativeImputer does not have the function/method 'complete' anymore and the fit or fit_transform should be used with it instead.
from fancyimpute import IterativeImputer as MICE
MICE().fit_transform(df)
Related
This is my first project with Python, which I wrote online by Repl.it, (disclaimer: I have very little programming experience), it's supposed to turn on an LED when I receive a message, but this error appears when I run it (I am running it on Windows 10, 64 bits).
import imaplib
import getpass
import email
import time
import serial
import os
os.system('cls')
**ser = serial.Serial("COM3", 9600)**
ser.close()
ser.open()
It says that in the bolded line, 'serial' has no attribute 'Serial', what can I do in order to fix it?
Thanks in advance and sorry for any dumb mistake I may have committed.
Repl.it for whatever reason interprets import serial as the package 'serial', not 'pyserial', even if you manually specify pyserial as a requirement. This is just an idiosyncrasy with the repl.it virtual machine as far as I can tell. Run it on your local machine with pyserial installed and it should work fine.
I'm trying to do the Udacity mini project and I've got the latest version of the SKLearn library installed (20.2).
When I run:
from sklearn.decomposition import RandomizedPCA
I get the error:
ImportError: cannot import name 'RandomizedPCA' from 'sklearn.decomposition' (/Users/kintesh/Documents/udacity_ml/python3/venv/lib/python3.7/site-packages/sklearn/decomposition/__init__.py)
I actually even upgraded the version using:
pip3 install -U scikit-learn
Which upgraded from 0.20.0 to 0.20.2, which also uninstalled and reinstalled... so I'm not sure why it can't initialise sklearn.decomposition.
Are there any solutions here that might not result in completely uninstalling python3 from my machine?! Would ideally like to avoid that.
Any help would be thoroughly appreciated!
Edit:
I'm doing some digging and trying to fix this, and it appears as though the __init__.py file in the decomposition library on the SKLearn GitHub doesn't reference RandomizedPCA... has it been removed or something?
Link to the GitHub page
As it turns out, RandomizePCA() was depreciated in an older version of SKLearn and is simply a parameter in PCA().
You can fix this by changing the import statement to:
from sklearn.decomposition import PCA as RandomizedPCA
... and then your classifier looks like this:
pca = RandomizedPCA(n_components=n_components, svd_solver='randomized', whiten=True).fit(X_train)
However, if you're here because you're doing the Udacity Machine Learning course on Eigenfaces.py, you'll notice that the PIL library is also deprecated.
Unfortunately I don't have a solution for that one, but here's the GitHub issue page, and here's a kind hearted soul that used a Jupyter Notebook to solve their mini-project back when these repositories worked.
I hope this helps, and gives enough information for the next person to get into Machine Learning. If I get some time I might take a crack at recoding eigenfaces.py for SKLearn 0.20.2, but for now I'm just going to crack on with the rest of this course.
In addition to what #Aaraeus said, the PIL library has been forked to Pillow.
You can fix the PIL import error using
pip3 install pillow
I wanted to use the expit-function from scipy in VSCode. I imported scipy.special, but everytime I want to use expit I get the following error:
"[pylint] E1101:Module 'scipy.special' has no 'expit' member"
Other scipy.special functions like scipy.special.airy work, however.
I'm using python 3.6.5 and scipy 1.1.0. Reinstalling scipy did not help.
Any help would be greatly appreciated.
Edit:
I just found this answer, recommending to whitelist numpy for linting, the same should work for scipy.
I am having a similar issue with the function scipy.special.j1 right now.
Pylint complains saying
Module 'scipy.special' has no 'j1' member; maybe 'jv'?
The weird thing is that even though pylint apparently can't find the function, the following code works:
>>> from scipy.special import j1
>>> print(j1(2))
0.5767248077568734
I think this might be the exact same problem you have. Did you solve it yet? I'd love to get a solution or workaround for this.
Full disclosure: I am a total beginner when it comes to Python in particular and programming in general. So please bear with me.
Today I tried for the first time to play around some datasets on my own, outside of the sandboxed environment of online courses.
I downloaded both Anaconda and Rodeo (which somehow I feel more akin to than, say, Spyder or Jupyter).
Wrote down this code. It works in Spyder.
import numpy as np
import pandas as pd
myexcel="C:/Users/myname/folder/subfolder/file.xlsx"
xl=pd.ExcelFile(myexcel)
mydf=xl.parse(0)
print(mydf.head())
However, if I try to run the same code in Rodeo I get the following error message. Here, I am showing just a part.
----> 4 xl=pd.ExcelFile(myexcel)
ImportError: No module named 'xlrd'
I am getting that in Rodeo the script fail because it is missing the xlrd package, which admittedly after checking with help("modules") is not there. But I don't fully get the problem: if xlrd was quintessential to the correct execution of this code, then why doesn't it fail in Spyder?
I would like to work with excell sheets (.xls likely per .ods conversion) via python while maintaining all of the sheet's original content. Unlike xlutils (http://www.python-excel.org/) the iac-protocol (http://pythonhosted.org/iac-protocol/index.html) seems to me to be more fit/elegant tool to maintain sheet's style,formulas,dropboxes etc. One of the steps to launch iac's server or interpreter (iacs/iaci) is to initialize the interface which consists among others of this command:
import iac.app.libreoffice.calc as localc
While import iac.app.libreoffice works fine
moving to calc level
import iac.app.libreoffice.calc
throws following error
import iac.app.libreoffice.calc
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python3.4/site-packages/iac/app/libreoffice/calc.py", line 11, in
from uno import getComponentContext
ImportError: cannot import name 'getComponentContext'
From what I've learned so far on this forum it might be linked to method name duplicity between two modules. This is where I am stuck. How do I learn which other module has such name of a method and how to fix it? Both iac-protocol and unotools are modules downloaded via pip3. I did not created method of such name in any script.
Thank you in advance for any advice!
Python3.4 on Scientific Linux release 7.3 (Nitrogen) LibreOffice 5.0.6.2 00(Build:2)
Some questions to narrow down the problem:
Did you start libreoffice listening on a socket first?
Did you import anything else before import iac.app.libreoffice.calc?
What happens when you start python in a terminal and enter from uno import getComponentContext?
I installed iac-protocol on Linux Mint and was able to import iac.app.libreoffice.calc and then use it. The installation process was complex, so I wouldn't be surprised if there is some problem with how your packages were installed, or possibly it does not work on RHEL-based systems. For one thing, it required me to install gnumeric.
The Calc "Hello World" code that worked for me is as follows.
libreoffice "--accept=socket,host=localhost,port=18100;urp;StarOffice.ServiceManager" --norestore --nofirststartwizard --nologo --calc &
python3
>>> import iac.app.libreoffice.calc as localc
>>> doc = localc.Interface.current_document()
>>> sheet = doc.getSheets().getByIndex(0)
>>> cell = sheet.getCellByPosition(0,0)
>>> cell.setString("Hello, World!")
One more thought: Have you considered using straight PyUNO starting from import uno instead of a wrapper library? That would avoid dependency on some of the extra libraries which may be causing the problem. Also there is better documentation for straight PyUNO.