{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\nLeave-P-SubGroup-Out (LPSGO)\n======================================================\n\nThis example shows how to make a Leave-Percent-SubGroup-Out.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Import librairies\n-------------------------------------------\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from museotoolbox.cross_validation import LeavePSubGroupOut\nfrom museotoolbox import datasets,processing\nimport numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Load HistoricalMap dataset\n-------------------------------------------\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "raster,vector = datasets.load_historical_data(low_res=True)\nfield = 'Class'\ngroup = 'uniquefid'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create CV\n-------------------------------------------\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "valid_size = 0.5 # Means 50%\nLPSGO = LeavePSubGroupOut(valid_size = 0.5,\n random_state=12,verbose=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Extract X,y and group.\n-------------------------------------------\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "X,y,g= processing.extract_ROI(raster,vector,field,group)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
Split is made to generate each fold