Tutorial: Classifier
How to create an IRIS classifier on Android using Eclipse Deeplearning4j.
Setup
Setting up the neural network on a background thread
public class MainActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//get references to the editTexts that take the measurements
final EditText PL = (EditText) findViewById(R.id.editText);
final EditText PW = (EditText) findViewById(R.id.editText2);
final EditText SL = (EditText) findViewById(R.id.editText3);
final EditText SW = (EditText) findViewById(R.id.editText4);
//onclick to capture the input and launch the asyncTask
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final double pl = Double.parseDouble(PL.getText().toString());
final double pw = Double.parseDouble(PW.getText().toString());
final double sl = Double.parseDouble(SL.getText().toString());
final double sw = Double.parseDouble(SW.getText().toString());
AsyncTaskRunner runner = new AsyncTaskRunner();
//pass the measurement as params to the AsyncTask
runner.execute(pl,pw,sl,sw);
ProgressBar bar = (ProgressBar) findViewById(R.id.progressBar);
bar.setVisibility(View.VISIBLE);
}
});
}Preparing the training data set and user input
Building and Training the Neural Network
Updating the UI
Conclusion
Last updated
Was this helpful?