Implementing Q-Q Plot Within Orange Miner's Python Script Widget
I'm trying to create a QQ plot in Orange Miner's Python script. I keep getting an error that I'm assuming relates to Orange's native data format, stating "AttributeError: 'Table' object has no attribute 'shape'" when trying to read in a single column to the sm.qqplot function.
I've already used roughly this setup for other plots. I figured out how to convert the Orange table to a Pandas dataframe for doing correlation heatmaps like so:
import numpy as np from Orange.data import Table import Orange import matplotlib.pyplot as plt import pandas as pd import seaborn as sns data = in_data.copy() # Converts to pandas!!! frame = Orange.data.pandas_compat.table_to_frame(data) # Get all columns heatmap_sub = frame.corr(method = 'pearson') sns.heatmap(heatmap_sub, xticklabels=heatmap_sub.columns.values, yticklabels=heatmap_sub.columns.values, center = 0, annot = True) plt.title('Pearson correlation of Binder type = Acrylic') plt.show()
Here is the code that I am attempting to implement for the Q-Q plot though:
import numpy as np from Orange.data import Table import statsmodels.api as sm import pylab data = in_data.copy() sm.qqplot(data[:,1], line='45') pylab.show()
I expect a plot to be output from the code to be a plot, but I keep getting this:
Running script: Traceback (most recent call last): File "<console>", line 1, in <module> File "<string>", line 8, in <module> File "C:\Users\Doug\Anaconda3\lib\site-packages\statsmodels\graphics\gofplots.py", line 506, in qqplot fit=fit, a=a, loc=loc, scale=scale) File "C:\Users\Doug\Anaconda3\lib\site-packages\statsmodels\graphics\gofplots.py", line 130, in __init__ self.nobs = data.shape AttributeError: 'Table' object has no attribute 'shape'
I'm sure this has something to do with the Orange table object, but I'm not sure how to go about "converting" it to a numpy array or something comparable. the documentation simply says that data is a "1d data array". https://www.statsmodels.org/stable/generated/statsmodels.graphics.gofplots.qqplot.html
Thanks for your help in advance!
I figured it out if anyone else runs into this issue. Wrap the data you are trying to select with np.array() to convert, like so:
sm.qqplot(np.array(data[:,1]), line='45') pylab.show()
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module