How to use the orange.VarTypes.Continuous function in Orange

To help you get started, we’ve selected a few Orange examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github biolab / orange2 / Orange / misc / visfuncts.py View on Github external
def evaluateAttributesDiscClass(data, contMeasure, discMeasure):
    attrs = []
    #corr = MeasureCorrelation()
    for attr in data.domain.attributes:
        #if data.domain.classVar.varType == orange.VarTypes.Continuous and attr.varType == orange.VarTypes.Continuous: attrs.append((corr(attr.name, data), attr.name))
        if data.domain.classVar.varType == orange.VarTypes.Continuous and attr.varType == orange.VarTypes.Continuous: attrs.append((1, attr.name))
        elif data.domain.classVar.varType == orange.VarTypes.Continuous:            attrs.append((0.0, attr.name))
        elif discMeasure == None and attr.varType == orange.VarTypes.Discrete:      attrs.append((0.0, attr.name))
        elif contMeasure == None and attr.varType == orange.VarTypes.Continuous:    attrs.append((0.0, attr.name))
        elif attr.varType == orange.VarTypes.Continuous:                            attrs.append((contMeasure(attr.name, data), attr.name))
        else:                                                                       attrs.append((discMeasure(attr.name, data), attr.name))

    if discMeasure or contMeasure:
        attrs.sort()
        attrs.reverse()

    return [attr for (val, attr) in attrs]  # return only the ordered list of attributes and not also their values
github biolab / orange2 / orange / orng / orngMySQL.py View on Github external
def __attrname2sql(self, a):
    pom = a.name
    subs = [("'",''), ("-",'_'), ("/",'_'), ("\\",'_'), ("+",'__'), (" ",'_')]
    for s in subs:
      pom = pom.replace(*s)
    if pom in reserved_words:            # name of attributes can't be select,insert....
      pom = "$" + pom                    # for attribute names that are SQL keywords
    if a.varType == orange.VarTypes.Continuous:
      pom += " FLOAT"
    elif a.varType == orange.VarTypes.Discrete:
      if a.values:
        pom += " ENUM (%s)" % reduce(lambda x, y: "%s, %s" % (x, y), ['"%s"' % i for i in a.values])
      else:
        pom += ' ENUM ("empty")'
    elif a.varType == orange.VarTypes.String:
      pom += " " + char_sql
    return pom
github biolab / orange2 / Orange / OrangeWidgets / Regression / OWPade.py View on Github external
def onDataInput(self, data):
        self.closeContext()
        if data and self.isDataWithClass(data, orange.VarTypes.Continuous, checkMissing=True):
            orngPade.makeBasicCache(data, self)

            icons = OWGUI.getAttributeIcons()
            self.outputLB.clear()
            for attr in self.contAttributes:
                self.outputLB.addItem(icons[attr.varType], attr.name)

            self.dimensions = range(len(self.attributes))
        else:
            orngPade.makeEmptyCache(self)
            self.dimensions = []

        self.openContext("", data)
        self.dimensionsChanged()
github biolab / orange2 / Orange / OrangeWidgets / Data / OWDiscretize.py View on Github external
self.reportSettings("Settings", settings)
        
        attrs = []
        if self.data:
            for i, (attr, disc) in enumerate(zip(self.data.domain.attributes, self.discretizers)):
                if disc:
                    discType, intervals = self.indiData[i][:2]
                    cutpoints = ", ".join(str(attr(x)) for x in disc.getValueFrom.transformer.points)
                    if not cutpoints:
                        attrs.append((attr.name, "removed"))
                    elif not discType:
                        attrs.append((attr.name, cutpoints))
                    else:
                        attrs.append((attr.name, "%s (%s)" % (cutpoints, self.shortDiscNamesUnpar[discType])))
                elif disc == None:
                    if attr.varType == orange.VarTypes.Continuous:
                        attrs.append((attr.name, "left continuous"))
                    else:
                        attrs.append((attr.name, "already discrete"))
            classVar = self.data.domain.classVar
            if classVar:
                if classVar.varType == orange.VarTypes.Continuous:
                    attrs.append(("Class ('%s')" % classVar.name, "%s (%s)" % (self.classIntervalsLabel,
                                  ["equal frequency", "equal width", "custom"][self.classDiscretization])))
                    attrs.append(("Output discretized class", OWGUI.YesNo[self.outputOriginalClass]))
        self.reportSettings("Attributes", attrs)
github biolab / orange2 / docs / extend-widgets / rst / owplot_example.py View on Github external
if data.domain[x_i].varType == orange.VarTypes.Discrete:
            self.plot.set_axis_labels(xBottom, get_variable_values_sorted(domain[x_i]))
        else:
            self.plot.set_axis_autoscale(xBottom)

        if data.domain[y_i].varType == orange.VarTypes.Discrete:
            self.plot.set_axis_labels(yLeft, get_variable_values_sorted(domain[y_i]))
        else:
            self.plot.set_axis_autoscale(yLeft)
            
        x_data = []
        y_data = []
        c_data = []
        s_data = []
        
        color_cont = (domain[c_i].varType == orange.VarTypes.Continuous)
        
        legend_sizes = set()
        
        for e in data:
            x_data.append(e[x_i])
            y_data.append(e[y_i]) 
            c_data.append(e[c_i])
            size = 5 + round(e[s_i])
            s_data.append(size)
            
            legend_sizes.add( (size, float(e[s_i])) )
            
        if color_cont:
            m = min(c_data)
            M = max(c_data)
            legend_colors = set(float(c) for c in c_data)
github biolab / orange2 / Orange / OrangeWidgets / Data / OWDataInfo.py View on Github external
def data(self, data):
        if data:
            self.rowcount = len(data)
            self.columncount = len(list(data.domain.attributes) + data.domain.getmetas().keys())
            self.discattrcount = len([attr for attr in data.domain.attributes if attr.varType == orange.VarTypes.Discrete])
            self.contattrcount = len([attr for attr in data.domain.attributes if attr.varType == orange.VarTypes.Continuous])
            self.stringattrcount = len([attr for attr in data.domain.attributes if attr.varType == orange.VarTypes.String])
            self.metaattrcount = len(data.domain.getmetas())
            self.classattr = "Yes" if data.domain.classVar else "No"
        else:
            self.rowcount = 0
            self.columncount = 0
            self.discattroutn = 0
            self.contattrcount = 0
            self.stringattrcount = 0
            self.metaattrcount = 0
            self.classattr = "No"
github biolab / orange2 / Orange / orng / orngMySQL.py View on Github external
def __attrname2sql(self, a):
    pom = a.name
    subs = [("'",''), ("-",'_'), ("/",'_'), ("\\",'_'), ("+",'__'), (" ",'_')]
    for s in subs:
      pom = pom.replace(*s)
    if pom in reserved_words:            # name of attributes can't be select,insert....
      pom = "$" + pom                    # for attribute names that are SQL keywords
    if a.varType == orange.VarTypes.Continuous:
      pom += " FLOAT"
    elif a.varType == orange.VarTypes.Discrete:
      if a.values:
        pom += " ENUM (%s)" % reduce(lambda x, y: "%s, %s" % (x, y), ['"%s"' % i for i in a.values])
      else:
        pom += ' ENUM ("empty")'
    elif a.varType == orange.VarTypes.String:
      pom += " " + char_sql
    return pom
github biolab / orange2 / orange / orng / orngVisFuncts.py View on Github external
def evaluateAttributesDiscClass(data, contMeasure, discMeasure):
    attrs = []
    #corr = MeasureCorrelation()
    for attr in data.domain.attributes:
        #if data.domain.classVar.varType == orange.VarTypes.Continuous and attr.varType == orange.VarTypes.Continuous: attrs.append((corr(attr.name, data), attr.name))
        if data.domain.classVar.varType == orange.VarTypes.Continuous and attr.varType == orange.VarTypes.Continuous: attrs.append((1, attr.name))
        elif data.domain.classVar.varType == orange.VarTypes.Continuous:            attrs.append((0.0, attr.name))
        elif discMeasure == None and attr.varType == orange.VarTypes.Discrete:      attrs.append((0.0, attr.name))
        elif contMeasure == None and attr.varType == orange.VarTypes.Continuous:    attrs.append((0.0, attr.name))
        elif attr.varType == orange.VarTypes.Continuous:                            attrs.append((contMeasure(attr.name, data), attr.name))
        else:                                                                       attrs.append((discMeasure(attr.name, data), attr.name))

    if discMeasure or contMeasure:
        attrs.sort()
        attrs.reverse()

    return [attr for (val, attr) in attrs]  # return only the ordered list of attributes and not also their values
github biolab / orange2 / Orange / OrangeWidgets / VisualizeQt / OWScatterPlot3D.py View on Github external
'''
Scatterplot 3D
icons/ScatterPlot.svg
2001
'''

from math import log10, ceil, floor

from OWWidget import *
from plot.owplot3d import *
from plot.owtheme import ScatterLightTheme, ScatterDarkTheme
from plot import OWPoint

import orange
Discrete = orange.VarTypes.Discrete
Continuous = orange.VarTypes.Continuous

from Orange.data.preprocess.scaling import get_variable_values_sorted

import OWGUI
import orngVizRank
from OWkNNOptimization import *
from orngScaleScatterPlotData import *

import numpy

TooltipKind = enum('NONE', 'VISIBLE', 'ALL')
Axis = enum('X', 'Y', 'Z')

class Plane:
    '''Internal convenience class.'''
    def __init__(self, A, B, C, D):
github biolab / orange2 / orange / OrangeWidgets / Prototypes / OWDiscretizeQt.py View on Github external
self.reportSettings("Settings", settings)
        
        if self.data:
            attrs = []
            for i, (attr, disc) in enumerate(zip(self.data.domain.attributes, self.discretizers)):
                if disc:
                    discType, intervals = self.indiData[i][:2]
                    cutpoints = ", ".join(str(attr(x)) for x in disc.getValueFrom.transformer.points)
                    if not cutpoints:
                        attrs.append((attr.name, "removed"))
                    elif not discType:
                        attrs.append((attr.name, cutpoints))
                    else:
                        attrs.append((attr.name, "%s (%s)" % (cutpoints, self.shortDiscNamesUnpar[discType])))
                elif disc == None:
                    if attr.varType == orange.VarTypes.Continuous:
                        attrs.append((attr.name, "left continuous"))
                    else:
                        attrs.append((attr.name, "already discrete"))
            classVar = self.data.domain.classVar
            if classVar:
                if classVar.varType == orange.VarTypes.Continuous:
                    attrs.append(("Class ('%s')" % classVar.name, "%s (%s)" % (self.classIntervalsLabel,
                                  ["equal frequency", "equal width", "custom"][self.classDiscretization])))
                    attrs.append(("Output discretized class", OWGUI.YesNo[self.outputOriginalClass]))
        self.reportSettings("Attributes", attrs)