简体   繁体   中英

ModuleNotFoundError: No module named 'sklearn.family'

I am using Anaconda distribution. I try to work with Scikit-learn library for Machine Learning purposes. When I want to work with a model for training my data by below code it won't work at all.

import sklearn 
from sklearn.cross_validation import train_test_split
from sklearn.family import Model
from sklearn.linear_model import LinearRegression

The error I am receiving is:

ModuleNotFoundError: No module named 'sklearn.family'

What do you propose? Do you think it's because of my import issues?

There is no sklearn.family , what were you looking for?

import sklearn
"family" in sklearn.__all__
>>False

I propose to you that a LinearRegression forms a 'model' of the data as it is .fit ted. It is unclear what the separate Model class would do for you that you can't do without it.

from sklearn.[family] import [Model]

This is not an actual import statement. No module in sklearn is named family. The above line is an example on how to import the different models in sklearn. You need to replace the family in above line with the family in which a model belongs.

For example if you want to import LinearRegression or LogisticRegression, you can do this:

from sklearn.linear_model import LinearRegression
from sklearn.linear_model import LogisticRegression

Here linear_model is the "family" of the LinearRegression "model". Other examples could be:

from sklearn.tree import DecisionTreeClassifier
from sklearn.cluster import KMeans
from sklearn.feature_selection import SelectKBest

Here tree , cluster , feature_selection are the modules ( or "families") in which the specific classes ("models") are present.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM