Kaggle competition: PetFinder.my Adoption Prediction
<SOS> metric: QuadraticWeightedKappa Kaggle data source: petfinder.my-adoption-prediction<load_from_csv>
submission = pd.read_csv(input_path / 'sample_submission.csv', index_col='id')
 display(submission.head() )<count_missing_values>
%matplotlib inline
pd.options.display.max_rows = 128
pd.options.display.max_columns = 128
plt.rcParams['figure.figsize'] =(12, 9 )
features = [f'cont{x}'for x in range(1,15)]
data= train[features]
train.isnull().sum()<filter>
train = pd.read_csv('.. /input/train/train.csv')
 print('train shape:', train.shape)
 test = pd.read_csv('.. /input/test/test.csv')
 print('test shape:', test.shape)
 sample_submission = pd.read_csv('.. /input/test/sample_submission.csv')
 labels_breed = pd.read_csv('.. /input/breed_labels.csv')
 labels_state = pd.read_csv('.. /input/color_labels.csv')
 labels_color = pd.read_csv('.. /input/state_labels.csv')
 train_image_files = sorted(glob.glob('.. /input/train_images/*.jpg'))
train_metadata_files = sorted(glob.glob('.. /input/train_metadata/*.json'))
train_sentiment_files = sorted(glob.glob('.. /input/train_sentiment/*.json'))
print('num of train images files: {}'.format(len(train_image_files)))
 print('num of train metadata files: {}'.format(len(train_metadata_files)))
 print('num of train sentiment files: {}'.format(len(train_sentiment_files)))
 test_image_files = sorted(glob.glob('.. /input/test_images/*.jpg'))
test_metadata_files = sorted(glob.glob('.. /input/test_metadata/*.json'))
test_sentiment_files = sorted(glob.glob('.. /input/test_sentiment/*.json'))
print('num of test images files: {}'.format(len(test_image_files)))
 print('num of test metadata files: {}'.format(len(test_metadata_files)))
 print('num of test sentiment files: {}'.format(len(test_sentiment_files)) )
train[train['target'] == 0]<feature_engineering>
test_df_ids = test[['PetID']]
print(test_df_ids.shape)
 test_df_imgs = pd.DataFrame(test_image_files)
 test_df_imgs.columns = ['image_filename']
test_imgs_pets = test_df_imgs['image_filename'].apply(lambda x: x.split('/')[-1].split('-')[0])
 test_df_imgs = test_df_imgs.assign(PetID=test_imgs_pets)
 print(len(test_imgs_pets.unique()))
pets_with_images = len(np.intersect1d(test_imgs_pets.unique() , test_df_ids['PetID'].unique()))
print('fraction of pets with images: {:.3f}'.format(pets_with_images / test_df_ids.shape[0]))
test_df_ids = test[['PetID']]
test_df_metadata = pd.DataFrame(test_metadata_files)
 test_df_metadata.columns = ['metadata_filename']
test_metadata_pets = test_df_metadata['metadata_filename'].apply(lambda x: x.split('/')[-1].split('-')[0])
 test_df_metadata = test_df_metadata.assign(PetID=test_metadata_pets)
 print(len(test_metadata_pets.unique()))
pets_with_metadatas = len(np.intersect1d(test_metadata_pets.unique() , test_df_ids['PetID'].unique()))
print('fraction of pets with metadata: {:.3f}'.format(pets_with_metadatas / test_df_ids.shape[0]))
test_df_ids = test[['PetID']]
test_df_sentiment = pd.DataFrame(test_sentiment_files)
 test_df_sentiment.columns = ['sentiment_filename']
test_sentiment_pets = test_df_sentiment['sentiment_filename'].apply(lambda x: x.split('/')[-1].split('.')[0])
 test_df_sentiment = test_df_sentiment.assign(PetID=test_sentiment_pets)
 print(len(test_sentiment_pets.unique()))
pets_with_sentiments = len(np.intersect1d(test_sentiment_pets.unique() , test_df_ids['PetID'].unique()))
print('fraction of pets with sentiment: {:.3f}'.format(pets_with_sentiments / test_df_ids.shape[0]))
print()
print('images and metadata distributions the same? {}'.format(
 np.all(test_metadata_pets == test_imgs_pets)) )
def replace_outliers(data):
for col in data.columns:
Q1 = data[col].quantile(0.25)
 Q3 = data[col].quantile(0.75)
 IQR = Q3 - Q1
median_ = data[col].median()
data.loc[(( data[col] < Q1 - 1.5*IQR)|(data[col] > Q3 + 1.5*IQR)) , col] = median_
return data<define_variables>
class PetFinderParser(object):
def __init__(self, debug=False):
self.debug = debug
self.sentence_sep = ' '
self.extract_sentiment_text = False
def open_metadata_file(self, filename):

 with open(filename, 'r')as f:
metadata_file = json.load(f)
 return metadata_file
def open_sentiment_file(self, filename):

 with open(filename, 'r')as f:
sentiment_file = json.load(f)
 return sentiment_file
def open_image_file(self, filename):

 image = np.asarray(Image.open(filename))
return image
def parse_sentiment_file(self, file):

 file_sentiment = file['documentSentiment']
file_entities = [x['name'] for x in file['entities']]
file_entities = self.sentence_sep.join(file_entities)
 if self.extract_sentiment_text:
file_sentences_text = [x['text']['content'] for x in file['sentences']]
file_sentences_text = self.sentence_sep.join(file_sentences_text)
 file_sentences_sentiment = [x['sentiment'] for x in file['sentences']]
file_sentences_sentiment = pd.DataFrame.from_dict(
 file_sentences_sentiment, orient='columns' ).sum()
file_sentences_sentiment = file_sentences_sentiment.add_prefix('document_' ).to_dict()
file_sentiment.update(file_sentences_sentiment)
 df_sentiment = pd.DataFrame.from_dict(file_sentiment, orient='index' ).T
if self.extract_sentiment_text:
df_sentiment['text'] = file_sentences_text
df_sentiment['entities'] = file_entities
df_sentiment = df_sentiment.add_prefix('sentiment_')
 return df_sentiment
def parse_metadata_file(self, file):

 file_keys = list(file.keys())
 if 'labelAnnotations' in file_keys:
file_annots = file['labelAnnotations'][:int(len(file['labelAnnotations'])* 0.3)]
file_top_score = np.asarray([x['score'] for x in file_annots] ).mean()
file_top_desc = [x['description'] for x in file_annots]
else:
file_top_score = np.nan
file_top_desc = ['']
file_colors = file['imagePropertiesAnnotation']['dominantColors']['colors']
file_crops = file['cropHintsAnnotation']['cropHints']
file_color_score = np.asarray([x['score'] for x in file_colors] ).mean()
file_color_pixelfrac = np.asarray([x['pixelFraction'] for x in file_colors] ).mean()
file_crop_conf = np.asarray([x['confidence'] for x in file_crops] ).mean()
if 'importanceFraction' in file_crops[0].keys() :
file_crop_importance = np.asarray([x['importanceFraction'] for x in file_crops] ).mean()
else:
file_crop_importance = np.nan
df_metadata = {
'annots_score': file_top_score,
'color_score': file_color_score,
'color_pixelfrac': file_color_pixelfrac,
'crop_conf': file_crop_conf,
'crop_importance': file_crop_importance,
'annots_top_desc': self.sentence_sep.join(file_top_desc)
 }
df_metadata = pd.DataFrame.from_dict(df_metadata, orient='index' ).T
df_metadata = df_metadata.add_prefix('metadata_')
 return df_metadata
def extract_additional_features(pet_id, mode='train'):
sentiment_filename = '.. /input/{}_sentiment/{}.json'.format(mode, pet_id)
 try:
sentiment_file = pet_parser.open_sentiment_file(sentiment_filename)
 df_sentiment = pet_parser.parse_sentiment_file(sentiment_file)
 df_sentiment['PetID'] = pet_id
except FileNotFoundError:
df_sentiment = []
dfs_metadata = []
metadata_filenames = sorted(glob.glob('.. /input/{}_metadata/{}*.json'.format(mode, pet_id)))
 if len(metadata_filenames)> 0:
for f in metadata_filenames:
metadata_file = pet_parser.open_metadata_file(f)
 df_metadata = pet_parser.parse_metadata_file(metadata_file)
 df_metadata['PetID'] = pet_id
dfs_metadata.append(df_metadata)
 dfs_metadata = pd.concat(dfs_metadata, ignore_index=True, sort=False)
 dfs = [df_sentiment, dfs_metadata]
return dfs
pet_parser = PetFinderParser()
train = replace_outliers(train )<filter>
aggregates = ['mean', 'sum']
train_metadata_desc = train_dfs_metadata.groupby(['PetID'])['metadata_annots_top_desc'].unique()
train_metadata_desc = train_metadata_desc.reset_index()
train_metadata_desc[
'metadata_annots_top_desc'] = train_metadata_desc[
'metadata_annots_top_desc'].apply(lambda x: ' '.join(x))
prefix = 'metadata'
train_metadata_gr = train_dfs_metadata.drop(['metadata_annots_top_desc'], axis=1)
 for i in train_metadata_gr.columns:
if 'PetID' not in i:
train_metadata_gr[i] = train_metadata_gr[i].astype(float)
 train_metadata_gr = train_metadata_gr.groupby(['PetID'] ).agg(aggregates)
 train_metadata_gr.columns = pd.Index(['{}_{}_{}'.format(
 prefix, c[0], c[1].upper())for c in train_metadata_gr.columns.tolist() ])
 train_metadata_gr = train_metadata_gr.reset_index()
train_sentiment_desc = train_dfs_sentiment.groupby(['PetID'])['sentiment_entities'].unique()
train_sentiment_desc = train_sentiment_desc.reset_index()
train_sentiment_desc[
'sentiment_entities'] = train_sentiment_desc[
'sentiment_entities'].apply(lambda x: ' '.join(x))
prefix = 'sentiment'
train_sentiment_gr = train_dfs_sentiment.drop(['sentiment_entities'], axis=1)
 for i in train_sentiment_gr.columns:
if 'PetID' not in i:
train_sentiment_gr[i] = train_sentiment_gr[i].astype(float)
 train_sentiment_gr = train_sentiment_gr.groupby(['PetID'] ).agg(aggregates)
 train_sentiment_gr.columns = pd.Index(['{}_{}_{}'.format(
 prefix, c[0], c[1].upper())for c in train_sentiment_gr.columns.tolist() ])
 train_sentiment_gr = train_sentiment_gr.reset_index()
test_metadata_desc = test_dfs_metadata.groupby(['PetID'])['metadata_annots_top_desc'].unique()
test_metadata_desc = test_metadata_desc.reset_index()
test_metadata_desc[
'metadata_annots_top_desc'] = test_metadata_desc[
'metadata_annots_top_desc'].apply(lambda x: ' '.join(x))
prefix = 'metadata'
test_metadata_gr = test_dfs_metadata.drop(['metadata_annots_top_desc'], axis=1)
 for i in test_metadata_gr.columns:
if 'PetID' not in i:
test_metadata_gr[i] = test_metadata_gr[i].astype(float)
 test_metadata_gr = test_metadata_gr.groupby(['PetID'] ).agg(aggregates)
 test_metadata_gr.columns = pd.Index(['{}_{}_{}'.format(
 prefix, c[0], c[1].upper())for c in test_metadata_gr.columns.tolist() ])
 test_metadata_gr = test_metadata_gr.reset_index()
test_sentiment_desc = test_dfs_sentiment.groupby(['PetID'])['sentiment_entities'].unique()
test_sentiment_desc = test_sentiment_desc.reset_index()
test_sentiment_desc[
'sentiment_entities'] = test_sentiment_desc[
'sentiment_entities'].apply(lambda x: ' '.join(x))
prefix = 'sentiment'
test_sentiment_gr = test_dfs_sentiment.drop(['sentiment_entities'], axis=1)
 for i in test_sentiment_gr.columns:
if 'PetID' not in i:
test_sentiment_gr[i] = test_sentiment_gr[i].astype(float)
 test_sentiment_gr = test_sentiment_gr.groupby(['PetID'] ).agg(aggregates)
 test_sentiment_gr.columns = pd.Index(['{}_{}_{}'.format(
 prefix, c[0], c[1].upper())for c in test_sentiment_gr.columns.tolist() ])
 test_sentiment_gr = test_sentiment_gr.reset_index()
corr_feature = ['cont6','cont7','cont8','cont9','cont10','cont11','cont12','cont13']
corr_in = train[corr_feature]<drop_column>
train_proc = train.copy()
train_proc = train_proc.merge(
 train_sentiment_gr, how='left', on='PetID')
 train_proc = train_proc.merge(
 train_metadata_gr, how='left', on='PetID')
 train_proc = train_proc.merge(
 train_metadata_desc, how='left', on='PetID')
 train_proc = train_proc.merge(
 train_sentiment_desc, how='left', on='PetID')
 test_proc = test.copy()
test_proc = test_proc.merge(
 test_sentiment_gr, how='left', on='PetID')
 test_proc = test_proc.merge(
 test_metadata_gr, how='left', on='PetID')
 test_proc = test_proc.merge(
 test_metadata_desc, how='left', on='PetID')
 test_proc = test_proc.merge(
 test_sentiment_desc, how='left', on='PetID')
 print(train_proc.shape, test_proc.shape)
 assert train_proc.shape[0] == train.shape[0]
assert test_proc.shape[0] == test.shape[0]
train = train.drop(284103 )<split>
train_breed_main = train_proc[['Breed1']].merge(
 labels_breed, how='left',
left_on='Breed1', right_on='BreedID',
suffixes=('', '_main_breed'))
train_breed_main = train_breed_main.iloc[:, 2:]
train_breed_main = train_breed_main.add_prefix('main_breed_')
 train_breed_second = train_proc[['Breed2']].merge(
 labels_breed, how='left',
left_on='Breed2', right_on='BreedID',
suffixes=('', '_second_breed'))
train_breed_second = train_breed_second.iloc[:, 2:]
train_breed_second = train_breed_second.add_prefix('second_breed_')
 train_proc = pd.concat(
 [train_proc, train_breed_main, train_breed_second], axis=1)
 test_breed_main = test_proc[['Breed1']].merge(
 labels_breed, how='left',
left_on='Breed1', right_on='BreedID',
suffixes=('', '_main_breed'))
test_breed_main = test_breed_main.iloc[:, 2:]
test_breed_main = test_breed_main.add_prefix('main_breed_')
 test_breed_second = test_proc[['Breed2']].merge(
 labels_breed, how='left',
left_on='Breed2', right_on='BreedID',
suffixes=('', '_second_breed'))
test_breed_second = test_breed_second.iloc[:, 2:]
test_breed_second = test_breed_second.add_prefix('second_breed_')
 test_proc = pd.concat(
 [test_proc, test_breed_main, test_breed_second], axis=1)
 print(train_proc.shape, test_proc.shape )
target = train.pop('target')
 X_train, X_test, y_train, y_test = train_test_split(train, target, train_size=0.60 )<train_model>
X = pd.concat([train_proc, test_proc], ignore_index=True, sort=False)
 {}'.format(np.sum(pd.isnull(X))))
column_types = X.dtypes
int_cols = column_types[column_types == 'int']
float_cols = column_types[column_types == 'float']
cat_cols = column_types[column_types == 'object']
print('\tinteger columns:
{}'.format(int_cols))
print('
\tfloat columns:
{}'.format(float_cols))
print('
\tto encode categorical columns:
{}'.format(cat_cols))
model = XGBRegressor(n_estimators=500, learning_rate=0.05, n_jobs=4)
 model.fit(X_train, y_train,
early_stopping_rounds=5,
eval_set=[(X_test, y_test)],
verbose=False )<predict_on_test>
X_temp = X.copy()
text_columns = ['Description', 'metadata_annots_top_desc', 'sentiment_entities']
categorical_columns = ['main_breed_BreedName', 'second_breed_BreedName']
to_drop_columns = ['PetID', 'Name', 'RescuerID']
rescuer_count = X.groupby(['RescuerID'])['PetID'].count().reset_index()
rescuer_count.columns = ['RescuerID', 'RescuerID_COUNT']
X_temp = X_temp.merge(rescuer_count, how='left', on='RescuerID')
 for i in categorical_columns:
X_temp.loc[:, i] = pd.factorize(X_temp.loc[:, i])[0]
X_text = X_temp[text_columns]
for i in X_text.columns:
X_text.loc[:, i] = X_text.loc[:, i].fillna('<MISSING>' )
y_pred = model.predict(X_test)
 score = mean_squared_error(y_test, y_pred, squared=False)
 print(score )<save_to_csv>
n_components = 5
text_features = []
for i in X_text.columns:
print('generating features from: {}'.format(i))
svd_ = TruncatedSVD(
 n_components=n_components, random_state=1337)
 nmf_ = NMF(
 n_components=n_components, random_state=1337)
 tfidf_col = TfidfVectorizer().fit_transform(X_text.loc[:, i].values)
 svd_col = svd_.fit_transform(tfidf_col)
 svd_col = pd.DataFrame(svd_col)
 svd_col = svd_col.add_prefix('SVD_{}_'.format(i))
nmf_col = nmf_.fit_transform(tfidf_col)
 nmf_col = pd.DataFrame(nmf_col)
 nmf_col = nmf_col.add_prefix('NMF_{}_'.format(i))
text_features.append(svd_col)
 text_features.append(nmf_col)
 text_features = pd.concat(text_features, axis=1)
 X_temp = pd.concat([X_temp, text_features], axis=1)
 for i in X_text.columns:
X_temp = X_temp.drop(i, axis=1)
 X_temp = X_temp.drop(to_drop_columns, axis=1)
 print('X shape: {}'.format(X_temp.shape))
submission['target'] = model.predict(test)
 submission.to_csv('xgb_regressor.csv' )<install_modules>
X_temp_column_types = X_temp.dtypes
X_temp_int_cols = X_temp_column_types[X_temp_column_types == 'int']
X_temp_float_cols = X_temp_column_types[X_temp_column_types == 'float']
X_temp_cat_cols = X_temp_column_types[X_temp_column_types == 'object']
print('\tinteger columns:
{}'.format(X_temp_int_cols))
print('
\tfloat columns:
{}'.format(X_temp_float_cols))
print('
\tto encode categorical columns:
{}'.format(X_temp_cat_cols))
!pip install.. /input/stochastic/stochastic-0.4.0-py2.py3-none-any.whl<import_modules>
from sklearn.datasets import make_hastie_10_2
from sklearn.ensemble import GradientBoostingClassifier
import matplotlib.pyplot as plt
import gc
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from sklearn.metrics import f1_score
from sklearn.model_selection import KFold
import lightgbm as lgb<define_variables>
train_df, val_df = train_test_split(train_data, test_size =.2)
 print(train_df.shape)
 print(val_df.shape)
 train_df.head(5 )
SEED = 42
N_SPLITS = 5<data_type_conversions>
tr_y = train_df["AdoptionSpeed"]
tr_x = train_df.drop(['AdoptionSpeed'], axis=1)
 val_y = val_df["AdoptionSpeed"]
val_x = val_df.drop(['AdoptionSpeed'], axis=1)
 print(tr_x.shape)
 print(tr_y.shape )
def reduce_memory_usage(df):
numerics = ["int16", "int32", "int64", "float64"]
for col, col_type in df.dtypes.iteritems() :
best_type = None
if col_type == "object":
df[col] = df[col].astype("category")
 best_type = "category"
elif col_type in numerics:
downcast = "integer" if "int" in str(col_type)else "float"
df[col] = pd.to_numeric(df[col], downcast=downcast)
 best_type = df[col].dtype.name
return df<compute_test_metric>
clf = GradientBoostingClassifier(n_estimators=100, learning_rate=0.05, max_depth=5, random_state=0)
 clf.fit(tr_x, tr_y )
def macro_f1_score(preds, train_data):
labels = train_data.get_label()
preds = np.round(np.clip(preds, 0, 10)).astype(int)
 score = f1_score(labels, preds, average="macro")
 return "f1", score, True<feature_engineering>
val_prediction = clf.predict(val_x )
def features(df):
df = df.sort_values(by=["time"] ).reset_index(drop=True)
 df.index = df.time * 10000 - 1
df["batch"] = df.index // 25000
df["batch_index"] = df.index - df.batch * 25000
df["batch_slices"] = df["batch_index"] // 2500
df["batch_slices_2"] = df["batch"].astype(str)+ "_" + df["batch_slices"].astype(str)
 for c in ["batch", "batch_slices_2"]:
d = {}
d["mean_" + c] = df.groupby([c])["signal"].mean()
d["std_" + c] = df.groupby([c])["signal"].std()
d["median_" + c] = df.groupby([c])["signal"].median()
d["min_" + c] = df.groupby([c])["signal"].min()
d["max_" + c] = df.groupby([c])["signal"].max()
d["mean_abs_change_" + c] = df.groupby([c])["signal"].apply(lambda x: np.mean(np.abs(np.diff(x))))
d["abs_max_" + c] = df.groupby([c])["signal"].apply(lambda x: np.max(np.abs(x)))
 d["abs_min_" + c] = df.groupby([c])["signal"].apply(lambda x: np.min(np.abs(x)))
 d["range_" + c] = d["max_" + c] - d["min_" + c]
d["abs_range_" + c] = np.abs(d["max_" + c] - d["min_" + c])
 d["max_to_min_" + c] = d["max_" + c] / d["min_" + c]
d["abs_avg_" + c] =(d["abs_min_" + c] + d["abs_max_" + c])/ 2
for v in d:
df[v] = df[c].map(d[v].to_dict())
 df["signal_shift_+1"] = [0] + list(df["signal"].values[:-1])
 df["signal_shift_-1"] = list(df["signal"].values[1:])+ [0]
for i in df[df["batch_index"] == 0].index:
df["signal_shift_+1"][i] = np.nan
for i in df[df["batch_index"] == 49999].index:
df["signal_shift_-1"][i] = np.nan
for c in [x for x in df.columns if x not in ["time", "signal", "open_channels", "batch", "batch_index", "batch_slices", "batch_slices_2"]]:
df[c + "_minus_signal"] = df[c] - df["signal"]
return df<load_from_csv>
cohen_kappa_score(val_y, val_prediction, weights = "quadratic" )
train = pd.read_csv("/kaggle/input/liverpool-ion-switching/train.csv")
 test = pd.read_csv("/kaggle/input/liverpool-ion-switching/test.csv" )<feature_engineering>
train["signal"] = np.exp(train["signal"])
 test["signal"] = np.exp(test["signal"] )<feature_engineering>
%%time
train = features(train)
 test = features(test )<drop_column>
%%time
train = reduce_memory_usage(train)
 test = reduce_memory_usage(test )<define_variables>
features = [x for x in train.columns if x not in ["time", "open_channels", "batch", "batch_index", "batch_slices", "batch_slices_2"]]
target = "open_channels"<prepare_x_and_y>
clf_submit = GradientBoostingClassifier(n_estimators=100, learning_rate=0.05, max_depth=5, random_state=0)
 clf_submit.fit(all_x, all_y )
X, y = train[features], train[target]<set_options>
prediction = clf_submit.predict(test_data)
 submission = pd.DataFrame({'PetID': test['PetID'].values, 'AdoptionSpeed': [int(i)for i in prediction]})
 print(submission.head())
 submission.to_csv('submission.csv', index=False )
del train
gc.collect()<init_hyperparams>
params = {
"learning_rate": 0.1,
"max_depth": -1,
"num_leaves": 2**7 + 1,
"metric": "l2",
"random_state": SEED,
"n_jobs": -1,
"sample_fraction": 0.33
}<choose_model_class>
folds = KFold(n_splits=N_SPLITS, shuffle=True, random_state=SEED)
 preds = np.zeros(len(test))<create_dataframe>
feature_importance = pd.DataFrame()
feature_importance["Feature"] = X.columns
feature_importance["Value"] = 0<train_model>
for fold,(train_idx, test_idx)in enumerate(folds.split(X)) :
print("Fold", fold)
 X_train, y_train = X.iloc[train_idx], y.iloc[train_idx]
X_test, y_test = X.iloc[test_idx], y.iloc[test_idx]
model = lgb.train(params, train_set=lgb.Dataset(X_train, y_train), num_boost_round=2000, valid_sets=lgb.Dataset(X_test, y_test), feval=macro_f1_score, early_stopping_rounds=100, verbose_eval=100)
 preds += model.predict(test[features], num_iteration=model.best_iteration)
 current_importance = pd.DataFrame(zip(X.columns, model.feature_importance()), columns=["Feature", "Value"])
 feature_importance = pd.concat(( feature_importance, current_importance)).groupby("Feature", as_index=False ).sum()<prepare_output>
preds = preds / N_SPLITS<save_to_csv>
test["open_channels"] = np.round(np.clip(preds, 0, 10)).astype(int)
 test[["time", "open_channels"]].to_csv("submission.csv", index=False, float_format="%.4f" )<save_to_csv>
<set_options><EOS>