# Fit data into ND4J to get prediction of the model

**URL:** <https://community.konduit.ai/t/fit-data-into-nd4j-to-get-prediction-of-the-model/2060>\
**Category:** ND4J\
**Created:** [November 9, 2022, 4:29pm UTC](https://community.konduit.ai/t/fit-data-into-nd4j-to-get-prediction-of-the-model/2060 "2022-11-09T16:29:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![LEphongsac](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/lephongsac/32/961_2.png) [@LEphongsac](https://community.konduit.ai/u/LEphongsac)\
**Post date:** [November 9, 2022, 4:29pm UTC](https://community.konduit.ai/t/fit-data-into-nd4j-to-get-prediction-of-the-model/2060/1 "2022-11-09T16:29:45Z")

</div>

Hello,  
I’m newbie to DL4J, i read the document, i searched for the answer but i coudnt find it. I want to ask a question please. I have this file comme Json  
[  
{  
“asset”: {  
“ASSETTYPE”: “HAHA”,  
“ASSETTYPECODE”: “VN”,  
“ASSETUSED”: “N”,  
“BRANDCODE”: “CIT”,  
“MODELGROUPCODE”: “1CB6”  
},  
“customer”: {  
“ID” : 4751060,  
“PARTYTYPECODE”: “ECH”,  
“LEGALFORMCODE”: “AG”,  
“PROFESSIONCODE”: “None”,  
“ACTIVITYCODE”: “AUTO”,  
“COMPANYSTARTDATE”: 2.45429e+6,  
“COMPANYENDDATE”: null,  
“EMPLOYEESTARTDATE”: null,  
“SENIORITYNBMONTHS”: null,  
“INCOMESAMOUNT”: 0,  
}  
}

I also have a model H5 to import into MultiLayerNetwork model. I need to transform the json file into numeric so that i can put into ND4J ? to do model.output(input)  
I also watch some solution, but i dont understand how can be the same (Like the data transform in model H5 and the data transform in Json). Thank you in advance!

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [November 9, 2022, 11:07pm UTC](https://community.konduit.ai/t/fit-data-into-nd4j-to-get-prediction-of-the-model/2060/2 "2022-11-09T23:07:59Z")

</div>

@LEphongsac breaking this down a bit…your question is a bit confusing. I would need clarity on what you’re confused on regarding model import. Model import is just for loading the model in.

For conversion of your data in to a dataset, it sounds like you have a model and you’re asking how to create a data pipeline similar to what you already have in python? If so, do you have some pandas code already laying around?

It’s kind of hard to understand what you want here. Do you need help converting the data to an ndarray?  
It looks like you’re trading securities here? In here you have some categorical data, usually you convert that to one hot,.

Depending on your task, (forecasting or what have you) you would need to figure out what your target is. Is that going to be a price? Are you doing classification?

If you can elaborate more I’m happy to help.

---

<div class="post-metadata">

**Author:** ![LEphongsac](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/lephongsac/32/961_2.png) [@LEphongsac](https://community.konduit.ai/u/LEphongsac)\
**Post date:** [November 10, 2022, 8:12am UTC](https://community.konduit.ai/t/fit-data-into-nd4j-to-get-prediction-of-the-model/2060/3 "2022-11-10T08:12:42Z")

</div>

Thank you for your reply and sorry for my bad explaination.  
I am asking how to create a data pipeline similar to what i already have in python. But my pipeline in python hasnt finished yet, though i still want to know how can it be similar to each other.

My task is to create a model which can base on the database and tell exactly that the client will resigne the contract or not. So in python, i will transform and feed the model with the data in database. And with DL4J, i need to use the json like i mentionned before, and convert it to an ndarray (the way the model can understand), so that the model can analyse this json.

I don’t know if you can understand my thought, and sorry again for my English

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [November 10, 2022, 8:16am UTC](https://community.konduit.ai/t/fit-data-into-nd4j-to-get-prediction-of-the-model/2060/4 "2022-11-10T08:16:26Z")

</div>

> [@LEphongsac](#):
>
> which can base on the database and tell exactly that the client will resigne the contract or not

This might help you: [Quickstart with Deeplearning4J – dubs·tech](https://www.dubs.tech/guides/quickstart-with-dl4j/#loading-data)

The example used in that quick start guide uses the same kind of data as I expect you’ll be using.

You can start with the data the example uses to get accustomed to the way data loading works, and then you can switch to your data.

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [November 10, 2022, 8:22am UTC](https://community.konduit.ai/t/fit-data-into-nd4j-to-get-prediction-of-the-model/2060/5 "2022-11-10T08:22:17Z")

</div>

@LEphongsac I would perfect your pipeline in python first. If you want to, you can actually just use python4j to directly embed that pipeline in to a script and output an ndarray:

> **[Quickstart](https://deeplearning4j.konduit.ai/python4j/tutorials/quickstart)**
>
> Python4j Key features and brief samples.

You can see the quickstart for that above.

Then if your pipeline is set you can consider migrating over to a transform process. At that point you can follow Paul’s tutorial. If you can post more I can point to more specific data points.

---

<div class="post-metadata">

**Author:** ![LEphongsac](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/lephongsac/32/961_2.png) [@LEphongsac](https://community.konduit.ai/u/LEphongsac)\
**Post date:** [November 10, 2022, 8:36am UTC](https://community.konduit.ai/t/fit-data-into-nd4j-to-get-prediction-of-the-model/2060/6 "2022-11-10T08:36:17Z")

</div>

Thank you for your reply, i’ll take a look this example

---

<div class="post-metadata">

**Author:** ![LEphongsac](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/lephongsac/32/961_2.png) [@LEphongsac](https://community.konduit.ai/u/LEphongsac)\
**Post date:** [November 10, 2022, 8:44am UTC](https://community.konduit.ai/t/fit-data-into-nd4j-to-get-prediction-of-the-model/2060/7 "2022-11-10T08:44:20Z")

</div>

Thank you, i’ll will try to go further, ill show you more point if i has a problem, Thank you for the example

---

<div class="post-metadata">

**Author:** ![LEphongsac](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/lephongsac/32/961_2.png) [@LEphongsac](https://community.konduit.ai/u/LEphongsac)\
**Post date:** [November 16, 2022, 10:47am UTC](https://community.konduit.ai/t/fit-data-into-nd4j-to-get-prediction-of-the-model/2060/8 "2022-11-16T10:47:10Z")

</div>

> [@agibsonccc](#):
>
> python4j to

Hello,  
Do you have any example in detail for the python4j, pls ?

Otherwise, I have a database with plein of data, and each categorical data have like 30 40 differents value, so i cant use like one hot code. And i do see the example of using schema with add categorical column, but its difficile because i cant write on my own 30 40 different value and change it to integer.

In python, I use catboost to transform categorical data to numeric. So, can I import the database into java, use some algorithme like catboost to transform categorical data to numeric (so that when i put my data to predict, it can transform just like the way it transform the database). And i use the same algorithme in Python to train the model (So that the result of this transformation would be the same with java =\> the same with the data that i want to predict).

Sorry if its hard to understand. Thank you for giving me some advices.

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [November 16, 2022, 2:15pm UTC](https://community.konduit.ai/t/fit-data-into-nd4j-to-get-prediction-of-the-model/2060/9 "2022-11-16T14:15:35Z")

</div>

@LEphongsac

> **[Quickstart](https://deeplearning4j.konduit.ai/python4j/tutorials/quickstart)**
>
> Python4j Key features and brief samples.

> **[Write Python Script](https://deeplearning4j.konduit.ai/python4j/how-to-guides/write-python-script)**
>
> How to write a python script for python4j

Just ensure you have the relevant version of conda installed and the python path setup + have the python version match ours when we execute.
