rep_features_train = imputer.transform (features_train)change into Data Frame
rep_features_train_df = pd.DataFrame (rep_features_train,
columns = features_train.columns)
display (rep_features_train_df.head ())
When I execute the above, I get the following error.
ImportError Traceback (most recent call last)
1 # fill median values to NaN with Imputer
---->2 from sklearn.preprocessing import Imputer
3 imputer = Imputer (strategy ='median')
4 imputer.fit (features_scaling [numerical])
ImportError: cannot import name'Imputer' from'sklearn.preprocessing' (/Users/opt/anaconda3/lib/python3.8/site-packages/sklearn/preprocessing/init.py)
Can you tell me what's wrong and what to do?
Answer # 1
I think the above article will be helpful.
It seems that Imputer is not supported when the version of scikit-learn which is the environment of the above article is 0.22.2.
Answer # 2
I think that you are referring to some material, but the version of sklearn of the environment assumed in that material is probably old.
I found that 0.19.2 has Imputer in sklearn.preprocessing, but later versions don't.
The module versions must match for the same source to work. The same thing may happen with other modules, so it's safe to get information from the document/author who is visa.
If the module etc. cannot be replaced from the current environment, the function with the same function has moved to another place, so there is no choice but to correct it by referring to the API document.
Answer # 3
ImportError: cannot import name'Imputer' from'sklearn.preprocessingIs very important, so if you can decipher this content yourself, you will be able to solve the problem smoothly.
This time, I will write a sample of the decoding result for reference.
ImputerThe one named
sklearn.preprocessingIt is written that it cannot be imported because it is not included in.
sklearn.preprocessingI don't know because I haven't used
ImputerIt seems that you need to check if the name is correct and if scikit_learn? Is installed correctly.
- about errors when drawing graphs in python
- python - about errors when using the camera module of raspberry pie
- i have a question about runtime errors and exception handling in python
- python - what i don't understand about yolo9000 (v2)
- python - about hamiltonian neural networks
- python - about write loop to csv
- about python argument and data definition
- python 3x - about downloading anaconda
- python - about the optimum angle of rotation matrix
- python - about downloading youtube videos by youtube-dl
- about processing to exclude the character string group specified from list in python
- i have a question about basic python problems
- about batch change of file name using python
- python, about the fire spread step of forest fire simulation
- about the implementation of combinations in python
- please tell me about the role of python tag = "mychr"
- about python def issues
- about the operation of python's speedtest module (library)
- pythonista - [python] questions about line splitting in dataframe
- How to split 2D array in Python?
- python : How to translate the NUMPY INT64 values in JSON?
- I do not know how to deal with ValueError: Length Mismatch at Python.
- python : How in Pandas based on DateTimeIndex one array get values from another array focusing on his DateTimeIndex
- In Python TFIDF TWIDF does not accept the to_NumpY () method
- python : Pandas: Delete empty value in the Data Prase
- python : The np.hstack () method "plays" with the dimension of frames on rows -instead of 88 lines at the output 84
- pandas : I am trying to convert categorical variables using oneHotencoder, but gives an error
- Python Pandas Opening XLS File
- python : How to pass the average value of each column in the DataFrame with the replacement of NAN?