File: sgd.py

package info (click to toggle)
orange3 3.40.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 15,912 kB
  • sloc: python: 162,745; ansic: 622; makefile: 322; sh: 93; cpp: 77
file content (23 lines) | stat: -rw-r--r-- 851 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from sklearn.linear_model import SGDClassifier

from Orange.base import SklLearner
from Orange.preprocess import Normalize
from Orange.regression.linear import LinearModel

__all__ = ["SGDClassificationLearner"]


class SGDClassificationLearner(SklLearner):
    name = 'sgd'
    __wraps__ = SGDClassifier
    __returns__ = LinearModel
    preprocessors = SklLearner.preprocessors + [Normalize()]
    supports_weights = True

    def __init__(self, loss='hinge', penalty='l2', alpha=0.0001,
                 l1_ratio=0.15, fit_intercept=True, max_iter=5,
                 tol=1e-3, shuffle=True, epsilon=0.1, random_state=None,
                 learning_rate='invscaling', eta0=0.01, power_t=0.25,
                 warm_start=False, average=False, preprocessors=None):
        super().__init__(preprocessors=preprocessors)
        self.params = vars()