@@ -213,6 +213,64 @@ def pipelines():
213
213
print ("*** End pipelines examples ***" )
214
214
print ()
215
215
216
+ def pipelines_2 ():
217
+ """
218
+ Scikit learn pipeline with a molecular neural network
219
+ """
220
+
221
+ print ("\n *** Begin pipelines example with molecular Neural Network ***" )
222
+
223
+ data = qmlearn .Data ("../test/qm7/*.xyz" )
224
+ energies = np .loadtxt ("../test/data/hof_qm7.txt" , usecols = 1 )
225
+ data .set_energies (energies )
226
+
227
+ # Create model
228
+ model = sklearn .pipeline .make_pipeline (
229
+ qmlearn .preprocessing .AtomScaler (data ),
230
+ qmlearn .representations .CoulombMatrix (),
231
+ qmlearn .models .NeuralNetwork (iterations = 500 , batch_size = 50 , learning_rate = 0.005 ),
232
+ )
233
+
234
+ indices = np .arange (1000 )
235
+ np .random .shuffle (indices )
236
+
237
+ model .fit (indices [:100 ])
238
+
239
+ # Score on the TRAINING set, since you won't get good predictions in 500 iterations
240
+ scores = model .score (indices [:100 ])
241
+ print ("Negative MAE:" , scores )
242
+
243
+ print ("*** End pipelines example with molecular Neural Network *** \n " )
244
+
245
+ def pipelines_3 ():
246
+ """
247
+ Scikit learn pipeline with an atomic neural network
248
+ """
249
+
250
+ print ("\n *** Begin pipelines example with atomic Neural Network ***" )
251
+
252
+ data = qmlearn .Data ("../test/qm7/*.xyz" )
253
+ energies = np .loadtxt ("../test/data/hof_qm7.txt" , usecols = 1 )
254
+ data .set_energies (energies )
255
+
256
+ # Create model
257
+ model = sklearn .pipeline .make_pipeline (
258
+ qmlearn .preprocessing .AtomScaler (data ),
259
+ qmlearn .representations .AtomCenteredSymmetryFunctions (),
260
+ qmlearn .models .NeuralNetwork (iterations = 500 , batch_size = 50 , learning_rate = 0.005 ),
261
+ )
262
+
263
+ indices = np .arange (1000 )
264
+ np .random .shuffle (indices )
265
+
266
+ model .fit (indices [:100 ])
267
+
268
+ # Score on the TRAINING set, since you won't get good predictions in 500 iterations
269
+ scores = model .score (indices [:100 ])
270
+ print ("Negative MAE:" , scores )
271
+
272
+ print ("*** End pipelines example with atomic Neural Network *** \n " )
273
+
216
274
def cross_validation ():
217
275
"""
218
276
Doing cross validation with qmlearn
@@ -285,3 +343,5 @@ def cross_validation():
285
343
models ()
286
344
pipelines ()
287
345
cross_validation ()
346
+ pipelines_2 ()
347
+ pipelines_3 ()
0 commit comments