Package: arc-py
arc-py - types and utilities for dealing with ARC Challenge in pythonarc-pypackage provides types and utilities to handlethe ARC Challenge.It helps you convert the original .json files to numpy arrays, view them (and any edits or generation you might do) with matplotlib.
It also suggests an interface for an agent competing in ARC Challenge, and offers evaluation function.Install it by runningpip install arc-py.Accessing the dataUpon  installingarc-py, you will get the original .json files  locally.
You can find  the  folders containing them asfrom  arc import train_data_dir, eval_data_dir.
However, if you are going to be using  python, probably you will find it more convenient to get
the  data  as 2D numpy arrays, grouped logically under two sets of  problems,  train and validation.
These are available asfrom arc import train_problems, validation_problems.Data Typesarc-pyintroduces a few types to structure the data in the challenge:arc.types.ArcProblemrepresent one task -  made of demonstrations (prob.train_pairs) and tests (prob.test_pairs).arc.types.ArcIOPairis a unit of the demonstrations/tests  making up a  problem  -  it's the  input  grid  (pair.x) and corresponding output grid (pair.y).arc.types.ArcGridis an alias fornp.ndarray. Specifically, an ArcGrid must be 2D, have dimensions between 1 to 30 each, and only have integers in range [0, 9] as it's elements. To verify some numpy array complies with this spec, a check function is offered:arc.types.verify_is_arc_grid.Viewing data with matplotlibarc-py provides few basics to view the grids with matplotlib (consistent with the web view in the original repo):arc.plot.plot_gridcan plot a single 2D gridarc.types.ArcIOPair.plot()will show a input/output pairimportnumpyasnpfrommatplotlibimportpyplotaspltfromarc.plotimportplot_gridgrid=np.zeros([4,4],dtype=np.uint8)foriinrange(4):grid[i,i]=3plot_grid(grid)plt.show()Constructing agents and evaluating resultsAgent APIThe concept for an agent is the following - it's the program you develop/train by looking on training problems, which then goes on to be scored on validation problems.
Per the rules of original kaggle competition:a problem can contain multiple test grids.it's  acceptable  to make up to 3 guesses  as  to what  the answer to a given test grid  could be.Since the agent must not be shown the answers to test grids, we give it following signature:defpredict(self,demo_pairs:List[ArcIOPair],test_grids:List[ArcGrid])->List[ArcPrediction]:Here,ArcPredictionis alist[ArcGrid]- containing 1 to 3 guesses. First element  of the output list corresponds to the first test grid, and so on (meaning for the return valueresult, you could match inputs and outputs withx, y in zip(test_grids, result)).Evaluationarc-pyoffers a class that can keep track  of your accuracy and few auxillary  target metrics:arc.evaluation.ArcEvaluationResult. It's best demonstrated with an example:defevaluate_agent(agent:ArcAgent,problems:List[ArcProblem]=validation_problems)->ArcEvaluationResult:result=ArcEvaluationResult()forprobinproblems:pred=agent.predict(prob.train_pairs,prob.test_inputs)result.add_answer(prob,pred)returnresultJust print theArcEvaluationResultobject to see the results. Sample output:ARC results for 400 problems. Stats:
Accuracy                 : 2.2%
Accuracy(at least one)   : 2.5%
Correct answer shape     : 52.4%Examplesfor an example of a project using arc-py, seehttps://github.com/ikamensh/solve_arcView training examples:fromarcimporttrain_problems,validation_problems,describe_task_groupdescribe_task_group(train_problems)describe_task_group(validation_problems)forn,taskinenumerate(train_problems,start=1):fori,pairinenumerate(task.train_pairs,start=1):pair.plot(show=True,title=f"Task{n}: Demo{i}")fori,pairinenumerate(task.test_pairs,start=1):pair.plot(show=True,title=f"Task{n}: Test{i}")Note: The ARC challenge is designed for the developer not knowing the test problems. If you know those problems, you will overfit to them. We recommend not to view the evaluation set.View output of a random agentfromtypingimportListimportnumpyasnpfromarc.typesimportArcIOPair,ArcGrid,ArcPredictionfromarc.agentsimportArcAgentclassRandomAgent(ArcAgent):"""Makes random predicitons. Low chance of success. """defpredict(self,demo_pairs:List[ArcIOPair],test_grids:List[ArcGrid])->List[ArcPrediction]:"""We are allowed to make up to 3 guesses per challange rules. """outputs=[]fortgintest_grids:out_shape=tg.shapeout1=np.random.randint(0,9,out_shape)out2=np.random.randint(0,9,out_shape)out3=np.random.randint(0,9,out_shape)outputs.append([out1,out2,out3])returnoutputsfromarcimporttrain_problemsp1=next(iter(train_problems))# problem #1agent=RandomAgent()outs=agent.predict(p1.train_pairs,p1.test_inputs)fortest_pair,predicitonsinzip(p1.test_pairs,outs):forpinpredicitons:prediction=ArcIOPair(test_pair.x,p)prediction.plot(show=True)Evaluate the random agentfromarc.agentsimportRandomAgent,CheatingAgentfromarc.evaluationimportevaluate_agentagent=RandomAgent()results=evaluate_agent(agent)print(results)assertresults.accuracy<0.5assertresults.accuracy_any<0.5assertresults.shape_accuracy>0# random agent guesses the shape of some outputs correctlyARC results for 400 problems. Stats:Accuracy                 : 0.0%Accuracy(at least one)   : 0.0%Correct answer shape     : 67.5%