[scikit-learn] How can i write the birch prediction results to the file

David Nicholson nicholdav at gmail.com
Mon Aug 21 10:38:57 EDT 2017

Hi Sema,

You can save using pickle from the Python standard library, or using the
joblib library which is a dependency of sklearn (so you have it already).

The sklearn docs show examples of saving models but it will work for your
predict results too:

You'd just do something like:
import joblib
# your code here
birch_predict = brc.predict(X)
filename = 'predictions'
joblib.dump(birch_predict, filename)

And you can get the values back into memory with joblib.load

--David (list lurker)

On Aug 21, 2017 10:13, "Sema Atasever" <s.atasever at gmail.com> wrote:

Dear scikit-learn developers,

I have a text file where the columns represent the 22 features and the rows
represent the amino asid . (you can see in the attachment)

I want to apply hierarchical clustering to this database usign

There are too many prediction results and it is not possible to see them on
the screen.
How can i write the birch prediction results to the file?

I would appreciate if you could advise on some methods.

*Birch Codes:*
from sklearn.cluster import Birch
import numpy as np

X=np.loadtxt(open("C:\class1.txt", "rb"), delimiter=";")

brc = Birch(branching_factor=50, n_clusters=None,


centroids = brc.subcluster_centers_

labels = brc.subcluster_labels_
n_clusters = np.unique(labels).size

print("\n brc.predict(X)")

scikit-learn mailing list
scikit-learn at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20170821/dd480f2e/attachment.html>

More information about the scikit-learn mailing list