<jupyter_start><jupyter_text>An example or two of Running SPIT [v1]<jupyter_code># imports
from pkg_resources import resource_filename

from spit import io as spit_io
from spit import preprocess as spit_p
from spit import classify as spit_c
from spit.classifier import Classifier<jupyter_output><empty_output><jupyter_text>Load the Classifier    This requires that you have downloaded it (see README.md in spit/data/checkpoints)<jupyter_code># Classifier
kast = Classifier.load_kast()<jupyter_output>Loading the Classifier: /home/xavier/SPIT_DATA//Kast/checkpoints/final/best_validation
INFO:tensorflow:Restoring parameters from /home/xavier/SPIT_DATA//Kast/checkpoints/final/best_validation<jupyter_text>Load an image (skip if you have one in memory already)<jupyter_code>test_file = resource_filename('spit', 'tests/files/r6.fits')
# Read fits
data = spit_io.read_fits(test_file, exten=0)
data.shape<jupyter_output><empty_output><jupyter_text>Pre-process<jupyter_code># Process dict -- for turning numbers to image_types
pdict = spit_p.original_preproc_dict()
# Pre-Process
images_array = spit_p.flattened_array(data, pdict)
images_array.shape<jupyter_output><empty_output><jupyter_text>Classify<jupyter_code># Prediction
prediction, results = spit_c.get_prediction(images_array, kast)
pred_type = kast.classify_dict[prediction]<jupyter_output><empty_output><jupyter_text>Answers<jupyter_code>prediction, results, pred_type<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09003436426116838, 'fraction_numerical': 0.002061855670103093, 'mean_word_length': 8.837837837837839, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '473743', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 520, 'n_tokens_neox': 499, 'n_words': 99, 'path': 'docs/nb/Running_SPIT.ipynb', 'repo_name': 'PYPIT/spit', 'size': '1455'}