Python: Can I take a manifold object as a model - python

I have a group of high-dimensional (250 dimensions) data. To get rid of unnecessary dimensions and to easily visualize data on a figure, I used class sklearn.manifold.MDS and its method fit_transform(data) and already got the transformed data in 2-dimension space.
I have plotted the figure out, which looks like
The problem is: now I have some new coming data. In my case, I want to take the figure shown above as the basic model. For new coming data, I want to implement the same MDS on them and also plot them on this figure, so that I can know which area and how large area the new data will occupy.
However, I realized that MDS class only has fit_transform() method but doesn't have independent transform() method. I want to know, if for new coming data, I do another fit_transform(new_data), can these transformed data be directly plotted on top of this figure?
p.s. I do fit_transform(new_data) after I do fit_transform(old_data)

Related

3D interpolation and plotting into a volume/isosurface on python

I'm looking for a way to interpolate 2D fields that are arranged on a list, making the shape data = [11,2016,2016]
Up to the moment I've managed to stack the 2D plots over the Z axis and create an interactive plot, but i want to create a plot of the volume and thought that an interpolation through the 11 steps would work, I'd like to get only one 2D array at the end to plot.
Any suggestions about how to perform this? can I make it on one single operation or am I obliged to perform step by step interpolations between each step?
edit: a picture showing the image that i'm able to generate now and can maybe explain better my problem.

Customizing matlab plots for high resolution and custom scaling

I have a 1d signal of many samples (millions). I also have it's wavelet transform coefficients (in float64) and frequencies stored in arrays. I am trying to make a high resolution plot of both the signal level vs time and also of the scallogram. The default parameters for size etc are too small for effective visualization. I am exporting it to both png and pdf using savefig object.
I would like to make it higher resolution (1920*1080 or equivalent sizes depending upon aspect ratio). I am unable to comprehend matplotlib arguments and objects and unfortunately I have not been able to follow well with tutorials available online. There is so much functionality and different ways of doing it, that moving from one resource to another for learning required re learning something new for the same task.
So far I have been able to understand interpolation choices, colormap choices, figure label, x and y labels. I am unable to understand the difference between imshow and plot, how to pass on size and fidelity of the plot etc, or passing the axis scales (currently my scales are off). The figsize is mentioned in inches and I am not sure how it relates to pixels. Would love to hear guidance on the same.
I would also like to plot STFT for my samples with high image fidelity with custom window size etc. Currently using specgram but would like to know how to pass on window size, overlap etc and the color map and interpolation schemes, and if other alternatives are available.
I'm plotting these for multiple different data sets in a single code (for loop) and would like to have all images being of uniform size and same scale since all have equal sample sizes.

Plotting hierarchical clustering dendrograms for large data sets

I have a huge data set of time series data. In order to visualise the clustering in python, I want to plot time series graphs along with the dendrogram as shown below.
I tried to do it by using subgrid2plot() function in python by creating two subplots side by side. I filled first one with series graphs and second one with dendrograms. But once number of time series increased, it became blur.
Can someone suggest a nice way to plot this type of dendrogram? I have around 50,000 time series to cluster and visualise.
Convert data into JSON with json module of python and then use D3.js for graph ploting.
Check the Gallery from here where you can find dendrogram and time series graph

Dealing with empty regions of data in a histogram

I have 2 arrays of shape (1,N) which are right ascension and declination. The scatter plot of that data is
As you can see in the top-left, data was not collected in this region and so is empty.
I would like to form the histogram of this data as a method of investigating data clustering. That empty spot (and many others like it), it seems to me, will cause a problem -- when numpy.histogram2d draws a grid on this data and begins counting data points in the cells, it will see cells that fall on the empty region and determine that there is no data there; hence the cell histogram value is zero. This pulls down the mean of the whole histogram. Having a sensible mean is important because I identify clusters via their standard deviation from the mean.
The problem is, of course, not that those cells are empty, but that there is no data to count; ideally those cells should be ignored.

Swarmplot with more than just one categorical level (Python)

I am trying to make a swam plot that contains more information than a single categorical level and two variables. I am looking to create something like this
So ideally, something like this would work (but it does not):
ax = sns.swarmplot(x="round_id", y="independent_error_abs", hue="difficulty", hue_order=['easy','medium','hard'], size="followers", markershape="rank",data=df)
where "difficulty", "followers", and "rank" determine the color of the point, the size of the point, and the shape of the point, respectively.
No, this is not possible with swarmplot. Personally I find this kind of plot very difficult to interpret: a good statistical plot should make the patterns in the data immediately apparent, whereas plots with multiple categorical variables that manipulate the size or shape of the points quickly become more like puzzles. My recommendation in these cases (following Andrew Gelman) is to make more than one plot, each with relatively simple semantics.
You don't have to agree, of course, but you will have to make it yourself using matplotlib.
I am facing the same issue, and actually the solution seems to be pretty simple at least for the marker type!
Just divide your dataframe in subdataframes, each for a different marker type. The you make a swarmplot on top of each other, and that's it.
If the size of the dot, is also a categorical variable, you just need to do the same as above where each subdtaframe will represent a marker and a different size.
If size is continuous, then it seems you would need to plot each dot independently in a for loop, but for that I would use matplotlib.pyplot.

Categories

Resources