Assume that I have 3 different classes which follow a Gaussian distribution generated in the following way : x1 = np.random.random((100,7)) x2 = np.random.random((200,7)) x3 = np.random.random((300,7)) mean_x1 = np.mean(x1, axis = 0) mean_x2 = np.mean(x2, axis = 0) mean_x3 = np.mean(x3, axis = 0) cov_x1 = np.cov(x1.T) cov_x2 = np.cov(x2.T) cov_x3 = np.cov(x3.T) Class_1 ..

#### Category : knn

I am doing a project on multi-class text classification and could do with some advice. I have a dataset of reviews which are classified into 7 product categories. Firstly, I create a term document matrix using TF-IDF (tfidfvectorizer from sklearn). This generates a matrix of n x m where n in the number of reviews ..

I am using gridsearch to find the best parameters and I want to save them and use them for the testing. When saving the best ^parameters and giving it to the algo, I encountered an error : BEST PARAMETERS: {‘metric’: ‘euclidean’, ‘n_neighbors’: 5, ‘weights’: ‘uniform’} BEST SCORE: 0.631578947368421 —Filename in processed corpus_ix_test_FMC_ small Traceback (most ..

I have been trying to distinguish between words by extracting MFCCs from audios (with the librosa library), then applying Dynamic Time Warping to classify between the audios using kNN. For example, I am trying to recognize between the words "cat" and "anything". My problem is that I can’t find similarities between two different pronunciations of ..

In most cases, linalg.eigs has similar results with results from eigs in MATLAB. However in some cases, the two results are quite different. I offered two dates here: https://drive.google.com/file/d/1xBWCu_uUwEsAeF85uZAb70Bf4A2SOpM2/view?usp=sharing https://drive.google.com/file/d/1z3QFHiDfX8Qz099yTSJdGvwot9uMW8K4/view?usp=sharing (you can use it to create a KNN graph then calculate the generalized eigenvalue) when K =10, the biggest generalized eigenvalue from linalg.eigs would be ..

i am working on KNN in python. Anyone who can help me with this. MY CODE import numpy as np import pandas as pd from sklearn.model_selection import train_test_split import matplotlib.pyplot as plt from sklearn.preprocessing import StandardScaler from sklearn.neighbors import KNeighborsClassifier from sklearn.metrics import confusion_matrix import pickle import glob from sklearn.model_selection import GridSearchCV from sklearn.multioutput import ..

I read so much information from https://pythonawesome.com/python-implementation-of-feature-extraction-with-k-nearest-neighbor/ But how to use this , after extract feature with knn i want to use random forest on output of knn…. Source: Python..

I can run a KNN classifier with the default classifier (L2 – Euclidean distance): def L2(trainx, trainy, testx): from sklearn.neighbors import KNeighborsClassifier # Create KNN Classifier knn = KNeighborsClassifier(n_neighbors=1) # Train the model using the training sets knn.fit(trainx, trainy) # Predict the response for test dataset y_pred = knn.predict(testx) return y_pred However, I want to ..

I have a question regarding the cross validation used in ML problems.If we apply 5-folds cross validation for a dataset say for example 2 times, one in Monday and one in Friday, just two separate times. Does the elements that exist in a particular fold in Monday are the same elements that would exist in ..

Hello I am at the first steps of machine learning and this is my first tutorial/small project that i am trying to do. I want to use Nearest Neighbor method in the Fashion MNIST Dataset but i am having an error. I know that maybe my question is a bit silly but its the first ..

## Recent Comments