Skip to content

Commit

Permalink
isort
Browse files Browse the repository at this point in the history
  • Loading branch information
louisabraham committed Aug 24, 2024
1 parent 118051e commit a84ed7b
Show file tree
Hide file tree
Showing 18 changed files with 58 additions and 71 deletions.
10 changes: 4 additions & 6 deletions examples/boston_housing.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#!/usr/bin/env python

from sklearn.datasets import load_boston
from sklearn.preprocessing import StandardScaler
from sklearn.preprocessing import scale
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error
import matplotlib.pyplot as plt
import numpy as np
from sklearn.datasets import load_boston
from sklearn.metrics import mean_squared_error
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler, scale

from lassonet import LassoNetRegressor


dataset = load_boston()
X = dataset.data
y = dataset.target
Expand Down
10 changes: 4 additions & 6 deletions examples/boston_housing_group.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#!/usr/bin/env python

from sklearn.datasets import load_boston
from sklearn.preprocessing import StandardScaler
from sklearn.preprocessing import scale
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error
import matplotlib.pyplot as plt
import numpy as np
from sklearn.datasets import load_boston
from sklearn.metrics import mean_squared_error
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler, scale

from lassonet import LassoNetRegressor


dataset = load_boston()
X = dataset.data
y = dataset.target
Expand Down
16 changes: 6 additions & 10 deletions examples/cox_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,18 @@

from pathlib import Path
from time import time
from matplotlib import pyplot as plt

import numpy as np
import pandas as pd
from tqdm import tqdm

from sklearn import preprocessing
from sklearn.model_selection import train_test_split, StratifiedKFold

import sksurv.datasets

from lassonet import LassoNetCoxRegressorCV

from joblib import Parallel, delayed
from matplotlib import pyplot as plt
from sklearn import preprocessing
from sklearn.model_selection import StratifiedKFold, train_test_split
from tqdm import tqdm
from tqdm_joblib import tqdm_joblib

from lassonet import plot_cv
from lassonet import LassoNetCoxRegressorCV, plot_cv
from lassonet.utils import confidence_interval

DATA_PATH = Path(__file__).parent / "data"
Expand Down
2 changes: 1 addition & 1 deletion examples/cox_regression.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env python
from pathlib import Path

import matplotlib.pyplot as plt
import numpy as np
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt

from lassonet import LassoNetCoxRegressor, plot_path

Expand Down
8 changes: 3 additions & 5 deletions examples/diabetes.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#!/usr/bin/env python

from sklearn.datasets import load_diabetes
from sklearn.preprocessing import StandardScaler
from sklearn.preprocessing import scale
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
import numpy as np
from sklearn.datasets import load_diabetes
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler, scale

from lassonet import LassoNetRegressor, plot_path


dataset = load_diabetes()
X = dataset.data
y = dataset.target
Expand Down
7 changes: 3 additions & 4 deletions examples/friedman.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import matplotlib.pyplot as plt
import numpy as np
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
from sklearn.metrics import r2_score
import matplotlib.pyplot as plt

from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler

from lassonet import LassoNetRegressor, plot_path

Expand Down
5 changes: 2 additions & 3 deletions examples/friedman/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import matplotlib.pyplot as plt
import numpy as np
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import r2_score
import matplotlib.pyplot as plt

from sklearn.preprocessing import StandardScaler

from lassonet import LassoNetRegressor, plot_path

Expand Down
5 changes: 2 additions & 3 deletions examples/generated.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from functools import partial

import numpy as np
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
from sklearn.metrics import r2_score

from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler

from lassonet import LassoNetRegressor, plot_path

Expand Down
7 changes: 3 additions & 4 deletions examples/miceprotein.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
Each feature is the expression level of one protein.
"""

import matplotlib.pyplot as plt
from sklearn.datasets import fetch_openml
from sklearn.impute import SimpleImputer
from sklearn.preprocessing import StandardScaler, LabelEncoder
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
from sklearn.preprocessing import LabelEncoder, StandardScaler

from lassonet import LassoNetClassifier, plot_path
from lassonet import LassoNetClassifier, plot_cv, plot_path
from lassonet.interfaces import LassoNetClassifierCV
from lassonet import plot_cv

X, y = fetch_openml(name="miceprotein", return_X_y=True)
# Fill missing values with the mean
Expand Down
5 changes: 3 additions & 2 deletions examples/mnist_ae.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import matplotlib.pyplot as plt
from sklearn.datasets import fetch_openml
from lassonet import LassoNetAutoEncoder
from sklearn.metrics import mean_squared_error
import matplotlib.pyplot as plt

from lassonet import LassoNetAutoEncoder

X, y = fetch_openml(name="mnist_784", return_X_y=True)
filter = y == "3"
Expand Down
6 changes: 3 additions & 3 deletions examples/mnist_classif.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import matplotlib.pyplot as plt
from sklearn.datasets import fetch_openml
from sklearn.preprocessing import LabelEncoder
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder

from lassonet import LassoNetClassifier

Expand Down
5 changes: 3 additions & 2 deletions examples/mnist_reconstruction.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import matplotlib.pyplot as plt
from sklearn.datasets import fetch_openml
from lassonet import LassoNetRegressor
from sklearn.metrics import mean_squared_error
import matplotlib.pyplot as plt

from lassonet import LassoNetRegressor

X, y = fetch_openml(name="mnist_784", return_X_y=True)
filter = y == "3"
Expand Down
12 changes: 6 additions & 6 deletions experiments/data_utils.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import pickle
from collections import defaultdict
from os.path import join
from pathlib import Path
from sklearn.model_selection import train_test_split
from collections import defaultdict

import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import MinMaxScaler


# The code to load some of these datasets is reproduced from
# https://github.com/mfbalin/Concrete-Autoencoders/blob/master/experiments/generate_comparison_figures.py

import numpy as np
from sklearn.preprocessing import MinMaxScaler


def load_mice(one_hot=False):
Expand Down Expand Up @@ -181,9 +179,10 @@ def load_epileptic():
return (X[:8000], Y[:8000]), (X[8000:], Y[8000:])


from PIL import Image
import os

from PIL import Image


def load_coil():
samples = []
Expand Down Expand Up @@ -294,6 +293,7 @@ def load_mnist_two_digits(digit1, digit2):


import os

from sklearn.preprocessing import MinMaxScaler


Expand Down
12 changes: 6 additions & 6 deletions lassonet/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# flake8: noqa
from .model import LassoNet
from .prox import prox
from .interfaces import (
LassoNetClassifier,
LassoNetRegressor,
LassoNetCoxRegressor,
LassoNetClassifierCV,
LassoNetRegressorCV,
LassoNetCoxRegressor,
LassoNetCoxRegressorCV,
LassoNetRegressor,
LassoNetRegressorCV,
lassonet_path,
)
from .plot import plot_path, plot_cv
from .model import LassoNet
from .plot import plot_cv, plot_path
from .prox import prox
2 changes: 1 addition & 1 deletion lassonet/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from torch import nn
from torch.nn import functional as F

from .prox import inplace_prox, inplace_group_prox, prox
from .prox import inplace_group_prox, inplace_prox, prox


class LassoNet(nn.Module):
Expand Down
2 changes: 1 addition & 1 deletion lassonet/plot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import matplotlib.pyplot as plt
from .interfaces import BaseLassoNetCV

from .interfaces import BaseLassoNetCV
from .utils import confidence_interval, eval_on_path


Expand Down
11 changes: 5 additions & 6 deletions lassonet/r.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from dataclasses import asdict
import torch
from .interfaces import (
lassonet_path as _lassonet_path,
LassoNetClassifier,
LassoNetRegressor,
)

import numpy as np
import torch

from .interfaces import LassoNetClassifier, LassoNetRegressor
from .interfaces import lassonet_path as _lassonet_path


def make_writable(x):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_interface.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from lassonet import LassoNetRegressor, LassoNetClassifier

from sklearn.datasets import load_diabetes, load_digits

from lassonet import LassoNetClassifier, LassoNetRegressor


def test_regressor():
X, y = load_diabetes(return_X_y=True)
Expand Down

0 comments on commit a84ed7b

Please sign in to comment.