Giter Club home page Giter Club logo

classificationlib's Introduction

logo.png

Complete ML toolset for classification-based prediction problems.

Install + Import:

Release v1.0 (download and unzip)

# importing all library modules:
import dataframe
import correlation_module
import sqrt_distance_classifier
import abs_distance_classifier
import percent_distance_classifier
import stddev_distance_classifier
import knn
import classnet

Initializing Dataframe + Correlating Input Features to Output Feature:

df = dataframe.Dataframe('test-data/drug200.csv')
correlation_module.run(df)
output:

highest correlation
---
Na_to_K
Cholesterol
BP
Sex
Age
---
lowest correlation

Example CSV Format (Drug200 Dataset)

Training + Predictions - Square Root Distance Classifier:

 # (dataframe, input features)
model = sqrt_distance_classifier.train(df, ['Na_to_K', 'Cholesterol', 'BP'])
 # (model, dataframe, output feature)
print(sqrt_distance_classifier.eval(model, df, 'Drug')) # get accuracy
output: 0.7
point = {
    'Age': 23,
    'Sex': 'F',
    'BP': 'HIGH',
    'Cholesterol': 'HIGH',
    'Na_to_K': 25.355
}
point_numerical = df.convert_point(point)
# (converted numerical point, model)
print(sqrt_distance_classifier.predict(point_numerical, model))
output: DrugY

Training + Predictions - Absolute Distance Classifier:

# (dataframe, input features)
model = abs_distance_classifier.train(df, ['Na_to_K', 'BP', 'Sex'])
# (model, dataframe, output feature)
print(abs_distance_classifier.eval(model, df, 'Drug')) # get accuracy
output: 0.7
point = {
    'Age': 23,
    'Sex': 'F',
    'BP': 'HIGH',
    'Cholesterol': 'HIGH',
    'Na_to_K': 25.355
}
point_numerical = df.convert_point(point)
# (converted numerical point, model)
print(abs_distance_classifier.predict(point_numerical, model))
output: DrugY

Training + Predictions - Percent Distance Classifier:

# (dataframe, input features)
model = percent_distance_classifier.train(df, ['Na_to_K', 'BP', 'Age'])
# (model, dataframe, output feature)
print(percent_distance_classifier.eval(model, df, 'Drug')) # get accuracy
output: 0.715
point = {
    'Age': 23,
    'Sex': 'F',
    'BP': 'HIGH',
    'Cholesterol': 'HIGH',
    'Na_to_K': 25.355
}
point_numerical = df.convert_point(point)
# (converted numerical point, model)
print(percent_distance_classifier.predict(point_numerical, model))
output: DrugY

Training + Predictions - Standard Deviation Distance Classifier:

# (dataframe, input features)
model = stddev_distance_classifier.train(df, ['Na_to_K', 'BP', 'Age'])
# (model, dataframe, output feature)
print(stddev_distance_classifier.eval(model, df, 'Drug')) # get accuracy
output: 0.705
point = {
    'Age': 23,
    'Sex': 'F',
    'BP': 'HIGH',
    'Cholesterol': 'HIGH',
    'Na_to_K': 25.355
}
point_numerical = df.convert_point(point)
# (converted numerical point, model)
print(stddev_distance_classifier.predict(point_numerical, model))
output: DrugY

Training + Predictions - ClassNet:

# (dataframe, input features)
model = classnet.train(df, ['Na_to_K', 'Cholesterol', 'Sex', 'BP', 'Age'])
# (model, dataframe, output feature)
print(classnet.eval(model, df, 'Drug')) # get accuracy
output: 0.24
point = {
    'Age': 23,
    'Sex': 'F',
    'BP': 'HIGH',
    'Cholesterol': 'HIGH',
    'Na_to_K': 25.355
}
point_numerical = df.convert_point(point)
# (converted numerical point, model)
print(classnet.predict(point_numerical, model))
output: DrugC

Training + Predictions - KNN:

df = dataframe.Dataframe('test-data/drug200.csv')
# (dataframe, input features, training dataset ratio)
model = knn.train(df, ['Na_to_K', 'Cholesterol', 'BP'], 'Drug', 0.5)
# (model, dataframe, output feature)
print(knn.eval(model, df, 'Drug'))
output: 0.88
point = {
    'Age': 23,
    'Sex': 'F',
    'BP': 'HIGH',
    'Cholesterol': 'HIGH',
    'Na_to_K': 25.355
}
point_numerical = df.convert_point(point)
# (converted numerical point, output feature, model)
print(knn.predict(point_numerical, 'Drug', model))
output: DrugY

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.