{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy.stats import cauchy","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"target = pd.read_csv('../input/train.csv',usecols=['target'],squeeze=True)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"6c7b16932af692e0d9dca9bc30d8373a85b6f07a"},"cell_type":"markdown","source":"Look at frequency of target"},{"metadata":{"trusted":true,"_uuid":"0572d0eda003de79e272ea07af9a2d807d142e52"},"cell_type":"code","source":"target.value_counts().head(10)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"fdee7ac04fd3774bce5c5c8ee98fe28b8dcc375b"},"cell_type":"markdown","source":"Isolate the top 4 values.. is there a different process involved in their assignment?"},{"metadata":{"trusted":true,"_uuid":"825d8adecd93be4995bb40a8a98e7e5125af5f0e"},"cell_type":"code","source":"top_targets = list(target.value_counts().head(4).index)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"f3265bc2ba1a3f5c1e5327d6af26ee570c1c5307"},"cell_type":"markdown","source":"Sample data, bin by 2 decimal places"},{"metadata":{"trusted":true,"_uuid":"be3d5b77df3470062f3fefe802d52554ecb288a1"},"cell_type":"code","source":"def sample_targets(n):\n    sample_plot_data=target[~target.isin(top_targets)].sample(n)\n    sample_plot_data=sample_plot_data.groupby(np.round(sample_plot_data,2)).agg('count')\n    sample_plot_data=sample_plot_data.rename('count').reset_index()\n    return sample_plot_data","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"ef6709aa4002d5087bee7caba84da7f7f384b313"},"cell_type":"markdown","source":"Plot 50 random samples of 10,000 records, <font color='green'>rounded data observations in green</font>,  <font color='red'>cauchy PDF  of sample in red</font> :"},{"metadata":{"trusted":true,"_uuid":"555f1ccd7048f699dcb8fa035d21ad7d697bde87","scrolled":false},"cell_type":"code","source":"k=50\nfig = plt.figure(figsize=(25,k*5))\nfor i in range(k) : \n    if i==0:\n        ax = fig.add_subplot(k,1,i+1)\n    else:\n        ax = fig.add_subplot(k,1,i+1,sharex=ax,sharey=ax)\n    sample_plot_data = sample_targets(10000)\n    ax.plot(sample_plot_data['target'],sample_plot_data['count'],linewidth=.2,color='g')\n    plt.plot(sample_plot_data['target'],cauchy.pdf(sample_plot_data['target'])*120,color='r')\n    plt.xticks(np.linspace(-15,15,15+15+1),np.linspace(-15,15,15+15+1))\n    plt.xlabel(f'Mean : %.2f, Std : %.2f' % (np.mean(sample_plot_data.target),np.std(sample_plot_data.target)) ) \nplt.show()","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}