Skip to content

F3licity/yart

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yet another regression toolkit

YART implements linear, logistic and ordinal regression with L2 regularization.

LBFGS is used to minimize the loss functions.

Linear regression example

from sklearn import datasets, cross_validation, metrics
from scipy.sparse import csr_matrix
from yart import LinearRegression
diabetes = datasets.load_diabetes()
X = csr_matrix(diabetes.data)
y = diabetes.target
X_train, X_test, y_train, y_test = cross_validation.train_test_split(X, y, test_size=0.5)
model = LinearRegression(l2=0.1)
model.fit(X_train, y_train)
print('MAE: {}'.format(metrics.mean_absolute_error(model.predict(X_test), y_test)))

Logistic regression example

from sklearn import datasets, cross_validation, metrics
from scipy.sparse import csr_matrix
from yart import LogisticRegression
digits = datasets.load_digits()
X = csr_matrix(digits.data)
y = digits.target
X_train, X_test, y_train, y_test = cross_validation.train_test_split(X, y, test_size=0.5)
model = LogisticRegression(l2=0.1)
model.fit(X_train, y_train)
print('Accuracy: {}'.format(metrics.accuracy_score(model.predict(X_test), y_test)))

Ordinal regression example

import numpy
from sklearn import datasets, cross_validation, metrics
from scipy.sparse import csr_matrix
from yart import OrdinalRegression
boston = datasets.load_boston()
X = csr_matrix(boston.data)
y = numpy.round(boston.target/10)
X_train, X_test, y_train, y_test = cross_validation.train_test_split(X, y, test_size=0.5)
model = OrdinalRegression(l2=0.1)
model.fit(X_train, y_train)
print('MAE: {}'.format(metrics.mean_absolute_error(model.predict(X_test), y_test)))

About

Yet another regression toolkit

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%