ModuleNotFoundError:没有名为"sklearn.family"的模块 [英] ModuleNotFoundError: No module named 'sklearn.family'

查看:414
本文介绍了ModuleNotFoundError:没有名为"sklearn.family"的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Anaconda发行版.我尝试使用Scikit学习库进行机器学习.当我想使用通过以下代码训练我的数据的模型时,它将根本无法工作.

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

我收到的错误是:

ModuleNotFoundError: No module named 'sklearn.family'

您有什么建议? 您是否认为是因为我的进口问题?

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

推荐答案

from sklearn.[family] import [Model]

这不是实际的导入语句. sklearn中没有模块被命名为family.上一行是有关如何在sklearn中导入不同模型的示例.您需要用模型所属的族替换上一行中的family.

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.

例如,如果要导入LinearRegression或LogisticRegression,则可以执行以下操作:

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

此处linear_modelLinearRegression模型"的家族".其他示例可能是:

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

treeclusterfeature_selection是其中存在特定类(模型")的模块(或家族").

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

这篇关于ModuleNotFoundError:没有名为"sklearn.family"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆