<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Hi Sergio, in Intel® Distribution for Python*</title>
    <link>https://community.intel.com/t5/Intel-Distribution-for-Python/DAAL-issue-TypeError-in-method-Input-set-argument-3-of-type-daal/m-p/1107437#M570</link>
    <description>&lt;P&gt;Hi Sergio,&lt;/P&gt;

&lt;P&gt;I was incorrectly assuming a separate DAAL installation. Sorry about that. For Intel Python, the utils folder can be found in &amp;lt;install_root&amp;gt;/share/pydaal_examples/examples/python/source. Just make sure that folder is on your sys.path at runtime, or you can point the PYTHONPATH environment variable there.&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
    <pubDate>Tue, 16 May 2017 16:17:51 GMT</pubDate>
    <dc:creator>Christophe_H_Intel2</dc:creator>
    <dc:date>2017-05-16T16:17:51Z</dc:date>
    <item>
      <title>DAAL issue: TypeError: in method 'Input_set', argument 3 of type 'daal::data_management:</title>
      <link>https://community.intel.com/t5/Intel-Distribution-for-Python/DAAL-issue-TypeError-in-method-Input-set-argument-3-of-type-daal/m-p/1107431#M564</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I am trying the Intel DAAL example from &lt;A href="https://swdevtoolsmag.makebettercode.com/"&gt;&lt;STRONG&gt;The Parallel Universe, issue 28&lt;/STRONG&gt;&lt;/A&gt; (https://swdevtoolsmag.makebettercode.com/). The example start on page 26, using with the Kaggle Leaf Classification data set.&lt;/P&gt;

&lt;P&gt;I set up the data using the reference provided in the essay &lt;A href="https://www.kaggle.com/jeffd23/10-classifier-showdown-in-scikit-learn" target="_blank"&gt;https://www.kaggle.com/jeffd23/10-classifier-showdown-in-scikit-learn&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;After reaching the DAAL line of code:&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;trainAlg.input.set(classifier.training.data, X_train)
&lt;/PRE&gt;

&lt;P&gt;the program crashed with throwing the error:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;
		&amp;nbsp; File "zz_kaggle_leaf_01.py", line 42, in &amp;lt;module&amp;gt;&lt;BR /&gt;
		&amp;nbsp;&amp;nbsp;&amp;nbsp; trainAlg.input.set(classifier.training.data, X_train)&lt;BR /&gt;
		&amp;nbsp; File "/home/intel/intelpython3/lib/python3.5/site-packages/daal/algorithms/classifier/training.py", line 175, in set&lt;BR /&gt;
		&amp;nbsp;&amp;nbsp;&amp;nbsp; return _training3.Input_set(self, id, value)&lt;BR /&gt;
		TypeError: in method 'Input_set', argument 3 of type 'daal::data_management::NumericTablePtr const &amp;amp;'&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;&lt;STRONG&gt;The piece of code I am using is as follows&lt;/STRONG&gt;:&lt;/P&gt;

&lt;PRE class="brush:python;"&gt;# This part from 
# &lt;A href="https://www.kaggle.com/jeffd23/10-classifier-showdown-in-scikit-learn" target="_blank"&gt;https://www.kaggle.com/jeffd23/10-classifier-showdown-in-scikit-learn&lt;/A&gt;

import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

from sklearn.preprocessing import LabelEncoder
#from sklearn.cross_validation import StratifiedShuffleSplit
from sklearn.model_selection import StratifiedShuffleSplit

train = pd.read_csv('./Kaggle_data/Leaf/train.csv')
test = pd.read_csv('./Kaggle_data/Leaf/test.csv')

# 
#Data Preparation

# Swiss army knife function to organize the data

def encode(train, test):
    le = LabelEncoder().fit(train.species) 
    labels = le.transform(train.species)           # encode species strings
    classes = list(le.classes_)                    # save column names for submi
ssion
    test_ids = test.id                             # save test ids for submissio
n
    
    train = train.drop(['species', 'id'], axis=1)  
    test = test.drop(['id'], axis=1)
    
    return train, labels, test, test_ids, classes

train, labels, test, test_ids, classes = encode(train, test)
print(train.head(1))

#sss = StratifiedShuffleSplit(labels, 10, test_size=0.2, random_state=23)
sss = StratifiedShuffleSplit(n_splits=10, test_size=0.2, random_state=23)

#for train_index, test_index in sss:
for train_index, test_index in sss.split(train.values, labels):
    X_train, X_test = train.values[train_index], train.values[test_index]
    y_train, y_test = labels[train_index], labels[test_index]

# Here start 
# The Parallel Universe, issue 28. The exampe start on page 26

from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
favorite_clf = LinearDiscriminantAnalysis()
favorite_clf.fit(X_train, y_train)
test_predictions = favorite_clf.predict(X_test)
#test_predictions = favorite_clf.predict_proba(X_test) # WORK end of INTEL_leaf_
knn_01.py

input("\t pg 28 passed with warnings. Hit return")

# pg 30
#And KNN in Python (scikit-learn):

from sklearn.neighbors import KNeighborsClassifier
#favorite_clf = KNeighborsClassifier(k=4)
favorite_clf = KNeighborsClassifier(4)
favorite_clf.fit(X_train, y_train)
test_predictions = favorite_clf.predict(X_test)

input("\t Pg 30, KNN scikit-learn, passed Hit return")


# pg 30
# KNN training stage in Python (Intel DAAL):

from daal.algorithms.kdtree_knn_classification import training, prediction
from daal.algorithms import classifier, kdtree_knn_classification
trainAlg = kdtree_knn_classification.training.Batch()
trainAlg.input.set(classifier.training.data, X_train)
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Regards,&lt;/P&gt;

&lt;P&gt;Sergio&lt;BR /&gt;
	Enhance your #MachineLearning and #BigData skills via #Python #SciPy&lt;BR /&gt;
	1) &lt;A href="https://www.packtpub.com/big-data-and-business-intelligence/numerical-and-scientific-computing-scipy-video" target="_blank"&gt;https://www.packtpub.com/big-data-and-business-intelligence/numerical-and-scientific-computing-scipy-video&lt;/A&gt;&lt;BR /&gt;
	2) &lt;A href="https://www.packtpub.com/big-data-and-business-intelligence/learning-scipy-numerical-and-scientific-computing-second-edition" target="_blank"&gt;https://www.packtpub.com/big-data-and-business-intelligence/learning-scipy-numerical-and-scientific-computing-second-edition&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2017 14:26:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Distribution-for-Python/DAAL-issue-TypeError-in-method-Input-set-argument-3-of-type-daal/m-p/1107431#M564</guid>
      <dc:creator>sergio_r_</dc:creator>
      <dc:date>2017-05-15T14:26:17Z</dc:date>
    </item>
    <item>
      <title>Hi Sergio,</title>
      <link>https://community.intel.com/t5/Intel-Distribution-for-Python/DAAL-issue-TypeError-in-method-Input-set-argument-3-of-type-daal/m-p/1107432#M565</link>
      <description>&lt;P&gt;Hi Sergio,&lt;/P&gt;

&lt;P&gt;Thanks for raising this question. &amp;nbsp;PyDAAL algorithms operate on NumericTable data structures instead of directly on numpy arrays. You can do the appropriate conversions as follows.&lt;/P&gt;

&lt;PRE class="brush:python;"&gt;from daal.data_management import HomogenNumericTable
from daal.algorithms.kdtree_knn_classification import training, prediction
from daal.algorithms import classifier, kdtree_knn_classification
trainAlg = kdtree_knn_classification.training.Batch()
trainAlg.input.set(classifier.training.data, HomogenNumericTable(X_train))
trainAlg.input.set(classifier.training.labels, HomogenNumericTable(np.array(y_train.reshape(792, 1), dtype=np.intc), ntype=np.intc))
trainAlg.parameter.k = 4
trainingResult = trainAlg.compute()&lt;/PRE&gt;

&lt;P&gt;The prediction algorithm will also require a HomogenNumericTable as input.&lt;/P&gt;

&lt;PRE class="brush:python;"&gt;predictAlg = kdtree_knn_classification.prediction.Batch()
predictAlg.input.setTable(classifier.prediction.data, HomogenNumericTable(X_test))
predictAlg.input.setModel(classifier.prediction.model, trainingResult.get(classifier.training.model))
predictAlg.compute()
predictionResult = predictAlg.getResult()
test_predictions = predictionResult.get(classifier.prediction.prediction)&lt;/PRE&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2017 19:11:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Distribution-for-Python/DAAL-issue-TypeError-in-method-Input-set-argument-3-of-type-daal/m-p/1107432#M565</guid>
      <dc:creator>Christophe_H_Intel2</dc:creator>
      <dc:date>2017-05-15T19:11:57Z</dc:date>
    </item>
    <item>
      <title> </title>
      <link>https://community.intel.com/t5/Intel-Distribution-for-Python/DAAL-issue-TypeError-in-method-Input-set-argument-3-of-type-daal/m-p/1107433#M566</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thanks Christopher,&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp; Your clarification makes the code pass that stage. Surely it might help to continue with the rest of the essay..&lt;/P&gt;

&lt;P&gt;Ragards,&lt;/P&gt;

&lt;P&gt;Sergio&lt;/P&gt;

&lt;P&gt;Enhance your #MachineLearning and #BigData skills via #Python #SciPy&lt;BR /&gt;
	1) &lt;A href="https://www.packtpub.com/big-data-and-business-intelligence/numerical-and-scientific-computing-scipy-video" target="_blank"&gt;https://www.packtpub.com/big-data-and-business-intelligence/numerical-and-scientific-computing-scipy-video&lt;/A&gt;&lt;BR /&gt;
	2) &lt;A href="https://www.packtpub.com/big-data-and-business-intelligence/learning-scipy-numerical-and-scientific-computing-second-edition" target="_blank"&gt;https://www.packtpub.com/big-data-and-business-intelligence/learning-scipy-numerical-and-scientific-computing-second-edition&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 01:15:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Distribution-for-Python/DAAL-issue-TypeError-in-method-Input-set-argument-3-of-type-daal/m-p/1107433#M566</guid>
      <dc:creator>sergio_r_</dc:creator>
      <dc:date>2017-05-16T01:15:22Z</dc:date>
    </item>
    <item>
      <title> </title>
      <link>https://community.intel.com/t5/Intel-Distribution-for-Python/DAAL-issue-TypeError-in-method-Input-set-argument-3-of-type-daal/m-p/1107434#M567</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Hi Chris,&lt;/P&gt;

&lt;P&gt;&amp;nbsp; As expected I was able to finish this example. Now, &lt;STRONG&gt;how can I get to print the values returned in&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE class="brush:python;"&gt;trainingResult = trainAlg.compute()&lt;/PRE&gt;

&lt;P&gt;and in&lt;/P&gt;

&lt;PRE class="brush:python;"&gt;test_predictions = predictionResult.get(classifier.prediction.prediction)&lt;/PRE&gt;

&lt;P&gt;straightforward printing gives&lt;/P&gt;

&lt;PRE class="brush:python;"&gt;In [23]: print(trainingResult)
    ...: 
&amp;lt;daal.algorithms.kdtree_knn_classification.training.Result; proxy of &amp;lt;Swig Object of type 'daal::services::SharedPtr&amp;lt; daal::algorithms::kdtree_knn_classification::training::interface1::Result &amp;gt; *' at 0x7f39f53a4090&amp;gt; &amp;gt;

In [24]: print(test_predictions)
    ...: 
&amp;lt;daal.data_management.NumericTable; proxy of &amp;lt;Swig Object of type 'daal::services::SharedPtr&amp;lt; daal::data_management::interface1::NumericTable &amp;gt; *' at 0x7f39a7627f60&amp;gt; &amp;gt;
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Salut,&lt;/P&gt;

&lt;P&gt;Sergio&lt;BR /&gt;
	Enhance your #MachineLearning and #BigData skills via #Python #SciPy&lt;BR /&gt;
	1) &lt;A href="https://www.packtpub.com/big-data-and-business-intelligence/numerical-and-scientific-computing-scipy-video" target="_blank"&gt;https://www.packtpub.com/big-data-and-business-intelligence/numerical-and-scientific-computing-scipy-video&lt;/A&gt;&lt;BR /&gt;
	2) &lt;A href="https://www.packtpub.com/big-data-and-business-intelligence/learning-scipy-numerical-and-scientific-computing-second-edition" target="_blank"&gt;https://www.packtpub.com/big-data-and-business-intelligence/learning-scipy-numerical-and-scientific-computing-second-edition&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 02:16:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Distribution-for-Python/DAAL-issue-TypeError-in-method-Input-set-argument-3-of-type-daal/m-p/1107434#M567</guid>
      <dc:creator>sergio_r_</dc:creator>
      <dc:date>2017-05-16T02:16:37Z</dc:date>
    </item>
    <item>
      <title>Hi Sergio,</title>
      <link>https://community.intel.com/t5/Intel-Distribution-for-Python/DAAL-issue-TypeError-in-method-Input-set-argument-3-of-type-daal/m-p/1107435#M568</link>
      <description>&lt;P&gt;Hi Sergio,&lt;/P&gt;

&lt;P&gt;To print a NumericTable, you can use the utility functions found in &amp;lt;daalroot&amp;gt;/examples/python/source/utils.&lt;/P&gt;

&lt;PRE class="brush:python;"&gt;import os
import sys
from os.path import join as jp
sys.path.insert(0, jp(os.environ['DAALROOT'], 'examples', 'python', 'source'))
from utils import printNumericTable

printNumericTable(test_predictions)&lt;/PRE&gt;

&lt;P&gt;There is a complete list of PyDAAL examples at&amp;nbsp;&lt;A href="https://software.intel.com/en-us/node/682181"&gt;https://software.intel.com/en-us/node/682181&lt;/A&gt;. &amp;nbsp;You may also find the tutorials at&amp;nbsp;&lt;A href="https://github.com/daaltces/pydaal-tutorials"&gt;https://github.com/daaltces/pydaal-tutorials&lt;/A&gt;&amp;nbsp;useful.&lt;/P&gt;

&lt;P&gt;You should be able to run the remaining algorithms from the essay by using the HomogenNumericTable constructor on any inputs that are numpy arrays. The only caveat is that the only integer type accepted by NumericTables is numpy.intc, so numpy.int64 arrays will need to be converted. The other thing to pay attention to is array shape. You may need to transpose one here or there. In the meantime, I will see if it's possible to publish the complete code samples somewhere. &amp;nbsp;Let me know if you run into any problems.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 13:49:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Distribution-for-Python/DAAL-issue-TypeError-in-method-Input-set-argument-3-of-type-daal/m-p/1107435#M568</guid>
      <dc:creator>Christophe_H_Intel2</dc:creator>
      <dc:date>2017-05-16T13:49:44Z</dc:date>
    </item>
    <item>
      <title> </title>
      <link>https://community.intel.com/t5/Intel-Distribution-for-Python/DAAL-issue-TypeError-in-method-Input-set-argument-3-of-type-daal/m-p/1107436#M569</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thanks Chris,&lt;/P&gt;

&lt;P&gt;I am getting the error:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from utils import printNumericTable&lt;BR /&gt;
		ImportError: No module named 'utils'&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Before running the code I did: export DAALROOT=/home/intel/intelpython3/pkgs/pydaal-2018.0.0b20170313-py35_intel_0&lt;/P&gt;

&lt;P&gt;I also tried (obviously NO success):&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;$ conda install utils
Fetching package metadata .........
Solving package specifications: .


PackageNotFoundError: Package not found: '' Package missing in current linux-64 channels: 
  - utils

Close matches found; did you mean one of these?

    utils: xlutils, docutils, psutil

You can search for packages on anaconda.org with

    anaconda search -t conda utils

You may need to install the anaconda-client command line client with

    conda install anaconda-client
&lt;/PRE&gt;

&lt;P&gt;By the way, &lt;STRONG&gt;I was able to successfully run the examples&lt;/STRONG&gt; at pydaal-2018.0.0b20170313-py35_intel_0/sh&lt;BR /&gt;
	are/pydaal_examples/examples/python via the command &lt;STRONG&gt;python run_examples.py&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Regards,&lt;/P&gt;

&lt;P&gt;Sergio&lt;BR /&gt;
	Enhance your #MachineLearning and #BigData skills via #Python #SciPy&lt;BR /&gt;
	1) &lt;A href="https://www.packtpub.com/big-data-and-business-intelligence/numerical-and-scientific-computing-scipy-video" target="_blank"&gt;https://www.packtpub.com/big-data-and-business-intelligence/numerical-and-scientific-computing-scipy-video&lt;/A&gt;&lt;BR /&gt;
	2) &lt;A href="https://www.packtpub.com/big-data-and-business-intelligence/learning-scipy-numerical-and-scientific-computing-second-edition" target="_blank"&gt;https://www.packtpub.com/big-data-and-business-intelligence/learning-scipy-numerical-and-scientific-computing-second-edition&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 15:53:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Distribution-for-Python/DAAL-issue-TypeError-in-method-Input-set-argument-3-of-type-daal/m-p/1107436#M569</guid>
      <dc:creator>sergio_r_</dc:creator>
      <dc:date>2017-05-16T15:53:28Z</dc:date>
    </item>
    <item>
      <title>Hi Sergio,</title>
      <link>https://community.intel.com/t5/Intel-Distribution-for-Python/DAAL-issue-TypeError-in-method-Input-set-argument-3-of-type-daal/m-p/1107437#M570</link>
      <description>&lt;P&gt;Hi Sergio,&lt;/P&gt;

&lt;P&gt;I was incorrectly assuming a separate DAAL installation. Sorry about that. For Intel Python, the utils folder can be found in &amp;lt;install_root&amp;gt;/share/pydaal_examples/examples/python/source. Just make sure that folder is on your sys.path at runtime, or you can point the PYTHONPATH environment variable there.&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 16:17:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Distribution-for-Python/DAAL-issue-TypeError-in-method-Input-set-argument-3-of-type-daal/m-p/1107437#M570</guid>
      <dc:creator>Christophe_H_Intel2</dc:creator>
      <dc:date>2017-05-16T16:17:51Z</dc:date>
    </item>
    <item>
      <title> </title>
      <link>https://community.intel.com/t5/Intel-Distribution-for-Python/DAAL-issue-TypeError-in-method-Input-set-argument-3-of-type-daal/m-p/1107438#M571</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;OK. Its working. Now what remains is to make sense of output. It does not look any close to the sklearn one.&lt;/P&gt;

&lt;P&gt;Sergio&lt;BR /&gt;
	Enhance your #MachineLearning and #BigData skills via #Python #SciPy&lt;BR /&gt;
	1) &lt;A href="https://www.packtpub.com/big-data-and-business-intelligence/numerical-and-scientific-computing-scipy-video" target="_blank"&gt;https://www.packtpub.com/big-data-and-business-intelligence/numerical-and-scientific-computing-scipy-video&lt;/A&gt;&lt;BR /&gt;
	2) &lt;A href="https://www.packtpub.com/big-data-and-business-intelligence/learning-scipy-numerical-and-scientific-computing-second-edition" target="_blank"&gt;https://www.packtpub.com/big-data-and-business-intelligence/learning-scipy-numerical-and-scientific-computing-second-edition&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 17:21:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Distribution-for-Python/DAAL-issue-TypeError-in-method-Input-set-argument-3-of-type-daal/m-p/1107438#M571</guid>
      <dc:creator>sergio_r_</dc:creator>
      <dc:date>2017-05-16T17:21:05Z</dc:date>
    </item>
  </channel>
</rss>

