60 lines
1.2 KiB
Markdown
60 lines
1.2 KiB
Markdown
|
# Xlswriter
|
||
|
|
||
|
|
||
|
```
|
||
|
|
||
|
Import xlswriter
|
||
|
|
||
|
|
||
|
#create file (workbook) and worksheet
|
||
|
outWorkbook = xlsxwriter.Workbook("out.xlsx")
|
||
|
outSheet = outWorkbook.add_worksheet()
|
||
|
|
||
|
#declare data
|
||
|
Names = ["Oklahoma", "Non", "Mary"]
|
||
|
Values = [70,80,90]
|
||
|
|
||
|
|
||
|
#write headers
|
||
|
For item in range(len(names)):
|
||
|
outSheet.write(x, y
|
||
|
outSheet.write("A1", "ANMES)
|
||
|
outSheet.write("B1", "Scores")
|
||
|
|
||
|
#declare data to file
|
||
|
outSheet.write("
|
||
|
|
||
|
outWorkbook.close()
|
||
|
|
||
|
|
||
|
```
|
||
|
|
||
|
Sci- kit Learn & keras:
|
||
|
|
||
|
```
|
||
|
# create a function that returns a model, taking as parameters things you
|
||
|
# want to verify using cross-valdiation and model selection
|
||
|
def create_model(optimizer='adagrad',
|
||
|
kernel_initializer='glorot_uniform',
|
||
|
dropout=0.2):
|
||
|
model = Sequential()
|
||
|
model.add(Dense(64,activation='relu',kernel_initializer=kernel_initializer))
|
||
|
model.add(Dropout(dropout))
|
||
|
model.add(Dense(1,activation='sigmoid',kernel_initializer=kernel_initializer))
|
||
|
|
||
|
model.compile(loss='binary_crossentropy',optimizer=optimizer, metrics=['accuracy'])
|
||
|
|
||
|
return model
|
||
|
|
||
|
# wrap the model using the function you created
|
||
|
clf = KerasRegressor(build_fn=create_model,verbose=0)
|
||
|
|
||
|
# just create the pipeline
|
||
|
pipeline = Pipeline([
|
||
|
('clf',clf)
|
||
|
])
|
||
|
|
||
|
pipeline.fit(X_train, y_train)
|
||
|
|
||
|
```
|