human
3. Create the PixieApp<a class="anchor" id="createpixieapp"></a>
There are currently two options for algorithms:

Isolation Forest 

<a href="http://scikit-learn.org/stable/modules/generated/sklearn.ensemble.IsolationForest.html" target="_blank" rel="noopener no referrer">Sklearn documentation</a> 
<a href="https://cs.nju.edu.cn/zhouzh/zhouzh.files/publication/icdm08b.pdf" target="_blank" rel="noopener no referrer">Paper</a> 


One Class SVM with RBF Kernel

<a href="http://scikit-learn.org/stable/modules/generated/sklearn.svm.OneClassSVM.html" target="_blank" rel="noopener no referrer">Sklearn documentation</a>
<a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3041295/" target="_blank" rel="noopener no referrer">An academic application example</a>


In each case, the PixieApp generates a binary column (is_outlier_iforest or is_outlier_svm) indicating how the algorithm classified the BPS school. Click map to plot the schools on a map. Outlier schools are dark blue."
Please write code following the instructions in jupyter notebook style.
assistant
#Here is code to 3.

from pixiedust.display.app import *

@PixieApp
class TestPixieApp:

    @route()
    def main(self):
        return"""
            <input pd_options="iForest_clicked=true"
            type="button" value = "Outliers by Isolation Forest">
            <input pd_options="SVM_clicked=true"
            type="button" value = "Outliers by One-Class Support Vector Machine">          
            """
    
    @route(iForest_clicked="true")
    def iForest_clicked(self):
        return """
            <div id="target{{prefix}}"> 
            <input pd_options="handlerId=dataframe"
            pd_entity = "trainIForest(a.pixieapp_entity, 256)"
            type="button" value="Table">
            <input pd_options="handlerId=mapView;aggregation=SUM;rowCount=500;mapboxtoken=pk.eyJ1IjoidHJ1ZGFrZSIsImEiOiJjajN5c29wbWUwMDQwMnZvZWNmZWxiNmNuIn0.gFeF4D4TkU2Tro-EB7HF0w;valueFields=is_outlier_iforest;rendererId=mapbox"
            pd_entity = "trainIForest(a.pixieapp_entity, 256)"
            type="button" value="Map">
            </div>
            """
    
    def numeric_columns(self, df):
        return list(df.select_dtypes(include=[np.number]).columns.values) 

    def trainIForest(self, df, maxsample_input):
        # fit an isolation forest (more adapted to large-dimensional settings)
        if type(df) is pyspark.sql.dataframe.DataFrame: 
            df = df.toPandas()
        
        # fits on all numeric features
        numeric_columns = list(df.select_dtypes(include=[np.number]).columns.values) 
        df_num = df[numeric_columns]

        # fill missing values with column mean
        df_num = df_num.fillna(df.mean())

        clf = sklearn.ensemble.IsolationForest(max_samples=maxsample_input)
        clf.fit(df_num)
        y_pred_train = clf.predict(df_num)
        df['is_outlier_iforest'] = y_pred_train
        df['is_outlier_iforest'] = df['is_outlier_iforest'].map({1: 0, -1: 1})
        return df.sort_values('is_outlier_iforest', ascending = False)

    @route(SVM_clicked="true")
    def SVM_clicked(self):
...