This repository has been archived by the owner on Jul 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
993 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,3 @@ | |
Gallery of examples | ||
=================== | ||
|
||
|
||
First section | ||
------------- | ||
|
||
One example of a gallery. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
""" | ||
Trains a Random Forest on Iris dataset | ||
====================================== | ||
The following example shows how to create and train | ||
a pipeline using :ref:`l-fasttree-(boosted-trees)-classification`. | ||
""" | ||
import sys | ||
import os | ||
import unittest | ||
import numpy | ||
from sklearn import datasets | ||
from sklearn.model_selection import train_test_split | ||
import pandas | ||
from csharpyml.binaries import CSPipeline | ||
|
||
############################## | ||
# Let's first retrieve the data. | ||
|
||
X, y = datasets.load_iris(return_X_y=True) | ||
X_train, X_test, y_train, y_test = train_test_split( | ||
X.astype(numpy.float32), y.astype(numpy.float32)) | ||
df_train = pandas.DataFrame(data=X_train, columns=["FA", "FB", "FC", "FD"]) | ||
df_train["Label"] = y_train | ||
|
||
df_test = pandas.DataFrame(data=X_test, columns=["FA", "FB", "FC", "FD"]) | ||
df_test["Label"] = y_test | ||
|
||
############################## | ||
# Let's create a pipeline. | ||
pipe = CSPipeline(["concat{col=Feat:FA,FB,FC,FD}"], | ||
"oova{p=ft}", verbose=2) | ||
|
||
############################# | ||
# Let's train it. | ||
pipe.fit(df_train, feature="Feat", label="Label") | ||
|
||
############################################### | ||
# Let's show the output. | ||
|
||
print(pipe.StdOut) | ||
|
||
################################# | ||
# Let's predict. | ||
|
||
pred = pipe.predict(df_test) | ||
print(pred.head()) | ||
|
||
########################### | ||
# Let's save the model. | ||
|
||
outfile = "model.zip" | ||
pipe.save(outfile) | ||
|
||
############################# | ||
# Let's load it. | ||
|
||
pipe2 = CSPipeline.load(outfile) | ||
pred2 = pipe2.predict(df_test) | ||
print(pred2.head()) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,8 @@ Through documentation | |
filechanges | ||
README | ||
all_indexes | ||
|
||
.. toctree:: | ||
:hidden: | ||
|
||
blog/index_blog |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.