Skip to content
Snippets Groups Projects
Commit 063ac998 authored by BARTHES Nicolas's avatar BARTHES Nicolas
Browse files

beginning of lwPlsr - Julia Jchemo

parent 3461d3b0
No related branches found
No related tags found
No related merge requests found
...@@ -5,4 +5,5 @@ data/models/ ...@@ -5,4 +5,5 @@ data/models/
data/predictions/ data/predictions/
data/sample_selections/ data/sample_selections/
Report/*.pdf Report/*.pdf
Report/*.tex Report/*.tex
\ No newline at end of file Report/figures/
\ No newline at end of file
...@@ -14,5 +14,25 @@ def model_LWPLSR(xcal_csv, ycal_csv, sep, hdr): ...@@ -14,5 +14,25 @@ def model_LWPLSR(xcal_csv, ycal_csv, sep, hdr):
# Assign data to training and test sets # Assign data to training and test sets
X_train, y_train, X_test, y_test = x[train_index], y[train_index], x[test_index], y[test_index] X_train, y_train, X_test, y_test = x[train_index], y[train_index], x[test_index], y[test_index]
st.write("Size of train and test sets: train " + str(X_train.shape) + ' ' + str(y_train.shape) + ' / test ' + str(X_test.shape) + ' ' + str(y_test.shape)) st.write("Size of train and test sets: train " + str(X_train.shape) + ' ' + str(y_train.shape) + ' / test ' + str(X_test.shape) + ' ' + str(y_test.shape))
# prepare to send dataframes to julia and Jchemo
# Jchemo.lwplsr(X_train, y_train, nlvdis=4, metric = eucl, k = 10) Main.X_train,Main.y_train,Main.X_test,Main.y_test = X_train, y_train, X_test, y_test
\ No newline at end of file Main.eval("""
#convert python pd.dataframes to julia dataframes
X_train_j = Main.X_train |> Pandas.DataFrame|> DataFrames.DataFrame;
y_train_j = Main.y_train |> Pandas.DataFrame|> DataFrames.DataFrame;
X_test_j = Main.X_test |> Pandas.DataFrame|> DataFrames.DataFrame;
y_test_j = Main.y_test |> Pandas.DataFrame|> DataFrames.DataFrame;
# Main.println(string("Size of X_train ", size(X_train_j), " ; Size of y_train ", size(y_train_j)))
# Main.println(string("Size of X_test ", size(X_test_j), " ; Size of y_test ", size(y_test_j)))
# Compute model
nlvdis = 5 ; metric = :mah
h = 1 ; k = 200 ; nlv = 15 #; scal = true
mod = Main.Jchemo.model(Main.Jchemo.lwplsr; nlvdis, metric, h, k, nlv)
Main.Jchemo.fit!(mod, X_train_j, y_train_j)
# predictions on test data calculation
res = Main.Jchemo.predict(mod, X_test_j) ;
score = Main.Jchemo.rmsep(res.pred, y_test_j)
resjp = Pandas.DataFrame(res.pred);
""")
score = Main.score
predicted_results_on_test = pd.DataFrame(Main.resjp)
...@@ -24,7 +24,7 @@ from scipy.sparse import csgraph ...@@ -24,7 +24,7 @@ from scipy.sparse import csgraph
# Modelling # Modelling
# import julia # import julia
# from julia import Jchemo from julia import Main, Jchemo, DataFrames, Base, Pandas
from pinard import utils from pinard import utils
from pinard import preprocessing as pp from pinard import preprocessing as pp
......
...@@ -20,10 +20,11 @@ This package is written in python. You can clone the repository: git clone https ...@@ -20,10 +20,11 @@ This package is written in python. You can clone the repository: git clone https
Then install the requirements: pip install -r requirements.txt Then install the requirements: pip install -r requirements.txt
(OPTIONNAL) To use Locally weighted PLS Regression for creation model, you will need to install Jchemo.jl (https://github.com/mlesnoff/Jchemo.jl), a Julia package. (OPTIONNAL) To use Locally weighted PLS Regression for creation model, you will need to install Jchemo.jl (https://github.com/mlesnoff/Jchemo.jl), a Julia package.
From the CLI: python From the CLI: python
> '>>> import julia > python
'>>> julia.install() '>>> import julia
'>>> from julia import Pkg '>>> julia.install()
'>>> Pkg.add("Jchemo") '>>> from julia import Pkg
'>>> Pkg.add(["Jchemo","DataFrames","Pandas"])
To check if Jchemo is installed without errors: To check if Jchemo is installed without errors:
> '>>> Pkg.status() > '>>> Pkg.status()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment