This repository has been archived by the owner on Nov 22, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
classification.pyi
151 lines (139 loc) · 5.11 KB
/
classification.pyi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from typing import overload
from typing import Optional, Union
from pyspark.context import SparkContext
from pyspark.rdd import RDD
from pyspark.mllib._typing import VectorLike
from pyspark.mllib.linalg import Vector
from pyspark.mllib.regression import LabeledPoint, LinearModel, StreamingLinearAlgorithm
from pyspark.mllib.util import Saveable, Loader
from pyspark.streaming.dstream import DStream
from numpy import float64, ndarray # type: ignore[import]
class LinearClassificationModel(LinearModel):
def __init__(self, weights: Vector, intercept: float) -> None: ...
def setThreshold(self, value: float) -> None: ...
@property
def threshold(self) -> Optional[float]: ...
def clearThreshold(self) -> None: ...
@overload
def predict(self, test: VectorLike) -> Union[int, float, float64]: ...
@overload
def predict(self, test: RDD[VectorLike]) -> RDD[Union[int, float]]: ...
class LogisticRegressionModel(LinearClassificationModel):
def __init__(
self, weights: Vector, intercept: float, numFeatures: int, numClasses: int
) -> None: ...
@property
def numFeatures(self) -> int: ...
@property
def numClasses(self) -> int: ...
@overload
def predict(self, x: VectorLike) -> Union[int, float]: ...
@overload
def predict(self, x: RDD[VectorLike]) -> RDD[Union[int, float]]: ...
def save(self, sc: SparkContext, path: str) -> None: ...
@classmethod
def load(cls, sc: SparkContext, path: str) -> LogisticRegressionModel: ...
class LogisticRegressionWithSGD:
@classmethod
def train(
cls,
data: RDD[LabeledPoint],
iterations: int = ...,
step: float = ...,
miniBatchFraction: float = ...,
initialWeights: Optional[VectorLike] = ...,
regParam: float = ...,
regType: str = ...,
intercept: bool = ...,
validateData: bool = ...,
convergenceTol: float = ...,
) -> LogisticRegressionModel: ...
class LogisticRegressionWithLBFGS:
@classmethod
def train(
cls,
data: RDD[LabeledPoint],
iterations: int = ...,
initialWeights: Optional[VectorLike] = ...,
regParam: float = ...,
regType: str = ...,
intercept: bool = ...,
corrections: int = ...,
tolerance: float = ...,
validateData: bool = ...,
numClasses: int = ...,
) -> LogisticRegressionModel: ...
class SVMModel(LinearClassificationModel):
def __init__(self, weights: Vector, intercept: float) -> None: ...
@overload
def predict(self, x: VectorLike) -> float64: ...
@overload
def predict(self, x: RDD[VectorLike]) -> RDD[float64]: ...
def save(self, sc: SparkContext, path: str) -> None: ...
@classmethod
def load(cls, sc: SparkContext, path: str) -> SVMModel: ...
class SVMWithSGD:
@classmethod
def train(
cls,
data: RDD[LabeledPoint],
iterations: int = ...,
step: float = ...,
regParam: float = ...,
miniBatchFraction: float = ...,
initialWeights: Optional[VectorLike] = ...,
regType: str = ...,
intercept: bool = ...,
validateData: bool = ...,
convergenceTol: float = ...,
) -> SVMModel: ...
class NaiveBayesModel(Saveable, Loader[NaiveBayesModel]):
labels: ndarray
pi: ndarray
theta: ndarray
def __init__(self, labels, pi, theta) -> None: ...
@overload
def predict(self, x: VectorLike) -> float64: ...
@overload
def predict(self, x: RDD[VectorLike]) -> RDD[float64]: ...
def save(self, sc: SparkContext, path: str) -> None: ...
@classmethod
def load(cls, sc: SparkContext, path: str) -> NaiveBayesModel: ...
class NaiveBayes:
@classmethod
def train(cls, data: RDD[VectorLike], lambda_: float = ...) -> NaiveBayesModel: ...
class StreamingLogisticRegressionWithSGD(StreamingLinearAlgorithm):
stepSize: float
numIterations: int
regParam: float
miniBatchFraction: float
convergenceTol: float
def __init__(
self,
stepSize: float = ...,
numIterations: int = ...,
miniBatchFraction: float = ...,
regParam: float = ...,
convergenceTol: float = ...,
) -> None: ...
def setInitialWeights(
self, initialWeights: VectorLike
) -> StreamingLogisticRegressionWithSGD: ...
def trainOn(self, dstream: DStream[LabeledPoint]) -> None: ...