3
$\begingroup$

I just started using Orange, and am having trouble finding how to get basic summary statistics, like the n (count), average, and standard deviation.

Is there a widget that does this and I'm simply overlooking it?

$\endgroup$
1
  • 1
    $\begingroup$ This is blowing my mind too!! There is an object in the code Orange.statistics.basic.Variable that has all of the work done, we just need a widget to output it. Please make this into a widget someone! $\endgroup$ – Adam Johnston Apr 19 '17 at 14:35
3
$\begingroup$

I found 3 ways to do it :

  • you have to use the Data Info widget who gives the number of rows of your dataset and the Box Plot widget who prints the average and the standard deviation of each feature in your dataset. Pro: easy to use. Con: you are unable to use this data.
  • you can create a Python script who will compute the average and the standard deviation using the statistics package. Pro: you can reuse your data. Con: you have to write a script and format the output data correctly.
  • it exists an add-on call "Orange3-Timeseries" with a Moving Transform widget who can compute the average and the standard deviation of your series. Pro: easy to use. Cons: the package is still a beta-version and have some bugs, the widget only works with timeseries.
$\endgroup$
0
$\begingroup$

For those of us who want more examples of scripts with the Orange3 API on the web, here is a solution that worked for me.

from Orange.data import ContinuousVariable,DiscreteVariable
import numpy as np
dom = in_data.domain
continuous = [d for d in dom.variables if type(d) == ContinuousVariable]
rows = ["mean","std","min","max","range"]
dom = Domain(continuous,metas = [DiscreteVariable(name="stat",values=rows)])
summary = [
    [np.mean(in_data[:,dom.index(d)]) for d in continuous],
    [np.std(in_data[:,dom.index(d)]) for d in continuous],
    [np.min(in_data[:,dom.index(d)]) for d in continuous],
    [np.max(in_data[:,dom.index(d)]) for d in continuous],
    [np.ptp(in_data[:,dom.index(d)]) for d in continuous] ]
meta = [[i] for i in range(0,5)]
out_data = Table.from_numpy(dom,summary,metas=meta)
$\endgroup$
0
$\begingroup$

Thanks. Worked for me after minor changes:

from Orange.data import Domain, ContinuousVariable,DiscreteVariable
from Orange.data.pandas_compat import table_from_frame
import numpy as np
import pandas as pd
dom = in_data.domain
df = pd.DataFrame(in_data.X)

Table=table_from_frame(df)
continuous = [d for d in dom.variables if type(d) == ContinuousVariable]
rows = ["mean","std","min","max","range"]
dom = Domain(continuous,metas = [DiscreteVariable(name="stat",values=rows)])
summary = [
[np.mean(in_data[:,dom.index(d)]) for d in continuous],
[np.std(in_data[:,dom.index(d)]) for d in continuous],
[np.min(in_data[:,dom.index(d)]) for d in continuous],
[np.max(in_data[:,dom.index(d)]) for d in continuous],
[np.ptp(in_data[:,dom.index(d)]) for d in continuous] ]
meta = [[i] for i in range(0,5)]
out_data = Table.from_numpy(dom,summary,metas=meta)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.