Python Forum
Which app do I import to fix this error?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Which app do I import to fix this error?
#1
In the following snippet of code, I made a replacement:

import pandas as pd
import numpy as np
from sklearn.linear_model import LinearRegression
from sklearn.cross_validation import train_test_split
from sklearn.preprocessing import Imputer
import matplotlib.pyplot as plt

%matplotlib inline
The new code is

import pandas as pd
import numpy as np
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import Imputer
import matplotlib.pyplot as plt

%matplotlib inline
I replaced cross_validation in line 4 with model selection. It worked.



Now I get the following error when I run the code.









Error:
ImportError Traceback (most recent call last) <ipython-input-11-8cc04663b4cc> in <module> 3 from sklearn.linear_model import LinearRegression 4 from sklearn.model_selection import train_test_split ----> 5 from sklearn.preprocessing import Imputer 6 import matplotlib.pyplot as plt 7 ImportError: cannot import name 'Imputer' from 'sklearn.preprocessing' (/opt/conda/lib/python3.7/site-packages/sklearn/preprocessing/__init__.py)
Now I am confused since when I ran pip list and conda list I got that

sklearn 0.0

see attached screenshot. What import app covers this function?

It seems that I have sklearn 0.0 installed. That make no sense.

HowdoI correct this error. Is this handled by scikit-learn?

I am not sure what to do.

Respectfully,

ErnestTBass
Reply


Messages In This Thread
Which app do I import to fix this error? - by ErnestTBass - Apr-25-2020, 07:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Error on import: SyntaxError: source code string cannot contain null bytes kirkwilliams2049 7 6,845 Aug-03-2023, 06:00 PM
Last Post: Gribouillis
  import module error tantony 5 3,460 Dec-15-2022, 01:55 PM
Last Post: Lauraburmrs
  Cryptic Error with import statement Led_Zeppelin 2 2,558 Jan-11-2022, 01:13 PM
Last Post: Led_Zeppelin
  Install any library via pip get an error cannot import name 'SCHEME_KEYS' from 'pip. Anldra12 2 10,671 Jan-04-2022, 01:05 PM
Last Post: Anldra12
  import module with syntax error Skaperen 7 5,324 Jun-22-2021, 10:38 AM
Last Post: Skaperen
  Import Error Christian 3 3,211 Apr-17-2021, 11:27 PM
Last Post: bowlofred
  Folium import error kashif_flavio 2 3,672 Dec-07-2020, 08:58 AM
Last Post: bowlofred
  Import error Beingcode 0 2,512 Nov-20-2020, 02:57 AM
Last Post: Beingcode
Smile Import error with local file colt 1 1,950 Nov-08-2020, 07:56 AM
Last Post: Gribouillis
  switch from version 3.5.3 to 3.8.6 get import error python001 9 4,026 Oct-31-2020, 03:02 PM
Last Post: python001

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020