예제 #1
0
    def __init__(self, arg, attribute='C', values=[0.1, 1, 10, 100, 1000]):
        """
        :Parameters:
          - `arg` - another Param object, or the classifier to be used
          - `attribute` - the attribute of the classifier that needs tuning
          - `values` - a list of values to try
        """

        if arg.__class__ == self.__class__:
            other = arg
            self.attribute = other.attribute
            self.values = other.values[:]
            self.classifiers = [
                classifier.__class__(classifier)
                for classifier in other.classifiers
            ]
            for i in range(len(self)):
                misc.mysetattr(self.classifiers[i], self.attribute,
                               self.values[i])
        elif hasattr(arg, 'type') and arg.type == 'classifier':
            self.attribute = attribute
            self.values = values
            self.classifiers = [
                arg.__class__(arg) for i in range(len(self.values))
            ]
            for i in range(len(self)):
                misc.mysetattr(self.classifiers[i], self.attribute,
                               self.values[i])
        elif type(arg) == type([]):
            self.classifiers = [
                arg[i].__class__(arg[i]) for i in range(len(arg))
            ]
예제 #2
0
    def __init__(self, arg, attribute = 'C', values = [0.1, 1, 10, 100, 1000]) :
        """
        :Parameters:
          - `arg` - another Param object, or the classifier to be used
          - `attribute` - the attribute of the classifier that needs tuning
          - `values` - a list of values to try
        """

        if arg.__class__ == self.__class__ :
            other = arg
            self.attribute = other.attribute
            self.values = other.values[:]
            self.classifiers = [classifier.__class__(classifier)
                                for classifier in other.classifiers]
            for i in range(len(self)) :
                misc.mysetattr(self.classifiers[i], self.attribute, self.values[i])
        elif hasattr(arg, 'type') and arg.type == 'classifier' :
            self.attribute = attribute
            self.values = values
            self.classifiers = [arg.__class__(arg)
                                for i in range(len(self.values))]
            for i in range(len(self)) :
                misc.mysetattr(self.classifiers[i], self.attribute, self.values[i])
        elif type(arg) == type([]) :
            self.classifiers = [arg[i].__class__(arg[i])
                                for i in range(len(arg))]
예제 #3
0
    def __init__(self,
                 arg,
                 attribute1='C',
                 values1=[0.1, 1, 10, 100, 1000],
                 attribute2='kernel.gamma',
                 values2=[0.001, 0.01, 0.1, 1, 10]):
        """
        :Parameters:
          - `arg` - another Param object, or the classifier to be used
          - `attribute1` - the first attribute of the classifier that needs tuning
          - `values1` - a list of values to try for attribute1
          - `attribute2` - the second attribute 
          - `values2` - a list of values to try for attribute2
          
        """

        if arg.__class__ == self.__class__:
            other = arg
            self.attribute1 = other.attribute1
            self.values1 = other.values1[:]
            self.attribute2 = other.attribute2
            self.values2 = other.values2[:]
            self.classifiers = [
                classifier.__class__(classifier)
                for classifier in other.classifiers
            ]
        elif hasattr(arg, 'type') and arg.type == 'classifier':
            self.attribute1 = attribute1
            self.values1 = values1
            self.attribute2 = attribute2
            self.values2 = values2

            self.classifiers = [
                arg.__class__(arg) for i in range(len(values1) * len(values2))
            ]

        for i in range(len(self.values1)):
            for j in range(len(self.values2)):
                classifierID = i * len(self.values2) + j
                misc.mysetattr(self.classifiers[classifierID], self.attribute1,
                               self.values1[i])
                misc.mysetattr(self.classifiers[classifierID], self.attribute2,
                               self.values2[j])
예제 #4
0
    def __init__(self, arg,
                 attribute1 = 'C', values1 = [0.1, 1, 10, 100, 1000],
                 attribute2 = 'kernel.gamma', values2 = [0.001, 0.01, 0.1, 1, 10]) :

        """
        :Parameters:
          - `arg` - another Param object, or the classifier to be used
          - `attribute1` - the first attribute of the classifier that needs tuning
          - `values1` - a list of values to try for attribute1
          - `attribute2` - the second attribute 
          - `values2` - a list of values to try for attribute2
          
        """


        if arg.__class__ == self.__class__ :
            other = arg
            self.attribute1 = other.attribute1
            self.values1 = other.values1[:]
            self.attribute2 = other.attribute2
            self.values2 = other.values2[:]
            self.classifiers = [classifier.__class__(classifier)
                                for classifier in other.classifiers]
        elif hasattr(arg, 'type') and arg.type == 'classifier' :
            self.attribute1 = attribute1
            self.values1 = values1
            self.attribute2 = attribute2
            self.values2 = values2
            
            self.classifiers = [arg.__class__(arg)
                                for i in range(len(values1) * len(values2))]

        for i in range(len(self.values1)) :
            for j in range(len(self.values2)) :
                classifierID = i * len(self.values2) + j
                misc.mysetattr(self.classifiers[classifierID],
                               self.attribute1,
                               self.values1[i])
                misc.mysetattr(self.classifiers[classifierID],
                               self.attribute2,
                               self.values2[j])