machine-learning

Creating a dataset from 2d matrices

Creating a dataset from 2d matrices Question: I have a series of 2d matrices like these two: matrix_1 = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) matrix_2 = np.array([[10, 11, 12], [13, 14, 15], [16, 17, 18]]) And Each matrix has a label like: labels = np.array([0, 1]) I want to make a …

Total answers: 2

Add a column from a Pandas dataframe to a new dataframe [Solved]

Add a column from a Pandas dataframe to a new dataframe [Solved] Question: So I have a graph which I use to get the optimal path using Dijkstra. The path is returned as a list of index. I want to extract that path to a csv, but adding the coordinates to be able to visualize …

Total answers: 1

Loss is Nan for SegFormer vision transformer trained on BDD10k

Loss is Nan for SegFormer vision transformer trained on BDD10k Question: I’m trying to implement a SegFormer pretrained with a mit-b0 model to perform semantic segmentation on images obtained from the bdd100k dataset. Specifically, semantic segmentation has masks for only a subset of the 100k images, being 10k with appropriate masks for segmentation where the …

Total answers: 4

AttributeError: 'CountVectorizer' object has no attribute 'get_feature_names'

AttributeError: 'CountVectorizer' object has no attribute 'get_feature_names' Question: The code was working before without showing any errors. It’s for a sentimental analysis machine learning project. The code is on logistic regression model for word count: c = CountVectorizer(stop_words = ‘english’) def text_fit(X, y, model,clf_model,coef_show=1): X_c = model.fit_transform(X) print(‘# features: {}’.format(X_c.shape[1])) X_train, X_test, y_train, y_test = …

Total answers: 1

python machine learning evaluation metric

python machine learning evaluation metric Question: I apply SVM(rbf) model on a pandas dataframe which has 8528 rows (8528 samples) and it classify 4 classes. train-test split is 50-50. at the end I get this results : precision recall f1-score support A 0.00 0.00 0.00 386 N 0.60 1.00 0.75 2563 O 0.00 0.00 0.00 …

Total answers: 1

NotFittedError (instance is not fitted yet) after invoked cross_validate

NotFittedError (instance is not fitted yet) after invoked cross_validate Question: This is my minimal reproducible example: x = np.array([ [1, 2], [3, 4], [5, 6], [6, 7] ]) y = [1, 0, 0, 1] model = GaussianNB() scores = cross_validate(model, x, y, cv=2, scoring=("accuracy")) model.predict([8,9]) What I intended to do is instantiating a Gaussian Naive …

Total answers: 1

Failure to install old versions of transformers in colab

Failure to install old versions of transformers in colab Question: I recently had a problem installing Transformer version 2.9.0 in colab. Asked By: hana || Source Answers: Colab has recently upgraded to Python 3.9. There is a temporary mechanism for users to run Python 3.8 runtime (Linux-5.10.147+-x86_64-with-glibc2.29 platform). This is available from the Command Palette …

Total answers: 2

How does TensorFlow perform algorithms so fast?

How does TensorFlow perform algorithms so fast? Question: I wanted to solve a linear regression problem by creating by myself the Adam optimization algorithm and performing it on my dataset. However, the problem is solved with an acceptable loss in around 100 epochs, while a tenth than my loss is computed by TensorFlow in just …

Total answers: 1

parameter b diverges when calculating gradient descent for linear regression

parameter b diverges when calculating gradient descent for linear regression Question: I have two arrays x and y: x = np.arange(-500, 500, 3) y = 2.5*x+5 I want to perform a linear regression by calculating gradient descent I implemented a gradient descent function, def gradient_descent(x, y, alpha, epochs): w = 0.0 b = 0.0 n …

Total answers: 1

High metrics value for linear regression model

High metrics value for linear regression model Question: I’m working with a dataset of cars, containing 10k rows and 5 columns: id mileage_per_year model_year price sold There are two negative values in the price column, I didn’t know if I should 0 it or just leave it, and so, I left it untouched. I don’t …

Total answers: 1