.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "glr_examples/applications/plot_flow_rate_prediction.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_glr_examples_applications_plot_flow_rate_prediction.py: ========================================= Predict FR from DC-Resistivity data ========================================= shows some steps for predicting flow rate(FR) from DC-ERP and VES data .. GENERATED FROM PYTHON SOURCE LINES 9-12 .. code-block:: Python # Author: L.Kouadio # Licence: BSD-3-clause .. GENERATED FROM PYTHON SOURCE LINES 13-14 Import the required modules .. GENERATED FROM PYTHON SOURCE LINES 14-22 .. code-block:: Python from watex.datasets import fetch_data from watex.datasets import load_gbalo, load_tankesse, load_bagoue from watex.methods import ResistivityProfiling, VerticalSounding from watex.methods import DCProfiling, DCSounding from watex.view.plot import QuickPlot from watex.models import pModels from watex.exlib import train_test_split, accuracy_score .. GENERATED FROM PYTHON SOURCE LINES 23-32 The raw DC data is recorded in zenodo during the drinking water supply campaign (DWSC) in 2012-2014 in `Cote d'Ivoire `_ in partnership with global organizations. The objective was to supply 2000 villages with potable water. The geophysical companies were associated with drilling ventures to locate the best position to carry out the drilling operations. The data is free of charge and can be distributed to a third party provided that it cites the authors as a reference. First, I randomly fetch the raw DC profiling and sounding data of one of these localities (Gbalo) during the DWSC project as: .. GENERATED FROM PYTHON SOURCE LINES 32-36 .. code-block:: Python gdata= load_gbalo () gdata.head(2) .. raw:: html
station resistivity longitude latitude easting northing
0 0.0 1101 0.0 0.0 790752 1092750.0
1 10.0 1147 0.0 0.0 790747 1092758.0


.. GENERATED FROM PYTHON SOURCE LINES 37-51 Secondly, I will compute the DC prediction parameters by calling the appropriate methods. For demonstration, I assume that the drilling is performed at station 5(S05) on the survey line, i.e the DC parameters are computed at that station. However, if the station is not specified, the algorithm will find the best conductive zone based on the resistivity values and will store the value in attribute :attr:`sves_` (position to locate a drill). The auto-detection can be used when users need to propose a place to make a drill. Note that for a real case study, it is recommended to specify the station where the drilling operation was performed through the parameter station. For instance, automatic drilling location detection can predict a station located in a marsh area that is not a suitable place for making a drill. Therefore, to avoid any misinterpretation due to the complexity of the geological area, it is useful to provide the station position. The code snippets are: .. GENERATED FROM PYTHON SOURCE LINES 51-55 .. code-block:: Python erpo = ResistivityProfiling (station = 'S05').fit(gdata ) erpo.conductive_zone_ #(1) .. rst-class:: sphx-glr-script-out .. code-block:: none array([1345, 1369, 1406, 1543, 1480, 1517, 1754]) .. GENERATED FROM PYTHON SOURCE LINES 56-58 .. code-block:: Python erpo.summary(keep_params=True,return_table= True) #(2) .. raw:: html
power magnitude shape type sfi
0 60 409 K PC 0.926003


.. GENERATED FROM PYTHON SOURCE LINES 59-64 `#(1)` shows the resistivity of the best conductive zone and `#(2)` returns the main prediction parameters. For reading multiple ERP data, it is suggested to use the :class:`~watex.methods.DCProfiling` method. It performs the same task but each parameter is stored in a line object. Let's go ahead by fetching another locality of ERP data (**Tankesse**) for demonstration: .. GENERATED FROM PYTHON SOURCE LINES 64-68 .. code-block:: Python dcpo= DCProfiling (stations =['S05', 'S07'] ).fit(gdata, load_tankesse() ) dcpo.nlines_ #(3) .. rst-class:: sphx-glr-script-out .. code-block:: none dc-erp : 0%| | 0/2 [00:00 1500`) do not mean that they should be more productive since all of the drillings performed on the wide fracture do not always give a productive FR ( :math:`FR>3m^3/hr`) contrary to the narrow fractures (around `1000 ohmS`). As a result, it is reliable to consider this approach during a future DWSC such as the geology of the area and also the rock fracturing ratio computed thanks to the parameters sfi and ohmS. The following examples demonstrate how to predict FR with a complete preprocessed dataset of DC parameters. The pre-trained models (optimal model with acceptable variance and bias) of :class:`~watex.models.pModels` can be used to predict FR as: .. GENERATED FROM PYTHON SOURCE LINES 149-158 .. code-block:: Python X, y = fetch_data ('bagoue prepared data') X_train, X_test, y_train, y_test = train_test_split ( X, y, test_size =0.2 ) pmo = pModels (model='svm', kernel ='poly').fit (X_train, y_train ) y_pred = pmo.predict (X_test ) accuracy_score (y_test, y_pred ) .. rst-class:: sphx-glr-script-out .. code-block:: none 0.7246376811594203 .. GENERATED FROM PYTHON SOURCE LINES 159-161 Note the pre-trained estimator is stored in an attribute :attr:`estimator_`. For instance, the pre-trained SVM model can be retrieved using .. GENERATED FROM PYTHON SOURCE LINES 161-163 .. code-block:: Python pmo.estimator_ .. raw:: html
SVC(C=128.0, coef0=7, degree=5, gamma=0.00048828125, kernel='poly', tol=0.01)
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.


.. GENERATED FROM PYTHON SOURCE LINES 164-165 or .. GENERATED FROM PYTHON SOURCE LINES 165-168 .. code-block:: Python pmo.SVM.poly.best_estimator_ .. raw:: html
SVC(C=128.0, coef0=7, degree=5, gamma=0.00048828125, kernel='poly', tol=0.01)
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.


.. GENERATED FROM PYTHON SOURCE LINES 169-170 If the model is not a kernel machine, the kernel attribute is discarded instead. For example: .. GENERATED FROM PYTHON SOURCE LINES 170-176 .. code-block:: Python pmo=pModels(model ='xgboost').fit (X_train, y_train ) # where xgboost stands for extreme gradient boosting machine(Friedman, 2001) # and the pre-trained estimator could be retrieved as pmo.XGB.best_estimator_ .. raw:: html
XGBClassifier(base_score=None, booster='gbtree', callbacks=None,
                  colsample_bylevel=None, colsample_bynode=None,
                  colsample_bytree=None, device=None, early_stopping_rounds=None,
                  enable_categorical=False, eval_metric=None, feature_types=None,
                  gamma=1.5, grow_policy=None, importance_type=None,
                  interaction_constraints=None, learning_rate=0.07, max_bin=None,
                  max_cat_threshold=None, max_cat_to_onehot=None,
                  max_delta_step=None, max_depth=2, max_leaves=None,
                  min_child_weight=None, missing=nan, monotone_constraints=None,
                  multi_strategy=None, n_estimators=300, n_jobs=None,
                  num_parallel_tree=None, objective='multi:softprob', ...)
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.


.. GENERATED FROM PYTHON SOURCE LINES 177-178 Let make a new prediction with XGB .. GENERATED FROM PYTHON SOURCE LINES 178-182 .. code-block:: Python y_pred = pmo.predict (X_test ) accuracy_score (y_test, y_pred ) .. rst-class:: sphx-glr-script-out .. code-block:: none 0.8115942028985508 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.652 seconds) .. _sphx_glr_download_glr_examples_applications_plot_flow_rate_prediction.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/watex/watex/master?urlpath=lab/tree/notebooks/glr_examples/applications/plot_flow_rate_prediction.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_flow_rate_prediction.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_flow_rate_prediction.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_