• Stars
    star
    261
  • Rank 155,739 (Top 4 %)
  • Language
    Python
  • License
    Other
  • Created over 8 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A python port of the glmnet package for fitting generalized linear models via penalized maximum likelihood.

Python GLMNET

Build status Latest version on conda forge Latest version on PyPI Supported python versions for python-glmnet

This is a Python wrapper for the fortran library used in the R package glmnet. While the library includes linear, logistic, Cox, Poisson, and multiple-response Gaussian, only linear and logistic are implemented in this package.

The API follows the conventions of Scikit-Learn, so it is expected to work with tools from that ecosystem.

Installation

requirements

python-glmnet requires Python version >= 3.6, scikit-learn, numpy, and scipy. Installation from source or via pip requires a Fortran compiler.

conda

conda install -c conda-forge glmnet

pip

pip install glmnet

source

glmnet depends on numpy, scikit-learn and scipy. A working Fortran compiler is also required to build the package. For Mac users, brew install gcc will take care of this requirement.

git clone [email protected]:civisanalytics/python-glmnet.git
cd python-glmnet
python setup.py install

Usage

General

By default, LogitNet and ElasticNet fit a series of models using the lasso penalty (伪 = 1) and up to 100 values for 位 (determined by the algorithm). In addition, after computing the path of 位 values, performance metrics for each value of 位 are computed using 3-fold cross validation. The value of 位 corresponding to the best performing model is saved as the lambda_max_ attribute and the largest value of 位 such that the model performance is within cut_point * standard_error of the best scoring model is saved as the lambda_best_ attribute.

The predict and predict_proba methods accept an optional parameter lamb which is used to select which model(s) will be used to make predictions. If lamb is omitted, lambda_best_ is used.

Both models will accept dense or sparse arrays.

Regularized Logistic Regression

from glmnet import LogitNet

m = LogitNet()
m = m.fit(x, y)

Prediction is similar to Scikit-Learn:

# predict labels
p = m.predict(x)
# or probability estimates
p = m.predict_proba(x)

Regularized Linear Regression

from glmnet import ElasticNet

m = ElasticNet()
m = m.fit(x, y)

Predict:

p = m.predict(x)

More Repositories

1

swagger-diff

Utility for comparing two Swagger specifications.
Ruby
262
star
2

ruby_audit

Checks Ruby and RubyGems against known security vulnerabilities.
Ruby
70
star
3

civisml-extensions

scikit-learn-compatible estimators from Civis Analytics
Python
59
star
4

muffnn

Multilayer Feed-Forward Neural Network predictive model implementations with TensorFlow and scikit-learn
Python
45
star
5

civis-python

Civis API Client for Python: https://civisanalytics.com/products/civis-platform/
Python
34
star
6

dpwgan

Differentially-private Wasserstein GAN implementation in PyTorch
Python
27
star
7

iam-role-injector

Assumes an IAM role via awscli STS call, injecting temporary credentials into shell environment
Shell
26
star
8

datascience-python

Common dependencies for data science workflows
Python
25
star
9

potato

d3 force graph viz tool
CoffeeScript
25
star
10

tableau_api

Ruby interface to the Tableau API
Ruby
22
star
11

civis-r

Civis API Client for R: https://civisanalytics.com/products/civis-platform/
R
16
star
12

workflows-public

Civis workflows examples.
Python
13
star
13

d3_tutorial

How to use D3 to build data visualizations.
HTML
12
star
14

async-graph-data-flow

Asynchronous functions that pass data along a directed acyclic graph
Python
12
star
15

datascience-r

Docker image for R.
Dockerfile
11
star
16

civis-d4bl-data-viz

Materials for the 'Data Visualization for Black Lives' workshop presented by Brecia Young and Cameron Clarke (Civis Analytics) at the 2019 Data for Black Lives II conference.
R
11
star
17

GephiForceDiagramTool

Command-line tool for building Gephi force-directed graph diagrams.
Java
10
star
18

go-makefile

Compile a go project, package it to a defined format, and push a release to GitHub.
Shell
6
star
19

mistral_client

Ruby client for Mistral, OpenStack's workflow service
Ruby
5
star
20

civis-jupyter-r

Custom Jupyter Notebook image for R
Dockerfile
4
star
21

platform-code-examples

JavaScript
4
star
22

model-deployment

App for deploying CivisML models as web APIs
Python
3
star
23

gogelf

Go Library for the Graylog Extended Log Format
Go
3
star
24

civis-jupyter-python3

Custom Jupyter Notebook image for Python 3
Dockerfile
3
star
25

civis_political_r_training

An R package for the "Introduction to Data Munging and Visualization in R" session at the Civis 2019 Political Community Summit.
R
2
star
26

civis-jupyter-python2

Custom Jupyter Notebook image for Python 2
Dockerfile
1
star
27

civis-services-streamlit

Civis Services Docker Image for Streamlit
Python
1
star
28

civis-services-flask

Example Flask app hosted in Civis
Python
1
star