Skip to content

Commit

Permalink
updated regressor models with plot_tree
Browse files Browse the repository at this point in the history
  • Loading branch information
abhsharma2 committed Nov 3, 2023
1 parent 1a28455 commit 550a8b5
Showing 1 changed file with 75 additions and 12 deletions.
87 changes: 75 additions & 12 deletions verticapy/machine_learning/memmodel/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class RandomForestRegressor(Ensemble):
children_right = [2, 4, None, None, None],
feature = [0, 1, None, None, None],
threshold = ["female", 30, None, None, None],
value = [None, None, 3, 11, 23])
value = [None, None, 3.0, 11.0, 23.5])
model2 = BinaryTreeRegressor(children_left = [1, 3, None, None, None],
children_right = [2, 4, None, None, None],
feature = [0, 1, None, None, None],
Expand Down Expand Up @@ -142,13 +142,34 @@ class RandomForestRegressor(Ensemble):
**Making In-Memory Predictions**
Use
:py:meth:`verticapy.machine_learning.memmodel.tree.RandomForestRegressor.predict`
:py:meth:`verticapy.machine_learning.memmodel.ensemble.RandomForestRegressor.predict`
method to do predictions.
.. ipython:: python
model_rfr.predict(data)
Use
:py:meth:`verticapy.machine_learning.memmodel.ensemble.RandomForestRegressor.plot_tree`
method to draw the input tree.
.. code-block:: python
model_rfr.plot_tree()
.. ipython:: python
:suppress:
res = model_rfr.plot_tree()
res.render(filename='figures/machine_learning_memmodel_tree_rndforestreg', format='png')
.. image:: /../figures/machine_learning_memmodel_tree_rndforestreg.png
.. important::
:py:meth:`verticapy.machine_learning.memmodel.ensemble.RandomForestRegressor.plot_tree`
requires the `Graphviz <https://graphviz.org/download/>`_ module.
**Deploy SQL Code**
Let's use the following column names:
Expand All @@ -158,7 +179,7 @@ class RandomForestRegressor(Ensemble):
cnames = ["sex", "fare"]
Use
:py:meth:`verticapy.machine_learning.memmodel.tree.RandomForestRegressor.predict_sql`
:py:meth:`verticapy.machine_learning.memmodel.ensemble.RandomForestRegressor.predict_sql`
method to get the SQL code needed to deploy the model using its attributes.
.. ipython:: python
Expand Down Expand Up @@ -329,15 +350,15 @@ class RandomForestClassifier(Ensemble, MulticlassClassifier):
cnames = ["sex", "fare"]
Use
:py:meth:`verticapy.machine_learning.memmodel.tree.RandomForestClassifier.predict_sql`
:py:meth:`verticapy.machine_learning.memmodel.ensemble.RandomForestClassifier.predict_sql`
method to get the SQL code needed to deploy the model using its attributes.
.. ipython:: python
model_rfc.predict_sql(cnames)
Use
:py:meth:`verticapy.machine_learning.memmodel.tree.RandomForestClassifier.predict_proba_sql`
:py:meth:`verticapy.machine_learning.memmodel.ensemble.RandomForestClassifier.predict_proba_sql`
method to get the SQL code needed to deploy the model using its attributes.
.. ipython:: python
Expand Down Expand Up @@ -508,13 +529,34 @@ class XGBRegressor(Ensemble):
**Making In-Memory Predictions**
Use
:py:meth:`verticapy.machine_learning.memmodel.tree.XGBRegressor.predict`
:py:meth:`verticapy.machine_learning.memmodel.ensemble.XGBRegressor.predict`
method to do predictions.
.. ipython:: python
model_xgbr.predict(data)
Use
:py:meth:`verticapy.machine_learning.memmodel.ensemble.XGBRegressor.plot_tree`
method to draw the input tree.
.. code-block:: python
model_xgbr.plot_tree()
.. ipython:: python
:suppress:
res = model_xgbr.plot_tree()
res.render(filename='figures/machine_learning_memmodel_tree_xgbreg', format='png')
.. image:: /../figures/machine_learning_memmodel_tree_xgbreg.png
.. important::
:py:meth:`verticapy.machine_learning.memmodel.ensemble.XGBRegressor.plot_tree`
requires the `Graphviz <https://graphviz.org/download/>`_ module.
**Deploy SQL Code**
Let's use the following column names:
Expand All @@ -524,7 +566,7 @@ class XGBRegressor(Ensemble):
cnames = ["sex", "fare"]
Use
:py:meth:`verticapy.machine_learning.memmodel.tree.XGBRegressor.predict_sql`
:py:meth:`verticapy.machine_learning.memmodel.ensemble.XGBRegressor.predict_sql`
method to get the SQL code needed to deploy the model using its attributes.
.. ipython:: python
Expand Down Expand Up @@ -702,7 +744,7 @@ class XGBClassifier(Ensemble, MulticlassClassifier):
.. important::
:py:meth:`verticapy.machine_learning.memmodel.tree.BinaryTreeClassifier.plot_tree`
:py:meth:`verticapy.machine_learning.memmodel.ensemble.XGBClassifier.plot_tree`
requires the `Graphviz <https://graphviz.org/download/>`_ module.
**Deploy SQL Code**
Expand All @@ -714,15 +756,15 @@ class XGBClassifier(Ensemble, MulticlassClassifier):
cnames = ["sex", "fare"]
Use
:py:meth:`verticapy.machine_learning.memmodel.tree.XGBClassifier.predict_sql`
:py:meth:`verticapy.machine_learning.memmodel.ensemble.XGBClassifier.predict_sql`
method to get the SQL code needed to deploy the model using its attributes.
.. ipython:: python
model_xgbc.predict_sql(cnames)
Use
:py:meth:`verticapy.machine_learning.memmodel.tree.XGBClassifier.predict_proba_sql`
:py:meth:`verticapy.machine_learning.memmodel.ensemble.XGBClassifier.predict_proba_sql`
method to get the SQL code needed to deploy the model using its attributes.
.. ipython:: python
Expand Down Expand Up @@ -875,13 +917,34 @@ class IsolationForest(Ensemble):
**Making In-Memory Predictions**
Use
:py:meth:`verticapy.machine_learning.memmodel.tree.IsolationForest.predict`
:py:meth:`verticapy.machine_learning.memmodel.ensemble.IsolationForest.predict`
method to do predictions.
.. ipython:: python
model_isf.predict(data)
Use
:py:meth:`verticapy.machine_learning.memmodel.ensemble.IsolationForest.plot_tree`
method to draw the input tree.
.. code-block:: python
model_isf.plot_tree()
.. ipython:: python
:suppress:
res = model_isf.plot_tree()
res.render(filename='figures/machine_learning_memmodel_ensemble_iforest', format='png')
.. image:: /../figures/machine_learning_memmodel_ensemble_iforest.png
.. important::
:py:meth:`verticapy.machine_learning.memmodel.ensemble.IsolationForest.plot_tree`
requires the `Graphviz <https://graphviz.org/download/>`_ module.
**Deploy SQL Code**
Let's use the following column names:
Expand All @@ -891,7 +954,7 @@ class IsolationForest(Ensemble):
cnames = ["sex", "fare"]
Use
:py:meth:`verticapy.machine_learning.memmodel.tree.IsolationForest.predict_sql`
:py:meth:`verticapy.machine_learning.memmodel.ensemble.IsolationForest.predict_sql`
method to get the SQL code needed to deploy the model using its attributes.
.. ipython:: python
Expand Down

0 comments on commit 550a8b5

Please sign in to comment.