我与Scikit-学习的最近的邻居/半径分类与一个预先计算的度量。这意味着,我向分类器的拟合方法传递成对距离的n_samples_train x n_samples_train矩阵。
现在我想知道为什么要这样做。用knn学习只意味着“存储样本”,但是距离的计算应该只在泛化过程中进行(在这一步骤中,我当然要计算我的训练样本和测试样本之间的距离矩阵,所以是一个大小为n_samples_train x n_samples_test的矩阵)。
例如,在支持向量机的情况下,我将一个预先计算的矩阵( Gramian,一个相似矩阵)传递给smv.v.VC-对象的拟合方法。然后进行优化处理,找出支持向量等。在
在jupyterlab中使用scikit-学习版本0.22.1。我不能提供一个最小的可重复的例子,然而,希望这是好的,因为这是一个概念性的问题。
我在建立分类模型。我在X中有我的特征,在y中有我的目标变量。我拟合一个logistic回归模型并计算预测:
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)
from sklearn.linear_model im
在csv文件上的代码i中,该文件只有一列。里面的数据并不那么重要,只有正常的数字。
# Pandas - data handling
import pandas as pd
# Numpy for mathematical operations
import numpy as np
import pandas as pd
# Scikit learn for the DBSCAN algorithm
from sklearn.cluster import KMeans
# Matplotlib - plots
import matplotlib.pyplot as plt
import
我正在尝试使用scikit-学习DecisionTree和Pandas对文本进行分类:首先,我构建了一个如下所示的Dataframe:
cat1 cat2 corpus title
0 0 1 Test Test Test erster titel
1 1 0 Test Super Super zweiter titel
2 0 1 Tes