diff --git a/rampy/ml_exploration.py b/rampy/ml_exploration.py index 184cb1c..49489a4 100644 --- a/rampy/ml_exploration.py +++ b/rampy/ml_exploration.py @@ -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) @@ -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): diff --git a/rampy/ml_regressor.py b/rampy/ml_regressor.py index 3f86282..a69f250 100644 --- a/rampy/ml_regressor.py +++ b/rampy/ml_regressor.py @@ -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 -------