Skip to content

Commit

Permalink
fix readme example
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahmish committed Sep 25, 2023
1 parent 68538ac commit 5934e48
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,11 @@ pipeline which combines primitives from [MLPrimitives](https://github.com/MLBaza
[scikit-learn](https://scikit-learn.org/) and [xgboost](https://xgboost.readthedocs.io/).

```python3
import pandas as pd
from mlblocks import MLPipeline
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score

import pandas as pd

dataset = pd.read_csv('http://mlblocks.s3.amazonaws.com/census.csv')
label = dataset.pop('label')

Expand Down
14 changes: 10 additions & 4 deletions docs/getting_started/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,13 @@ labels.
.. ipython:: python
:okwarning:
from mlprimitives.datasets import load_census
dataset = load_census()
X_train, X_test, y_train, y_test = dataset.get_splits(1)
import pandas as pd
from sklearn.model_selection import train_test_split
dataset = pd.read_csv('http://mlblocks.s3.amazonaws.com/census.csv')
label = dataset.pop('label')
X_train, X_test, y_train, y_test = train_test_split(dataset, label, stratify=label)
pipeline.fit(X_train, y_train)
Once we have fitted our model to our data, we can call the ``predict`` method passing new data
Expand All @@ -115,9 +119,11 @@ to obtain predictions from the pipeline.
.. ipython:: python
:okwarning:
from sklearn.metrics import accuracy_score
predictions = pipeline.predict(X_test)
predictions
dataset.score(y_test, predictions)
accuracy_score(y_test, predictions)
.. _you have already installed them: install.html#additional-dependencies
.. _MLPipeline class: ../api_reference.html#mlblocks.MLPipeline
Expand Down

0 comments on commit 5934e48

Please sign in to comment.