Skip to content

Commit

Permalink
Add example sections in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesll committed May 30, 2019
1 parent 87e6732 commit 1a8eb0b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
17 changes: 17 additions & 0 deletions rampy/ml_exploration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
class mlexplorer:
"""use machine learning algorithms from scikit learn to explore spectroscopic datasets
Performs automatic scaling and train/test split before NMF or PCA fit.
Attributes
----------
x : {array-like, sparse matrix}, shape = (n_samples, n_features)
Expand Down Expand Up @@ -32,6 +34,21 @@ class mlexplorer:
Results for machine learning algorithms can vary from run to run. A way to solve that is to fix the random_state.
Example
-------
Given an array X of n samples by m frequencies, and Y an array of n x 1 concentrations
>>> explo = rampy.mlexplorer(X) # X is an array of signals built by mixing two partial components
>>> explo.algorithm = 'NMF' # using Non-Negative Matrix factorization
>>> explo.nb_compo = 2 # number of components to use
>>> explo.test_size = 0.3 # size of test set
>>> explo.scaler = "MinMax" # scaler
>>> explo.fit() # fitting!
>>> W = explo.model.transform(explo.X_train_sc) # getting the mixture array
>>> H = explo.X_scaler.inverse_transform(explo.model.components_) # components in the original space
>>> plt.plot(X,H.T) # plot the two components
"""

def __init__(self,x,**kwargs):
Expand Down
5 changes: 4 additions & 1 deletion rampy/ml_regressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ class mlregressor:
Given an array X of n samples by m frequencies, and Y an array of n x 1 concentrations
>>> model = rampy.mlregressor(X,y)
>>>
>>> model.algorithm("SVM")
>>> model.user_kernel = 'poly'
>>> model.fit()
>>> y_new = model.predict(X_new)
Remarks
-------
Expand Down

0 comments on commit 1a8eb0b

Please sign in to comment.