Skip to main content

All Questions

Filter by
Sorted by
Tagged with
3 votes
1 answer
217 views

PartialDependenceDisplay.from_estimator plots having lines with 0 values

Need to evaluate the two way interaction between two variables after regressor model. Used PartialDependenceDisplay.from_estimator to plot but the contour lines inside the plot all have value 0.Not ...
new world's user avatar
  • 107
0 votes
1 answer
58 views

Why does plotting errors vs actual via PredictionErrorDisplay result in a value error?

I have trained a random forest regression model using sklearn, and used it to make some predictions on a test dataset. Naturally there are errors where the values predicted by the model are not the ...
SRJCoding's user avatar
  • 473
0 votes
1 answer
142 views

plotting only points that are stable from a time series and perform linear regression

I have two questions that I put in one help request. so I hope it will not make this overcrowded. I spend quite some time figuring this out but not successful so far. I am trying to plot only points ...
K S's user avatar
  • 19
0 votes
0 answers
115 views

Visualizing Sklearn Logistic Regression on Multiclass Text Data

I'm performing logistic regression on the 20 news group dataset, which is designed for multiclass classification. I've successfully built the model but am now looking to visualize the results for my ...
Abby's user avatar
  • 15
0 votes
0 answers
44 views

Scatter Plot: Value Error, Unable to Coerce to Series

I am currently working on a residual plot visualization for my perceptron. As the title states I am running into an error when calling pyplot.scatter. It seems as though the function wants n_samples ...
Cyrxs's user avatar
  • 41
0 votes
0 answers
42 views

Cross-Validation Visualization Mulfunctions

I am inspired by the scikit-learn's cross-validation visuailization guide to visuailize the distribution of training and testing indicies in each CV split: cmap_data = plt.cm.Paired cmap_cv = plt.cm....
Kevin Li's user avatar
  • 532
0 votes
0 answers
118 views

how to plot multiple linear regression features vs predicted results on individual graphs

I was working on a TV advertisement dataset with 3 features (TV, radio, newspaper) and 1 dependent variable (sales). By using multiple linear regression, I estimated sales and compared them with ...
R47's user avatar
  • 21
1 vote
0 answers
76 views

My Principal components plotted using sklearn seems a bit rotated by some degrees. What have I missed? [duplicate]

import numpy as np import seaborn as sns import matplotlib.pyplot as plt from sklearn.decomposition import PCA # generate synthetic data with a linear relationship np.random.seed(0) mean = [0, 0] # ...
Neil Panchal's user avatar
0 votes
2 answers
679 views

How can I achieve a scikit-learn confusion matrix without extra columns?

I have a classifier that does binary classification. For training I take the data I trust. For testing, I take the data I trust and also some not so good data (real world data). How do I get a ...
fepduk's user avatar
  • 21
0 votes
1 answer
856 views

How to plot accuracy, precision and recall in confusion matrix plot using seaborn

I want to plot precision, and recall and accuracy of my prediction in confusion matrix using seaborn. The figure i want to achieve is. This image: . So I tried to fit my model with data, and got the ...
Rachit Sharma's user avatar
0 votes
0 answers
153 views

How do I set a xlim and ylim on PartialDependenceDisplay?

def partial_2d(model, data, features, xlim=None, ylim=None): print('Computing partial dependence plots...') tic = time() display = PartialDependenceDisplay.from_estimator(model, data, ...
Kytothetop's user avatar
0 votes
0 answers
90 views

panoramic x-ray normalization in python

I have this screenshot of an x-ray image in a jupyter notebook: and after applying normalization in this code from sklearn.preprocessing import StandardScaler import numpy as np X_train = np.reshape(...
Farah's user avatar
  • 1
0 votes
1 answer
544 views

Problems plotting loss vs epochs for train and test data in MLPClassifier using sklean

I saw this code in the community to plot loss vs epochs using MLPClassifier. I think there is something is wrong in the code because the validation curve looks odd. Could someone give me an advice on ...
user14929029's user avatar
0 votes
1 answer
256 views

Plotting a classifier learning curve

For a school project I've developed an AdaBoost classifier as follows (I'm using decision stumps as weak learners ): class AdaBoost: def __init__(self, boosting_rounds): self.boosting_rounds = ...
Gio Formichella's user avatar
0 votes
1 answer
76 views

Linear Decision Boundary in Logistic Regression

Which line(s) of code are responsible for the additional linear decision boundaries, 15%, 30%, etc., in the following code? import matplotlib.pyplot as plt import numpy as np from sklearn import ...
John Conor's user avatar
1 vote
1 answer
196 views

Missing markers in the plot legends of scikit-learn examples [duplicate]

I have been looking at the Scikit library documentation and example codes. Many of the plots does not have markers in the legends, leaving us to guess everything. Example code : import matplotlib....
Mainland's user avatar
  • 4,544
0 votes
1 answer
41 views

Set model_pred_proba while using sklearn.metrics..roc_curve to evaluate anormaly detection model

I want to evaluate model performance of anormaly detection using sklearn.metrics.roc_curve Since class 0 is anormaly data, I set pos_label parameters to 0. But when draw roc_curve, it is strange. ...
Junghw Park's user avatar
1 vote
1 answer
90 views

ValueError: x and y must have same first dimension, but have shapes (3,) and (1,)

I am a rookie in python and need help Here is my code import matplotlib.pyplot as plt import mpl_toolkits.mplot3d import pandas as pd import numpy as np from sklearn.datasets import load_iris from ...
rookie programmer's user avatar
1 vote
0 answers
296 views

How can I generate a contour plot with polar coordinates from scikitlearn's kernel density estimate function?

So I have a dataset from a molecular dynamics simulation in which I measured both tilt and rotation of a protein. I am using SciKitLearn's kernel Density estimate function to calculate the gaussian ...
hutchcha's user avatar
0 votes
1 answer
272 views

Plot many PartialDependencePlot lines in one plot for multiclass classification

Kind of a broad question but I need to plot many PartialDependencePlot lines in the same plot - one line for each target in the multiclass classification, for each variable in the dataset. So for ...
amestrian's user avatar
  • 582
1 vote
1 answer
4k views

How to solve Error `Axes' object has no attribute 'is_first_col'?

from sklearn.model_selection import train_test_split, cross_val_score, StratifiedKFold from matplotlib import pyplot from sklearn.preprocessing import StandardScaler import pandas as pd import ...
Bella Lee's user avatar
  • 117
0 votes
0 answers
126 views

Multiple confusion matrices with plot_confusion_matrix

I want plot three consufusion_matrix in the same windows. I used plot_confusion_matrix becouse i have a np.array to indicate the data of consusion matrix (I took some confusion matrix and i have do ...
Renlo's user avatar
  • 1
0 votes
0 answers
178 views

How to make a legend in the scipy dendrogram

I want to make a legend for a scipy dendrogram. I have tried to find hexadecimal color in the dendrogram function, but I didn't find anything. How to do this? This is the code: import pandas as pd ...
rerere L.'s user avatar
0 votes
0 answers
68 views

How to make an agglomerative clustering plot in sci-kit learn with an input list of arrays?

I try the following code, where X is an input list of array: colors = ["#f7bd01", "#377eb8", "#f781bf"] model = AgglomerativeClustering(n_clusters=3, linkage="...
Adagio's user avatar
  • 3
0 votes
1 answer
146 views

How to plot 3d scatter with QDA decision boundary?

With generated data, I am trying to plot 3d decision boundary of QDA in 3d spaces. I used sklearn library to calculate QDA, but couldn't plot 3d QDA decision boundary. Here is my code: import numpy as ...
Sunwoo Kwak's user avatar
0 votes
1 answer
92 views

How to create separate sub-plots

These are the outputs I am getting for my PDP: [output 1][1] How can I modify the code to create a separate PDP for each feature (6 separate plots, not combined in 1 plot)? Code Source https://stats....
user20155022's user avatar
0 votes
1 answer
84 views

Why does the y-intercept from the model not match the graph?

This code generates a graph of the regression line but the y-intercept taken from the LR model does not match the y-intercept on the graph. What am I missing? The script prints the y-intercept, taken ...
nicomp's user avatar
  • 4,629
1 vote
1 answer
277 views

Confusion matrix plot one decimal but exact zeros

I'm trying to plot a confusion matrix that has one decimal for all values but if the value is exact zero, I would like to keep it as an exact zero rather than 0.0. How can I achieve this? In this ...
scriptgirl_3000's user avatar
0 votes
1 answer
646 views

How to fix low quality decision tree visualisation

I'm trying to visulise a decision tree i've just constructed, however the figure is always low quality and you can't read the labels! Just wondering if there is a fix for this? My code for brining up ...
Ted's user avatar
  • 45
2 votes
1 answer
286 views

Feature importance using gridsearchcv for logistic regression

I've trained a logistic regression model like this: reg = LogisticRegression(random_state = 40) cvreg = GridSearchCV(reg, param_grid={'C':[0.05,0.1,0.5], 'penalty'...
Kev's user avatar
  • 375
0 votes
0 answers
216 views

How to customize plots that were made using "scikitplot.metrics" other than the arguments show in the function?

I made some graphs with scikit-plot package, but need to customize the axes colors and sizes as well the lines width. Here is what I already have plotted and the editable arguments of the function ...
Cesar Pereira's user avatar
0 votes
1 answer
217 views

Python adjust scale intensity at confusion matrix plot

I have a number of confusion matrix plots with numbers not summing up to the same sum (the numbers are out of 100 for a benchmark) Please see attached example image below: confusion matrix I do not ...
Farid's user avatar
  • 33
4 votes
1 answer
876 views

How to visualize cluster boundaries

I generated several datasets, and using classifiers, I predicted the distribution of clusters. I need to draw boundaries between clusters on the chart. In the form of lines or in the form of filled ...
VladislavOkatev's user avatar
0 votes
0 answers
20 views

matplotlib plotting multiple lines [duplicate]

Consider the following code: import matplotlib.pyplot as plt import numpy as np import pandas as pd from regressors import stats from sklearn.linear_model import LinearRegression from sklearn....
Oliver's user avatar
  • 1,635
0 votes
0 answers
280 views

How to plot loss vs number of epochs for a linear regression model with using only sklearn and matplotlib?

from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=101) from sklearn.preprocessing import StandardScaler scaler ...
Scumdium's user avatar
-1 votes
1 answer
625 views

Plot the results of a cluster analysis on a two-dimensional space

I'm not sure this can be done retrospectively, so I'm not sure my question makes sense. I used k-means in a 20-dimensional space, resulting in 17 clusters. I thus obtained a data frame containing the ...
LJG's user avatar
  • 767
0 votes
0 answers
182 views

Python data clustering with Kmeans rasterization

I am currently using the sklearn KMeans algorithm to cluster my data. This works well, and I can plot the centroids and data points. At the same time, I am also plotting a grid. I would now like to ...
Martin Zaubi's user avatar
0 votes
0 answers
281 views

Print range of accuracy for a Logistic Regression model

I have my Logistic Regression model trained on a range of n-grams, let's say from 1 to 5, generated by a TfidfVectorizer. On the other hand I have the accuracy of the model for each fold (since I'm ...
peplem's user avatar
  • 3
0 votes
1 answer
112 views

How to switch the position of values in a numpy array

I need some help in switching the position of the confusion matrix as shown in the image below.. The code below is the current version whereby the true positive is at the bottom right. Appreciate the ...
Colin Giam's user avatar
0 votes
1 answer
244 views

sklearn, linear regression - How do I predict population to a future year that is outside of the test data in the input dataframe?

My file input is a csv containing two columns, pop and year; year is an integer counting up from 0 to 67 in order. pop is a float showing the population for that year. import sklearn.linear_model as ...
Remixt's user avatar
  • 597
-1 votes
1 answer
1k views

How to colour a scatter plot of a 2d data frame (reduced using tsne/umap) according to label information in index ({country,year}) of different frame

The problem I am facing is that I have a dataframe - sector_features_ which looks like this: After running tsne on it I then have a 2d df which I plot with a scatter graph. The problem is that I don'...
Yannick Silva's user avatar
0 votes
1 answer
174 views

How to plot figure instance returned by a function side by side [duplicate]

I have figure instances, and I want to plot them side by side (e.g. two figures in one row and two columns). Below is the sample code which returns the figure instance. from sklearn.metrics import ...
Taha's user avatar
  • 65
0 votes
1 answer
142 views

How to resolve notfitted error on SelectKbest

#Correlation fature selection from sklearn.feature_selection import SelectKBest from sklearn.feature_selection import f_regression from matplotlib import pyplot def select_features (features_train, ...
trailblazer1996's user avatar
2 votes
1 answer
553 views

Polynomial regression plot looking weird [duplicate]

I'm trying to plot a fitted polynomial using matplotlib: my code: x = data['LSTAT'].values.reshape(-1,1).copy() y = data['MEDV'].values.reshape(-1,1).copy() plt.figure(figsize=(8,5)) from sklearn....
guin0x's user avatar
  • 357
0 votes
1 answer
323 views

Why we flip coordinates when we plot confusion matrix

I am trying to plot the confusion matrix, but I have a question, why the indices are flipped in the for loop below where we start with plt.text(j, i) instead of plt.text(i, j)? I assume that 2D ...
Avv's user avatar
  • 519
0 votes
1 answer
492 views

AttributeError: 'Functional' object has no attribute 'epochs'

I am getting this attribute error when I want to plot multiple accuracy curves into one graph. I am using functional methods for creating the model. The problem appeared when I tried to use transfer ...
5hi's user avatar
  • 23
0 votes
2 answers
67 views

Why do these work separately but not together [KMeans Clustering]

I am trying to plot the results from a KMeans model on 3 datasets. Code for those is as follows: blobsX, blobsY = make_blobs(n_samples=1000, n_features=2, random_state=177) classX, ...
user15404111's user avatar
0 votes
1 answer
68 views

I need help in this error "TypeError: only size-1 arrays can be converted to Python scalars"

My code is: escolaridade = dados4[dados4["DMDEDUC"] == 5] sentimento = dados4[dados4["DPQ020"] != 0].head(875) plt.bar(escolaridade,sentimento, color="blue") plt.xlabel(&...
Cairo Alcantara's user avatar
-1 votes
1 answer
72 views

Matplotlib - When I format ticks, they are not replaced and instead added to the plot

Hello I am using Matplotlib to plot some curves for machine learning. I have the problem that when I format my x_ticks , instead of replacing the old ones they are added to the plot. See the first ...
Nils Lcrx's user avatar
1 vote
1 answer
315 views

Changing values in confusion_matrix (sklearn)

How can i change a numbers values to letters in both axis? I got dictionary with keys = letters and values = numbers Code: cm = confusion_matrix(y_class, y_pred_class) disp = ConfusionMatrixDisplay(...
Socka's user avatar
  • 37

1
2 3 4 5
10