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?
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?
I found 3 ways to do it :
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)
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)