Commit Graph

591 Commits

Author SHA1 Message Date
MechCoder 7e79adca9d Huber regressor
Add gradient calculation in _huber_loss_and_gradient

Add tests to check the correctness of the loss and gradient

Fix for old scipy

Add parameter sigma for robust linear regression

Add gradient formula to robust _huber_loss_and_gradient

Add fit_intercept option and fix tests

Add docs to HuberRegressor and the helper functions

Add example demonstrating ridge_regression vs huber_regression

Add sample_weight implementation

Add scaling invariant huber test

Remove exp and add bounds to fmin_l_bfgs_b

Add sparse data support

Add more tests and refactoring of code

Add narrative docs

review huber regressor

Minor additions to docs and tests

Minor fixes that deals with dealing with NaN values in targets
and old verions of SciPy and NumPy

Add HuberRegressor to robust estimator

Refactored computation of gradient and make docs render properly

Temp

Remove float64 dtype conversion

trivial optimizations and add a note about R

Remove sample_weights special_casing

address @amueller comments
2016-02-25 16:31:08 -05:00
YenChenLin 46fc1be145 Remove redundant words in sklearn 2016-02-23 16:54:03 +08:00
giorgiop 140a5acda8 MAINT depr of center_data, normalize in linear_model 2016-02-17 14:26:50 -05:00
Olivier Grisel 9cbceb32c1 MAINT split test_ridge.test_dense_sparse with generator 2016-02-07 00:45:24 +01:00
giorgiop 9ee3f50c15 MAINT speed up test_coordinate_descent 2016-02-06 18:55:23 +01:00
MechCoder 761b1f7118 Deprecate residual_metric and add support for loss 2016-01-14 17:42:34 -05:00
imaculate 41526cb19c Added sample_weight parameter to ransac.fit 2016-01-14 12:49:40 -05:00
seales 0485ada58b General spelling fixes 2015-12-16 09:46:42 -08:00
TomDLT 9f136ff293 ENH add multinomial SAG solver for LogisticRegression 2015-12-04 18:36:37 +01:00
giorgiop 1d16ec4718 tests sample_weights linearreg, ridge 2015-11-10 22:08:26 +01:00
CJ Carey 219fe1045c BUG: use pre-parsed scipy version
This avoids a failure when using a development install of scipy.
2015-11-05 14:19:34 -06:00
Elvis DOHMATOB 56b51def64 DOC+ENH: RidgeClassifier doesn not support multi-label 2015-11-02 13:25:38 +01:00
Alexandre Gramfort d29562e9c9 Merge pull request #5666 from amueller/sag_sparse_warnings
[MRG] catch warnings in tests that the solver is changed to SAG in the sparse case
2015-11-02 13:59:21 +01:00
Arnaud Joly f4f8b99bd1 Merge pull request #5665 from amueller/no_deprecated_residuals
[MRG+1] don't use the deprecated residuals property of ols
2015-11-02 09:02:09 +01:00
Andreas Mueller 95f5e3addb TST close /dev/null in the theil sen tests. 2015-11-01 22:25:23 -05:00
Andreas Mueller e232ad60d3 TST catch warnings in tests that the solver is changed to SAG in the sparse case. 2015-11-01 22:21:11 -05:00
Andreas Mueller e3ff540991 COSMIT don't use the deprecated residuals property of ols 2015-11-01 22:13:54 -05:00
Andreas Mueller bac5e3942f Merge pull request #5626 from ogrisel/fix-osx-logistic-class-weights
[MRG+1] FIX increase tolerance of class weight check for OS X
2015-11-01 17:47:27 -05:00
TomDLT a4f125b552 FIX decrease tolerance in test_logistic for appveyor failure 2015-10-30 18:17:33 +01:00
Olivier Grisel 105326d840 FIX increase tolerance of class weight check for OS X 2015-10-30 16:52:35 +01:00
Elvis DOHMATOB 8c44bb6a74 REFACTOR: fixed huge code duplication in _RidgeGCV 2015-10-27 21:05:09 +01:00
Raghav R V 3f8743f47b Main Commits - Major
--------------------

* ENH Reogranize classes/fn from grid_search into search.py
* ENH Reogranize classes/fn from cross_validation into split.py
* ENH Reogranize cls/fn from cross_validation/learning_curve into validate.py

* MAINT Merge _check_cv into check_cv inside the model_selection module
* MAINT Update all the imports to point to the model_selection module
* FIX use iter_cv to iterate throught the new style/old style cv objs
* TST Add tests for the new model_selection members
* ENH Wrap the old-style cv obj/iterables instead of using iter_cv

* ENH Use scipy's binomial coefficient function comb for calucation of nCk
* ENH Few enhancements to the split module
* ENH Improve check_cv input validation and docstring
* MAINT _get_test_folds(X, y, labels) --> _get_test_folds(labels)
* TST if 1d arrays for X introduce any errors
* ENH use 1d X arrays for all tests;
* ENH X_10 --> X (global var)

Minor
-----

* ENH _PartitionIterator --> _BaseCrossValidator;
* ENH CVIterator --> CVIterableWrapper
* TST Import the old SKF locally
* FIX/TST Clean up the split module's tests.
* DOC Improve documentation of the cv parameter
* COSMIT consistently hyphenate cross-validation/cross-validator
* TST Calculate n_samples from X
* COSMIT Use separate lines for each import.
* COSMIT cross_validation_generator --> cross_validator

Commits merged manually
-----------------------

* FIX Document the random_state attribute in RandomSearchCV
* MAINT Use check_cv instead of _check_cv
* ENH refactor OVO decision function, use it in SVC for sklearn-like
  decision_function shape
* FIX avoid memory cost when sampling from large parameter grids

ENH Major to Minor incremental enhancements to the model_selection

Squashed commit messages - (For reference)

Major
-----

* ENH p --> n_labels
* FIX *ShuffleSplit: all float/invalid type errors at init and int error at split
* FIX make PredefinedSplit accept test_folds in constructor; Cleanup docstrings
* ENH+TST KFold: make rng to be generated at every split call for reproducibility
* FIX/MAINT KFold: make shuffle a public attr
* FIX Make CVIterableWrapper private.
* FIX reuse len_cv instead of recalculating it
* FIX Prevent adding *SearchCV estimators from the old grid_search module
* re-FIX In all_estimators: the sorting to use only the 1st item (name)
    To avoid collision between the old and the new GridSearch classes.
* FIX test_validate.py: Use 2D X (1D X is being detected as a single sample)
* MAINT validate.py --> validation.py
* MAINT make the submodules private
* MAINT Support old cv/gs/lc until 0.19
* FIX/MAINT n_splits --> get_n_splits
* FIX/TST test_logistic.py/test_ovr_multinomial_iris:
    pass predefined folds as an iterable
* MAINT expose BaseCrossValidator
* Update the model_selection module with changes from master
  - From #5161
  -  - MAINT remove redundant p variable
  -  - Add check for sparse prediction in cross_val_predict
  - From #5201 - DOC improve random_state param doc
  - From #5190 - LabelKFold and test
  - From #4583 - LabelShuffleSplit and tests
  - From #5300 - shuffle the `labels` not the `indxs` in LabelKFold + tests
  - From #5378 - Make the GridSearchCV docs more accurate.
  - From #5458 - Remove shuffle from LabelKFold
  - From #5466(#4270) - Gaussian Process by Jan Metzen
  - From #4826 - Move custom error / warnings into sklearn.exception

Minor
-----

* ENH Make the KFold shuffling test stronger
* FIX/DOC Use the higher level model_selection module as ref
* DOC in check_cv "y : array-like, optional"
* DOC a supervised learning problem --> supervised learning problems
* DOC cross-validators --> cross-validation strategies
* DOC Correct Olivier Grisel's name ;)
* MINOR/FIX cv_indices --> kfold
* FIX/DOC Align the 'See also' section of the new KFold, LeaveOneOut
* TST/FIX imports on separate lines
* FIX use __class__ instead of classmethod
* TST/FIX import directly from model_selection
* COSMIT Relocate the random_state documentation
* COSMIT remove pass
* MAINT Remove deprecation warnings from old tests
* FIX correct import at test_split
* FIX/MAINT Move P_sparse, X, y defns to top; rm unused W_sparse, X_sparse
* FIX random state to avoid doctest failure
* TST n_splits and split wrapping of _CVIterableWrapper
* FIX/MAINT Use multilabel indicator matrix directly
* TST/DOC clarify why we conflate classes 0 and 1
* DOC add comment that this was taken from BaseEstimator
* FIX use of labels is not needed in stratified k fold
* Fix cross_validation reference
* Fix the labels param doc

FIX/DOC/MAINT Addressing the review comments by Arnaud and Andy

COSMIT Sort the members alphabetically
COSMIT len_cv --> n_splits
COSMIT Merge 2 if; FIX Use kwargs
DOC Add my name to the authors :D
DOC make labels parameter consistent
FIX Remove hack for boolean indices; + COSMIT idx --> indices; DOC Add Returns
COSMIT preds --> predictions
DOC Add Returns and neatly arrange X, y, labels
FIX idx(s)/ind(s)--> indice(s)
COSMIT Merge if and else to elif
COSMIT n --> n_samples
COSMIT Use bincount only once
COSMIT cls --> class_i / class_i (ith class indices) -->
perm_indices_class_i

FIX/ENH/TST Addressing the final reviews

COSMIT c --> count
FIX/TST make check_cv raise ValueError for string cv value
TST nested cv (gs inside cross_val_score) works for diff cvs
FIX/ENH Raise ValueError when labels is None for label based cvs;
TST if labels is being passed correctly to the cv and that the
ValueError is being propagated to the cross_val_score/predict and grid
search
FIX pass labels to cross_val_score
FIX use make_classification
DOC Add Returns; COSMIT Remove scaffolding
TST add a test to check the _build_repr helper
REVERT the old GS/RS should also be tested by the common tests.
ENH Add a tuple of all/label based CVS
FIX raise VE even at get_n_splits if labels is None
FIX Fabian's comments
PEP8
2015-10-23 17:28:08 +02:00
MechCoder 41cbfded7c Add check for sample_weights 2015-10-23 00:06:07 -04:00
MechCoder 80e22b3ddf Patch liblinear for sample_weights in LogisticRegression(and CV) 2015-10-23 00:00:31 -04:00
Andreas Mueller 5d3bb933e0 Merge pull request #5008 from TomDLT/logistic_multiclass
[MRG+1] fix logistic regression class weights
2015-10-22 12:44:37 +02:00
TomDLT d439dc4d9e FIX class_weight in LogisticRegression and LogisticRegressionCV 2015-10-21 17:41:39 +02:00
Arnaud Rachez 5db2adf93c MAINT Removed deprecated stuff. 2015-10-21 10:24:23 +02:00
Raghav R V e3afc0e8c9 MAINT move custom error/warning classes into sklearn.exceptions
ENH NonBLASDotWarning -> EfficiencyWarning; Improve error message
DOC Add exceptions module to modules/classes.rst
MAINT Move ConvergenceWarning, UndefinedMetricWarning et al into exceptions
MAINT Remove ChangedBehaviorWarning from base
DOC/FIX Improve DataConversionWarning's docstring
2015-10-19 22:35:35 +02:00
Andreas Mueller 31a5a5ff12 Fixed warnings for DataDimensionalityWarning, decision_function and decision_function_shape. 2015-10-14 15:38:07 -04:00
Jiali Mei 85223b9bcc a common test to check if classifiers fail when fed regression targets 2015-10-14 14:46:13 -04:00
Tom DLT d972da2403 FIX temporary fix for sparse ridge with intercept fitting 2015-10-13 10:12:19 +02:00
Olivier Grisel da9a7cd95f Merge pull request #5362 from MechCoder/lasso_fix
[MRG] Lasso and ElasticNet should handle non-integer dtypes for fit_intercept=False
2015-10-12 13:31:33 +02:00
Vighnesh Birodkar 735dd1fdca Fix warnings during tests 2015-10-08 14:52:21 -04:00
MechCoder 1d5b473705 Lasso and ElasticNet should handle non-float dtypes for fit_intercept=False 2015-10-07 16:49:28 -04:00
Andrew Lamb 176427e284 Fix SGD partial_fit multiclass w/ average.
See https://github.com/scikit-learn/scikit-learn/issues/5246#issuecomment-140062688.

`_fit_multiclass` was setting `self.intercept_` to a single element of the intercept, instead of the entire intercept.
2015-10-07 11:39:57 +02:00
Olivier Grisel 10259822fd Merge pull request #5337 from ogrisel/fix-coordinate-descent-memory-layout
[MRG+1] FIX consistency of memory layout for linear CD solver
2015-10-05 10:50:35 +02:00
Olivier Grisel 808fa6450e FIX consistency of memory layout for linear CD solver 2015-10-04 18:32:05 +02:00
Rohan Ramanath f8486a5b25 fixes scikit-learn/scikit-learn#5329 2015-10-01 21:42:27 -07:00
vstolbunov ebd5dbc68a Fixed syntax and combined two test functions 2015-09-15 12:40:08 -04:00
vstolbunov 942ff5c654 Updated logistic regression tests with sag solver 2015-09-15 12:40:08 -04:00
Valentin Stolbunov 1a15fdc4f5 Added handling of sample weights in logistic.py
* Updated _check_solver_option to include sample_weight check
* Updated all calls to _check_solver_option()
* Updated documentation of class_weight throughout logistic.py
* Added sample_weight parameter to logistic_regression_path.
* Added handling of sample weights to logistic_regression_path.
* Added sample_weight parameter to _log_reg_scoring_path.
* Added handling of sample weights to _log_reg_scoring_path.
* Added sample_weight parameter to fit() in the LogisticRegression class.
* Added handling of sample sample weights in LogisticRegression.fit()
* Added sample_weight parameter to fit() in the LogisticRegressionCV class.
* Added handling of sample weights in LogisticRegressionCV.fit()
* Added test_logistic_regressioncv_sample_weights, which:
  * tests that a ValueError is raised if liblinear is used with
    sample weights
  * tests that passing sample weights as np.ones(y.shape[0]) is
    the same as not passing them (default None)
  * tests that using both lbfgs and newton-cg solvers with
    sample weights yields the same results
  * tests that passing class weights to scale one class is the
    same as passing sample weights for the training data of just
    that class
* Fixed bug with *= in logistic_regression_path.
* Fixed bug in test_logistic_regressioncv_sample_weights where
  no data was created prior to fitting.
* Changes to accepted sample_weight type.
* Fixed bug in naming of sample_weight when passed from
  _log_reg_scoring_path to logistic_regression_path.
* Fixed issue of sample_weight=None being converted to np.array()
  and then not being reconigzed as None.
* Added tests for LogisticRegression
* Attempting to fix same issue as 9d3becf by instead implementing
  if statement in bagging.py.
* Added TODO to eliminate check for liblinear w/ sample weights
  in bagging.py
2015-09-15 12:40:08 -04:00
TomDLT 94eb61960a ENH add sag solver in LogisticRegression and Ridge 2015-09-10 13:28:02 -04:00
Danny Sullivan 4ceffe05a1 Adding Implementation of SAG 2015-09-10 13:27:04 -04:00
Vighnesh Birodkar 2f099334f9 MAINT deprecate 1d input arrays for all estimators
Passing 1D arrays to check_array, without setting `ensure_2d` to false now
raises a deprecation warning before reshaping it. This will later throw an
error.

All Scaler classes also throw warnings when 1D arrays are passed.

All unit tests/doctests are modified to ensure that no 1D arrays are passed,
except in explicit 1D array tests where the warnings have been silenced.

Additional tests are also included which check for different 1D array cases.

2D array tests with one samples and one features are also added and where
they failed, `check_array` call has been modified to give a more useful error
message
2015-09-09 15:49:58 +02:00
Gael Varoquaux 4f713cec21 Merge pull request #5182 from MechCoder/predict_proba_fix
[MRG + 2] predict_proba should use the softmax function in the multinomial case
2015-08-30 21:44:11 +01:00
MechCoder c85f2ad596 Add non regression test 2015-08-30 11:44:58 -04:00
Gael Varoquaux 190abde442 Merge pull request #4881 from sonnyhu/weighted_least_squares
[MRG + 1] add sample_weight into LinearRegression
2015-08-30 16:35:00 +01:00
Gael Varoquaux 6e735f5968 Merge pull request #4767 from trevorstephens/passive-aggressive_cw
[MRG + 1] Add class_weight to PA Classifier, remove from PA Regressor
2015-08-30 16:25:51 +01:00
MechCoder c3cfebe4d6 [BUG] predict_proba should use the softmax function in the multinomial case 2015-08-28 17:06:20 -04:00
Alexandre Gramfort a8585a4b0d pep8 + simplify positive test 2015-08-28 21:43:46 +02:00