<commit_before>import sys
import math

from PyQt4 import QtGui
from PyQt4.QtCore import Qt

import numpy as np
import sklearn.cross_validation as skl_cross_validation

from Orange.widgets import widget, gui
from Orange.widgets.settings import Setting
from Orange.data.table import Table
from Orange.data import DiscreteVariable


class OWDataSampler(widget.OWWidget):
    name = "Data Sampler"
    description = "Selects a subset of instances from the data set."
    icon = "icons/DataSampler.svg"
    priority = 100
    category = "Data"
    keywords = ["data", "sample"]
    inputs = [("Data", Table, "set_data")]
    outputs = [("Data Sample", Table), ("Remaining Data", Table)]

    want_main_area = False

    RandomSeed = 42
    FixedSize, FixedProportion, CrossValidation = range(3)

    use_seed = Setting(False)
    replacement = Setting(False)
    stratify = Setting(False)
    sampling_type = Setting(0)
    sampleSizeNumber = Setting(1)
    sampleSizePercentage = Setting(70)
    number_of_folds = Setting(10)
    selectedFold = Setting(1)

    def __init__(self):
        super().__init__()
        self.data = None
        self.indices = None

        box = gui.widgetBox(self.controlArea, "Information")
        self.dataInfoLabel = gui.widgetLabel(box, 'No data on input.')
        self.outputInfoLabel = gui.widgetLabel(box, ' ')

        box = gui.widgetBox(self.controlArea, "Sampling Type")
        sampling = gui.radioButtons(
            box, self, "sampling_type", callback=self.sampling_type_changed)

        def set_sampling_type(i):
            def f():
                self.sampling_type = i
                self.sampling_type_changed()
            return f

        gui.appendRadioButton(sampling, "Fixed sample size:")
        ibox = gui.indentedBox(sampling)
        self.sampleSizeSpin = gui.spin(
            ibox, self, "sampleSizeNumber", label="Instances: ",
            minv=1, maxv=2 ** 31 - 1,
            callback=set_sampling_type(self.FixedSize))
        gui.checkBox(
            ibox, self, "replacement", "Sample with replacement",
            callback=set_sampling_type(self.FixedSize))
        gui.separator(sampling, 12)

        gui.appendRadioButton(sampling, "Fixed proportion of data:")
        self.sampleSizePercentageSlider = gui.hSlider(
            gui.indentedBox(sampling), self,
            "sampleSizePercentage",
            minValue=0, maxValue=100, ticks=10, labelFormat="%d %%",
            callback=set_sampling_type(self.FixedProportion))

        gui.separator(sampling, 12)
        gui.appendRadioButton(sampling, "Cross Validation:")
        form = QtGui.QFormLayout(<commit_msg>Change the default sampling in Data sampler widget<commit_after>import sys
import math

from PyQt4 import QtGui
from PyQt4.QtCore import Qt

import numpy as np
import sklearn.cross_validation as skl_cross_validation

from Orange.widgets import widget, gui
from Orange.widgets.settings import Setting
from Orange.data.table import Table
from Orange.data import DiscreteVariable


class OWDataSampler(widget.OWWidget):
    name = "Data Sampler"
    description = "Selects a subset of instances from the data set."
    icon = "icons/DataSampler.svg"
    priority = 100
    category = "Data"
    keywords = ["data", "sample"]
    inputs = [("Data", Table, "set_data")]
    outputs = [("Data Sample", Table), ("Remaining Data", Table)]

    want_main_area = False

    RandomSeed = 42
    FixedProportion, FixedSize, CrossValidation = range(3)

    use_seed = Setting(False)
    replacement = Setting(False)
    stratify = Setting(False)
    sampling_type = Setting(FixedProportion)
    sampleSizeNumber = Setting(1)
    sampleSizePercentage = Setting(70)
    number_of_folds = Setting(10)
    selectedFold = Setting(1)

    def __init__(self):
        super().__init__()
        self.data = None
        self.indices = None

        box = gui.widgetBox(self.controlArea, "Information")
        self.dataInfoLabel = gui.widgetLabel(box, 'No data on input.')
        self.outputInfoLabel = gui.widgetLabel(box, ' ')

        box = gui.widgetBox(self.controlArea, "Sampling Type")
        sampling = gui.radioButtons(
            box, self, "sampling_type", callback=self.sampling_type_changed)

        def set_sampling_type(i):
            def f():
                self.sampling_type = i
                self.sampling_type_changed()
            return f

        gui.appendRadioButton(sampling, "Fixed proportion of data:")
        self.sampleSizePercentageSlider = gui.hSlider(
            gui.indentedBox(sampling), self,
            "sampleSizePercentage",
            minValue=0, maxValue=100, ticks=10, labelFormat="%d %%",
            callback=set_sampling_type(self.FixedProportion))

        gui.appendRadioButton(sampling, "Fixed sample size:")
        ibox = gui.indentedBox(sampling)
        self.sampleSizeSpin = gui.spin(
            ibox, self, "sampleSizeNumber", label="Instances: ",
            minv=1, maxv=2 ** 31 - 1,
            callback=set_sampling_type(self.FixedSize))
        gui.checkBox(
            ibox, self, "replacement", "Sample with replacement",
            callback=set_sampling_type(self.FixedSize))
        gui.separator(sampling, 12)

        gui.separator(sampling, 12)
        gui.appendRadioButton(sampling, "Cross Validation:")
        form = QtGui.QFormLayout(
{'fraction_non_alphanumeric': 0.10095344924284913, 'fraction_numerical': 0.011030099083940923, 'mean_word_length': 2.8768115942028984, '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': '6942477', 'n_tokens_mistral': 1658, 'n_tokens_neox': 1527, 'n_words': 370}