10

Don't worry - your hard-earned Python skills are still important ;) Tableau is not a replacement - it is essentially a means of sharing your insights/findings. It is a wrapper around your normal toolkit (Pandas, Scikit-Learn, Keras, etc.). It can do some basic analysis (just using basic models from sklearn), but the powerful thing is it can deploy your ...


6

TL;DR Use the two functions from below to get the index of the elbow: elbow_index = find_elbow(data, get_data_radiant(data)) Edit: I put all of the code below into a python package called kneebow. Now, you can simply do it like this: from kneebow.rotor import Rotor rotor = Rotor() rotor.fit_rotate(data) elbow_index = rotor.get_elbow_index() Long Answer ...


6

There is the official answer and the realistic answer (from a business perspective): Official Officially the greatest thing your Python skills will bring you is flexibility. If you are going to run some economical model where you want to show a gradient uncertainty or something else crazy, doing that manually in any Data Visualization/Business Intelligence ...


4

import pandas as pd df = pd.Series(data=[11, 8, 28, 1, 70, 13, 45], index=[22, 23, 27, 28, 29, 30, 31], name="age").rename_axis("age", axis=0) x = df.index y = df.values plt.bar(x, y)


4

Here is a working example to add a text to the right of horizontal bars: import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns df = pd.DataFrame(np.array([['a'], ['a'], ['b']]), columns=['current_status']) ax = sns.countplot(y="current_status", data=df) plt.title('Distribution of Configurations') plt.xlabel('Number ...


3

For answering questions from graph, you should not visualize it. Visualizing graphs is for sake of having an overview on how it looks like in general. There are Graph Visualization techniques that show graph for sake of getting some initial insight (e.g. if there are visually obvious communities or not). Your question has an analytic answer. After ...


3

I don't know what you mean by "with linear model" in the title, but here's code that generates a toy dataset and replicates your plot. library(tidyverse) x<-crossing(year=paste("Year", 1:3), avg=c("Above 4.0", "Below 4.0")) x$dat<-replicate(6, tibble(wrkday=runif(100, 1000, 2000))) x %>% unnest(dat) %>% ggplot(aes(dat)) + geom_histogram(...


3

I want to view a specific image or a dataset's distribution, and see if they are different. Does this do the trick? It depends what you want to understand or learn about your data. what does each axis mean then? In all of your plots, the x-axis ranges from 0-255, which is because in all your plots, you are creating histograms of the individual pixel ...


3

Its because you have not looked how the values are packed in plt.subplot function. >>> plt.subplots(2,2,figsize=(10,4)) (<matplotlib.figure.Figure at 0xa3918d0>, array([[<matplotlib.axes._subplots.AxesSubplot object at 0x000000000A389470>, <matplotlib.axes._subplots.AxesSubplot object at 0x000000000A41AD30>], [<...


3

Sorry for the late reply. I don't know whether the below kind of plot suffices for what you are looking. If yes is the case, you might like matplotlib.hlines. I am providing a sample code for generating a picture like the above. import matplotlib.pyplot as plt import random for x in range(0, 10, 2): color = random.choice(['red', 'green', 'blue', '...


3

Found the answer. Thank you @Aditya import seaborn as sns sns.lmplot('Time', 'Amount', dataset, hue='Class', fit_reg=False) fig = plt.gcf() fig.set_size_inches(15, 10) plt.show() where Time and Amount are the two features I needed to plot. Class is the column of the dataset that has the dependent binary class value. And this is the plot I got as required.


3

One approach is to plot the data as a scatter plot with a low alpha, so you can see the individual points as well as a rough measure of density. from sklearn.datasets import load_iris iris = load_iris() features = iris.data.T plt.scatter(features[0], features[1], alpha=0.2, s=100*features[3], c=iris.target, cmap='viridis') plt.xlabel(iris....


3

T-SNE is another dimensionality reduction algorithm not mentioned in the article in the other answer. Used for VERY high dimensional data, if you have trained some embeddings for your dataset. Reference Here . Python standard library here. cheers


3

Here is python code to make a pretty good match for your picture. from igraph import * AM = [[1,3,1,0], [3,7,3,0], [0,1,9,1], [0,1,3,1]] g = Graph.Weighted_Adjacency(AM) g.vs["color"] = ["red", "blue", "blue", "red"] g.vs["size"] = [30,40,40,30] g.es["width"] = [2,5,2,5,9,5,2,13,2,2,5,2] g.es["color"] = ["#FF000066", "#FF000066", "#FF000066", "#...


3

You can use the Kolmogorov-Smirnov Test. From Wikipedia In statistics, the Kolmogorov–Smirnov test (K–S test or KS test) is a nonparametric test of the equality of continuous, one-dimensional probability distributions that can be used to compare a sample with a reference probability distribution (one-sample K–S test), or to compare two samples (...


3

It seems what you are looking for is a function of your data, not of matplotlib. I would think of this as a second derivative problem -- you care about differences in slopes of successive lines. Sort a dataframe [x,y] by x values, in increasing order. Calculate the first discrete derivative delta1 = (y[i+1] - y[i]) / (x[i+1] - x[i]). This tells you the ...


3

It looks fine to me :) the only problem is that your plot (resulting from In [18]) is being displayed on your computer in a separate window somewhere - maybe you have to find it. Once you close that window, your iPython prompt woill return to In [19]. You could alternatively press Ctrl-C in the iPython session, but this will end the session. If the problem ...


3

Your context is different than the one provided in the link. There, the author has made a neural network in Keras and has plotted the accuracy against the number of epochs. One epoch is when an entire dataset is passed both forward and backward through the neural network once. So, he is calculating accuracy after every epoch while the weights vary to fit ...


3

I have three suggestions that may help. Reduce the point size Make the points highly transparent Downsample the points Since you do not provide any sample data, I will use some random data to illustrate. ## The purpose of S1 is to intermix the two classes at random S1 = sample(3000000) x = c(rnorm(2000000, 0, 1), rnorm(1000000, 3,1))[S1] y = c(rnorm(...


3

Using matplotlib, you could create a custom tick formatter to show the right ticks. The year and month can either be fetched from the dataframe via the index (df.iloc[value]['Month']) or just be calculated. Here is an example. You can also read the month name in the status bar when you hover over a position in the plot. The xticks (the positions where to ...


2

Your histogram is valid, but it has too many bins to be useful. If you want a number of equally spaced bins, you can simply pass that number through the bins argument of plt.hist, e.g.: plt.hist(data, bins=10) If you want your bins to have specific edges, you can pass these as a list to bins: plt.hist(data, bins=[0, 5, 10, 15, 20, 25, 30, 35, 40, 60, 100]...


2

You have to specify the bin size, if I've figured out the question. As stated here. You can give a list with the bin boundaries. plt.hist(data, bins=[0, 10, 20, 30, 40, 50, 100]) If you just want them equally distributed, you can simply use range: plt.hist(data, bins=range(min(data), max(data) + binwidth, binwidth)) You can also take a look at here and ...


2

This is exactly your code just with digits data: import matplotlib.pyplot as plt import numpy as np from sklearn.datasets import load_digits from sklearn.svm import SVC from sklearn.learning_curve import validation_curve import psutil from sklearn.tree import DecisionTreeClassifier np.random.seed(0) # X, y = prepareDataframeX.values, prepareDataframeY....


2

I recommend you to use the following example and try to manipulate the arguments and adjust them for your work: from matplotlib import cm cmap = cm.get_cmap('gnuplot') scatter = pd.scatter_matrix(YOUR_TRAINING_DATA, c = YOUR_LABELS_OF_TRAINING, marker = 'o', s = 40, hist_kwds = {'bins':15}, figsize = (12, 12), cmap = cmap)


2

As you can read from here plt.subplots() is a function that returns a tuple containing a figure and axes object(s). Thus when using fig, ax = plt.subplots() you unpack this tuple into the variables fig and ax. Having fig is useful if you want to change figure-level attributes or save the figure as an image file later (e.g. with fig.savefig('yourfilename.png')...


2

use matplotlib: import matplotlib.pyplot as plt %matplotlib inline f, (ax1, ax2) = plt.subplots(1, 2) ax1.plt(Data_X_err.min, Data_X_err.err) ax2.plt(Data_X_err.max, Data_X_err.err) Alternatively you could use seaborn's pairplot import seaborn as sns %matplotlib inline sns.set(style="ticks") sns.pairplot(df)


2

Several options: Locally Linear Embedding (LLE): This method construct a set of local geometric patches on each of which a data point is reconstructed through the weighted sum of its K nearest neighbor and maps these patches into a lower dimensional space. Find the code here and I strongly advice to use both LLE and Modified LLE and use the better one (...


2

You can use the seaborn package, using the scatterplot marker size to generate your bubbles. Then you need to loop over the datapoints and add a text labet to each point in your scatterplot. # Load libraries import pandas as pd import matplotlib.pylab as plt import seaborn as sns # Create example dataframe df = pd.DataFrame({ 'x': [1, 1.1, 1.2, 2, 5], 'y': ...


2

The PCA projections do not look not orthogonal because your figure axes are not equal. Set all axis equal with something like this: ax.axis('equal') or ax.xlim(-5, 5) ax.ylim(-5, 5) ax.zlim(-5, 5) ax.gca().set_aspect('equal')


2

Instead of import matplotlib as plt use import matplotlib.pyplot as plt


Only top voted, non community-wiki answers of a minimum length are eligible