Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #325 from RavirajBaraiya/exportModel
new python phase exportModel
- Loading branch information
Showing
6 changed files
with
67 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from zingg import * | ||
import argparse | ||
import sys | ||
import os | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
LOG = logging.getLogger("zingg.exportModel") | ||
|
||
def main(): | ||
|
||
# ckecking for mandatory option --location for this phase | ||
if(ClientOptions(sys.argv[1:]).hasLocation()==False): | ||
LOG.error("--location argument is mandatory for this phase") | ||
LOG.info("--location is location of CSV file for exported data") | ||
sys.exit() | ||
|
||
LOG.info("Phase ExportModel starts") | ||
|
||
options = ClientOptions(sys.argv[1:]) | ||
options.setPhase("peekModel") | ||
arguments = Arguments.createArgumentsFromJSON(options.getConf(), options.getPhase()) | ||
client = Zingg(arguments, options) | ||
client.init() | ||
|
||
pMarkedDF = client.getPandasDfFromDs(client.getMarkedRecords()) | ||
labelledData = spark.createDataFrame(pMarkedDF) | ||
location = options.getLocation() | ||
|
||
export_data(labelledData, location) | ||
|
||
LOG.info("Phase ExportModel ends") | ||
|
||
def export_data(labelledData, location): | ||
|
||
baseCols = ['z_cluster', 'z_zid', 'z_prediction', 'z_score', 'z_source', 'z_isMatch'] | ||
sourceDataColumns = [c for c in labelledData.columns if c not in baseCols] | ||
additionalTrainingColumns = ['z_cluster','z_isMatch'] | ||
trainingSampleColumns = [*additionalTrainingColumns, *sourceDataColumns] | ||
trainingSamples = labelledData.select(trainingSampleColumns) | ||
|
||
# Getting schema | ||
trainingSamples.schema.jsonValue() | ||
trainingSamples.show() | ||
trainingSamples.columns | ||
print(trainingSampleColumns) | ||
|
||
# Exporting the labelled data as CSV | ||
trainingSamples.toPandas().to_csv(os.path.join(location,r'exportedData.csv')) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters