src.predictive_model.classification package

Subpackages

Submodules

src.predictive_model.classification.apps module

class src.predictive_model.classification.apps.ClassificationConfig(app_name, app_module)

Bases: src.predictive_model.apps.PredictiveModelConfig

name = 'src.predictive_model.classification'

src.predictive_model.classification.classification module

src.predictive_model.classification.custom_classification_models module

class src.predictive_model.classification.custom_classification_models.NNClassifier(**kwargs)

Bases: sklearn.base.ClassifierMixin

Neural Network classifier, implements the same methods as the sklearn models to make it simple to add

fit(train_data, targets)

creates and fits the predictive_model

first the encoded data is parsed, then the predictive_model created and then trained

Parameters:
  • train_data (DataFrame) – encoded training dataset
  • targets (ndarray) – encoded target dataset
Return type:

None

predict(test_data)

returns predictive_model predictions

parses the encoded test dataset, then returns the predictive_model predictions

Parameters:test_data (DataFrame) – encoded test dataset
Return type:ndarray
Returns:predictive_model predictions
predict_proba(test_data)

returns the classification probability

parses the test dataset and returns the raw prediction probabilities of the predictive_model

Parameters:test_data (DataFrame) – encoded test dataset
Return type:ndarray
Returns:predictive_model prediction probabilities
reset()

placeholder to allow use with other sklearn algorithms

Return type:None

src.predictive_model.classification.methods_default_config module

src.predictive_model.classification.methods_default_config.classification_decision_tree()
src.predictive_model.classification.methods_default_config.classification_incremental_adaptive_tree()
src.predictive_model.classification.methods_default_config.classification_incremental_hoeffding_tree()
src.predictive_model.classification.methods_default_config.classification_incremental_naive_bayes()
src.predictive_model.classification.methods_default_config.classification_incremental_perceptron()
src.predictive_model.classification.methods_default_config.classification_incremental_sgd_classifier()
src.predictive_model.classification.methods_default_config.classification_knn()
src.predictive_model.classification.methods_default_config.classification_nn()
src.predictive_model.classification.methods_default_config.classification_random_forest()
src.predictive_model.classification.methods_default_config.classification_xgboost()

src.predictive_model.classification.models module

class src.predictive_model.classification.models.AdaptiveHoeffdingTree(id, model_path, predictive_model, prediction_method, predictivemodel_ptr, classification_ptr, grace_period, split_criterion, split_confidence, tie_threshold, remove_poor_atts, leaf_prediction, nb_threshold)

Bases: src.predictive_model.classification.models.Classification

exception DoesNotExist

Bases: src.predictive_model.classification.models.DoesNotExist

exception MultipleObjectsReturned

Bases: src.predictive_model.classification.models.MultipleObjectsReturned

classification_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

classification_ptr_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_leaf_prediction_display(*, field=<django.db.models.fields.CharField: leaf_prediction>)
get_split_criterion_display(*, field=<django.db.models.fields.CharField: split_criterion>)
grace_period

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

leaf_prediction

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

nb_threshold

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

remove_poor_atts

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

split_confidence

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

split_criterion

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

tie_threshold

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

to_dict()
class src.predictive_model.classification.models.Classification(*args, **kwargs)

Bases: src.predictive_model.models.PredictiveModel

Container of Classification to be shown in frontend

exception DoesNotExist

Bases: src.predictive_model.models.DoesNotExist

exception MultipleObjectsReturned

Bases: src.predictive_model.models.MultipleObjectsReturned

adaptivehoeffdingtree

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

decisiontree

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

hoeffdingtree

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

static init(configuration)
Return type:PredictiveModel
knn

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

naivebayes

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

neuralnetwork

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

perceptron

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

predictivemodel_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

predictivemodel_ptr_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

randomforest

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

sgdclassifier

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

xgboost

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

class src.predictive_model.classification.models.ClassificationMethods

Bases: enum.Enum

An enumeration.

ADAPTIVE_TREE = 'adaptiveTree'
DECISION_TREE = 'decisionTree'
HOEFFDING_TREE = 'hoeffdingTree'
KNN = 'knn'
MULTINOMIAL_NAIVE_BAYES = 'multinomialNB'
NN = 'nn'
PERCEPTRON = 'perceptron'
RANDOM_FOREST = 'randomForest'
SGDCLASSIFIER = 'SGDClassifier'
XGBOOST = 'xgboost'
class src.predictive_model.classification.models.DecisionTree(id, model_path, predictive_model, prediction_method, predictivemodel_ptr, classification_ptr, max_depth, min_samples_split, min_samples_leaf)

Bases: src.predictive_model.classification.models.Classification

exception DoesNotExist

Bases: src.predictive_model.classification.models.DoesNotExist

exception MultipleObjectsReturned

Bases: src.predictive_model.classification.models.MultipleObjectsReturned

classification_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

classification_ptr_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

max_depth

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

min_samples_leaf

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

min_samples_split

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

to_dict()
class src.predictive_model.classification.models.HoeffdingTree(id, model_path, predictive_model, prediction_method, predictivemodel_ptr, classification_ptr, grace_period, split_criterion, split_confidence, tie_threshold, remove_poor_atts, leaf_prediction, nb_threshold)

Bases: src.predictive_model.classification.models.Classification

exception DoesNotExist

Bases: src.predictive_model.classification.models.DoesNotExist

exception MultipleObjectsReturned

Bases: src.predictive_model.classification.models.MultipleObjectsReturned

classification_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

classification_ptr_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_leaf_prediction_display(*, field=<django.db.models.fields.CharField: leaf_prediction>)
get_split_criterion_display(*, field=<django.db.models.fields.CharField: split_criterion>)
grace_period

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

leaf_prediction

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

nb_threshold

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

remove_poor_atts

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

split_confidence

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

split_criterion

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

tie_threshold

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

to_dict()
class src.predictive_model.classification.models.Knn(id, model_path, predictive_model, prediction_method, predictivemodel_ptr, classification_ptr, n_neighbors, weights)

Bases: src.predictive_model.classification.models.Classification

exception DoesNotExist

Bases: src.predictive_model.classification.models.DoesNotExist

exception MultipleObjectsReturned

Bases: src.predictive_model.classification.models.MultipleObjectsReturned

classification_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

classification_ptr_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_weights_display(*, field=<django.db.models.fields.CharField: weights>)
n_neighbors

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

to_dict()
weights

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class src.predictive_model.classification.models.NaiveBayes(id, model_path, predictive_model, prediction_method, predictivemodel_ptr, classification_ptr, alpha, fit_prior)

Bases: src.predictive_model.classification.models.Classification

exception DoesNotExist

Bases: src.predictive_model.classification.models.DoesNotExist

exception MultipleObjectsReturned

Bases: src.predictive_model.classification.models.MultipleObjectsReturned

alpha

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

classification_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

classification_ptr_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

fit_prior

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

to_dict()
class src.predictive_model.classification.models.NeuralNetwork(id, model_path, predictive_model, prediction_method, predictivemodel_ptr, classification_ptr, n_hidden_layers, n_hidden_units, activation, n_epochs, dropout_rate)

Bases: src.predictive_model.classification.models.Classification

exception DoesNotExist

Bases: src.predictive_model.classification.models.DoesNotExist

exception MultipleObjectsReturned

Bases: src.predictive_model.classification.models.MultipleObjectsReturned

activation

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

classification_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

classification_ptr_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

dropout_rate

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_activation_display(*, field=<django.db.models.fields.CharField: activation>)
n_epochs

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

n_hidden_layers

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

n_hidden_units

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

to_dict()
class src.predictive_model.classification.models.Perceptron(id, model_path, predictive_model, prediction_method, predictivemodel_ptr, classification_ptr, penalty, alpha, fit_intercept, tol, shuffle, eta0, validation_fraction, n_iter_no_change)

Bases: src.predictive_model.classification.models.Classification

exception DoesNotExist

Bases: src.predictive_model.classification.models.DoesNotExist

exception MultipleObjectsReturned

Bases: src.predictive_model.classification.models.MultipleObjectsReturned

alpha

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

classification_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

classification_ptr_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

eta0

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

fit_intercept

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_penalty_display(*, field=<django.db.models.fields.CharField: penalty>)
n_iter_no_change

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

penalty

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

shuffle

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

to_dict()
tol

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

validation_fraction

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class src.predictive_model.classification.models.RandomForest(id, model_path, predictive_model, prediction_method, predictivemodel_ptr, classification_ptr, n_estimators, max_depth, max_features)

Bases: src.predictive_model.classification.models.Classification

exception DoesNotExist

Bases: src.predictive_model.classification.models.DoesNotExist

exception MultipleObjectsReturned

Bases: src.predictive_model.classification.models.MultipleObjectsReturned

classification_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

classification_ptr_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

max_depth

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

max_features

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

n_estimators

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

to_dict()
class src.predictive_model.classification.models.SGDClassifier(id, model_path, predictive_model, prediction_method, predictivemodel_ptr, classification_ptr, loss, penalty, alpha, l1_ratio, fit_intercept, tol, epsilon, learning_rate, eta0, power_t, n_iter_no_change, validation_fraction, average)

Bases: src.predictive_model.classification.models.Classification

exception DoesNotExist

Bases: src.predictive_model.classification.models.DoesNotExist

exception MultipleObjectsReturned

Bases: src.predictive_model.classification.models.MultipleObjectsReturned

alpha

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

average

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

classification_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

classification_ptr_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

epsilon

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

eta0

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

fit_intercept

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_learning_rate_display(*, field=<django.db.models.fields.CharField: learning_rate>)
get_loss_display(*, field=<django.db.models.fields.CharField: loss>)
get_penalty_display(*, field=<django.db.models.fields.CharField: penalty>)
l1_ratio

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

learning_rate

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

loss

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

n_iter_no_change

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

penalty

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

power_t

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

to_dict()
tol

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

validation_fraction

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class src.predictive_model.classification.models.XGBoost(id, model_path, predictive_model, prediction_method, predictivemodel_ptr, classification_ptr, n_estimators, max_depth)

Bases: src.predictive_model.classification.models.Classification

exception DoesNotExist

Bases: src.predictive_model.classification.models.DoesNotExist

exception MultipleObjectsReturned

Bases: src.predictive_model.classification.models.MultipleObjectsReturned

classification_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

classification_ptr_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

max_depth

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

n_estimators

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

to_dict()

Module contents