我正在做我的人脸检测和识别工作,我想实时检测人脸,
但是到了训练的时候,要花很长的时间来训练
数据有没有可能减少训练的时间数据谁都能帮上忙
我把这个问题解决了
“”“
def train(train_dir, model_save_path=None, n_neighbors=None, knn_algo='ball_tree', verbose=False):
X = []
y = []
# Loop through each person in the training set
for class_dir in tqdm(os.l
我使用permutatation_importance来查找哪些值是最重要的
from sklearn.neighbors import KNeighborsClassifier
import numpy as np
from sklearn.inspection import permutation_importance
columns=['progresion', 'tipo']
X = df_cat.drop(columns, axis = 1)
y = df_cat['progresion']
X_train, X_test, y
由于kNN在内存级别处理训练和预测,并且不需要显式的训练过程,因此当拟合knn模型时到底会发生什么?我认为这一步与训练模型有关。谢谢。 如果我跳过拟合步骤,这是我将得到的错误。 NotFittedError: This KNeighborsClassifier instance is not fitted yet. Call 'fit' with appropriate arguments before using this estimator. 示例代码: from sklearn.neighbors import KNeighborsClassifier
from skl
我刚刚用R写了一个knn模型。然而,我不知道如何使用输出来预测新数据。
# split into train (treino) and test (teste)
treino_index <- sample(seq_len(nrow(iris)), size = round(0.75*nrow(iris)))
treino <- iris[treino_index, ]
teste <- iris[-treino_index, ]
# take a look at the sample
head(treino)
head(teste)
# save specie from
我正在用python构建自己的1-NN分类器,因为我需要在某些操作中使用最大速度来测试它,因为我想在遗传算法中使用它,每一毫秒对速度都很重要。
我正在尝试用numpy在我的KNN类中实现一个leave one out测试,但我在这个测试中获得了大约50%的成功。我试了一下scikit learn knn,同样去掉了一个,返回了大约97%的成功。
这是我的KNN类:
class KNN(object):
"""Documentation for KNK-clasifier"""
def __init__(self):
super(KNN,
我到处找遍了,找不到一个直接的解决办法。我有一组来自图像及其元素的元数据(name, heigh, width, position{top, right})。我想根据图像中几个项目的相对位置来创建图像类别。
示例:
img1 has
logo in top x1, right y1, and is height h1 and width w1
text in top x2, right y2, and is height h2 and width w2
from img1 to n
我考虑运行KNN分类器来查找与其他图像更相似的图像,但我在思考如何组织数据时遇到了困难。
我应该把他们按
我建立了一个knn分类模型。不幸的是,我的模型有超过80%的准确性,我想得到一个更好的结果。我能要些小费吗?也许我用了太多的预测器?
我的数据=
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import MinMaxScaler
from sklearn.neighbors import KNeighborsClassifier
from sklearn.metrics import confusion_matrix, accuracy_
我试图在MNIST示例数据集上实现KNearestNeighbors的使用。
在尝试使用cross_val_predict时,不管我离开它多长时间,脚本都会继续运行。
有什么东西我遗漏了/做错了吗?
如有任何反馈,将不胜感激。
from sklearn.datasets import fetch_openml
import numpy as np
mnist = fetch_openml('mnist_784', version=1) #Imports the dataset into the notebook
X, y = mnist["data"], mn
练习KNN和我只是有一个关于预处理的查询,因为我知道KNN不适用于分类特性。
我已经读到了一种热编码(虚拟变量),如果我应用到下面的数据集中,它实际上将是我的列数量的两倍。
然而,这是否需要。在整个数据集中,简单地将y替换为0,将n替换为1,会有效吗?
target Q1 Q2 Q3
Wealthy y y y
Wealthy n y y
Poor y y y
Poor n y n
我有一个包含字符串和浮动数据的数据集。numPy尝试将所有内容转换为浮点数,给出错误“不能将字符串转换为浮点数”。
import numpy as np
import scipy
import matplotlib.pyplot as plt
import pandas as pd
from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
pd.set_option('displ