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 ...


7

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

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>], [<...


4

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.


4

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....


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 ...


4

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

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

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 (...


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

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

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'...


3

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)


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

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

I think there are a few "easy wins" here. You might add more bins - you are already using the bin setting. Just add something high like 100 or even 1000 to get a first feeling for the data You can define the range of your bins. For example you could set the range with a list of two entries range = [0, 5000] as an additional parameter You can consider not ...


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

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

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

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

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

As the error message suggests, your error is caused by passing positional argument after keyword argument. Consider a function def foo(a,b,c): return a+b*c You can call this function by foo(3,4,5) and it returns 23. In this case, all three arguments are positional arguments, and Python understand them by their position: 3 is the first argument, ...


2

Use xticks. e.g. x=np.arange(1,16) y = -60000*(3+np.log(1/x)) plt.plot(x,y,'b') plt.xticks(x) plt.show()


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