Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, eta=0.01, epochs=50,
minibatches=None, random_seed=None,
print_progress=0):
_BaseModel.__init__(self)
_IterativeModel.__init__(self)
_Classifier.__init__(self)
self.eta = eta
self.minibatches = minibatches
self.epochs = epochs
self.random_seed = random_seed
self.print_progress = print_progress
self._is_fitted = False
# mlxtend Machine Learning Library Extensions
#
# Estimator for Linear Regression
# Author: Sebastian Raschka
#
# License: BSD 3 clause
import numpy as np
from .._base import _Cluster
from .._base import _BaseModel
from .._base import _IterativeModel
# from scipy.spatial.distance import euclidean
class Kmeans(_BaseModel, _Cluster, _IterativeModel):
""" K-means clustering class.
Added in 0.4.1dev
Parameters
------------
k : int
Number of clusters
max_iter : int (default: 10)
Number of iterations during cluster assignment.
Cluster re-assignment stops automatically when the algorithm
converged.
convergence_tolerance : float (default: 1e-05)
Compares current centroids with centroids of the previous iteration
using the given tolerance (a small positive float)to determine
if the algorithm converged early.
# mlxtend Machine Learning Library Extensions
#
# Estimator for Linear Regression
# Author: Sebastian Raschka
#
# License: BSD 3 clause
import tensorflow as tf
import numpy as np
from time import time
from .._base import _Cluster
from .._base import _BaseModel
from .._base import _IterativeModel
class TfKmeans(_BaseModel, _Cluster, _IterativeModel):
""" TensorFlow K-means clustering class.
Added in 0.4.1dev
Parameters
------------
k : int
Number of clusters
max_iter : int (default: 10)
Number of iterations during cluster assignment.
Cluster re-assignment stops automatically when the algorithm
converged.
convergence_tolerance : float (default: 1e-05)
Compares current centroids with centroids of the previous iteration
using the given tolerance (a small positive float)to determine
if the algorithm converged early.
# mlxtend Machine Learning Library Extensions
#
# Estimator for Linear Regression
# Author: Sebastian Raschka
#
# License: BSD 3 clause
import numpy as np
import tensorflow as tf
from time import time
from .._base import _BaseModel
from .._base import _IterativeModel
from .._base import _Regressor
class TfLinearRegression(_BaseModel, _IterativeModel, _Regressor):
"""Estimator for Linear Regression in TensorFlow using Gradient Descent.
Added in version 0.4.1
"""
def __init__(self, eta=0.1, epochs=50, print_progress=0,
random_seed=None, dtype=None):
"""
Parameters
------------
eta : float (default: 0.01)
solver rate (between 0.0 and 1.0)
epochs : int (default: 50)
Passes over the training dataset.
print_progress : int (default: 0)
# Implementation of a Multi-layer Perceptron in Tensorflow
# Author: Sebastian Raschka
#
# License: BSD 3 clause
import numpy as np
from time import time
from scipy.special import expit
from .._base import _BaseModel
from .._base import _IterativeModel
from .._base import _MultiClass
from .._base import _MultiLayer
from .._base import _Classifier
class MultiLayerPerceptron(_BaseModel, _IterativeModel,
_MultiClass, _MultiLayer, _Classifier):
"""Multi-layer perceptron classifier with logistic sigmoid activations
Parameters
------------
eta : float (default: 0.5)
Learning rate (between 0.0 and 1.0)
epochs : int (default: 50)
Passes over the training dataset.
Prior to each epoch, the dataset is shuffled
if `minibatches > 1` to prevent cycles in stochastic gradient descent.
hidden_layers : list (default: [50])
Number of units per hidden layer. By default 50 units in the
first hidden layer. At the moment only 1 hidden layer is supported
n_classes : int (default: None)