Data Science Asked by John Tarr on April 28, 2021
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 :
Correct answer by Pierre on April 28, 2021
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)
Answered by Collin Conway on April 28, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP