
[英]Extracting feature importances along with column names from sklearn pipeline
我有一个包含两个步骤的 sklearn 管道(一个带有 One hot 编码器的 columntransformer 预处理器和一个 randomforestregressor 估计器)。 我想在一次热编码后获取编码列的特征名称。 我的管道看起来像这样。 categorical_preproces ...
[英]Extracting feature importances along with column names from sklearn pipeline
我有一个包含两个步骤的 sklearn 管道(一个带有 One hot 编码器的 columntransformer 预处理器和一个 randomforestregressor 估计器)。 我想在一次热编码后获取编码列的特征名称。 我的管道看起来像这样。 categorical_preproces ...
[英]How to specify the memory directory for Agglomerative clustering using sklearn
我正在尝试使用 sklearn 的AgglomerativeClustering优化用于计算同一数据集上具有不同数量集群的多个结果的计算时间。 如https://stackoverflow.com/questions/36490241/sklearn-agglomerative-clustering ...
[英]Error using categorical data in Pipeline with OneHotEncoder
我想建立一个管道来预测“SibSp_category”、“Parch_category”、“Embarked”这三个特征的“生存”。 在预处理步骤中,我使用 (1) OrdinalEncoder 将字符串转换为整数,这应该是 (2) SimpleImputer 使用最频繁的值估算的。 (3) 从估 ...
[英]ModuleNotFoundError: No module named 'sklearn.decomposition.pca'
我使用的 model 是使用 scikit-learn==0.18 实现的,我尝试安装它但失败了,所以我安装了 scikit-learn==1.2.1。 但是,这个错误保持对我来说出现了,我不知道如何解决它。 此外,model 使用了 cPickle,它已被删除,所以我将其修复为“import pi ...
[英]MinmaxScaler: Normalise a 4D array of input
我有一个 4D 输入数组,我想使用MinMaxScaler进行归一化。 为简单起见,我给出了以下数组的示例:A = np.array([ [[[0, 1, 2, 3], [3, 0, 1, 2], [2, 3, 0, 1 ...
[英]Validation but not cross validation in Python sklearn Lasso
我需要使用sklearn 。 我得到了一对专门设计的训练和验证数据集。 目标是让算法自动生成一个alpha序列(L1 惩罚强度),并且对于每个alpha ,用训练数据拟合 model,然后在验证数据上评估 model。 最后,select model 在验证数据上表现最好。 如何以最有效的方式实现上 ...
[英]How to show confusion matrix with sklearn if all classes aren't included in dataset?
我正在尝试使用 sklearn 对 plot 混淆矩阵进行 model 和我在 pytorch 几何中创建的数据集。 我的真实值和预测值如下所示: 但是,我正在测试的数据集不包含我的 model 可以预测的所有标签。 因此,例如,如果我有 30 个类,我可能不会在预测标签或真实标签中看到 clas ...
[英]ImportError: cannot import name 'int' from 'numpy'
我正在尝试通过编写类似from sklearn.preprocessing import MinMaxScaler的代码来导入sklearn库,但它一直显示相同的错误。 我尝试卸载并重新安装但没有任何变化。 命令提示符也给出同样的错误。 最近我安装了一些 python 库,但这并没有影响我的环境。 ...
[英]sklearn.metrics r2_score negative
我无法理解r2_score中的 r2_score,它似乎返回无意义的值。 我遵循了 stackoverflow 提出的所有“类似问题”(其中一些避免了错误的参数序列,这就是为什么我在下面包含两个命令),但我仍然迷路了: 回报 绘制 Excel 中的数据和预测值表明linear_model返回值有意义 ...
[英]Force centroid initialization to array in k-means with sklearn
我正在从事一个异常检测项目,为此我有包含图像特征的嵌入(对抗性自动编码器模型)。 现在我想用 PCA 和 k-means 解释这些嵌入。 我需要在图像中找到特定的特征嵌入,使我能够区分两个图像数据集。 对于scikit-learn ,k-means 非常简单,但质心初始化几乎总是随机完成的。 我已经 ...
[英]Any idea how to deal with mglearn import error?
我是一名新的数据科学训练营学生。 最近买了一本书《Introduction to Machine Learning with Pyhton》。 然而,这本书大量使用了 mglearn 库。 当我想导入库时出现错误。 (您可以从下面看到。)我无法演示书中提供的示例。 有什么办法可以解决这个问题吗? ...
[英]Rescale data with rules
我想用一定的规则重新缩放数据。 我的数据范围为 -finite 到 +finite。 我想使用以下规则重新缩放: 对于 -finite 到 0:重新调整为 -1 到 0 对于 0 到有限:重新调整为 0 到 1 现在,我的数据显示错误的重新缩放... 回报 请注意正分数 ("3") 是如何按比例调整 ...
[英]Polynomial Features Error: X has 10 features, but PolynomialFeatures is expecting 9 features as input
今天我正在使用 sklearn 中的 PolinomialFeatures 对 dataframe 进行建模,但我一直遇到这个错误: ValueError: X has 10 features, but PolynomialFeatures is expecting 9 features as in ...
[英]GridSearchCV instance is not fitted yet. Call 'fit' with appropriate arguments before using this estimator
我正在 coursera 上一门课程,需要提交最后的作业才能通过。 但是,我无法完成它。 我在代码的第 16 行遇到了NotFittedError 。 有人可以帮我找出这段代码有什么问题吗? 我得到的错误是( https://i.stack.imgur.com/jEInr.png ) ...
[英]Why is cross_val_score not producing consistent results?
当这段代码执行时,结果是不一致的。 随机性从何而来? ...
[英]Access the `b` parametr in the SVC object of scikit learn
根据SVC 的 scikit learn 数学 model有一个参数b (模型的常数值): 然而,在SVC class 文档中,我看不到如何访问它的值。 有没有办法访问它? 真的用了吗? 请问是需要手动给数据加一列1还是model内置了。 ...
[英]I got an error when using linear_model.LogisticRegression
使用 linear_model.LogisticRegression 时出现错误。 与X和y的数据类型有关吗? 我正在使用 Python 3.8 64 位和 SkLearn 版本:1.2.0。 在此处输入图像描述 ...
[英]scikit-learn RandomForestClassifier list all variables of an estimator tree?
我训练一个RandomForestClassifier作为 其中X和y是一些特征向量和标签。 完成拟合后,我可以列出森林中每个估计器生长的所有树木的深度,如下所示: 现在我想找出所有其他公共变量(除了max_depth )一个estimator stores 中的tree_ 。 所以我尝试了: 但 ...
[英]Why is the ROC_AUC from cross_val_score so much higher than manually using a StratfiedKFold with metrics.roc_auc_score for an XGB classifier?
方法 1 - StratifiedKFold 交叉验证 方法 2 CrossValScore 我可能误解了 cross_val_score 的功能,但根据我的理解,它创建了 K 倍的训练和测试数据。 然后它在 K-1 折上训练 model,并在 1 折上重复测试。 它的准确度应该与使用 Strat ...