<commit_before>"""
Rank
====

Rank (score) features for prediction.

"""

from collections import namedtuple

import numpy as np

from PyQt4 import QtGui
from PyQt4.QtCore import Qt

import Orange
from Orange.base import Learner
from Orange.data import ContinuousVariable, DiscreteVariable, Domain, StringVariable
from Orange.preprocess import score
from Orange.canvas import report
from Orange.widgets import widget, settings, gui
from Orange.widgets.utils.sql import check_sql_input


def table(shape, fill=None):
    """ Return a 2D table with shape filed with ``fill``
    """
    return [[fill for j in range(shape[1])] for i in range(shape[0])]


score_meta = namedtuple(
    "score_meta",
    ["name",
     "shortname",
     "score"]
)

# Default scores.
SCORES = [
    score_meta("Information Gain", "Inf. gain", score.InfoGain),
    score_meta("Gain Ratio", "Gain Ratio", score.GainRatio),
    score_meta("Gini Gain", "Gini", score.Gini),
    score_meta("ReliefF", "ReliefF", score.ReliefF),
    score_meta("RReliefF", "RReliefF", score.RReliefF),
    score_meta("FCBF", "FCBF", score.FCBF),
]

_DEFAULT_SELECTED = set(m.name for m in SCORES)


class OWRank(widget.OWWidget):
    name = "Rank"
    description = "Rank and filter data features by their relevance."
    icon = "icons/Rank.svg"
    priority = 1102

    inputs = [("Data", Orange.data.Table, "setData"),
              ("Scorer", score.Scorer, "set_learner", widget.Multiple)]
    outputs = [("Reduced Data", Orange.data.Table),
               ("Scores", Orange.data.Table)]

    SelectNone, SelectAll, SelectManual, SelectNBest = range(4)

    selectMethod = settings.Setting(SelectNBest)
    nSelected = settings.Setting(5)
    auto_apply = settings.Setting(True)

    # Header state for discrete/continuous scores
    headerState = settings.Setting((None, None))

    def __init__(self):
        super().__init__()<commit_msg>OWRank: Reduced Data is default output.<commit_after>"""
Rank
====

Rank (score) features for prediction.

"""

from collections import namedtuple

import numpy as np

from PyQt4 import QtGui
from PyQt4.QtCore import Qt

import Orange
from Orange.base import Learner
from Orange.data import ContinuousVariable, DiscreteVariable, Domain, StringVariable
from Orange.preprocess import score
from Orange.canvas import report
from Orange.widgets import widget, settings, gui
from Orange.widgets.utils.sql import check_sql_input


def table(shape, fill=None):
    """ Return a 2D table with shape filed with ``fill``
    """
    return [[fill for j in range(shape[1])] for i in range(shape[0])]


score_meta = namedtuple(
    "score_meta",
    ["name",
     "shortname",
     "score"]
)

# Default scores.
SCORES = [
    score_meta("Information Gain", "Inf. gain", score.InfoGain),
    score_meta("Gain Ratio", "Gain Ratio", score.GainRatio),
    score_meta("Gini Gain", "Gini", score.Gini),
    score_meta("ReliefF", "ReliefF", score.ReliefF),
    score_meta("RReliefF", "RReliefF", score.RReliefF),
    score_meta("FCBF", "FCBF", score.FCBF),
]

_DEFAULT_SELECTED = set(m.name for m in SCORES)


class OWRank(widget.OWWidget):
    name = "Rank"
    description = "Rank and filter data features by their relevance."
    icon = "icons/Rank.svg"
    priority = 1102

    inputs = [("Data", Orange.data.Table, "setData"),
              ("Scorer", score.Scorer, "set_learner", widget.Multiple)]
    outputs = [("Reduced Data", Orange.data.Table, widget.Default),
               ("Scores", Orange.data.Table)]

    SelectNone, SelectAll, SelectManual, SelectNBest = range(4)

    selectMethod = settings.Setting(SelectNBest)
    nSelected = settings.Setting(5)
    auto_apply = settings.Setting(True)

    # Header state for discrete/continuous scores
    headerState = settings.Setting((None, None))

    def __init__(self):
        super().__init__()
{'fraction_non_alphanumeric': 0.12493492972410203, 'fraction_numerical': 0.005726184279021343, 'mean_word_length': 3.8955414012738854, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4413414', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1188, 'n_words': 339}