Skip to content
Advertisement

Tag: scikit-learn

Suppress scientific notation in sklearn.metrics.plot_confusion_matrix

I was trying to plot a confusion matrix nicely, so I followed scikit-learn’s newer version 0.22’s in built plot confusion matrix function. However, one value of my confusion matrix value is 153, but it appears as 1.5e+02 in the confusion matrix plot: Following the scikit-learn’s documentation, I spotted this parameter called values_format, but I do not know how to manipulate

How to split parallel corpora while keeping alignment?

I have two text files containing parallel text in two languages (potentially millions of lines). I am trying to generate random train/validate/test files from that single file, as train_test_split does in sklearn. However when I try to import it into pandas using read_csv I get errors from many of the lines because of erroneous data in there and it would

Sklearn PCA explained variance and explained variance ratio difference

I’m trying to get the variances from the eigen vectors. What is the difference between explained_variance_ratio_ and explained_variance_ in PCA? Answer The percentage of the explained variance is: The variance i.e. the eigenvalues of the covariance matrix is: Formula: explained_variance_ratio_ = explained_variance_ / np.sum(explained_variance_) Example: Also based on the above formula: 7.93954312 / (7.93954312+ 0.06045688) = 0.99244289 From the documentation:

Advertisement