Skip to main content

a library used for stacking based on scikit-learn

Project description

SKNet

Introduction

SKNet is a new type of neural network that is simple in structure but complex in neuron. Each of its neuron is a traditional estimator such as SVM, RF, etc.

Fetaures

We think that such a network has many applicable scenarios.

  • We don't have enough samples to train neural networks.
  • We hope to improve the accuracy of the model by means of emsemble.
  • We hope to learn some new features.
  • We want to save a lot of parameter adjustment time while getting a stable and good model.

Installation

pip install sknet

Example

Computation Graph

Code

from sknet.sequential import Layer,Sequential,SKNeuron

from sklearn.ensemble import RandomForestRegressor
from sklearn.ensemble import AdaBoostRegressor
from sklearn.ensemble import ExtraTreesRegressor
from sklearn.svm import LinearSVR
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.neighbors import KNeighborsRegressor


from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split


data = load_breast_cancer()
features = data.data
target = data.target

X_train, X_test, y_train, y_test = train_test_split(features, target, test_size=0.2, random_state=42)



layer1 = Layer([
    SKNeuron(RandomForestRegressor,params = {"random_state": 0}),
    SKNeuron(GradientBoostingRegressor,params = {"random_state": 0}),
    SKNeuron(AdaBoostRegressor,params = {"random_state": 0}),
    SKNeuron(KNeighborsRegressor),
    SKNeuron(ExtraTreesRegressor,params = {"random_state": 0}),
])

layer2 = Layer([
    SKNeuron(AdaBoostRegressor,params = {"random_state": 0}),
    SKNeuron(LinearSVR,params = {"random_state": 0}),
])

layer3 = Layer([
    SKNeuron(LogisticRegression,params = {"random_state": 0}),
])


model = Sequential([layer1,layer2,layer3],n_splits = 5)
y_pred = model.fit_predict(X_train,y_train, X_test)
print(model.score(y_test,y_pred))


# acc = 0.9736842105263158

Todo

  • Two or three level stacking
  • multi-processing
  • features proxy

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

SKNet-0.0.1.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file SKNet-0.0.1.tar.gz.

File metadata

  • Download URL: SKNet-0.0.1.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.7.3

File hashes

Hashes for SKNet-0.0.1.tar.gz
Algorithm Hash digest
SHA256 ffcb669c4a20230b3ccef30ca837915ae0b14bbe13129ac97ec66cb4cca3fc11
MD5 07921edaff56bcc6bf221e70196adb93
BLAKE2b-256 7e1ab533ba48054794b41898f4cccd18387586a6b4c568975e696c3ae5692e71

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page